前言
实现在线缓冲需要的软件和对应依赖的包,离线进行安装 ,用于软件封装。
测试下载一个gcc和依赖环境,关闭默认在线源,测试离线安装gcc和依赖环境
- 兼容 debian ubuntu
- /test 测试下载安装包到目录
vim /repo_download.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: make.han
# Email: CIASM@CIASM
# Date: 2024/07/16#禁止系统待机
echo "Disable system standby"
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target#阻止弹出框
echo "Pop-up block"
sed -i -e '$aexport DEBIAN_FRONTEND=noninteractive' /etc/profile
source /etc/profileecho "Installing Basic Tools"
apt install -y sudo
apt install -y apt-utils apt-show-versions apt-rdependsecho "create directory"
mkdir -p /test && cd /test#使用 xargs 和 apt-get 来下载所有依赖项和主包
echo "Download gcc and its dependencies"
apt-get download $(apt-rdepends --state-follow=Installed firewalld curl | grep -v "^ " | grep -v "^$")echo "backup Default Mirror Source Test"
mv /etc/apt/sources.list /etc/apt/sources.list.backupeecho "update repo"
apt update# 连接在线源批量安装插件,不能解决依赖只是安装离线的所有包
echo "install gcc"
dpkg -i /test/*.deb# 安装,如果没有网络则在离线安装
#echo "install gcc and its dependencies"
#apt install -y /test/*.deb# 离线安装后,恢复在线源异常问题解决
echo "Repairing dependencies"
apt update
apt --fix-broken install
执行测试
bash /repo_download.sh