build deb package on archlinux

目标: 以下功能可以正常使用:

devscripts(dget)

安装

因为debian 系统使用apt 作为包管理器,Archlinux 使用pacman,混用包管理器是非常危险的,所以我们应当在pbuilder 环境中进行编译等操作,以下将简单介绍工作流程

在Arch 上编译 devscripts,缺少依赖 debianutils, debhelpergit, sensible-utils,缺少编译依赖perl-git-wrapper, perl-list-compare, perl-parse-debcontrol,缺少可选依赖 dh-make,以上全部自己编译,推荐使用devtools 编译或者添加我的仓库

1
2
[peeweep]
Server = https://repo.peeweep.de/archlinux/$arch

sensible-utils 无法编译

AUR中的 sensible-utils 0.0.12-2 的已经无法编译,debian 已经解决这个BUG 并且推了0.0.13 (#963424),我flag 了一下 out-of-dated,以下是我用的 0.0.13 PKGBUILD

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
diff --git a/.SRCINFO b/.SRCINFO
index b7dfd1f..7f47dd4 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,15 +1,15 @@
pkgbase = sensible-utils
pkgdesc = Utilities for sensible alternative selection
- pkgver = 0.0.12
- pkgrel = 2
+ pkgver = 0.0.13
+ pkgrel = 1
url = http://packages.debian.org/source/sid/sensible-utils
arch = any
license = GPL
checkdepends = ed
makedepends = po4a
depends = bash
- source = http://ftp.de.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.12.tar.xz
- sha256sums = 99ba2ebf8c57447c69d426b99b84ff9dc817be0bc4988ec6890a14558c529e2e
+ source = http://ftp.de.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.tar.xz
+ sha256sums = 8627a530e48066282aa81384dddfb38cf53c8470ae7e633c14d2341418fa6298

pkgname = sensible-utils

diff --git a/PKGBUILD b/PKGBUILD
index 4d310ba..148c3f5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Pierre Carrier <pierre@gcarrier.fr>
pkgname=sensible-utils
-pkgver=0.0.12
-pkgrel=2
+pkgver=0.0.13
+pkgrel=1
pkgdesc="Utilities for sensible alternative selection"
arch=('any')
url="http://packages.debian.org/source/sid/sensible-utils"
@@ -10,23 +10,23 @@ depends=('bash')
makedepends=('po4a')
checkdepends=('ed')
source=(http://ftp.de.debian.org/debian/pool/main/s/$pkgname/${pkgname}_$pkgver.tar.xz)
-sha256sums=('99ba2ebf8c57447c69d426b99b84ff9dc817be0bc4988ec6890a14558c529e2e')
+sha256sums=('8627a530e48066282aa81384dddfb38cf53c8470ae7e633c14d2341418fa6298')

build() {
- cd $pkgname.git
+ cd $pkgname-$pkgver
export -n EDITOR VISUAL
./configure --prefix=/usr
make
}

check() {
- cd $pkgname.git
+ cd $pkgname-$pkgver
export -n EDITOR VISUAL
make -k check
}

package() {
- cd $pkgname.git
+ cd $pkgname-$pkgver
export -n EDITOR VISUAL
make DESTDIR="$pkgdir/" install
}

使用

1
dget http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.dsc

报错: dpkg-vendor: error: vendor default doesn’t exist in /etc/dpkg/origins

报错信息

1
2
3
4
5
6
7
8
[/tmp]$ dget http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.dsc
dget: retrieving http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.dsc
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1688 100 1688 0 0 3480 0 --:--:-- --:--:-- --:--:-- 3480
dget: using existing sensible-utils_0.0.13.tar.xz
dpkg-vendor: error: vendor default doesn't exist in /etc/dpkg/origins
dscverify: can't find any system keyrings

dpkg-vendor 找不到vendor信息,是因为Archlinux 上的dpkg 包没有把vendor预置到 /etc/dpkg/origins目录里,我们可以自己写一个archlinux

1
2
3
Vendor: ArchLinux
Vendor-URL: https://www.archlinux.org/
Bugs: https://bugs.archlinux.org/
1
2
sudo install -Dm644 archlinux /etc/dpkg/origins/archlinux -v
sudo ln -sf /etc/dpkg/origins/archlinux /etc/dpkg/origins/default -v

报错: Can’t locate File/HomeDir.pm

报错信息

1
2
3
4
5
6
7
8
9
10
11
12
[/tmp]$ dget http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils
_0.0.13.dsc
dget: retrieving http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.dsc
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1688 100 1688 0 0 4077 0 --:--:-- --:--:-- --:--:-- 4077
dget: retrieving http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.tar.xz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 62020 100 62020 0 0 150k 0 --:--:-- --:--:-- --:--:-- 150k
Can't locate File/HomeDir.pm in @INC (you may need to install the File::HomeDir module) (@INC contains: /usr/lib/perl5/5.32/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/5.32/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/5.32/core_perl /usr/share/perl5/core_perl) at /usr/bin/dscverify line 31.
BEGIN failed--compilation aborted at /usr/bin/dscverify line 31.
perl-file-homedir 在aur 上只是makedepnds,手动安装一下,已经报告给了维护者,让他加到depends里

报错: dscverify: can’t find any system keyrings

1
2
3
4
5
6
7
[/tmp]$ dget http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.dsc
dget: retrieving http://deb.debian.org/debian/pool/main/s/sensible-utils/sensible-utils_0.0.13.dsc
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1688 100 1688 0 0 4251 0 --:--:-- --:--:-- --:--:-- 4251
dget: using existing sensible-utils_0.0.13.tar.xz
dscverify: can't find any system keyrings

安装debian-keyring ,已经报告给了维护者,让他加到optdepends里。或者你可以用dpkg-source -x 手动解压

1
2
3
4
5
6
7
8
9
10
[/tmp]$ dpkg-source -x --skip-patches ./sensible-utils_0.0.13.dsc                             
dpkg-source: warning: --skip-patches is not a valid option for Dpkg::Source::Package::V3::Native
gpgv: unknown type of key resource 'trustedkeys.kbx'
gpgv: keyblock resource '/tmp/dpkg-verify-sig.KzVhNokQ/trustedkeys.kbx': General error
gpgv: Signature made Wed 08 Jul 2020 07:10:38 AM CST
gpgv: using RSA key 7C56ACFE947897D8
gpgv: Can't check signature: No public key
dpkg-source: warning: failed to verify signature on ./sensible-utils_0.0.13.dsc
dpkg-source: info: extracting sensible-utils in sensible-utils-0.0.13
dpkg-source: info: unpacking sensible-utils_0.0.13.tar.xz

pbuilder

安装

pbuilder-ubuntu

使用

修改/etc/pbuilderrc

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
--- /usr/share/pbuilder/pbuilderrc	2020-10-13 11:23:36.000000000 +0800
+++ /etc/pbuilderrc 2020-10-13 13:01:06.991275977 +0800
@@ -24,7 +24,7 @@
# Debian buildds too. You can set it to $BUILDDIR to get a working HOME, if
# you need to.
BUILD_HOME=/nonexistent
-MIRRORSITE=http://archive.ubuntu.com/ubuntu
+MIRRORSITE=https://mirrors.sjtug.sjtu.edu.cn/debian
#OTHERMIRROR="deb http://www.home.com/updates/ ./"
#export http_proxy=http://your-proxy:8080/
USESHM=yes
@@ -118,7 +118,7 @@
# Set the debootstrap variant to 'buildd' type.
DEBOOTSTRAPOPTS=(
'--variant=buildd'
- '--force-check-gpg'
+ '--no-check-gpg'
)
# or unset it to make it not a buildd type.
# unset DEBOOTSTRAPOPTS
@@ -147,7 +147,7 @@
AUTOCLEANAPTCACHE=""

#default COMPRESSPROG
-COMPRESSPROG="gzip"
+COMPRESSPROG="pigz"

# pbuilder copies some configuration files (like /etc/hosts or /etc/hostname)
# from the host system into the chroot. If the directory specified here
  • MIRRORSITE 指定仓库地址
  • DEBOOTSTRAPOPTS 指定debootstrap 的参数
  • COMPRESSPROG 使用pigz 来使用所有核心, 需要安装pigz 软件包

创建一个debian experimental的base.tgz

1
sudo pbuilder --create --distribution experimental --basetgz exp.tgz
报错: No such script:

没有当前dist对应的 deboostrap 脚本

报错信息:

1
E: No such script: /usr/share/debootstrap/scripts/experimental
1
2
3
4
5
6
7
8
9
10
11
12
13
[/tmp]$ sudo pbuilder --create --distribution experimental --basetgz exp.tgz
W: /root/.pbuilderrc does not exist
W: cgroups are not available on the host, not using them.
I: Distribution is experimental.
I: Current time: Tue Oct 13 14:24:21 CST 2020
I: pbuilder-time-stamp: 1602570261
I: Building the build environment
I: running debootstrap
/usr/sbin/debootstrap
E: No such script: /usr/share/debootstrap/scripts/experimental
E: debootstrap failed
E: debootstrap.log not present
W: Aborting with an error

解决方案: 添加dist对应的 deboostrap 脚本

1
dist=experimental; if [ ! -f /usr/share/debootstrap/scripts/$dist ]; then sudo install -Dm644 -v usr/share/debootstrap/scripts/buster /usr/share/debootstrap/scripts/$dist; fi

使用pbuilder 编译软件包

pbuilder 编译软件包有两种方式,通过软件包的dsc 编译,也可以使用pbuilder –login 当作chroot 进入

通过dsc编译

dsc 可以通过dpkg-source -b .生成

1
sudo pbuilder --build --basetgz exp.tgz sensible-utils_0.0.13.dsc
当作chroot
1
sudo pbuilder --login --basetgz exp.tgz

base环境里做的操作退出时会销毁,如果想保留,可以后边加–save-after-login 参数

1
sudo pbuilder --login --basetgz exp.tgz --save-after-login