From b3c490c9185d5c7b4dd5001a434a0d41b14ef084 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Wed, 28 Jun 2017 17:47:22 +0200 Subject: snapd: copied from meta-snappy https://github.com/morphis/meta-snappy/commit/f6df6a63756d9976bcccb5fefdbc64e5cc794c99 Signed-off-by: Marcel Ziswiler Acked-by: Dominik Sliwa --- ...-use-templates-for-relevant-systemd-units.patch | 156 +++++++++++++++++++++ ...-not-allow-classic-snaps-on-other-distrib.patch | 47 +++++++ .../0003-cmd-disable-check-for-xfs-xqm.h.patch | 26 ++++ ...d-don-t-fail-to-start-if-etc-environment-.patch | 27 ++++ ...y-to-the-list-of-distros-which-don-t-supp.patch | 30 ++++ recipes-support/snapd/snapd_2.25.bb | 119 ++++++++++++++++ 6 files changed, 405 insertions(+) create mode 100644 recipes-support/snapd/files/0001-packaging-use-templates-for-relevant-systemd-units.patch create mode 100644 recipes-support/snapd/files/0002-cmd-snap-do-not-allow-classic-snaps-on-other-distrib.patch create mode 100644 recipes-support/snapd/files/0003-cmd-disable-check-for-xfs-xqm.h.patch create mode 100644 recipes-support/snapd/files/0004-data-systemd-don-t-fail-to-start-if-etc-environment-.patch create mode 100644 recipes-support/snapd/files/0005-cmd-add-poky-to-the-list-of-distros-which-don-t-supp.patch create mode 100644 recipes-support/snapd/snapd_2.25.bb diff --git a/recipes-support/snapd/files/0001-packaging-use-templates-for-relevant-systemd-units.patch b/recipes-support/snapd/files/0001-packaging-use-templates-for-relevant-systemd-units.patch new file mode 100644 index 0000000..4132f8b --- /dev/null +++ b/recipes-support/snapd/files/0001-packaging-use-templates-for-relevant-systemd-units.patch @@ -0,0 +1,156 @@ +From 0ad3491ce6d26c3dc772a4397b98cb706dc53fbf Mon Sep 17 00:00:00 2001 +From: Simon Fels +Date: Fri, 24 Mar 2017 17:54:48 +0100 +Subject: [PATCH 1/4] packaging: use templates for relevant systemd units + +To make packaging across different distributionis a bit easier we +now use templates for some of our systemd units and replace things +which are in a different location with sed at build time. +--- + data/systemd/snapd.autoimport.service | 10 ---------- + data/systemd/snapd.autoimport.service.in | 10 ++++++++++ + data/systemd/snapd.refresh.service | 11 ----------- + data/systemd/snapd.refresh.service.in | 11 +++++++++++ + data/systemd/snapd.service | 11 ----------- + data/systemd/snapd.service.in | 11 +++++++++++ + packaging/ubuntu-16.04/rules | 11 +++++++++++ + 7 files changed, 43 insertions(+), 32 deletions(-) + delete mode 100644 data/systemd/snapd.autoimport.service + create mode 100644 data/systemd/snapd.autoimport.service.in + delete mode 100644 data/systemd/snapd.refresh.service + create mode 100644 data/systemd/snapd.refresh.service.in + delete mode 100644 data/systemd/snapd.service + create mode 100644 data/systemd/snapd.service.in + +diff --git a/data/systemd/snapd.autoimport.service b/data/systemd/snapd.autoimport.service +deleted file mode 100644 +index 2c75f15..0000000 +--- a/data/systemd/snapd.autoimport.service ++++ /dev/null +@@ -1,10 +0,0 @@ +-[Unit] +-Description=Auto import assertions from block devices +-After=snapd.service snapd.socket +- +-[Service] +-Type=oneshot +-ExecStart=/usr/bin/snap auto-import +- +-[Install] +-WantedBy=multi-user.target +diff --git a/data/systemd/snapd.autoimport.service.in b/data/systemd/snapd.autoimport.service.in +new file mode 100644 +index 0000000..04b9a7e +--- /dev/null ++++ b/data/systemd/snapd.autoimport.service.in +@@ -0,0 +1,10 @@ ++[Unit] ++Description=Auto import assertions from block devices ++After=snapd.service snapd.socket ++ ++[Service] ++Type=oneshot ++ExecStart=@bindir@/snap auto-import ++ ++[Install] ++WantedBy=multi-user.target +diff --git a/data/systemd/snapd.refresh.service b/data/systemd/snapd.refresh.service +deleted file mode 100644 +index 893217f..0000000 +--- a/data/systemd/snapd.refresh.service ++++ /dev/null +@@ -1,11 +0,0 @@ +-[Unit] +-Description=Automatically refresh installed snaps +-After=network-online.target snapd.socket +-Requires=snapd.socket +-ConditionPathExistsGlob=/snap/*/current +-Documentation=man:snap(1) +- +-[Service] +-Type=oneshot +-ExecStart=/usr/bin/snap refresh +-Environment=SNAP_REFRESH_FROM_EMERGENCY_TIMER=1 +diff --git a/data/systemd/snapd.refresh.service.in b/data/systemd/snapd.refresh.service.in +new file mode 100644 +index 0000000..d5cd14b +--- /dev/null ++++ b/data/systemd/snapd.refresh.service.in +@@ -0,0 +1,11 @@ ++[Unit] ++Description=Automatically refresh installed snaps ++After=network-online.target snapd.socket ++Requires=snapd.socket ++ConditionPathExistsGlob=@SNAP_MOUNTDIR@/*/current ++Documentation=man:snap(1) ++ ++[Service] ++Type=oneshot ++ExecStart=@bindir@/snap refresh ++Environment=SNAP_REFRESH_FROM_EMERGENCY_TIMER=1 +diff --git a/data/systemd/snapd.service b/data/systemd/snapd.service +deleted file mode 100644 +index 0863225..0000000 +--- a/data/systemd/snapd.service ++++ /dev/null +@@ -1,11 +0,0 @@ +-[Unit] +-Description=Snappy daemon +-Requires=snapd.socket +- +-[Service] +-ExecStart=/usr/lib/snapd/snapd +-EnvironmentFile=/etc/environment +-Restart=always +- +-[Install] +-WantedBy=multi-user.target +diff --git a/data/systemd/snapd.service.in b/data/systemd/snapd.service.in +new file mode 100644 +index 0000000..009e62e +--- /dev/null ++++ b/data/systemd/snapd.service.in +@@ -0,0 +1,11 @@ ++[Unit] ++Description=Snappy daemon ++Requires=snapd.socket ++ ++[Service] ++ExecStart=@libexecdir@/snapd/snapd ++EnvironmentFile=@SNAPD_ENVIRONMENT_FILE@ ++Restart=always ++ ++[Install] ++WantedBy=multi-user.target +diff --git a/packaging/ubuntu-16.04/rules b/packaging/ubuntu-16.04/rules +index a1328ac..18611b6 100755 +--- a/packaging/ubuntu-16.04/rules ++++ b/packaging/ubuntu-16.04/rules +@@ -90,6 +90,16 @@ override_dh_auto_build: + cd cmd && ( ./configure --prefix=/usr --libexecdir=/usr/lib/snapd $(VENDOR_ARGS)) + $(MAKE) -C cmd all + ++ # Generate the real systemd units out of the available templates ++ cat data/systemd/snapd.service.in | \ ++ sed s:@libexecdir@:/usr/lib:g | \ ++ sed s:@SNAPD_ENVIRONMENT_FILE@:/etc/environment:g > data/systemd/snapd.service ++ cat data/systemd/snapd.refresh.service.in | \ ++ sed s:@bindir@:/usr/bin:g | \ ++ sed s:@SNAP_MOUNTDIR@:/snap:g > data/systemd/snapd.refresh.service ++ cat data/systemd/snapd.autoimport.service.in | \ ++ sed s:@bindir@:/usr/bin:g > data/systemd/snapd.autoimport.service ++ + override_dh_auto_test: + dh_auto_test -- $(GCCGOFLAGS) + # a tested default (production) build should have no test keys +@@ -164,6 +174,7 @@ override_dh_install: + if [ -d share/locale ]; then \ + cp -R share/locale debian/snapd/usr/share; \ + fi ++ + # install snapd's systemd units, done here instead of + # debian/snapd.install because the ubuntu/14.04 release + # branch adds/changes bits here +-- +2.7.4 + diff --git a/recipes-support/snapd/files/0002-cmd-snap-do-not-allow-classic-snaps-on-other-distrib.patch b/recipes-support/snapd/files/0002-cmd-snap-do-not-allow-classic-snaps-on-other-distrib.patch new file mode 100644 index 0000000..b78eec0 --- /dev/null +++ b/recipes-support/snapd/files/0002-cmd-snap-do-not-allow-classic-snaps-on-other-distrib.patch @@ -0,0 +1,47 @@ +From 24616e1c2b8ade1700ee77dc9549ae839addebf6 Mon Sep 17 00:00:00 2001 +From: Simon Fels +Date: Mon, 27 Mar 2017 10:17:03 +0200 +Subject: [PATCH 2/4] cmd/snap: do not allow classic snaps on other + distributions + +As of right now classic snaps are not supported on other distributions +than Ubuntu or Debian. This is because of those not allowing us to have +a global /snap directory, so its moved into /var/lib/snapd/snap instead. + +The changed /snap directory breaks classic snaps as those have static +paths hardcoded to binaries/libraries in /snap for the sake of the +linker to work. +--- + cmd/snap/cmd_snap_op.go | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/cmd/snap/cmd_snap_op.go b/cmd/snap/cmd_snap_op.go +index 50095f4..fb86b41 100644 +--- a/cmd/snap/cmd_snap_op.go ++++ b/cmd/snap/cmd_snap_op.go +@@ -36,6 +36,7 @@ import ( + "github.com/snapcore/snapd/i18n" + "github.com/snapcore/snapd/osutil" + "github.com/snapcore/snapd/progress" ++ "github.com/snapcore/snapd/release" + ) + + func lastLogStr(logs []string) string { +@@ -438,6 +439,14 @@ func (x *cmdInstall) installOne(name string, opts *client.SnapOptions) error { + var installFromFile bool + var changeID string + ++ switch release.ReleaseInfo.ID { ++ case "fedora", "centos", "rhel", "opensuse", "suse": ++ if opts.Classic { ++ fmt.Fprintf(Stderr, i18n.G("snap %q can not be installed as classic snaps are not supported on your distribution\n"), name) ++ return nil ++ } ++ } ++ + cli := Client() + if strings.Contains(name, "/") || strings.HasSuffix(name, ".snap") || strings.Contains(name, ".snap.") { + installFromFile = true +-- +2.7.4 + diff --git a/recipes-support/snapd/files/0003-cmd-disable-check-for-xfs-xqm.h.patch b/recipes-support/snapd/files/0003-cmd-disable-check-for-xfs-xqm.h.patch new file mode 100644 index 0000000..4c667e8 --- /dev/null +++ b/recipes-support/snapd/files/0003-cmd-disable-check-for-xfs-xqm.h.patch @@ -0,0 +1,26 @@ +From 474abfb5460dcd4af5e651d12631b87d36c5fc66 Mon Sep 17 00:00:00 2001 +From: Simon Fels +Date: Mon, 27 Mar 2017 14:18:41 +0200 +Subject: [PATCH 3/4] cmd: disable check for xfs/xqm.h + +--- + cmd/configure.ac | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/cmd/configure.ac b/cmd/configure.ac +index 3c921ac..a6b62b3 100644 +--- a/cmd/configure.ac ++++ b/cmd/configure.ac +@@ -19,7 +19,8 @@ AC_LANG([C]) + # Checks for header files. + AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/mount.h unistd.h]) + AC_CHECK_HEADERS([sys/quota.h], [], [AC_MSG_ERROR(sys/quota.h unavailable)]) +-AC_CHECK_HEADERS([xfs/xqm.h], [], [AC_MSG_ERROR(xfs/xqm.h unavailable)]) ++# YOCTO: Disabled until we have a better way to do this check. ++# AC_CHECK_HEADERS([xfs/xqm.h], [], [AC_MSG_ERROR(xfs/xqm.h unavailable)]) + + # Checks for typedefs, structures, and compiler characteristics. + AC_CHECK_HEADER_STDBOOL +-- +2.7.4 + diff --git a/recipes-support/snapd/files/0004-data-systemd-don-t-fail-to-start-if-etc-environment-.patch b/recipes-support/snapd/files/0004-data-systemd-don-t-fail-to-start-if-etc-environment-.patch new file mode 100644 index 0000000..a202745 --- /dev/null +++ b/recipes-support/snapd/files/0004-data-systemd-don-t-fail-to-start-if-etc-environment-.patch @@ -0,0 +1,27 @@ +From d5a4787c00900a0a637507c978b3fec13edaf34b Mon Sep 17 00:00:00 2001 +From: Simon Fels +Date: Mon, 1 Aug 2016 12:08:13 +0200 +Subject: [PATCH 4/4] data/systemd: don't fail to start if /etc/environment + does not exist + +On some systems /etc/environment is not available by default and +should be prevent snapd from starting. +--- + data/systemd/snapd.service.in | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/data/systemd/snapd.service.in b/data/systemd/snapd.service.in +index 009e62e..35f083d 100644 +--- a/data/systemd/snapd.service.in ++++ b/data/systemd/snapd.service.in +@@ -4,7 +4,6 @@ Requires=snapd.socket + + [Service] + ExecStart=@libexecdir@/snapd/snapd +-EnvironmentFile=@SNAPD_ENVIRONMENT_FILE@ + Restart=always + + [Install] +-- +2.7.4 + diff --git a/recipes-support/snapd/files/0005-cmd-add-poky-to-the-list-of-distros-which-don-t-supp.patch b/recipes-support/snapd/files/0005-cmd-add-poky-to-the-list-of-distros-which-don-t-supp.patch new file mode 100644 index 0000000..5e29cfd --- /dev/null +++ b/recipes-support/snapd/files/0005-cmd-add-poky-to-the-list-of-distros-which-don-t-supp.patch @@ -0,0 +1,30 @@ +From 8462eb4536d0fa1e0ed704bc205b288341b66775 Mon Sep 17 00:00:00 2001 +From: Simon Fels +Date: Wed, 29 Mar 2017 17:33:34 +0200 +Subject: [PATCH] cmd: add poky to the list of distros which don't support + reexec + +'poky' is the std. release id for the Yocto reference distribution. This +wont cover all Yocto based product as Yocto is a meta distribution so +users are fine to change the release id to whatever they want. However +this clearly takes care just about our reference Yocto system. +--- + cmd/cmd.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmd/cmd.go b/cmd/cmd.go +index c70b6cc..c681b39 100644 +--- a/cmd/cmd.go ++++ b/cmd/cmd.go +@@ -62,7 +62,7 @@ func ExecInCoreSnap() { + + // can we re-exec? some distributions will need extra work before re-exec really works. + switch release.ReleaseInfo.ID { +- case "fedora", "centos", "rhel", "opensuse", "suse": ++ case "fedora", "centos", "rhel", "opensuse", "suse", "poky": + logger.Debugf("re-exec not supported on distro %q yet", release.ReleaseInfo.ID) + return + } +-- +2.7.4 + diff --git a/recipes-support/snapd/snapd_2.25.bb b/recipes-support/snapd/snapd_2.25.bb new file mode 100644 index 0000000..069b006 --- /dev/null +++ b/recipes-support/snapd/snapd_2.25.bb @@ -0,0 +1,119 @@ +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 += " \ + go-cross \ + glib-2.0 \ + 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 + +# 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" -- cgit v1.2.3