summaryrefslogtreecommitdiff
path: root/recipes-support/snapd/snapd_2.25.bb
blob: 740b16d248d781f917d8d1064bb7d9628a78deb1 (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
SUMMARY = "The snapd and snap tools enable systems to work with .snap files."
HOMEPAGE = "https://www.snapcraft.io"
LICENSE = "GPL-3.0"
LIC_FILES_CHKSUM = "file://${WORKDIR}/${PN}-${PV}/COPYING;md5=d32239bcb673463ab874e80d47fae504"

SRC_URI = "https://github.com/snapcore/snapd/releases/download/${PV}/snapd_${PV}.vendor.tar.xz"

SRC_URI[md5sum] = "453ffdc2ecdbb7058ac193f81ac37135"
SRC_URI[sha256sum] = "accd4c94049ce79443ff995c27111f3851e9896bbad502dd5d341f8847645b90"

SNAPD_PKG = "github.com/snapcore/snapd"

DEPENDS += " \
	glib-2.0 \
	go-cross \
	python3-docutils-native \
	udev \
	xfsprogs \
"

RDEPENDS_${PN} += " \
	ca-certificates \
	kernel-module-squashfs \
"

S = "${WORKDIR}/${PN}-${PV}"

EXTRA_OECONF += " \
	--disable-apparmor \
	--disable-seccomp \
	--libexecdir=${libdir}/snapd \
"

inherit systemd autotools pkgconfig python3native

# Our tools build with autotools are inside the cmd subdirectory
# and we need to tell the autotools class to look in there.
AUTOTOOLS_SCRIPT_PATH = "${S}/cmd"

SYSTEMD_SERVICE_${PN} = "snapd.service"

do_configure_prepend() {
	(cd ${S} ; ./mkversion.sh ${PV})
}

do_compile_prepend() {
	export GOARCH="${TARGET_ARCH}"
	# supported amd64, 386, arm arm64
	if [ "${TARGET_ARCH}" = "x86_64" ]; then
		export GOARCH="amd64"
	fi
	if [ "${TARGET_ARCH}" = "aarch64" ]; then
		export GOARCH="arm64"
	fi
	if [ "${TARGET_ARCH}" = "i586" ]; then
		export GOARCH="386"
	fi

	# Set GOPATH. See 'PACKAGERS.md'. Don't rely on
	# docker to download its dependencies but rather
	# use dependencies packaged independently.
	cd ${S}
	rm -rf .gopath
	mkdir -p .gopath/src/"$(dirname "${SNAPD_PKG}")"
	ln -sf ../../../.. .gopath/src/"${SNAPD_PKG}"
	export GOPATH="${S}/.gopath:${S}/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
	export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
	cd -

	# Pass the needed cflags/ldflags so that cgo
	# can find the needed headers files and libraries
	export CGO_ENABLED="1"
	export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
	export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"

	rm -rf ${B}/build
	mkdir ${B}/build
	go build -a -v -o ${B}/build/snapd ${SNAPD_PKG}/cmd/snapd
	go build -a -v -o ${B}/build/snap ${SNAPD_PKG}/cmd/snap
	go build -a -v -o ${B}/build/snapctl ${SNAPD_PKG}/cmd/snapctl
	go build -a -v -o ${B}/build/snap-exec ${SNAPD_PKG}/cmd/snap-exec
}

do_install_append() {
	install -d ${D}${libdir}/snapd
	install -d ${D}${bindir}
	install -d ${D}${systemd_unitdir}/system
	install -d ${D}/var/lib/snapd
	install -d ${D}/var/lib/snapd/snaps
	install -d ${D}/var/lib/snapd/lib/gl
	install -d ${D}/var/lib/snapd/desktop
	install -d ${D}/var/lib/snapd/environment
	install -d ${D}/var/snap
	install -d ${D}${sysconfdir}/profile.d

	# NOTE: This file needs to be present to allow snapd's service
	# units to startup.
	touch ${D}/${sysconfdir}/environment

	oe_runmake -C ${S}/data/systemd install DESTDIR=${D}

	install -m 0755 ${B}/build/snapd ${D}${libdir}/snapd/
	install -m 0755 ${B}/build/snap-exec ${D}${libdir}/snapd/
	install -m 0755 ${B}/build/snap ${D}${bindir}
	install -m 0755 ${B}/build/snapctl ${D}${bindir}

	echo "PATH=$PATH:/snap/bin" > ${D}${sysconfdir}/profile.d/20-snap.sh
}

RDEPENDS_${PN} += "squashfs-tools"
FILES_${PN} += " \
	${systemd_unitdir}/system/ \
	/var/lib/snapd \
	/var/snap \
	${baselib}/udev/snappy-app-dev \
"

# ERROR: snapd-2.23.5-r0 do_package_qa: QA Issue: No GNU_HASH in the elf binary:
# '.../snapd/usr/lib/snapd/snap-exec' [ldflags]
INSANE_SKIP_${PN} = "ldflags"