搭建本地apt仓库
1. 安装工具
#apt-get install dpkg-dev #这个比较全
apt-get install gnupg
apt-get install rng-tools
2. 搜集软件和依赖
# 查询依赖关系
root@localhost:~/df/packages# apt-cache depends nginx
nginx
|Depends: nginx-core
|Depends: nginx-full
|Depends: nginx-light
Depends: nginx-extras
|Depends: nginx-core
|Depends: nginx-full
|Depends: nginx-light
Depends: nginx-extras
# 下载
sudo rm -rf /var/cache/apt/archives/* # 清空缓存目录,这一步也可以不做
sudo apt-get -d install <包名>
root@localhost:~/df/packages# sudo apt-get install --reinstall -d `apt-cache depends nginx | grep depends | cut -d: f2 |tr -d "<>"`
root@localhost:~/df/packages# sudo apt-get download `apt-cache depends nginx | grep depends | cut -d: f2 |tr -d "<>"`
3. 生成包索引文件和Release文件
mkdir -p /opt/repository
cd /opt/repository
cp -rf /path/to/*.deb /opt/repository
apt-ftparchive packages . > Packages
apt-ftparchive release . > Release
4. 生成签名
在ubuntu下做,在centos下做会有问题
1. gpg --gen-key #gpg --list-keys查看
2. gpg -a --export pub_id | apt-key add - #apt客户端导入公钥
gpg -a --export username > username.pub #导出公钥
apt-key add username.pub #导入公钥
gpg -a --export 5789843F6B61B0B4 | apt-key add - #其中pub key可用gpg --list-keys查到
gpg --clearsign -o InRelease Release #gpg生成一个明文签名
gpg -abs -o Release.gpg Release #gpg生成一个分离签名
5. 更新apt源sources.list
vim /etc/apt/sources.list
添加 deb file:/opt/repository /
6. 客户端更新元数据
apt-get update