Creating a new GPG key

1
sudo apt install gnupg
1
gpg --full-gen-key
1
RSA (sign only)
1
2
# 4096 bits
4096
1
2
# key does not expire
0
1
y
1
2
3
pub   rsa4096 2023-11-14 [SC]
      5880510D3E9E0179D3E734F8BBA5403519EC0AE7
uid                      Ye Zheng <csyezheng@gmail.com>
1
vim .zshrc
1
2
3
4
5
6
7
8
DEBEMAIL="csyezheng@gmail.com"
DEBFULLNAME="Ye Zheng"
export DEBEMAIL DEBFULLNAME

DEBUILD_DPKG_BUILDPACKAGE_OPTS="-i -I -us -uc"
DEBUILD_LINTIAN_OPTS="-i -I --show-overrides"
DEBSIGN_KEYID="5880510D3E9E0179D3E734F8BBA5403519EC0AE7"
export DEBSIGN_KEYID

Launchpad Account

1
https://launchpad.net/~csyezheng

Add SSH keys

1
cat  ~/.ssh/id_dsa.pub
1
https://launchpad.net/~csyezheng/+editsshkeys

Publish Keys to keyserver

1
gpg --list-keys
1
gpg --keyserver keyserver.ubuntu.com --send-keys 3AB156E13F8B3955249FECC0FD96CCCB2DCE2762
1
gpg --keyserver keyserver.ubuntu.com --send-keys BE24FF2A72DE9BE1D086D416A15CEAE39BD5EB42

Add OpenPGP keys

Import an OpenPGP key

1
gpg --fingerprint
1
https://launchpad.net/~csyezheng/+editpgpkeys

Check the email account that Launchpad has sent the confirmation email to.

copy the encrypted email’s contents, type gpg in your terminal, then paste the email contents into your terminal window.

1
gpg
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-----BEGIN PGP MESSAGE-----

hQIMA2avPGnkhwiWAQ//cueyaUZv+XIScnXO19/WxknKYO7ZoDCCuh/ButR/ahoI
vYq4K/z5SWLTn/4eimdCsuaxo7iEw5uANFmU3fBH+FgMWWagUaG6lOK/KqYn5xd9
wlfGvEQWl2LdHYNm6byAGKMr4+b8s+a36XoRChDDO8G/SourpJtVf/zEmKGTuNgY
ptDSKauXBL1us+RVXf4kS/S9EF9Pe6An+T7qx4vzpeGusK/PIUJT8XJj7ZYNcZAX
e1nUwgm0oR/wOkxvZonREuGE4n4x54vXQv6yEuobDCzEcemSy3ffI6fyAT56qsST
OeQ/srnRUUpkFXNcipSZjhQvllymTmMfOPIzCOOvsDF9H5zNvkZvwILVugAcWkuW
8/ja748wm+m3BVhu7/yytJvk7otY0fL8nxVfYyFjWcd9v+qfaWCo5as6Ly/Yxjg+
XBteQmrUSRMLKJvlZiRxr1fTnW71sB0rTH35nNOLUFcESAKV1pTdQC2xhntiRKec
59oabNDTU3qpzL1cqUuGNlPT2XMPGBWvb7mBk+NxCuUJRw73cmMrQlJAeXZ8GtZX
cFH0FzTFj6+68pIloCSi6yE5sT7mzPGJ+4FJkuvHYY+EtAcCa7KBrv1F2qu8W2nR
v8BSaB1G0H3/HA5OGf8xTDlF7i8AcswWVM+O4rnF+fHbeFO33HiGhiB6c1O74prS
wKwBYe4oL12UhkM+4jG+CL1u1gigIdDvqyNT8zsIJd56vzHNFxmRwCMlAUq58MJv
64Fg4VGIQoYiiOZEqZeeSlJPKzKaIeLn8PvhTVTrMX4/iTlTw2t+PjQ4+ak75bHP
odMTycs8BDOg62gRzxbTUiAArZp8jBUCEa0ALYWJotq7eDI4Cd1jwFgsZSAZq1/o
DNn6W72ANKiwN++1FgiinF89o/2cUCYGR0By25tbmN/s0NeoVRKgieNracCBCmGn
hfdkJ6kfGxbHfvQlHyyHFupHHeifAAw3RfzSPIrTInaDyNGbeJXPGtS/sDjYNU6r
TinflKsnoFyQj7LIbSVXZ5P25njNGS+aWPjLqM4x4Mc3qq1c+yzFMsskOj4g5MQ4
LL2dvT/dC1uGBoy6lkU1SA2A4ugZg5yRIeTbjzpGRIo8CW0ShaVojNI7oAvGdee4
NY2AW8fd6jLrg+doeb/JN//O5VB4hmlNcIEgYpRV
=3rSi
-----END PGP MESSAGE-----

include begin and end line.

Back on the Launchpad website, click the Confirm button and Launchpad will complete the import of your OpenPGP key.

Create PPA

1
https://launchpad.net/~csyezheng/+activate-ppa

The debian directory

Required files under the debian directory

debian/control

debian/copyright

debian/changelog

debian/rules

Other files under the debian directory

debian/compat

The compat file defines the debhelper compatibility level.

1
$ echo 10 > debian/compat

debian/source/format

  • 3.0 (native) for native Debian packages or
  • 3.0 (quilt) for everything else.

Building the package

