Skip to content

Commit

Permalink
Introducing /snap/patches directory
Browse files Browse the repository at this point in the history
This patch introduces the /snap/patches directory for packagers to place
patches used in the packaging process.  A `patches` part is included to
install these files under $SNAPCRAFT_STAGE/packages to be used by other
parts.

A Sed script is also included to patch the desktop entries' name and
icon.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
  • Loading branch information
brlin-tw committed Jun 27, 2018
1 parent 1f673c0 commit 7392a2c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions snap/patches/README.markdown
@@ -0,0 +1,3 @@
# /snap/patches

Here are the patches that are required to build a snap package that functions correctly.
28 changes: 28 additions & 0 deletions snap/patches/patch-desktop-entries.sed
@@ -0,0 +1,28 @@
# This sed script patches the desktop entries of the snapped
# application.
#
# Documentation:
#
# * GNU Sed Manual
# https://www.gnu.org/software/sed/manual
# * `sed` script overview - `sed` scripts
# * `sed` commands summary - `sed` scripts
# * The `s` Command - `sed` scripts
# * Overview of basic regular expression syntax - Regular
# Expressions: selecting text
# * Back-references and Subexpressions - Regular Expressions:
# selecting text

## Append '(Snappy Edition)' to the application name to make it
## distinguishable with the other same application using different
## software distribution technologies
##
## FIXME: The appended string is not localizable, the proper way to
## implement this is to probably use a new X-Snappy-Name keys
## with localestring format to let the translators fill in
## additional localized string and use these values to replace
## the Name keys here.
s/^\(Name\(\[.\+\]\)\?=.*\)$/\1 (Snappy Edition)/g

## Fix-up application icon lookup
s|^Icon=.*|Icon=\${SNAP}/meta/gui/icon.svg|
41 changes: 41 additions & 0 deletions snap/snapcraft.yaml
Expand Up @@ -24,6 +24,47 @@ apps:
#slots:

parts:
# Patches to fix other parts
patches:
source: snap/patches
source-type: local
plugin: dump

# DISABLED: Bug #1775582 “`organize:{ /: another-dir/ }` causes the items under host root directory to be copied in another-dir” : Bugs : Snapcraft
# https://forum.snapcraft.io/t/organize-another-dir-causes-the-items-under-host-root-directory-to-be-copied-in-another-dir/5806
#organize:
#/: patches/
override-build: |
set -eu
snapcraftctl build
mkdir \
--parents \
"$SNAPCRAFT_PART_INSTALL"/patches
mv \
"$SNAPCRAFT_PART_INSTALL"/*.diff \
"$SNAPCRAFT_PART_INSTALL"/*.patch \
"$SNAPCRAFT_PART_INSTALL"/*.sed \
"$SNAPCRAFT_PART_INSTALL"/patches \
|| true # Empty patches folder is allowed
stage:
- patches/*
override-prime: 'true'

my-app:
after:
- patches

# See 'snapcraft plugins'
plugin: nil

override-stage: |
set -eu
snapcraftctl stage
sed \
--file "${SNAPCRAFT_STAGE}"/patches/patch-desktop-entries.sed \
--in-place \
"${SNAPCRAFT_STAGE}"/share/applications/*.desktop

0 comments on commit 7392a2c

Please sign in to comment.