[debian,ubuntu]从零开始搭建一个apt源服务器

来源:互联网 发布:阿里云有免费的吗 编辑:程序博客网 时间:2024/05/18 02:34

问题

手头上有一堆deb包,将包放到服务器上并组织成apt仓库布局,以供其他设备从此源上安装deb包。

原料

  1. gpg生成了公私钥对。其中公钥导出到公钥服务器上,或是在使用此源的设备上导入此公钥,从而信任此源上的deb包。
  2. 一台运行了web服务的Linux主机,并安装了apt-ftparchive
  3. 召唤一堆脚本:https://github.com/cee1/cee1.archive/tree/master/utilities/apt-repo-builder

注:第1点,如何再使用此源的设备上导入公钥?参考ubuntu-keyring神马的,下个包然后dpkg -e ubuntu-keyring_xxx.deb,阅读脚本DEBIAN/postinst

搭建

  • 假设:http://apt.example.com/ -> /home/sites/apt,建立一个发行版本(dist)名叫“shield”,有分块(section) “gnome2.32”
  • 建立文件夹:
cd /home/sites/aptmkdir -p dists/shieldmkdir -p pool/gnome2.32mkdir -p pool/incomingmkdir scriptscp /path/to/召唤的脚本/* scriptschmod +x scripts/*# vi release.shln -s scripts/release.sh release.shln -s scripts/updateidx.sh updateidx.shln -s scripts/updateidx.sh updateidx-full.shcd poolln -s ../scripts/chk_incoming.sh chk_incoming.shln -s ../scripts/fill_section.sh fill_section.sh

使用

  1. 将deb包以及md5sum *.deb >checksum 上传到服务器的pool/incoming下面
  2. 服务器:
    • 将文件安置到pool下,并按源码包(Source 包)名归类,并对此建文件夹式的索引:
cd /home/sites/apt/pool./chk_incoming.sh./fill_section.sh gnome2.32
    • 生成dists/shield下的索引,并签名
cd /home/sites/apt./updateidx.sh gnome2.32 shield  # or ./updateidx-full.sh./release.sh

原创粉丝点击