代码: 全选
# vim:se ft=debsources:fdm=marker:
#### 简单软件仓库结构: 创建仓库主目录 ${REPO}, deb文件放在 pool目录下, /*{{{*/
## 在主目录下运行 apt-ftparchive packages pool/ | gzip -9c > Packages.gz 结构如下: /*{{{*/
|-- Packages.gz
|-- pool
| |-- abc.deb
| |-- def.deb
`
/*}}}*/
#### 使用: 加入源
deb file:///media/g/ubt/debs/ /
#### apt-get update 生成的软件包列表
/var/lib/apt/lists/_media_g_ubt_debs_Packages
/*}}}*/
#### 标准deb仓库结构: 创建仓库主目录 ${REPO}, deb文件放在分层的pool目录下
## 创建 dists{发行版名}/{分类名}/{机器体系} 目录, 生成分类的包列表, 生成版本签名,生成内容包
## 创建仓库,并建立相关文件: /*{{{*/
mkdir /media/g/myubtrepo
cd /media/g/myubtrepo
mkdir project
gpg -K # 生成自己的gpg密钥(略), 列出自己的密钥ID,并导出到文件
gpg --export -a 4B1D5487 > project/myubtrepo-keyring.gpg
mkdir -p dists/jaunty/{main,multiverse,restricted,universe}/{binary-amd64,binary-i386,i18n,source}
mkdir -p pool/{main,multiverse,restricted,universe}
# 在 pool 目录下放入一些有效的deb文件
apt-ftparchive packages pool/main > dists/jaunty/main/binary-i386/Packages
apt-ftparchive packages pool/universe > dists/jaunty/universe/binary-i386/Packages
cat dists/jaunty/main/binary-i386/Packages | gzip -9c > dists/jaunty/main/binary-i386/Packages.gz
cat dists/jaunty/universe/binary-i386/Packages | gzip -9c > dists/jaunty/universe/binary-i386/Packages.gz
cat > dists/jaunty/main/binary-i386/Release <<"EOF"
Archive: jaunty
Version: 9.04
Component: main
Origin: Ubuntu
Label: Ubuntu
Architecture: i386
EOF
cat > dists/jaunty/universe/binary-i386/Release <<"EOF"
Archive: jaunty
Version: 9.04
Component: universe
Origin: Ubuntu
Label: Ubuntu
Architecture: i386
EOF
cat > dists/jaunty/pt.conf <<"EOF"
APT::FTPArchive::Release {
Origin "Ubuntu";
Label "Ubuntu";
Suite "jaunty";
Codename "jaunty";
Version "9.04";
Architectures "amd64 hppa i386 ia64 lpia powerpc sparc";
Components "main restricted universe multiverse";
Description "My test Ubuntu Depository";
};
EOF
apt-ftparchive contents pool/ | gzip -9c > dists/jaunty/Contents-i386.gz
# 签名包列表
apt-ftparchive -c dists/jaunty/pt.conf release dists/jaunty > dists/jaunty/Release
gpg -a --detach-sign -o dists/jaunty/Release.gpg dists/jaunty/Release
/*}}}*/
## 目录结构: /*{{{*/
|-- dists
| |-- jaunty
| | |-- Contents-i386.gz
| | |-- pt.conf
| | |-- Release
| | |-- Release.gpg
| | |-- main
| | | |-- binary-amd64
| | | |-- binary-i386
| | | | |-- Packages
| | | | |-- Packages.gz
| | | | |-- Release
| | | |-- i18n
| | | |-- source
| | |-- multiverse
| | | |-- binary-amd64
| | | |-- binary-i386
| | | |-- i18n
| | | |-- source
| | |-- restricted
| | | |-- binary-amd64
| | | |-- binary-i386
| | | |-- i18n
| | | |-- source
| | |-- universe
| | | |-- binary-amd64
| | | |-- binary-i386
| | | | |-- Packages
| | | | |-- Packages.gz
| | | | |-- Release
| | | |-- i18n
| | | |-- source
|-- pool
| |-- main
| | |-- a
| | | |-- abc.deb
| | |-- b
| | | |-- bcd.deb
| | |-- f
| | | |-- fci.deb
| |-- multiverse
| |-- restricted
| |-- universe
| | |-- s
| | | |-- stu.deb
| | |-- t
| | | |-- test1.deb
|-- project
| |-- myubtrepo-keyring.gpg
`
/*}}}*/
#### 使用源: 在 /etc/apt/sources.list.d/20-myubtrepo.list 加入 /*{{{*/
deb file:///media/g/myubtrepo/ jaunty main universe
#deb-src file:///media/g/myubtrepo/ jaunty main universe
# 类型: deb,deb-src (二进制或源码包)
# 路径: file:///path/to, http://www.name.org/ubuntu, ftp://ftp.name.org/ubuntu,
# 发行版名: intrepid, jaunty,
# 软件包分类: main restricted universe multiverse (ubuntu默认固定使用)
#### 添加签名公钥
# 下载仓库的签名公钥并加入
sudo apt-key add myubtrepo-keyring.gpg
#### apt-get update 生成的软件包列表(下划线分隔目录,原目录下划线变成%5f)
/var/lib/apt/lists/_media_g_myubtrepo_dists_jaunty_main_binary-i386_Packages
/var/lib/apt/lists/_media_g_myubtrepo_dists_jaunty_Release
/var/lib/apt/lists/_media_g_myubtrepo_dists_jaunty_Release.gpg
/var/lib/apt/lists/_media_g_myubtrepo_dists_jaunty_universe_binary-i386_Packages
/*}}}*/