From e9a3a0b925915c50dd54d4e9722d56e14d37d2eb Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 11 Jun 2018 10:47:22 -0500 Subject: [PATCH] snap: Enable builds for the daemon This requires a newer version of gettext than is in Ubuntu 16.04 in order to support GETTEXTDATADIRS --- contrib/ci/Dockerfile-snap.in | 1 + contrib/snap/dfu-tool.wrapper | 2 + contrib/snap/fwupd-command | 44 ++++++++++++++ contrib/snap/fwupd.wrapper | 2 + contrib/snap/fwupdmgr.wrapper | 2 + contrib/snap/fwupdtool.wrapper | 44 +------------- contrib/snap/snapcraft-master.yaml | 83 +++++++++++++++++++++----- contrib/snap/snapcraft-stable.yaml | 93 +++++++++++++++++++++++++----- 8 files changed, 200 insertions(+), 71 deletions(-) create mode 100755 contrib/snap/dfu-tool.wrapper create mode 100755 contrib/snap/fwupd-command create mode 100755 contrib/snap/fwupd.wrapper create mode 100755 contrib/snap/fwupdmgr.wrapper diff --git a/contrib/ci/Dockerfile-snap.in b/contrib/ci/Dockerfile-snap.in index 7ab883792..2daef5334 100644 --- a/contrib/ci/Dockerfile-snap.in +++ b/contrib/ci/Dockerfile-snap.in @@ -2,4 +2,5 @@ FROM snapcore/snapcraft RUN mkdir /build WORKDIR /build COPY . . +RUN apt update CMD ["./contrib/ci/snap.sh"] diff --git a/contrib/snap/dfu-tool.wrapper b/contrib/snap/dfu-tool.wrapper new file mode 100755 index 000000000..8c73cc841 --- /dev/null +++ b/contrib/snap/dfu-tool.wrapper @@ -0,0 +1,2 @@ +#!/bin/sh +exec "$SNAP/fwupd-command" $SNAP/usr/bin/dfu-tool $@ diff --git a/contrib/snap/fwupd-command b/contrib/snap/fwupd-command new file mode 100755 index 000000000..3a5db03fb --- /dev/null +++ b/contrib/snap/fwupd-command @@ -0,0 +1,44 @@ +#!/bin/sh + +export XDG_CACHE_HOME=$SNAP_USER_COMMON/.cache +mkdir -p $XDG_CACHE_HOME +export GIO_MODULE_DIR=$XDG_CACHE_HOME/gio-modules +export XDG_DATA_DIRS="$SNAP/usr/share" + +# don't update between versions, we want to preserve previous data +[ ! -d "$SNAP_USER_DATA/etc" ] && cp -R "$SNAP/etc" "$SNAP_USER_DATA" +[ ! -d "$SNAP_USER_DATA/var" ] && cp -R "$SNAP/var" "$SNAP_USER_DATA" + +#determine architecture +if [ "$SNAP_ARCH" = "amd64" ]; then + ARCH="x86_64-linux-gnu" +elif [ "$SNAP_ARCH" = "armhf" ]; then + ARCH="arm-linux-gnueabihf" +elif [ "$SNAP_ARCH" = "arm64" ]; then + ARCH="aarch64-linux-gnu" +else + ARCH="$SNAP_ARCH-linux-gnu" +fi + +# re-generate gio modules in local cache +needs_update=true +if [ -f $SNAP_USER_DATA/.last_revision ]; then + . $SNAP_USER_DATA/.last_revision 2>/dev/null +fi +if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then + needs_update=false +fi +if [ $needs_update = true ]; then + if [ -f $SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules ]; then + rm -rf $GIO_MODULE_DIR + mkdir -p $GIO_MODULE_DIR + ln -s $SNAP/usr/lib/$ARCH/gio/modules/*.so $GIO_MODULE_DIR + $SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules $GIO_MODULE_DIR + fi + echo "SNAP_DESKTOP_LAST_REVISION=$SNAP_REVISION" > $SNAP_USER_DATA/.last_revision +fi + +export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH" +export LD_LIBRARY_PATH="$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/$ARCH:$SNAP/usr/lib/$ARCH" +export LD_LIBRARY_PATH=$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH +exec "$@" diff --git a/contrib/snap/fwupd.wrapper b/contrib/snap/fwupd.wrapper new file mode 100755 index 000000000..25cdafbda --- /dev/null +++ b/contrib/snap/fwupd.wrapper @@ -0,0 +1,2 @@ +#!/bin/sh +exec "$SNAP/fwupd-command" $SNAP/usr/lib/fwupd/fwupd $@ diff --git a/contrib/snap/fwupdmgr.wrapper b/contrib/snap/fwupdmgr.wrapper new file mode 100755 index 000000000..180dc34ff --- /dev/null +++ b/contrib/snap/fwupdmgr.wrapper @@ -0,0 +1,2 @@ +#!/bin/sh +exec "$SNAP/fwupd-command" $SNAP/usr/bin/fwupdmgr $@ diff --git a/contrib/snap/fwupdtool.wrapper b/contrib/snap/fwupdtool.wrapper index cbceee8d3..1f3f05411 100755 --- a/contrib/snap/fwupdtool.wrapper +++ b/contrib/snap/fwupdtool.wrapper @@ -1,44 +1,2 @@ #!/bin/sh - -export XDG_CACHE_HOME=$SNAP_USER_COMMON/.cache -mkdir -p $XDG_CACHE_HOME -export GIO_MODULE_DIR=$XDG_CACHE_HOME/gio-modules -export XDG_DATA_DIRS="$SNAP/usr/share" - -# don't update between versions, we want to preserve previous data -[ ! -d "$SNAP_USER_DATA/etc" ] && cp -R "$SNAP/etc" "$SNAP_USER_DATA" -[ ! -d "$SNAP_USER_DATA/var" ] && cp -R "$SNAP/var" "$SNAP_USER_DATA" - -#determine architecture -if [ "$SNAP_ARCH" = "amd64" ]; then - ARCH="x86_64-linux-gnu" -elif [ "$SNAP_ARCH" = "armhf" ]; then - ARCH="arm-linux-gnueabihf" -elif [ "$SNAP_ARCH" = "arm64" ]; then - ARCH="aarch64-linux-gnu" -else - ARCH="$SNAP_ARCH-linux-gnu" -fi - -# re-generate gio modules in local cache -needs_update=true -if [ -f $SNAP_USER_DATA/.last_revision ]; then - . $SNAP_USER_DATA/.last_revision 2>/dev/null -fi -if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then - needs_update=false -fi -if [ $needs_update = true ]; then - if [ -f $SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules ]; then - rm -rf $GIO_MODULE_DIR - mkdir -p $GIO_MODULE_DIR - ln -s $SNAP/usr/lib/$ARCH/gio/modules/*.so $GIO_MODULE_DIR - $SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules $GIO_MODULE_DIR - fi - echo "SNAP_DESKTOP_LAST_REVISION=$SNAP_REVISION" > $SNAP_USER_DATA/.last_revision -fi - -export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH" -export LD_LIBRARY_PATH="$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/$ARCH:$SNAP/usr/lib/$ARCH" -export LD_LIBRARY_PATH=$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH -exec "$SNAP/usr/lib/fwupd/fwupdtool" "$@" +exec "$SNAP/fwupd-command" $SNAP/usr/lib/fwupd/fwupdtool $@ diff --git a/contrib/snap/snapcraft-master.yaml b/contrib/snap/snapcraft-master.yaml index 6abcf13ef..09f3d5e63 100644 --- a/contrib/snap/snapcraft-master.yaml +++ b/contrib/snap/snapcraft-master.yaml @@ -17,10 +17,38 @@ apps: command: fwupdtool.wrapper completer: usr/share/bash-completion/completions/fwupdtool + fwupd: + command: fwupd.wrapper + daemon: simple + slots: [fwupd, daemon] + fwupdmgr: + command: fwupdmgr.wrapper + completer: + usr/share/bash-completion/completions/fwupdmgr + plugs: [network, fwupdmgr, client] plugs: + client: + interface: dbus + bus: system + name: org.freedesktop.fwupd fwupdtool: interface: home + fwupdmgr: + interface: home + +slots: + daemon: + interface: dbus + bus: system + name: org.freedesktop.fwupd + fwupd: + interface: fwupd + fwupd-data: + content: fwupd-data + interface: content + write: + - $SNAP_DATA parts: libefivar-dev: @@ -188,6 +216,35 @@ parts: - -usr - -lib - -var + #0.19.8.1 adds support for GETTEXTDATADIRS which is needed by meson's msgfmthelper + gettext: + source: https://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz + plugin: autotools + build-packages: + - bison + - libunistring-dev + - libxml2-dev + configflags: + - --prefix=/usr + - --disable-static + - --disable-curses + - --disable-java + - --enable-relocatable + - --without-emacs + - --without-included-glib + - --without-included-libunistring + - --without-included-libxml + stage-packages: + - libunistring0 + - libxml2 + - libgomp1 + prime: + - -**/*.a + - -**/*.la + - -usr/bin + - -usr/include + - -usr/lib/gettext + - -usr/share fwupd: plugin: meson meson-parameters: [--prefix=/usr, @@ -196,29 +253,28 @@ parts: -Defi-ldsdir=$SNAPCRAFT_STAGE/usr/lib, -Defi-libdir=$SNAPCRAFT_STAGE/usr/lib, -Dtests=false, - -Ddaemon=false, + -Ddaemon=true, -Dgtkdoc=false, -Dintrospection=false, - -Dsystemd=false, -Dman=false, - -Dconsolekit=false, - -Dpkcs7=false, - -Dgpg=false] + -Dudevdir=$SNAPCRAFT_STAGE/lib/udev, + -Dpkcs7=false] source: . source-type: git override-build: | snapcraftctl build - echo $(git describe HEAD) > $SNAPCRAFT_STAGE/version + echo $(git describe HEAD --always) > $SNAPCRAFT_STAGE/version build-packages: - bash-completion - gcab - - gettext + - gnutls-dev - libarchive-dev - libelf-dev - libgcab-dev - libglib2.0-dev - libgpgme11-dev - libjson-glib-dev + - libpolkit-gobject-1-dev - libsoup2.4-dev - libsqlite3-dev - locales @@ -229,8 +285,9 @@ parts: - libelf1 - libgpgme11 - libjson-glib-1.0-0 + - libpolkit-gobject-1-0 + - gnupg prime: - - -usr/bin - -usr/sbin - -usr/lib/gnupg - -usr/share/man @@ -248,11 +305,8 @@ parts: - -usr/share/glib-2.0/schemas - -usr/share/X11 - -usr/include - - -etc/dbus-1 - -lib/systemd - -lib/udev - - -usr/lib/fwupd/fwupd - - -usr/share/dbus-1 - -usr/share/gnupg - -usr/share/lintian - -usr/share/pkgconfig @@ -266,7 +320,7 @@ parts: - -usr/share/upstart - -usr/lib/*/glib-2.0 - -usr/lib/*/pkgconfig - after: [appstream-glib-dev, gudev, gusb, gnu-efi, libefivar-fixpkgconfig, libsmbios, build-introspection] + after: [appstream-glib-dev, gudev, gusb, gnu-efi, libefivar-fixpkgconfig, libsmbios, build-introspection, gettext] fix-bash-completion: plugin: make source: contrib/snap/fix-bash-completion @@ -287,8 +341,11 @@ parts: - -usr/share/pkgconfig - -usr/share/GConf after: [fwupd] - fwupdtool-wrapper: + fwupd-wrappers: plugin: dump source: contrib/snap stage: + - fwupd-command - fwupdtool.wrapper + - fwupd.wrapper + - fwupdmgr.wrapper diff --git a/contrib/snap/snapcraft-stable.yaml b/contrib/snap/snapcraft-stable.yaml index 0305b009b..10c4ea683 100644 --- a/contrib/snap/snapcraft-stable.yaml +++ b/contrib/snap/snapcraft-stable.yaml @@ -13,14 +13,42 @@ architectures: - amd64 apps: + dfu-tool: + command: dfu-tool.wrapper fwupdtool: command: fwupdtool.wrapper completer: usr/share/bash-completion/completions/fwupdtool + fwupd: + command: fwupd.wrapper + daemon: simple + slots: [fwupd, daemon] + plugs: [dcdbas-control] + fwupdmgr: + command: fwupdmgr.wrapper + completer: + usr/share/bash-completion/completions/fwupdmgr + plugs: [network, fwupdmgr, client] plugs: + client: + interface: dbus + bus: system + name: org.freedesktop.fwupd fwupdtool: interface: home + dfu-tool: + interface: home + fwupdmgr: + interface: home + +slots: + daemon: + interface: dbus + bus: system + name: org.freedesktop.fwupd + fwupd: + interface: fwupd parts: libefivar-dev: @@ -183,6 +211,35 @@ parts: - -usr - -lib - -var + #0.19.8.1 adds support for GETTEXTDATADIRS which is needed by meson's msgfmthelper + gettext: + source: https://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz + plugin: autotools + build-packages: + - bison + - libunistring-dev + - libxml2-dev + configflags: + - --prefix=/usr + - --disable-static + - --disable-curses + - --disable-java + - --enable-relocatable + - --without-emacs + - --without-included-glib + - --without-included-libunistring + - --without-included-libxml + stage-packages: + - libunistring0 + - libxml2 + - libgomp1 + prime: + - -**/*.a + - -**/*.la + - -usr/bin + - -usr/include + - -usr/lib/gettext + - -usr/share fwupd: plugin: meson meson-parameters: [--prefix=/usr, @@ -191,29 +248,28 @@ parts: -Defi-ldsdir=$SNAPCRAFT_STAGE/usr/lib, -Defi-libdir=$SNAPCRAFT_STAGE/usr/lib, -Dtests=false, - -Ddaemon=false, + -Ddaemon=true, -Dgtkdoc=false, -Dintrospection=false, - -Dsystemd=false, -Dman=false, - -Dconsolekit=false, - -Dpkcs7=false, - -Dgpg=false] + -Dudevdir=$SNAPCRAFT_STAGE/lib/udev, + -Dpkcs7=false] source: . source-type: git override-build: | snapcraftctl build - echo $(git describe HEAD) > $SNAPCRAFT_STAGE/version + echo $(git describe HEAD --always) > $SNAPCRAFT_STAGE/version build-packages: - bash-completion - gcab - - gettext + - gnutls-dev - libarchive-dev - libelf-dev - libgcab-dev - libglib2.0-dev - libgpgme11-dev - libjson-glib-dev + - libpolkit-gobject-1-dev - libsoup2.4-dev - libsqlite3-dev - locales @@ -224,10 +280,17 @@ parts: - libelf1 - libgpgme11 - libjson-glib-1.0-0 + - libpolkit-gobject-1-0 prime: - - -usr/bin + # we explicitly don't want /usr/bin/gpgconf + # this will cause gpgme to error finding it + # but that also avoids trying to use non-existent + # /usr/bin/gpg2 + - -usr/bin/gpg* + - -usr/bin/watchgnupg + - -usr/bin/kbxutil + - -usr/bin/pinentry* - -usr/sbin - - -usr/lib/gnupg - -usr/share/man - -usr/share/GConf - -etc/X11 @@ -243,12 +306,8 @@ parts: - -usr/share/glib-2.0/schemas - -usr/share/X11 - -usr/include - - -etc/dbus-1 - -lib/systemd - -lib/udev - - -usr/lib/fwupd/fwupd - - -usr/share/dbus-1 - - -usr/share/gnupg - -usr/share/lintian - -usr/share/pkgconfig - -usr/share/installed-tests @@ -261,7 +320,7 @@ parts: - -usr/share/upstart - -usr/lib/*/glib-2.0 - -usr/lib/*/pkgconfig - after: [appstream-glib-dev, gudev, gusb, gnu-efi, libefivar-fixpkgconfig, libsmbios, build-introspection] + after: [appstream-glib-dev, gudev, gusb, gnu-efi, libefivar-fixpkgconfig, libsmbios, build-introspection, gettext] fix-bash-completion: plugin: make source: contrib/snap/fix-bash-completion @@ -282,8 +341,12 @@ parts: - -usr/share/pkgconfig - -usr/share/GConf after: [fwupd] - fwupdtool-wrapper: + fwupd-wrappers: plugin: dump source: contrib/snap stage: + - dfu-tool.wrapper + - fwupd-command - fwupdtool.wrapper + - fwupd.wrapper + - fwupdmgr.wrapper