github.com/rigado/snapd@v2.42.5-go-mod+incompatible/packaging/arch/PKGBUILD (about) 1 # Maintainer: aimileus <me at aimileus dot nl> 2 # Maintainer: Maciej Borzecki <maciek.borzecki@gmail.com> 3 # Contributor: Timothy Redaelli <timothy.redaelli@gmail.com> 4 # Contributor: Zygmunt Krynicki <me at zygoon dot pl> 5 # 6 # Environment variables that can set by CI: 7 # - WITH_TEST_KEYS=1 - enable use of testing keys 8 9 pkgname=snapd 10 pkgdesc="Service and tools for management of snap packages." 11 depends=('squashfs-tools' 'libseccomp' 'libsystemd') 12 optdepends=('bash-completion: bash completion support') 13 pkgver=2.42.5 14 pkgrel=1 15 arch=('x86_64') 16 url="https://github.com/snapcore/snapd" 17 license=('GPL3') 18 makedepends=('git' 'go' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'python-docutils' 'apparmor') 19 # the following checkdepends are only required for static checks and unit tests, 20 # unit tests are currently enabled 21 checkdepends=('python' 'squashfs-tools' 'shellcheck') 22 conflicts=('snap-confine') 23 options=('!strip' 'emptydirs') 24 install=snapd.install 25 source=("git+https://github.com/snapcore/$pkgname.git") 26 sha256sums=('SKIP') 27 28 _gourl=github.com/snapcore/snapd 29 30 pkgver() { 31 cd "$srcdir/snapd" 32 git describe --tag | sed -r 's/([^-]*-g)/r\1/; s/-/./g' 33 } 34 35 prepare() { 36 cd "$pkgname" 37 38 export GOPATH="$srcdir/go" 39 40 # Have snapd checkout appear in a place suitable for subsequent GOPATH. This 41 # way we don't have to go get it again and it is exactly what the tag/hash 42 # above describes. 43 mkdir -p "$(dirname "$srcdir/go/src/${_gourl}")" 44 ln --no-target-directory -fs "$srcdir/$pkgname" "$srcdir/go/src/${_gourl}" 45 } 46 47 build() { 48 cd "$pkgname" 49 export GOPATH="$srcdir/go" 50 51 # GOFLAGS may be modified by CI tools 52 GOFLAGS="" 53 if [[ "$WITH_TEST_KEYS" == 1 ]]; then 54 GOFLAGS="$GOFLAGS -tags withtestkeys" 55 fi 56 57 export CGO_ENABLED="1" 58 export CGO_CFLAGS="${CFLAGS}" 59 export CGO_CPPFLAGS="${CPPFLAGS}" 60 export CGO_CXXFLAGS="${CXXFLAGS}" 61 export CGO_LDFLAGS="${LDFLAGS}" 62 63 ./mkversion.sh $pkgver-$pkgrel 64 65 # Use get-deps.sh provided by upstream to fetch go dependencies using the 66 # godeps tool and dependencies.tsv (maintained upstream). 67 cd "$srcdir/go/src/${_gourl}" 68 XDG_CONFIG_HOME="$srcdir" ./get-deps.sh 69 70 gobuild="go build -x -v -buildmode=pie" 71 gobuild_static="go build -x -v -buildmode=pie -ldflags=-extldflags=-static" 72 # Build/install snap and snapd 73 $gobuild -o $srcdir/go/bin/snap $GOFLAGS "${_gourl}/cmd/snap" 74 $gobuild -o $srcdir/go/bin/snapd $GOFLAGS "${_gourl}/cmd/snapd" 75 $gobuild -o $srcdir/go/bin/snap-seccomp $GOFLAGS "${_gourl}/cmd/snap-seccomp" 76 $gobuild -o $srcdir/go/bin/snap-failure $GOFLAGS "${_gourl}/cmd/snap-failure" 77 # build snap-exec and snap-update-ns completely static for base snaps 78 $gobuild_static -o $srcdir/go/bin/snap-update-ns $GOFLAGS "${_gourl}/cmd/snap-update-ns" 79 $gobuild_static -o $srcdir/go/bin/snap-exec $GOFLAGS "${_gourl}/cmd/snap-exec" 80 $gobuild_static -o $srcdir/go/bin/snapctl $GOFLAGS "${_gourl}/cmd/snapctl" 81 82 # Generate data files such as real systemd units, dbus service, environment 83 # setup helpers out of the available templates 84 make -C data \ 85 BINDIR=/bin \ 86 LIBEXECDIR=/usr/lib \ 87 SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system \ 88 SNAP_MOUNT_DIR=/var/lib/snapd/snap \ 89 SNAPD_ENVIRONMENT_FILE=/etc/default/snapd 90 91 cd cmd 92 autoreconf -i -f 93 ./configure \ 94 --prefix=/usr \ 95 --libexecdir=/usr/lib/snapd \ 96 --with-snap-mount-dir=/var/lib/snapd/snap \ 97 --enable-apparmor \ 98 --enable-nvidia-biarch \ 99 --enable-merged-usr 100 make $MAKEFLAGS 101 } 102 103 check() { 104 export GOPATH="$srcdir/go" 105 cd "$srcdir/go/src/${_gourl}" 106 107 SKIP_UNCLEAN=1 ./run-checks --unit 108 # XXX: Static checks choke on autotools generated cruft. Let's not run them 109 # here as they are designed to pass on a clean tree, before anything else is 110 # done, not after building the tree. 111 # ./run-checks --static 112 TMPDIR=/tmp make -C cmd -k check 113 114 mv $srcdir/xxx-info data/info 115 } 116 117 package() { 118 cd "$pkgname" 119 export GOPATH="$srcdir/go" 120 121 # Install bash completion 122 install -Dm644 data/completion/snap \ 123 "$pkgdir/usr/share/bash-completion/completions/snap" 124 install -Dm644 data/completion/complete.sh \ 125 "$pkgdir/usr/lib/snapd/complete.sh" 126 install -Dm644 data/completion/etelpmoc.sh \ 127 "$pkgdir/usr/lib/snapd/etelpmoc.sh" 128 129 # Install systemd units, dbus services and a script for environment variables 130 make -C data/ install \ 131 DBUSSERVICESDIR=/usr/share/dbus-1/services \ 132 BINDIR=/usr/bin \ 133 SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system \ 134 SNAP_MOUNT_DIR=/var/lib/snapd/snap \ 135 DESTDIR="$pkgdir" 136 137 # Install polkit policy 138 install -Dm644 data/polkit/io.snapcraft.snapd.policy \ 139 "$pkgdir/usr/share/polkit-1/actions/io.snapcraft.snapd.policy" 140 141 # Install executables 142 install -Dm755 "$srcdir/go/bin/snap" "$pkgdir/usr/bin/snap" 143 install -Dm755 "$srcdir/go/bin/snapd" "$pkgdir/usr/lib/snapd/snapd" 144 install -Dm755 "$srcdir/go/bin/snap-seccomp" "$pkgdir/usr/lib/snapd/snap-seccomp" 145 install -Dm755 "$srcdir/go/bin/snap-failure" "$pkgdir/usr/lib/snapd/snap-failure" 146 install -Dm755 "$srcdir/go/bin/snap-update-ns" "$pkgdir/usr/lib/snapd/snap-update-ns" 147 install -Dm755 "$srcdir/go/bin/snap-exec" "$pkgdir/usr/lib/snapd/snap-exec" 148 # Ensure /usr/bin/snapctl is a symlink to /usr/libexec/snapd/snapctl 149 install -Dm755 "$srcdir/go/bin/snapctl" "$pkgdir/usr/lib/snapd/snapctl" 150 ln -s ../lib/snapd/snapctl "$pkgdir/usr/bin/snapctl" 151 152 # pre-create directories 153 install -dm755 "$pkgdir/var/lib/snapd/snap" 154 install -dm755 "$pkgdir/var/cache/snapd" 155 install -dm755 "$pkgdir/var/lib/snapd/apparmor" 156 install -dm755 "$pkgdir/var/lib/snapd/assertions" 157 install -dm755 "$pkgdir/var/lib/snapd/desktop/applications" 158 install -dm755 "$pkgdir/var/lib/snapd/device" 159 install -dm755 "$pkgdir/var/lib/snapd/hostfs" 160 install -dm755 "$pkgdir/var/lib/snapd/mount" 161 install -dm755 "$pkgdir/var/lib/snapd/seccomp/bpf" 162 install -dm755 "$pkgdir/var/lib/snapd/snap/bin" 163 install -dm755 "$pkgdir/var/lib/snapd/snaps" 164 install -dm755 "$pkgdir/var/lib/snapd/lib/gl" 165 install -dm755 "$pkgdir/var/lib/snapd/lib/gl32" 166 install -dm755 "$pkgdir/var/lib/snapd/lib/vulkan" 167 install -dm755 "$pkgdir/var/lib/snapd/lib/glvnd" 168 # these dirs have special permissions 169 install -dm111 "$pkgdir/var/lib/snapd/void" 170 install -dm700 "$pkgdir/var/lib/snapd/cookie" 171 install -dm700 "$pkgdir/var/lib/snapd/cache" 172 173 make -C cmd install DESTDIR="$pkgdir/" 174 175 # Install man file 176 mkdir -p "$pkgdir/usr/share/man/man8" 177 "$srcdir/go/bin/snap" help --man > "$pkgdir/usr/share/man/man8/snap.8" 178 179 # Install the "info" data file with snapd version 180 install -m 644 -D "$srcdir/go/src/${_gourl}/data/info" \ 181 "$pkgdir/usr/lib/snapd/info" 182 183 # Remove snappy core specific units 184 rm -fv "$pkgdir/usr/lib/systemd/system/snapd.system-shutdown.service" 185 rm -fv "$pkgdir/usr/lib/systemd/system/snapd.autoimport.service" 186 rm -fv "$pkgdir"/usr/lib/systemd/system/snapd.snap-repair.* 187 rm -fv "$pkgdir"/usr/lib/systemd/system/snapd.core-fixup.* 188 # and scripts 189 rm -fv "$pkgdir/usr/lib/snapd/snapd.core-fixup.sh" 190 rm -fv "$pkgdir/usr/bin/ubuntu-core-launcher" 191 rm -fv "$pkgdir/usr/lib/snapd/system-shutdown" 192 }