From 81d4d49234b04ac72dbf2e531a5d3b0bafc1e47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=8D=9A=E4=BB=81=28Buo-ren=20Lin=29?= Date: Fri, 29 Mar 2019 16:55:43 +0800 Subject: [PATCH] Snap packaging improvements (#207) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixup! snap: Support official config paths via *-files confinement interfaces (#197) * FIXME no longer applied * Obsoleted HOME environment variable assignment Signed-off-by: 林博仁(Buo-ren Lin) * snap: Migrate to selective-checkout The selective-pull stage snap is superseded by selective-checkout, prefer the new one. Refer-to: Selective-checkout: Check out the tagged release revision if it isn't promoted to the stable channel Signed-off-by: 林博仁(Buo-ren Lin) * snap: Support bash completion Refer-to: Scriptlets Refer-to: Tab completion for snaps Signed-off-by: 林博仁(Buo-ren Lin) * snap: Implement interface connection warning in the launcher This patch ensures that the user will be acknowledge the missing connection to the `removable-media` interface. Signed-off-by: 林博仁(Buo-ren Lin) --- snap/local/launchers/gallery-dl-launch | 15 ++++++++++++++- snap/snapcraft.yaml | 23 +++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/snap/local/launchers/gallery-dl-launch b/snap/local/launchers/gallery-dl-launch index ed0ab489..908f303f 100755 --- a/snap/local/launchers/gallery-dl-launch +++ b/snap/local/launchers/gallery-dl-launch @@ -8,12 +8,25 @@ set \ -o pipefail # Use user's real home directory for canonical configuration path access -# FIXME: Waiting for Snap Store assertion declare REALHOME="$( getent passwd "${USER}" \ | cut --delimiter=: --fields=6 )" HOME="${REALHOME}" +if ! test -f "${SNAP_USER_COMMON}"/marker_disable_interface_warning; then + # Warn if the `removable-media` interface isn't connected + if ! ls /media &>/dev/null; then + printf -- \ + "It seems that this snap isn't connected to the \`removable-media\` security confinement interface. If you want to save the files under \`/media\`, \`/run/media\`, or \`/mnt\` directories you need to connect this snap to the \`removable-media\` interface by running the following command in a terminal:\\n\\n sudo snap connect %s:removable-media\\n\\n" \ + "${SNAP_NAME}" \ + >&2 + printf -- \ + "To disable this warning create an empty file at the following path:\\n\\n %s/marker_disable_interface_warning\\n\\n" \ + "${SNAP_USER_COMMON}" \ + >&2 + fi +fi + # Finally run the next part of the command chain exec "${@}" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 9e17a413..4420501d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -55,22 +55,34 @@ parts: organize: '*': bin/ - selective-pull: + # Check out the tagged release revision if it isn’t promoted to the stable channel + # https://forum.snapcraft.io/t/selective-checkout-check-out-the-tagged-release-revision-if-it-isnt-promoted-to-the-stable-channel/10617 + selective-checkout: plugin: nil build-packages: - git stage-snaps: - - selective-pull + - selective-checkout gallery-dl: after: - - selective-pull + - selective-checkout source: . - override-pull: $SNAPCRAFT_STAGE/scriptlets/selective-pull + override-pull: | + snapcraftctl pull + $SNAPCRAFT_STAGE/scriptlets/selective-checkout + plugin: python + build-packages: + - make python-packages: - youtube_dl + override-build: | + # build manpages and bash completion + make + + snapcraftctl build ffmpeg: plugin: nil @@ -94,11 +106,10 @@ apps: command-chain: - bin/gallery-dl-launch command: bin/gallery-dl + completer: etc/bash_completion.d/gallery-dl.bash_completion environment: LANG: C.UTF-8 LC_ALL: C.UTF-8 # Satisfy FFmpeg's libpulsecommon dependency LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio - - HOME: $SNAP_USER_COMMON