Reprepro是一个小的命令行工具来轻松创建和管理的.deb库,今天我们将展示如何轻松地创建一个Debian软件包仓库使用reprepro以及如何使用rsync命令将其上传到Sourceforge.net。
创建Deb包存储库
第1步:安装Reprepro和生成密钥
首先,使用以下apt-get命令安装所有必需的软件包。
$ sudo apt-get install reprepro gnupg
现在,你需要生成使用GnuPG一个GPG密钥,要做到这一点,应用此命令。
$ gpg --gen-key
它会问你一些问题,像那种你想要的关键,关键应该多长时间有效,如果你不知道该怎么回答的,只需点击输入默认选项(建议)。
当然,它会要求您提供用户名和密码,记住这些,因为我们以后需要它们。
gpg (GnuPG) 1.4.14; Copyright (C) 2013 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) Requested keysize is 2048 bits Please specify how long the key should be valid. 0 = key does not expire = key expires in n days w = key expires in n weeks m = key expires in n months y = key expires in n years Key is valid for? (0) Key does not expire at all Is this correct? (y/N) Y You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>" Real name: ravisaive Email address: youcl.com@gmail.com Comment: youcl You selected this USER-ID: "Ravi Saive (youcl) <youcl.com@gmail.com>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O You need a Passphrase to protect your secret key. We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy. +++++ gpg: key 2EB446DD marked as ultimately trusted public and secret key created and signed. gpg: checking the trustdb gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u pub 2048R/2EB446DD 2014-06-24 Key fingerprint = D222 B1C9 342E 5911 02B1 9147 3BD6 7918 2EB4 46DD uid Ravi Saive (youcl) <youcl.com@gmail.com> sub 2048R/7EF2F750 2014-06-24
现在您的密钥将被生成,检查如果是,请以root权限运行此命令。
$ sudo gpg --list-keys
示例输出
/home/ravisaive/.gnupg/pubring.gpg ---------------------------------- pub 2048R/2EB446DD 2014-06-24 uid ravisaive (youcl) <youcl.com@gmail.com> sub 2048R/7EF2F750 2014-06-24
第2步:创建软件包存储库和导出密钥
我们将开始工作,现在打造资源库,首先你必须创建一些文件夹,我们的代码库将在/ var / WWW /公寓目录,让我们创建一些文件夹。
$ sudo su # cd /var/www # mkdir apt # mkdir -p ./apt/incoming # mkdir -p ./apt/conf # mkdir -p ./apt/key
您现在要将创建的密钥导出到存储库文件夹,运行。
# gpg --armor --export username yourmail@mail.com >> /var/www/apt/key/deb.gpg.key
注 :您在上面步骤中输入的用户名替换用户名和yourmail@mail.com与您的电子邮件。
我们需要创建一个名为“ 发行 ”/无功/网络/公寓/ conf目录内的文件。
# touch /var/www/apt/conf/distributions
将以下行添加到分发文件并保存文件。
Origin: (yourname) Label: (name of repository) Suite: (stable or unstable) Codename: (the codename for the distribution you are using, like trusty) Version: (the version for the distribution you are using, like 14.04) Architectures: (the repository packages architecture, like i386 or amd64) Components: (main restricted universe multiverse) Description: (Some information about the repository) SignWith: yes
接下来,我们必须创建存储库树,为此,运行这些命令。
# reprepro --ask-passphrase -Vb /var/www/apt export
示例输出
Created directory "/var/www/apt/db" Exporting Trusty... Created directory "/var/www/apt/dists" Created directory "/var/www/apt/dists/Trusty" Created directory "/var/www/apt/dists/Trusty/universe" Created directory "/var/www/apt/dists/Trusty/universe/binary-i386" FF5097B479C8220C ravisaive (youcl) <youcl.com@gmail.com> needs a passphrase Please enter passphrase: Successfully created '/var/www/apt/dists/Trusty/Release.gpg.new' FF5097B479C8220C ravisaive (youcl) <youcl.com@gmail.com> needs a passphrase Please enter passphrase: Successfully created '/var/www/apt/dists/Trusty/InRelease.new'
第3步:将软件包添加到新创建的存储库
现在准备.deb软件包被添加到库中。 去到/ var / WWW /公寓目录,你有这个您要添加的包,每次做。
# cd /var/www/apt # reprepro --ask-passphrase -Vb . includedeb Trusty /home/ravisaive/packages.deb
注意 :更换信赖与您的发行文件的库中输入的代号,并与路径替换包/home/username/package.deb,你会被询问密码进入。
示例输出
/home/ravisaive/packages.deb : component guessed as 'universe' Created directory "./pool" Created directory "./pool/universe" Created directory "./pool/universe/o" Created directory "./pool/universe/o/ojuba-personal-lock" Exporting indices... FF5097B479C8220C ravisaive (youcl) <youcl.com@gmail.com> needs a passphrase Please enter passphrase: Successfully created './dists/Trusty/Release.gpg.new' FF5097B479C8220C ravisaive (youcl) <youcl.com@gmail.com> needs a passphrase Please enter passphrase: Successfully created './dists/Trusty/InRelease.new'
您的包被添加到存储库,以将其删除。
# reprepro --ask-passphrase -Vb /var/www/apt remove trusty package.deb
当然,您需要使用您的包名称和存储库代号修改命令。
第4步:将资源库上传到Sourceforge.net
要上传存储库Sourceforge.net,你需要有一个流水账那里当然,和一个正在运行的项目,让我们假设你想存储库上传到http://sourceforge.net/projects/myfoo/testrepository哪里myfoo为您的项目名称(UNIX名称,而不是网址,而不是标题),以及testrepository是你要上传的文件到,我们将做到这一点使用的文件夹rsync命令 。
# rsync -avP -e ssh /var/www/apt/ username@frs.sourceforge.net:/home/frs/project/myfoo/testrepository/
注 :在sourceforge.net和myfoo与项目UNIX的名称和testrepository你想将文件存储在文件夹您的用户名替换用户名。
现在,多数民众赞成你的资料库上传到http://sourceforge.net/projects/myfoo/testrepository,将其添加到已安装的系统,首先你要导入存储库密钥,它会在/ var / WWW /公寓/关键/deb.gpg.key,但这是一个本地路径并为您的存储库中的用户将无法将其添加到他们的系统,这就是为什么我们会从进口的sourceforge.net关键。
$ sudo su # wget -O - http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key | apt-key add -
现在,您可以轻松地添加存储库到系统,开放的/etc/apt/sources.list并添加此行。
deb http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key trusty main
注 :与您的项目UNIX的名称,值得信赖与你的资料库代号替换myfoo,testrepository与文件夹你上传的文件进去,主要与您加入到发行文件存储库组件。
接下来,运行以下命令以更新存储库列表。
$ sudo apt-get update
恭喜!您的存储库是活跃! 你现在可以轻松安装包,如果你想要的。