写一个deb文件安装脚本,缺少未安装的依赖从当前目录查找
时间: 2024-05-24 20:10:44 浏览: 130
#!/bin/bash
# 获取deb文件名
PACKAGE_NAME=$(ls *.deb)
echo "正在安装 $PACKAGE_NAME ..."
# 检查依赖
DEPS=$(dpkg-deb -I $PACKAGE_NAME | grep Depends | sed 's/.*ends:\ //' | sed 's/,//g')
for DEP in $DEPS
do
if ! dpkg -s $DEP > /dev/null 2>&1; then
# 依赖未安装,尝试从当前目录查找
echo "依赖 $DEP 未安装,正在查找..."
DEP_PACKAGE=$(ls $DEP*.deb)
if [ -z $DEP_PACKAGE ]; then
echo "找不到 $DEP 的安装包,请手动安装"
exit 1
else
echo "找到 $DEP 的安装包 $DEP_PACKAGE,正在安装..."
dpkg -i $DEP_PACKAGE
if [ $? -ne 0 ]; then
echo "安装 $DEP_PACKAGE 失败,请手动安装"
exit 1
fi
fi
fi
done
# 安装deb文件
dpkg -i $PACKAGE_NAME
if [ $? -ne 0 ]; then
echo "安装 $PACKAGE_NAME 失败,请检查依赖并手动安装"
exit 1
fi
echo "安装完成"
阅读全文