Personal Package Archives(个人软件包档案)是Ubuntu Launchpad网站提供的一项服务,允许个人用户上传软件源代码,通过Launchpad进行编译并发布为2进制软件包,作为APT/新立得源供其他用户下载和更新。在Launchpad网站上的每一个用户和团队都可以拥有一个或多个PPA。
1.安装打包需要的软件环境
1 |
$ sudo apt-get install packaging-dev |
2.创建自己的GPG KEY
1 |
$ gpg --gen-key |
接下来,一路回车,在要求确认信息的时候,点击y。最后一步是一通的键盘乱按。整个过程如下图所示:
1 2 3 4 5 6 7 |
gpg: 正在检查信任度数据库 gpg: 需要 3 份勉强信任和 1 份完全信任,PGP 信任模型 gpg: 深度:0 有效性: 1 已签名: 0 信任度:0-,0q,0n,0m,0f,1u pub 2048R/47EDFAD4 2016-01-23 密钥指纹 = 043D A507 281E D8F8 6D79 9806 34F5 C3F3 47ED FAD4 uid LongSky (LongSky) <wangqiang1588@sina.com> sub 2048R/5A23BF98 2016-01-23 |
注意,我们需要的KEY ID为47EDFAD4
.
将KEY的公共部分上传到KEY SERVER,这样全世界的开发者就可以根据你的KEY来识别你的信息和文件.
1 |
$ gpg --send-keys --keyserver keyserver.ubuntu.com <KEY ID> |
我们自己的Key发送就是
1 |
$ gpg --send-keys --keyserver keyserver.ubuntu.com 47EDFAD4 |
3.创建你的SSH KEY
1 |
$ ssh-keygen -t rsa |
4.创建pbuilder(允许开发者在本地创建PPA包)
1 2 3 4 |
pbuilder-dist <release> create where <release> is for example raring, saucy, trusty or in the case of Debian maybe sid. This will take a while as it will download all the necessary packages for a “minimal installation”. These will be cached though. |
我的系统版本是Ubuntu 15.10 (Wily Werewolf),所以执行如下命令:
1 |
$ pbuilder-dist wily create |
这部分的耗时比较长,会安装全部的编译工具,要耐心等待一下!
5.创建Launchpad账户
帐号可以去Launchpad 官网注册
上传GPG KEY到Launchpad,通过如下指令查看自己的GPG KEY:
1 |
$ gpg --fingerprint wangqiang1588@sina.com |
会得到如下结果:
1 2 3 4 |
pub 2048R/47EDFAD4 2016-01-23 密钥指纹 = 043D A507 281E D8F8 6D79 9806 34F5 C3F3 47ED FAD4 uid LongSky (LongSky) <wangqiang1588@sina.com> sub 2048R/5A23BF98 2016-01-23 |
运行如下指令提交你的KEY到Ubuntu Key Server:
1 |
$ gpg --send-keys --keyserver keyserver.ubuntu.com 47EDFAD4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
将Key fingerprint拷贝到文本框,点击 “Import Key”. 如果导入成功,系统会发送一封邮件到你的邮箱,用来对导入的Key进行验证 其中邮件的内容为不可读的,需要编译,内容类似于: BEGIN PGP MESSAGE Version: GnuPG v1.4.3 (GNU/Linux) hQIOA0THhKozD+K5EAf9F3PcOL2iU6onH2YsvB6IKDXNxbK0NBVy6ppxcNq8hoTe cuHvzWLFfh1ehhSNe1V6xpuFnt5sJoeA4qEEOxez3HmY80tKIKMPLyhC/8JiSIW9 fwuxj4C0F6pdyrpvGbQAzfPEFk/P1AtIHXm4WLXduhBT7YEpmUk/I4A/KlSrKoiP J5vBtbroUyp2jvIhDUmY7ToU+ifrDe3+VP1ZzSEJzOOXec9oPbcbvf5NptXA7Hbp S0ElBAcLjKpAu7VKotCwFZIsVXDHT/mxf2qm88bGIrlXS5uTzvmyhQps1KmyNiCz I0i5kSVvHZWyVZ+8FrROLqYAqqnEIMg9hUnbFAervgf/YiYs0xxWLYf9e14eoMZA ranGT72q/JHmBNBYenOijaquFNi1TH5J8Udtt2RfdyRUlmGilxRvtIYL8gpnuNpS +GHOoBWUN2f4nawaDeqgrf6Nt3qQWWLO4iJPgieejFP2FP6zkLme1t7dXo+z1ary EZuxSLtKIWkOFEZ8Gcn02hBgOhJZucnkF6BmVW9dr1C4QEAmGM631uqfsp5PapAn yjHbEU1L2R9i7vPtJNRr6ubFLWg1Yhfv63ByxSx/WQHMMqlrbL+moXBGED3L2hM8 7FP9eapBRgmS+Bda9ArcGMUElTOkWoUYIOPyLOYmo15LvbxHOVaXjn7+fDgr2S1J R9LArwHycmdKKelRww+ZvylHIfq8xy10atRQIYawchh9A1myXD1TlWbrrIkodQJF iEpO2i1LKvqwZHOx3szT4hF+44tNFzQIL1j+zF5Hrt2WOTnS5WXGgGRtfEd8F7fN khQZOAdhwrnlY+yknruC8Y8Jm8vM57+KnPgBfvxuxzLX1XFTfTZCHXeUmwwu3mga m+6WzckeBGBDHKK6GqwFoOAykTwjyqOZaty7DPHeoINc0tLMVr9Ks64DScf8bgh4 MkNonA0YhMQbkmwRc33APw441+/iLw5gqndQdX44kKqC71dG6LqanAOjD29Xj3JV ZBsjg95Jrx7Sx+i/V0PUeaU9QjCT0Q1jEy1Bcs8NYtTJnpG+4oHYJ0pyiGxIquQH V9E+hW6Qehx5DbsIXEvfeaBBHOfAHHOhUH14WK4bsJWm8wZ50XiYBZrNFOqzsm13 2STcY4VIoJp3Uw2qNyvZXQUhpndlfgQGO14CMSadzDn6Vts= =hTe6 END PGP MESSAGE 将邮件中这些内容拷贝到一个文件中,例如:file.txt,然后执行如下命令: gpg --decrypt file.txt 此时会提示你输入之前设置的key密码,验证成功后,会有如下提示: Please go here to finish adding the key to your Launchpad account: [[https://launchpad.net/token/bP56TDKg8HXQbBs6LsN0]] 点击该链接,选择continue , 完成GPG Key 上传 |
6.上传SSH KEY
打开~/.ssh/id_rsa.pub
文件,将其中的内容拷贝到帐号的add ssh key
文本框中,选择导入后完成上传
7.配置 Bazzar
(一个版本控制软件,可以储存代码)之所以需要使用Bazzar,原因是Launchpad的默认BUG管理器,并且编译代码的时候,要求用bzr
进行代码编译。
首先告诉Bazzar你是谁:
1 2 3 |
$ bzr whoami "LongSky <wangqiang1588@sina.com>" $ bzr launchpad-login wangqiang1588(我的Launchpad账户id) |
官方教程:http://packaging.ubuntu.com/html/packaging-new-software.html
开源许可证:http://opensource.org/licenses
8.配置你的shell环境变量
打开~/.bashrc 文件,在文件开头加上如下内容:
1 2 3 |
$ export DEBFULLNAME="LongSky" $ export DEBEMAIL="wangqiang1588@sina.com" |
然后执行:
1 |
$ source ~/.bashrc |
9.安装编译工具
1 |
$ sudo apt-get install build-essential dh-make |
10.下载源代码,以Openyoudao为例
1 |
$ wget https://github.com/justzx2011/openyoudao/archive/beta0.2.tar.gz |
11.开始打包
a.根据模板生成配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ bzr dh-make openyoudao 0.2 beta0.2.tar.gz Fetching tarball Looking for a way to retrieve the upstream tarball Upstream tarball already exists in build directory, using that Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch? [s/i/m/l/k/n] s Maintainer name : LongSky Email-Address : wangqiang1588@sina.com Date : Sun, 24 Jan 2016 17:09:27 +0800 Package Name : openyoudao Version : 0.2 License : blank Type of Package : Single Hit <enter> to confirm: Skipping creating ../openyoudao_0.2.orig.tar.gz because it already exists Currently there is no top level Makefile. This may require additional tuning. Done. Please edit the files in the debian/ subdirectory now. You should also check that the openyoudao Makefiles install into $DESTDIR and not in / . Package prepared in /home/longsky/openyoudao |
b.将修改提交到打包分支
1 2 3 |
$ cd /home/longsky/openyoudao $ bzr commit -m "Initial commit of Debian packaging." |
c.在当前环境中编译软件包
1 |
$ bzr builddeb -- -us -uc |
d.检测软件包是否存在BUG
1 2 3 |
$ cd .. $ lintian openyoudao_0.2-1.dsc |
e.给软件包签名(需要输入之前设置的密码)
1 2 3 |
$ cd /home/longsky/openyoudao $ debuild -S -k47EDFAD4 |
12.上传软件包
a.编辑~/.dput.cf
通过上面的一系列流程,我们生成了一组经过数字签名的文件,最后需要做的是将这些文件上传到PPA官方的FTP,此时会用到一个叫dput
的软件,要使用dput
,首先要编辑文件~/.dput.cf
,没有就创建.在这个文件里面定义要上传的Launchpad账号。我的~/.dput.cf
文件内容如下:
1 2 3 4 5 6 |
[youdao-beta0.2] fqdn = ppa.launchpad.net method = ftp incoming = ~wangqiang1588/openyoudao-v0.2/ubuntu/ login = anonymous allow_unsigned_uploads = 0 |
b.执行上传
1 |
$ dput my-ppa openyoudao_0.2-1ubuntu1_source.changes |
上传成功后会收到一封PPA发来的邮件,内容如下:
1 2 3 4 5 6 7 8 9 10 |
Accepted: OK: openyoudao_0.2.orig.tar.gz OK: openyoudao_0.2-1ubuntu1.debian.tar.gz OK: openyoudao_0.2-1ubuntu1.dsc -> Component: main Section: net openyoudao (0.2-1ubuntu1) trusty; urgency=low * fix issue#8, exception interrupt https://launchpad.net/~wangqiang1588/+archive/openyoudao-v0.2 You are receiving this email because you are the uploader of the above PPA package. |
接下来就静待官方编译吧~
编译完成后,就可以通过ppa源进行安装了
编译进度可查看:http://ppa.launchpad.net/wangqiang1588/