---Create own APT Repository---
爬了許多文,為架設 repository 據我所知有兩大工具,reprepro 與 apt-ftparchive,
稍微研究過 reprepro 但是比起 ftparchive 操作方式複雜了許多,
所以暫時先使用 ftparchive 來架設。
首先在你喜好的目錄下建立一個 Repository directory ,
個人是建立在家目錄底下 如下,
[root@debian] ~
→mkdir /home/repository
[root@debian] ~
→cd /home/repositroy
接下來需要建立 ftparchive 所需的設定檔,generate.conf 與 release.conf。
建立一個 conf 目錄。
[root@debian] /home/repository
→mkdir conf
[root@debian] /home/repository
→cd conf
[root@debian] /home/repository/conf
→touch generate.conf release.conf
generate.conf
Dir {
ArchiveDir ".";
CacheDir ".";
};
Default {
Packages::Compress ". gzip bzip2";
Sources::Compress "gzip bzip2";
Contents::Compress "gzip bzip2";
};
TreeDefault::Directory "pool";
TreeDefault::SrcDirectory "pool";
BinDirectory "pool" {
Packages "dists/unstable/main/binary-amd64/Packages";
Contents "dists/unstable/Contents-amd64";
SrcPackages "dists/unstable/main/source/Sources";
};
BinDirectory "pool" {
Packages "dists/unstable/main/binary-i386/Packages";
Contents "dists/unstable/Contents-i386";
SrcPackages "dists/unstable/main/source/Sources";
};
Tree "dists/unstable" {
Sections "main";
Architectures "i386 amd64 source";
};
Default {
Packages {
Extensions ".deb";
};
};
release.conf
APT::FTPArchive::Release::Origin "disney";
APT::FTPArchive::Release::Label "unstable";
APT::FTPArchive::Release::Suite "unstable";
APT::FTPArchive::Release::Codename "jessie";
APT::FTPArchive::Release::Architectures "i386 amd64 source";
APT::FTPArchive::Release::Components "main";
APT::FTPArchive::Release::Description "hr hr hr hr hr~~";
這兩個設定檔加入之後,這裡提供一個已寫好的 shell script,
在 repository 目錄下建立目錄 bin,進入 bin 目錄並建立檔案 update.sh 。
[root@debian] /home/repository/conf
→mkdir /home/repositroy/bin
[root@debian] /home/repository/conf
→cd /home/repository/bin
update.sh
#!/bin/bash
BASEDIR=$(dirname $0)/../web
pushd $BASEDIR > /dev/null
rm -fr dists
mkdir -p pool
mkdir -p dists/unstable/main/binary-amd64
mkdir -p dists/unstable/main/binary-i386
mkdir -p dists/unstable/main/source
apt-ftparchive generate ../conf/generate.conf
apt-ftparchive -c ../conf/release.conf release dists/unstable/ > dists/unstable/Release
gpg -abs --homedir ~/.gnupg --default-key E57952A1 -o dists/unstable/Release.gpg dists/unstable/Release
popd > /dev/null
在 repositroy 目錄底下建立 web 目錄,以上 script 需要用到的。
[root@debian] ~
→mkdir /home/repositroy/web
接下來執行 update.sh ,將會自動建立套件庫所需目錄及檔案。
[root@debian] ~
→cd /home/repository/bin
[root@debian] ~
→bash update.sh
將出現類似以下訊息。
pool: New 1,736 B 1 files 6,554 kB 0s
pool: New 1,736 B 1 files 6,554 kB 0s
pool: 0 files 0 B 0s
pool: New 34 B 0 pkgs in 0s
Packages done, Starting contents.
dists/unstable/Contents-i386: New 34 B 0 files 0 B 0s
dists/unstable/main/Contents-amd64: New 1,369 B 1 files 6,554 kB 0s
dists/unstable/main/Contents-i386: New 34 B 0 files 0 B 0s
Done. 13.1 MB in 2 archives. Took 0s
你需要用密語來解開下列使用者的
私鑰: "Disney <abc57911@gmail.com>"
2048 位元長的 RSA 金鑰, ID E57952A1, 建立於 2015-02-04
請輸入密語:
上面訊息之中,所要求的金鑰,必須自行先建立,
在這裡我提供網址給各位做參考,GnuPG Gentoo 使用者指南 。
而 update.sh 之中 gpg 指令的參數 --default-key 必須修改為自己所產生的 key,
以指令 gpg --list-key 查看。
套件庫建立完成之後,就差 nginx 的設定。
server {
server_name ftp.disney.com;
location /web/ {
autoindex on;
alias /home/repository/web/;
}
}
在 source.list 增加套件庫網址即可使用,在 /etc/apt/ 目錄底下。
deb http://ftp.disney.com/web/ unstable main
沒有留言 :
張貼留言