show me the code !Ubuntu制作离线offline软件源的可用脚本

该博客详细介绍了如何在Ubuntu环境下制作离线软件源,包括生成GPG签名密钥,复制软件包,构建Packages索引文件,以及设置本地源。提供了一段脚本展示整个流程,帮助用户在无网络连接的环境中便捷地安装和更新软件。
摘要由CSDN通过智能技术生成

在Ubuntu一些标准化服务的部署环境中,如果能够在离线环境中获得某些软件包的安装将是非常方便的。

看了一些网上关于制作Ubuntu离线offline软件源的博文,就一个相对目录的问题就说的不清不楚。Linus大神说,Talk is Cheap,Show me The Code!

如果能够看到代码中是如何制作离线软件源,就会更容易理解这个过程。。。

注意:在事先需要利用GPG产生对软件包签名的公钥和私钥,并导出为二进制格式

 

见github中积累的制作脚本:Show me the Code

# !/bin/sh
# required: before excuted,please use sudo su to switch to root user!
# required: curl && gpg shell scripts

# user must be root!
usertest=`whoami`

if [ $usertest != "root" ];then
  echo "you must use root to run this script!use 'sudo su' to switch to root user!"
  exit 1
fi

# you can create the keys using gpg and import these in binary format
echo "use key sign..."

if [ ! -r go-private-key.sec ] ; then
   echo "get private key from deploying server..."
   OFFLINE_DEBS_SITE="http://192.168.31.133/"
   OFFLINE_DEBS_JUMPER_URL="$OFFLINE_DEBS_SITE/go"
   curl -O $OFFLINE_DEBS_JUMPER_URL/go-private-key.sec
fi

gpg --import go-private-key.sec

echo "get the needed deb resources ..."

# maybe mirror changed,so update firstly to reform indexs 
apt-get update

apt-get install -y xrdp xorg openbox wish freerdp-x11 ntpdate zip unzip numlockx

rm -rf /var/debs

if [ -r /var/debs.tar ] ; then 
   yes | rm -f /var/debs.tar
fi

mkdir -p /var/debs
cp -r /var/cache/apt/archives/*.deb /var/debs/

echo "to form debs index file..."
cd /var/

apt-ftparchive packages debs > debs/Packages
cd debs
gzip -c Packages > Packages.gz
apt-ftparchive release . > Release

# you should use your signature user name e.g 'go'
gpg --local-user go --clearsign -o InRelease Release
gpg --local-user go -abs -o Release.gpg Release


echo "create debs tar file at /var/debs.tar ..."
cd /var/
tar cvf debs.tar debs/

echo "create debs tar file at /var/debs.tar end..."

 

补使用离线软件源的部分代码:

echo "use local offline debs site..."
mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb $OFFLINE_DEBS_SITE/jumper debs/" > /etc/apt/sources.list


echo "import deb release key..."
apt-key add ~/jumper/jumper-public-key.sec
apt-get update

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值