diff options
author | Maciek Borzecki | 2017-11-08 08:20:06 +0100 |
---|---|---|
committer | Maciek Borzecki | 2017-11-17 07:47:38 +0100 |
commit | 198d3e60baca1808dc53a9ddacc6a4e51721a1a1 (patch) | |
tree | 7e5a0d8af379d0ae876fdfd324913e0b37a481a3 | |
download | aur-198d3e60baca1808dc53a9ddacc6a4e51721a1a1.tar.gz |
snapd-git: initial packaging of -git package, based on upstream arch packaging
Arch packaging updates as compared to repo version:
- convert the package to *-git (i.e. built from VCS)
- update conflicts to fully replace community repo snapd package
- update build to properly set up CGO_CFLAGS, CGO_CPPFLAGS, CGO_CXXFLAGS,
CGO_LDFLAGS to include settings configured in /etc/makepkg.conf
- use `go build` rather than `go install` in build step to prevent go from
trying to install *.a in system locations
- enable verbose build (go build -x -v)
- refactor package()
- do not hand install support files (systemd units, DBus service)
- cleanup unused ubuntu core files
- snapd environment file is now at /etc/default/snapd
- package snap-exec binary
- symlink /var/lib/snapd/snap to /snap so that --classic confinement snaps
work
Notes:
`run-checks --unit` errors are currently masked until the upstream figures out
integration of Arch into their CI workflow.
Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
-rw-r--r-- | .SRCINFO | 35 | ||||
-rw-r--r-- | PKGBUILD | 187 | ||||
-rw-r--r-- | snapd.install | 43 |
3 files changed, 265 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..caafbf8f2278 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,35 @@ +pkgbase = snapd-git + pkgdesc = Service and tools for management of snap packages. + pkgver = 2.29.3.r611.gdb1fc27cb + pkgrel = 1 + url = https://github.com/snapcore/snapd + install = snapd.install + arch = i686 + arch = x86_64 + license = GPL3 + checkdepends = python + checkdepends = squashfs-tools + checkdepends = indent + checkdepends = shellcheck + makedepends = git + makedepends = go + makedepends = go-tools + makedepends = libseccomp + makedepends = libcap + makedepends = python-docutils + makedepends = systemd + makedepends = xfsprogs + makedepends = libseccomp + depends = squashfs-tools + depends = libseccomp + depends = libsystemd + provides = snapd + conflicts = snapd + conflicts = snap-confine + options = !strip + options = emptydirs + source = git+https://github.com/snapcore/snapd.git + md5sums = SKIP + +pkgname = snapd-git + 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" +} diff --git a/snapd.install b/snapd.install new file mode 100644 index 000000000000..fd43f4f25caf --- /dev/null +++ b/snapd.install @@ -0,0 +1,43 @@ +## arg 1: the new package version +post_install() { + echo + echo 'To use snapd start/enable the snapd.socket' + echo + echo 'If you want your apps to be automatically updated' + echo 'from the store start/enable the snapd.refresh.timer' + echo + echo 'NOTE: Desktop entries show up after logging in again' + echo ' or rebooting after snapd installation' + echo + echo 'For more informations, see https://wiki.archlinux.org/index.php/Snapd' +} + +_stop_services() { + /usr/bin/systemctl stop \ + snapd.service \ + snapd.socket \ + snapd.refresh.timer \ + snapd.refresh.service > /dev/null 2>&1 +} + +pre_remove() { + _stop_services +} + +pre_upgrade() { + _stop_services +} + +post_upgrade() { + /usr/bin/systemctl daemon-reload > /dev/null 2>&1 || : + + # restore the services after an upgrade + if /usr/bin/systemctl -q is-enabled snapd.socket > /dev/null 2>&1; then + /usr/bin/systemctl start snapd.socket > /dev/null 2>&1 || : + fi + if systemctl -q is-enabled snapd.refresh.timer > /dev/null 2>&1; then + systemctl start snapd.refresh.timer > /dev/null 2>&1 || : + fi +} + +# vim:set ts=2 sw=2 et: |