snap: Enable builds for the daemon

This requires a newer version of gettext than is in Ubuntu 16.04
in order to support GETTEXTDATADIRS
This commit is contained in:
Mario Limonciello 2018-06-11 10:47:22 -05:00 committed by Mario Limonciello
parent 4e0bb5d5c9
commit e9a3a0b925
8 changed files with 200 additions and 71 deletions

View File

@ -2,4 +2,5 @@ FROM snapcore/snapcraft
RUN mkdir /build
WORKDIR /build
COPY . .
RUN apt update
CMD ["./contrib/ci/snap.sh"]

2
contrib/snap/dfu-tool.wrapper Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec "$SNAP/fwupd-command" $SNAP/usr/bin/dfu-tool $@

44
contrib/snap/fwupd-command Executable file
View File

@ -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 "$@"

2
contrib/snap/fwupd.wrapper Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec "$SNAP/fwupd-command" $SNAP/usr/lib/fwupd/fwupd $@

2
contrib/snap/fwupdmgr.wrapper Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec "$SNAP/fwupd-command" $SNAP/usr/bin/fwupdmgr $@

View File

@ -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 $@

View File

@ -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

View File

@ -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