Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
WIP: use meson on arch
  • Loading branch information
valentindavid committed Sep 24, 2026
commit 7a6be3bad163255d93658fd36397c608f41d0e33
155 changes: 13 additions & 142 deletions packaging/arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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' 'autoconf-archive' 'm4')
makedepends=('meson' 'git' 'go' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'python-docutils' 'apparmor' 'm4')
# the following checkdepends are only required for static checks and unit tests,
# unit tests are currently enabled
checkdepends=('python' 'squashfs-tools' 'shellcheck' 'openssh')
Expand All @@ -27,152 +27,23 @@ install=snapd.install
source=("${pkgname}_${pkgver}.vendor.tar.xz")
sha256sums=('SKIP')

prepare() {
cd "$pkgname-$pkgver"

:
}

build() {
cd "$pkgname-$pkgver"

unset GO111MODULE

export CGO_ENABLED="1"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"

# Generate snapd.defines.mk, this file is included by snapd.mk.
cat >"$srcdir/snapd.defines.mk" <<__DEFINES__
# This file is generated by snapd packaging
# Directory variables.
prefix = /usr
bindir = /usr/bin
sbindir = /usr/sbin
libexecdir = /usr/lib
mandir = /usr/share/man
datadir = /usr/share
localstatedir = /var
sharedstatedir = /var/lib
unitdir = /usr/lib/systemd/system
builddir = $srcdir/_go_build
# Build configuration
with_core_bits = 0
with_alt_snap_mount_dir = 1
with_apparmor = 1
with_testkeys = ${WITH_TEST_KEYS:-0}
with_vendor = 1
with_static_pie = 0
EXTRA_GO_BUILD_FLAGS = -trimpath
EXTRA_GO_LDFLAGS = -w -s
# The source tarball carries the upstream version (snapdtool/version_generated.go,
# cmd/VERSION, data/info). Only the downstream release suffix is set here and is
# baked into the binaries via a linker flag, without patching the source.
downstream_version_suffix = -$pkgrel
__DEFINES__

# Set cmd/VERSION and data/info VERSION to the full package version (pkgver +
# pkgrel), so snap-confine and the installed info file match the binaries'
# FullVersion().
packaging/mod-version.sh "$pkgver-$pkgrel"

make -f packaging/snapd.mk \
SNAPD_DEFINES_DIR="$srcdir"

# 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 \
USE_CANONICAL_SNAP_MOUNT_DIR=false \
USE_ALT_SNAP_MOUNT_DIR=true \
SNAPD_ENVIRONMENT_FILE=/etc/default/snapd

cd cmd
autoreconf -i -f
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--libexecdir=/usr/lib/snapd \
--with-snap-mount-dir=/var/lib/snapd/snap \
--enable-apparmor \
--enable-nvidia-biarch \
--enable-merged-usr
make $MAKEFLAGS
arch-meson "$pkgname-$pkgver" build \
--libexecdir lib/snapd \
-Ddracut=disabled \
-Dlibselinux=disabled \
-Dselinux=disabled \
-Dstatic-checks=false \
-Dsnapmountdir=/var/lib/snapd/snap \
-Dset-perms=true \
-Ddownstream_version_suffix="-$pkgrel"
meson compile -C build
}

check() {
cd "$pkgname-$pkgver"

make -f packaging/snapd.mk \
SNAPD_DEFINES_DIR="$srcdir" \
check \
check-static-binaries \
check-trusted-account-keys
TMPDIR=/tmp make -C cmd -k check
TMPDIR=/tmp make -C data -k check
meson test -C build --print-errorlogs
}

package() {
cd "$pkgname-$pkgver"

# 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 \
USE_CANONICAL_SNAP_MOUNT_DIR=false \
USE_ALT_SNAP_MOUNT_DIR=true \
DESTDIR="$pkgdir"

make -C cmd install DESTDIR="$pkgdir/"

make -f packaging/snapd.mk \
SNAPD_DEFINES_DIR="$srcdir" \
DESTDIR="$pkgdir" \
install

# Install the "info" data file with snapd version
install -m 644 -D "data/info" "$pkgdir/usr/lib/snapd/info"

# Install the news file
install -m 644 -D "NEWS.md" "$pkgdir/usr/share/doc/snapd/NEWS.md"

# these locations are created at runtime but were not part of the packaging
# previously, thus would trigger a file conflict on upgrade
rm -rfv "$pkgdir/var/cache/snapd"
rm -rfv "$pkgdir/var/lib/snapd/snap/README"
rm -rfv "$pkgdir/var/lib/snapd/state.json"
rm -rfv "$pkgdir/var/lib/snapd/system-key"

# Remove snappy core specific units
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"

# drop the last remaining Ubuntu Core specific service
rm -fv "$pkgdir/usr/lib/systemd/system/snapd.failure.service"

# Remove prompt services
rm -fv "$pkgdir/usr/lib/systemd/system/snapd.aa-prompt-listener.service"
rm -fv "$pkgdir/usr/lib/systemd/user/snapd.aa-prompt-ui.service"
rm -fv "$pkgdir/usr/share/dbus-1/services/io.snapcraft.Prompt.service"

# Remove gpio-chardev ordering target
rm -fv "$pkgdir/usr/lib/systemd/system/snapd.gpio-chardev-setup.target"
meson install -C build --destdir "$pkgdir"
}
Loading