制作软件包
前提
使用相同的系统版本
环境
root@ubuntu:/home/tiffin/archives# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
*载下**依赖
- 使用apt-rdepends查找依赖
- 如果apt-rdepends不存在使用apt进行安装sudo apt install apt-rdepends
- 如果目标软件在当前的仓库源中没有,那么还需要手动添加对应的源
- 使用apt download*载下**依赖,以timescaledb为例
apt-rdepends timescaledb-2-postgresql-15 | grep Depends | awk '{print $2}'| sort -u | xargs -I {} apt download {}
apt download timescaledb-2-postgresql-15
apt download timescaledb-tools
注意:
- apt-rdepends查找的依赖不一定包含应用程序的本身,如果不包含还需要自己单独*载下**,如本文以timescaledb-2-postgresql-15为例,就没有包含这个程序本身,所以我们需要再次执行apt download timescaledb-2-postgresql-15
- 使用apt download的命令时不要使用root权限
制作仓库索引
mkdir -p archives/packages
cp *.deb archives/packages
# 建立索引
cd archives
dpkg-scanpackages packages/ /dev/null | gzip > Packages.gz
cd ..
tar -czvf archives.tgz archives/
软件安装
创建本地仓库源
tar -xzf archives.tgz
cp -f /etc/apt/sources.list /etc/apt/sources.list.bak
# path 是指archive存放的父级绝对目录,最后一个/之前是有空格的
echo 'deb [trusted=yes] file:///path/archives/ /' > /etc/apt/sources.list
apt update
执行软件安装命令
apt install timescaledb-2-postgresql-15
apt install timescaledb-tools
timescaledb-tune --quiet --yes
systemctl restart postgresql
还原本地仓库源
rm /etc/apt/sources.list
mv /etc/apt/sources.list.bak /etc/apt/sources.list
apt update