1
sudo apt install devscripts debhelper dh-golang golang-go
1
vim  ~/.devscripts
1
2
3
DEBUILD_DPKG_BUILDPACKAGE_OPTS="-us -uc -I -i"
DEBUILD_LINTIAN_OPTS="-i -I --show-overrides"
DEBSIGN_KEYID=3AB156E13F8B3955249FECC0FD96CCCB2DCE2762
1
vim ~/.bashrc
1
export DEBSIGN_KEYID=3AB156E13F8B3955249FECC0FD96CCCB2DCE2762

Test

1
debian/rules build
1
fakeroot debian/rules install
1
sudo apt install devscripts dh-make dh-golang
1
curl -OL https://github.com/csyezheng/a2fa/archive/refs/tags/v0.16.5.tar.gz
1
mv v0.16.5.tar.gz a2fa_0.16.5.tar.gz
1
tar xzf a2fa_0.16.5.tar.gz
1
cd a2fa-0.16.5
1
mkdir debian
1
dch --create -v 0.16.5 --package a2fa
1
paru -S devscripts
1
vim ~/.devscripts
1
2
3
DEBUILD_DPKG_BUILDPACKAGE_OPTS="-i -I -us -uc"
DEBUILD_LINTIAN_OPTS="-i -I --show-overrides"
DEBSIGN_KEYID="Your_GPG_keyID"
1
dch --create -v 0.16.5 --package a2fa
1
2
sudo pacman -S base-devel
paru -S dh-make
1
2
mkdir a2fa-0.16.5
cd a2fa-0.16.5
1
dh_make --native
1
2
cd debian
tree .
1
git clone https://github.com/csyezheng/a2fa.git
1
2
3
4
5
6
7
arch% tree -L 1
.
├── a2fa
│   ├── cmd
│   ├── go.mod
│   ├── go.sum
└── debian

write makefile

1
vim makefile
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

PRO_NAME:=a2fa
PRO_MAK:=./.${PRO_NAME}.mak

PWD := $(shell pwd)/a2fa
TARGET := a2fa

all: clean
    cd $(PWD) && go build -v -o $(TARGET) .

clean:
    rm -f a2fa-0.16.5/$(TARGET)

install:
    mkdir -p ${DESTDIR}/usr/bin/a2fa
    install -Dm755 ./demo/${TARGET}  ${DESTDIR}/usr/bin/demo/

Packing using dpkg-buildpackage

1
dpkg-buildpackage -D -us -uc -b

Packing using debuild

1
sudo apt install dh-make
1
dh_make --packagename a2fa_0.16.5.0 --single --native --copyright apache --email csyezheng@gmail.com

debian/changelog

A field in the first line of debian/changelog specifies the target distroseries. For Debian it might be ‘unstable’ or ‘stable’, but for Ubuntu you need to specify the codename of your target – eg. ‘Focal’ or ‘**Jammy **’.

1
perl -i -pe "s/unstable/$(lsb_release -cs)/" debian/changelog

Install dependencies

1
sudo apt-get install -y equivs
1
sudo mk-build-deps -i

build using debuild

1
export DEBSIGN_KEYID=3AB156E13F8B3955249FECC0FD96CCCB2DCE2762
1
debuild -S -k$DEBSIGN_KEYID | tee /tmp/debuild.log 2>&1
1
debuild -S -sd
1
debuild -S -sa
1
debuild -S 
1
cd ..
1
debsign -k$DEBSIGN_KEYID a2fa_0.16.5.0_source.changes

Uploading the package to a PPA

1
sudo apt install python3 python3-pip
1
pip3 install paramiko
1
vim ~/.dput.cf
1
2
3
4
5
6
[a2fa-ppa]
fqdn = ppa.launchpad.net
method = sftp
incoming = ~csyezheng/ubuntu/a2fa/
login = csyezheng
allow_unsigned_uploads = 0
1
dput a2fa-ppa a2fa_0.16.5.0_source.changes
1
https://launchpad.net/~csyezheng/+archive/ubuntu/a2fa/+packages

If after a rejected upload you try to upload the same source package again and dput complains that the source package has already been uploaded, it’s because the logfile <package>_source.<host>.upload exists. Just remove the .upload file and re-run dput, or invoke dput with the flag -f.

Installing software from a PPA

1
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 6BBC27E1D59463FEFB095F03E1145C4C1D83F192

Visit the PPA’s overview page in Launchpad and look for the PPA’s location

1
ppa:csyezheng/a2fa

Add repository and fetch the PPA’s key

1
sudo add-apt-repository ppa:csyezheng/a2fa

Pull down the latest list of software from each archive

1
sudo apt-get update

Installing software from the PPA

1
sudo apt-get dist-upgrade

Remove a PPA using APT in the terminal:

1
sudo add-apt-repository --remove ppa:csyezheng/a2fa

Reference

Building a source package

Packaging New Software

introduction to Debian Packaging

rclone control

dh-make-golang: creating Debian packages from Go packages

dh-make-golang

dh-golang

debhelper

发布你的开源软件到 Ubuntu PPA

rclone makefile

internal/initialize/version.go

Uploading a package to a PPA

git-lfs debian

dcs debian

botanist debian

snapd packaging

artifact-registry-apt-transport packaging debian

Debian New Maintainers’ Guide

Chapter 2. First steps

Chapter 4. Required files under the debian directory

Chapter 5. Other files under the debian directory

Debian Go Packaging

Packaging Go application for Debian

Automatically install unmet build dependencies as detected by dpkg-checkbuilddeps