-
Notifications
You must be signed in to change notification settings - Fork 562
/
PKGBUILD
209 lines (182 loc) · 8.22 KB
/
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# Maintainer: aimileus <me at aimileus dot nl>
# Maintainer: Maciej Borzecki <maciek.borzecki@gmail.com>
# Contributor: Timothy Redaelli <timothy.redaelli@gmail.com>
# Contributor: Zygmunt Krynicki <me at zygoon dot pl>
#
# Environment variables that can set by CI:
# - WITH_TEST_KEYS=1 - enable use of testing keys
pkgname=snapd
pkgdesc="Service and tools for management of snap packages."
depends=('squashfs-tools' 'libseccomp' 'libsystemd' 'apparmor')
optdepends=('bash-completion: bash completion support'
'xdg-desktop-portal: desktop integration')
pkgver=2.61.2
pkgrel=1
arch=('x86_64' 'i686' 'armv7h' 'aarch64')
url="https://github.com/snapcore/snapd"
license=('GPL3')
makedepends=('git' 'go' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'python-docutils' 'apparmor')
# the following checkdepends are only required for static checks and unit tests,
# unit tests are currently enabled
checkdepends=('python' 'squashfs-tools' 'shellcheck')
conflicts=('snap-confine')
options=('!strip' 'emptydirs')
install=snapd.install
source=("git+https://github.com/snapcore/$pkgname.git")
sha256sums=('SKIP')
_gourl=github.com/snapcore/snapd
pkgver() {
cd "$srcdir/snapd"
git describe --tag | sed -r 's/([^-]*-g)/r\1/; s/-/./g'
}
prepare() {
cd "$pkgname"
export GOPATH="$srcdir/go"
# Have snapd checkout appear in a place suitable for subsequent GOPATH. This
# way we don't have to go get it again and it is exactly what the tag/hash
# above describes.
mkdir -p "$(dirname "$srcdir/go/src/${_gourl}")"
ln --no-target-directory -fs "$srcdir/$pkgname" "$srcdir/go/src/${_gourl}"
}
build() {
cd "$pkgname"
export GOPATH="$srcdir/go"
# GOFLAGS may be modified by CI tools
# GOFLAGS are the go build flags for all binaries, GOFLAGS_SNAP are for snap
# build only.
GOFLAGS=""
GOFLAGS_SNAP="-tags nomanagers"
if [[ "$WITH_TEST_KEYS" == 1 ]]; then
GOFLAGS="$GOFLAGS -tags withtestkeys"
GOFLAGS_SNAP="-tags nomanagers,withtestkeys"
fi
export CGO_ENABLED="1"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
./mkversion.sh $pkgver-$pkgrel
# because argument expansion with quoting in bash is hard, and -ldflags=-extldflags='-foo'
# is not exactly the same as -ldflags "-extldflags '-foo'" use the array trick
# to pass exactly what we want
flags=(-buildmode=pie -ldflags "-s -linkmode external -extldflags '$LDFLAGS'" -trimpath -mod=vendor)
staticflags=(-buildmode=pie -ldflags "-s -linkmode external -extldflags '$LDFLAGS -static'" -trimpath -mod=vendor)
# Build/install snap and snapd
go build "${flags[@]}" -o "$srcdir/go/bin/snap" $GOFLAGS_SNAP "${_gourl}/cmd/snap"
go build "${flags[@]}" -o "$srcdir/go/bin/snapd" $GOFLAGS "${_gourl}/cmd/snapd"
go build "${flags[@]}" -o "$srcdir/go/bin/snap-seccomp" $GOFLAGS "${_gourl}/cmd/snap-seccomp"
go build "${flags[@]}" -o "$srcdir/go/bin/snap-failure" $GOFLAGS "${_gourl}/cmd/snap-failure"
go build "${flags[@]}" -o "$srcdir/go/bin/snapd-apparmor" $GOFLAGS "${_gourl}/cmd/snapd-apparmor"
# build snap-exec and snap-update-ns completely static for base snaps
go build "${staticflags[@]}" -o "$srcdir/go/bin/snap-update-ns" $GOFLAGS "${_gourl}/cmd/snap-update-ns"
go build "${staticflags[@]}" -o "$srcdir/go/bin/snap-exec" $GOFLAGS "${_gourl}/cmd/snap-exec"
go build "${staticflags[@]}" -o "$srcdir/go/bin/snapctl" $GOFLAGS "${_gourl}/cmd/snapctl"
# Generate data files such as real systemd units, dbus service, environment
# setup helpers out of the available templates
make -C data \
BINDIR=/bin \
LIBEXECDIR=/usr/lib \
SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system \
SNAP_MOUNT_DIR=/var/lib/snapd/snap \
SNAPD_ENVIRONMENT_FILE=/etc/default/snapd
cd cmd
autoreconf -i -f
./configure \
--prefix=/usr \
--libexecdir=/usr/lib/snapd \
--with-snap-mount-dir=/var/lib/snapd/snap \
--enable-apparmor \
--enable-nvidia-biarch \
--enable-merged-usr
make $MAKEFLAGS
}
check() {
export GOPATH="$srcdir/go"
cd "$srcdir/go/src/${_gourl}"
# make sure the binaries that need to be built statically really are
for binary in snap-exec snap-update-ns snapctl; do
LC_ALL=C ldd "$srcdir/go/bin/$binary" 2>&1 | grep -q 'not a dynamic executable'
done
SKIP_UNCLEAN=1 ./run-checks --unit
# XXX: Static checks choke on autotools generated cruft. Let's not run them
# here as they are designed to pass on a clean tree, before anything else is
# done, not after building the tree.
# ./run-checks --static
TMPDIR=/tmp make -C cmd -k check
mv $srcdir/xxx-info data/info
}
package() {
cd "$pkgname"
export GOPATH="$srcdir/go"
# Install bash completion
install -Dm644 data/completion/bash/snap \
"$pkgdir/usr/share/bash-completion/completions/snap"
install -Dm644 data/completion/bash/complete.sh \
"$pkgdir/usr/lib/snapd/complete.sh"
install -Dm644 data/completion/bash/etelpmoc.sh \
"$pkgdir/usr/lib/snapd/etelpmoc.sh"
# Install zsh completion
install -Dm644 data/completion/zsh/_snap \
"$pkgdir/usr/share/zsh/site-functions/_snap"
# Install systemd units, dbus services and a script for environment variables
make -C data/ install \
DBUSSERVICESDIR=/usr/share/dbus-1/services \
BINDIR=/usr/bin \
SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system \
SNAP_MOUNT_DIR=/var/lib/snapd/snap \
DESTDIR="$pkgdir"
# Install polkit policy
install -Dm644 data/polkit/io.snapcraft.snapd.policy \
"$pkgdir/usr/share/polkit-1/actions/io.snapcraft.snapd.policy"
# Install executables
install -Dm755 "$srcdir/go/bin/snap" "$pkgdir/usr/bin/snap"
install -Dm755 "$srcdir/go/bin/snapctl" "$pkgdir/usr/lib/snapd/snapctl"
install -Dm755 "$srcdir/go/bin/snapd" "$pkgdir/usr/lib/snapd/snapd"
install -Dm755 "$srcdir/go/bin/snap-seccomp" "$pkgdir/usr/lib/snapd/snap-seccomp"
install -Dm755 "$srcdir/go/bin/snap-failure" "$pkgdir/usr/lib/snapd/snap-failure"
install -Dm755 "$srcdir/go/bin/snapd-apparmor" "$pkgdir/usr/lib/snapd/snapd-apparmor"
install -Dm755 "$srcdir/go/bin/snap-update-ns" "$pkgdir/usr/lib/snapd/snap-update-ns"
install -Dm755 "$srcdir/go/bin/snap-exec" "$pkgdir/usr/lib/snapd/snap-exec"
# Ensure /usr/bin/snapctl is a symlink to /usr/libexec/snapd/snapctl
ln -s /usr/lib/snapd/snapctl "$pkgdir/usr/bin/snapctl"
# pre-create directories
install -dm755 "$pkgdir/var/lib/snapd/snap"
install -dm755 "$pkgdir/var/cache/snapd"
install -dm755 "$pkgdir/var/lib/snapd/apparmor"
install -dm755 "$pkgdir/var/lib/snapd/assertions"
install -dm755 "$pkgdir/var/lib/snapd/dbus-1/services"
install -dm755 "$pkgdir/var/lib/snapd/dbus-1/system-services"
install -dm755 "$pkgdir/var/lib/snapd/desktop/applications"
install -dm755 "$pkgdir/var/lib/snapd/device"
install -dm755 "$pkgdir/var/lib/snapd/hostfs"
install -dm755 "$pkgdir/var/lib/snapd/mount"
install -dm755 "$pkgdir/var/lib/snapd/seccomp/bpf"
install -dm755 "$pkgdir/var/lib/snapd/snap/bin"
install -dm755 "$pkgdir/var/lib/snapd/snaps"
install -dm755 "$pkgdir/var/lib/snapd/inhibit"
install -dm755 "$pkgdir/var/lib/snapd/lib/gl"
install -dm755 "$pkgdir/var/lib/snapd/lib/gl32"
install -dm755 "$pkgdir/var/lib/snapd/lib/vulkan"
install -dm755 "$pkgdir/var/lib/snapd/lib/glvnd"
# these dirs have special permissions
install -dm111 "$pkgdir/var/lib/snapd/void"
install -dm700 "$pkgdir/var/lib/snapd/cookie"
install -dm700 "$pkgdir/var/lib/snapd/cache"
make -C cmd install DESTDIR="$pkgdir/"
# Install man file
mkdir -p "$pkgdir/usr/share/man/man8"
"$srcdir/go/bin/snap" help --man > "$pkgdir/usr/share/man/man8/snap.8"
# Install the "info" data file with snapd version
install -m 644 -D "$srcdir/go/src/${_gourl}/data/info" \
"$pkgdir/usr/lib/snapd/info"
# Remove snappy core specific units
rm -fv "$pkgdir/usr/lib/systemd/system/snapd.system-shutdown.service"
rm -fv "$pkgdir/usr/lib/systemd/system/snapd.autoimport.service"
rm -fv "$pkgdir/usr/lib/systemd/system/snapd.recovery-chooser-trigger.service"
rm -fv "$pkgdir"/usr/lib/systemd/system/snapd.snap-repair.*
rm -fv "$pkgdir"/usr/lib/systemd/system/snapd.core-fixup.*
# and scripts
rm -fv "$pkgdir/usr/lib/snapd/snapd.core-fixup.sh"
rm -fv "$pkgdir/usr/bin/ubuntu-core-launcher"
rm -fv "$pkgdir/usr/lib/snapd/system-shutdown"
}