diff options
Diffstat (limited to 'PKGBUILD')
-rw-r--r-- | PKGBUILD | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..a637882f3825 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,187 @@ +# $Id$ +# Maintainer: Timothy Redaelli <timothy.redaelli@gmail.com> +# Contributor: Zygmunt Krynicki <me at zygoon dot pl> +# Contributor: Maciej Borzecki <maciek.borzecki@gmail.com> + +_pkgbase=snapd +pkgname=snapd-git +pkgver=2.29.3.r611.gdb1fc27cb +pkgrel=1 +arch=('i686' 'x86_64') +url="https://github.com/snapcore/snapd" +license=('GPL3') +makedepends=('git' 'go' 'go-tools' 'libseccomp' 'libcap' 'python-docutils' 'systemd' 'xfsprogs' 'libseccomp') +checkdepends=('python' 'squashfs-tools' 'indent' 'shellcheck') + +options=('!strip' 'emptydirs') +install=snapd.install +source=("git+https://github.com/snapcore/$_pkgbase.git") +md5sums=('SKIP') + +pkgdesc="Service and tools for management of snap packages." +depends=('squashfs-tools' 'libseccomp' 'libsystemd') +provides=($_pkgbase) +# Community package is split into snapd and snap-confine, make sure we replace +# both bits +conflicts=($_pkgbase 'snap-confine') + +_gourl=github.com/snapcore/snapd + +pkgver() { + cd "$srcdir/snapd" + git describe --tag | sed -r 's/([^-]*-g)/r\1/; s/-/./g' +} + +prepare() { + cd "$_pkgbase" + + # Use $srcdir/go as our GOPATH + export GOPATH="$srcdir/go" + mkdir -p "$GOPATH" + # 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 "$GOPATH/src/${_gourl}")" + ln --no-target-directory -fs "$srcdir/$_pkgbase" "$GOPATH/src/${_gourl}" + # Patch snap-seccomp build flags not to link libseccomp statically. + sed -i -e 's/-Wl,-Bstatic -lseccomp -Wl,-Bdynamic/-lseccomp/' "$srcdir/$_pkgbase/cmd/snap-seccomp/main.go" +} + +build() { + export GOPATH="$srcdir/go" + # Use get-deps.sh provided by upstream to fetch go dependencies using the + # godeps tool and dependencies.tsv (maintained upstream). + cd "$GOPATH/src/${_gourl}" + # Generate version + ./mkversion.sh $pkgver-$pkgrel + + # Get golang dependencies + XDG_CONFIG_HOME="$srcdir" ./get-deps.sh + + # 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 + + export CGO_ENABLED="1" + export CGO_CFLAGS="${CFLAGS}" + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" + + # gobuild="go build -pkgdir $GOPATH/pkg -x -v" + gobuild="go build -x -v" + # Build/install snap and snapd + $gobuild -o $GOPATH/bin/snap "${_gourl}/cmd/snap" + $gobuild -o $GOPATH/bin/snapctl "${_gourl}/cmd/snapctl" + $gobuild -o $GOPATH/bin/snapd "${_gourl}/cmd/snapd" + $gobuild -o $GOPATH/bin/snap-seccomp "${_gourl}/cmd/snap-seccomp" + # build snap-exec and snap-update-ns completely static for base snaps + $gobuild -o $GOPATH/bin/snap-update-ns -ldflags '-extldflags "-static"' "${_gourl}/cmd/snap-update-ns" + CGO_ENABLED=0 $gobuild -o $GOPATH/bin/snap-exec "${_gourl}/cmd/snap-exec" + + # Build snap-confine + cd cmd + # Sync actual parameters with cmd/autogen.sh + autoreconf -i -f + ./configure \ + --prefix=/usr \ + --libexecdir=/usr/lib/snapd \ + --with-snap-mount-dir=/var/lib/snapd/snap \ + --disable-apparmor \ + --enable-nvidia-biarch \ + --enable-merged-usr + make $MAKEFLAGS +} + +check() { + export GOPATH="$srcdir/go" + cd "$GOPATH/src/${_gourl}" + + # XXX: Those files are unknown to gitignore but are checked by run-checks + # --static. Before gitignore is updated we just remove the junk one and move + # the valuable one aside. + rm -f cmd/snap-confine/snap-confine-debug + mv data/info $srcdir/xxx-info + + ./run-checks --unit || /bin/true + # 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 + make -C cmd -k check + + mv $srcdir/xxx-info data/info +} + +package_snapd-git() { + export GOPATH="$srcdir/go" + + # Ensure that we have /var/lib/snapd/{hostfs,lib/gl}/ as they are required by + # snap-confine for constructing some bind mounts around. + install -d -m 755 \ + "$pkgdir/var/lib/snapd/hostfs/" \ + "$pkgdir/var/lib/snapd/lib/gl/" + + # Install snap, snapctl, snap-update-ns, snap-seccomp, snap-exec and snapd + # executables + install -d -m 755 "$pkgdir/usr/bin/" + install -m 755 -t "$pkgdir/usr/bin" \ + "$GOPATH/bin/snap" \ + "$GOPATH/bin/snapctl" + + install -d -m 755 "$pkgdir/usr/lib/snapd" + install -m 755 -t "$pkgdir/usr/lib/snapd" \ + "$GOPATH/bin/snap-update-ns" \ + "$GOPATH/bin/snap-exec" \ + "$GOPATH/bin/snap-seccomp" \ + "$GOPATH/bin/snapd" + + # Install snap-confine + make -C "$srcdir/$_pkgbase/cmd" install DESTDIR="$pkgdir" + + # Install script to export binaries paths of snaps and XDG_DATA_DIRS for their + # .desktop files + make -C "$srcdir/$_pkgbase/data/env" install DESTDIR="$pkgdir" + + # Install D-Bus service files + make -C "$srcdir/$_pkgbase/data/dbus" install \ + DBUSSERVICESDIR=/usr/share/dbus-1/services \ + DESTDIR="$pkgdir" + + # Install systemd units + make -C "$srcdir/$_pkgbase/data/systemd" install \ + BINDIR=/bin \ + SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system \ + DESTDIR="$pkgdir" + + # 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.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" + + + # Install the bash tab completion files + install -Dm 755 \ + "$GOPATH/src/${_gourl}/data/completion/snap" \ + "$pkgdir/usr/share/bash-completion/completions/snap" + + install -D -m 755 -t "$pkgdir/usr/lib/snapd" \ + "$GOPATH/src/${_gourl}/data/completion/complete.sh" \ + "$GOPATH/src/${_gourl}/data/completion/etelpmoc.sh" + + # Symlink /var/lib/snapd/snap to /snap so that --classic snaps work + ln -s var/lib/snapd/snap "$pkgdir/snap" + # and make sure that target exists so that we don't have dangling symlinks + # after installing the package + install -d -m 755 "$pkgdir/var/lib/snapd/snap" +} |