欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > debian 实现离线批量安装软件包

debian 实现离线批量安装软件包

2024/10/23 23:32:44 来源:https://blog.csdn.net/hanzheng260561728/article/details/140457710  浏览:    关键词:debian 实现离线批量安装软件包

前言

实现在线缓冲需要的软件和对应依赖的包,离线进行安装 ,用于软件封装。

测试下载一个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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com