自制 PPA

创建 PPA

  1. 注册 Ubuntu One 帐号。

  2. Launchpad 上传 GPG 公钥。

    解密你收到的邮件,并打开其中的验证链接:

    pbpaste | gpg -d
    
  3. 签名行为准则:

    wget -O UbuntuCodeofConduct-2.0.txt https://launchpad.net/codeofconduct/2.0/+download
    gpg --clear-sign UbuntuCodeofConduct-2.0.txt
    cat UbuntuCodeofConduct-2.0.txt.asc | pbcopy
    

    上传签名:Codes of Conduct

  4. 个人资料页找到 Create a new PPA,创建一个 PPA。

上传包

添加 Debian 打包文件

  1. 安装打包依赖:

    sudo apt install build-essential devscripts debhelper
    
  2. 获取你要上传的软件包的源码,如 hithere-1.0.tar.gz

    mkdir build && cd build
    wget --content-disposition "https://wiki.debian.org/Packaging/Intro?action=AttachFile&do=get&target=hithere-1.0.tar.gz"
    
  3. 将源码压缩包重命名为 pkgname_ver.orig.tar.gz 的形式:

    mv hithere-1.0.tar.gz hithere_1.0.orig.tar.gz
    
  4. 解压源码:

    tar -xzf hithere_1.0.orig.tar.gz  # 得到 hithere-1.0 目录
    cd hithere-1.0
    
  5. 创建 changelog 文件:

    export DEBFULLNAME="John Connor" DEBEMAIL="email@example.com"
    mkdir -p debian/source
    dch --create -v 1.0-1 -u low --package hithere
    sed -i "s/UNRELEASED/jammy/" debian/changelog
    
  6. 创建 control 文件:

    vim debian/control
    
    Source: hithere
    Maintainer: Lars Wirzenius <liw@liw.fi>
    Section: misc
    Priority: optional
    Standards-Version: 4.7.0
    Build-Depends: debhelper-compat (= 13)
    
    Package: hithere
    Architecture: any
    Depends: ${shlibs:Depends}, ${misc:Depends}
    Description: greet user
     hithere greets the user, or the world.
    

    第一段描述源码包,剩下的段描述由源码构建的二进制包。

  7. 创建 copyright 文件:

    touch debian/copyright
    
  8. 创建 rules 文件:

    vim debian/rules
    
    #!/usr/bin/make -f
    %:
    	dh $@
    
    override_dh_auto_install:
    	$(MAKE) DESTDIR=$$(pwd)/debian/hithere prefix=/usr install
    

    构建规则 override_dh_auto_install 用于将安装目录修改为 ./debian/hithere/usr

  9. 创建 .dirs 文件:

    vim debian/hithere.dirs
    
    usr/bin
    usr/share/man/man1
    

    .dirs 文件用于创建目录

  10. 创建 source/format 文件:

    echo "3.0 (quilt)" > debian/source/format
    

    source/format 文件用于指定 Debian 软件包的源格式。

打包并上传到 PPA

  1. 构建包:

    debuild -S
    
  2. 上传包:

    cd ..
    dput ppa:your-lp-id/ppa <source.changes>  # 上传到 PPA
    

拷贝包

如果只是想拷贝其他人上传到 PPA 的包,那么无需自己构建 PPA。Launchpad 提供了拷贝其他包到自己 PPA 的功能。

  1. 打开你要拷贝的 PPA:

    以 NeoVim Stable 为例:https://launchpad.net/~neovim-ppa/+archive/ubuntu/stable

  2. 点击 View package details

    Package Details:https://launchpad.net/~neovim-ppa/+archive/ubuntu/stable/+packages

    image

  3. 点击 Copy packages

    Copy Packages:https://launchpad.net/~neovim-ppa/+archive/ubuntu/stable/+copy-packages

    image

  4. 选择需要拷贝的包,并拷贝到自己的 PPA:

    image

    Copy options 建议选择 Copy existing binaries,这样不用重新构建包,避免编译错误。

杂项

相关工具:

  • debsign:对软件包签名(主要是 .changes 文件)
  • debmake:自动构建
  • dh_make:一键搭建构建框架(较老)

参考:

Troubleshooting

常见上传问题:Packaging/UploadErrors | Launchpad Help

No secret key

运行 debuild 时出现错误:

Now signing changes and any dsc files...
 signfile dsc hithere_1.0-1.dsc Xiao Li <xiaoli3397@gmail.com>
gpg: skipped "Someone <someone@gmail.com>": No secret key
gpg: /tmp/debsign.bLUHk893/hithere_1.0-1.dsc: clear-sign failed: No secret key
debsign: gpg error occurred!  Aborting....
debuild: fatal error at line 1114:
running debsign failed

原因是找不到指定名称的 GPG 私钥。检查私钥名和邮件地址。

Source/binary (i.e. mixed) uploads are not allowed

上传 PPA 后收到邮件提示被拒绝:

Rejected:
Source/binary (i.e. mixed) uploads are not allowed.

原因:上传了二进制包。

解决方法:只编译并上传源码包

debuild -S

参考:Source/binary (i.e. mixed) uploads are not allowed | Launchpad

posted @ 2025-05-12 23:57  Undefined443  阅读(46)  评论(0)    收藏  举报