summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a637882f3825ea4ac16668eecaff87ab7c2e925b (plain)
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
# $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"
}