summaryrefslogtreecommitdiffstats
path: root/snap
diff options
context:
space:
mode:
Diffstat (limited to 'snap')
-rw-r--r--snap/README.md10
-rwxr-xr-xsnap/hooks/configure19
-rw-r--r--snap/local/print-inkscape-version.cpp43
-rwxr-xr-xsnap/local/scripts/ghostscript-libraries7
-rwxr-xr-xsnap/local/scripts/private-fontcache39
-rw-r--r--snap/snapcraft.yaml175
6 files changed, 293 insertions, 0 deletions
diff --git a/snap/README.md b/snap/README.md
new file mode 100644
index 0000000..baa681f
--- /dev/null
+++ b/snap/README.md
@@ -0,0 +1,10 @@
+Snap
+====
+
+This directory and `../snappy/` are used for building the snap (https://snapcraft.io/) package of Inkscape.
+
+Each commit to master sends a new build to the "edge" version.
+
+For build status and logs, see https://launchpad.net/~ted/+snap/inkscape-master. That account on launchpad.net is owned by Ted Gould <ted@gould.cx>.
+
+If the snap does no longer build or run, the most probable reason is that we added a new dependency. Have a look at the recent changes in https://gitlab.com/inkscape/inkscape-ci-docker, and try to make a similar change to `build-packages` (build dependency) or `stage-packages` (runtime dependency) in `snapcraft.yaml`.
diff --git a/snap/hooks/configure b/snap/hooks/configure
new file mode 100755
index 0000000..cbd76dd
--- /dev/null
+++ b/snap/hooks/configure
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+# Small hook to build a system font cache in the Snap's system directory
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+export SNAP_DESKTOP_RUNTIME=${SNAP}/gnome-platform
+
+mkdir -p $SNAP_DATA/fontconfig
+
+echo "<fontconfig>" > ${SNAP_DATA}/fontconfig/fonts.conf
+echo "<cachedir>${SNAP_DATA}/fontconfig</cachedir>" >> ${SNAP_DATA}/fontconfig/fonts.conf
+echo "<include ignore_missing=\"yes\">/etc/fonts/fonts.conf</include>" >> ${SNAP_DATA}/fontconfig/fonts.conf
+if [ ! -z $SNAP_DESTKOP_RUNTIME ]; then
+echo "<include ignore_missing=\"yes\">${SNAP_DESKTOP_RUNTIME}/etc/fonts/fonts.conf</include>" >> ${SNAP_DATA}/fontconfig/fonts.conf
+fi
+echo "</fontconfig>" >> ${SNAP_DATA}/fontconfig/fonts.conf
+
+export FONTCONFIG_FILE=${SNAP_DATA}/fontconfig/fonts.conf
+
+exec ${SNAP}/snap/command-chain/snapcraft-runner ${SNAP_DESKTOP_RUNTIME}/usr/bin/fc-cache --force --system-only --verbose
diff --git a/snap/local/print-inkscape-version.cpp b/snap/local/print-inkscape-version.cpp
new file mode 100644
index 0000000..210f806
--- /dev/null
+++ b/snap/local/print-inkscape-version.cpp
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Use the Inkscape compiled version identifier and print it out with
+// the Snap restrictions on versions. Only a few characters are allowed
+// and a limit of 32 characters total.
+
+#include "inkscape-version.h"
+
+#include <iostream>
+#include <cctype>
+
+int main (int argc, char ** argv) {
+ std::string outstr;
+
+ for (const auto& c : std::string{Inkscape::version_string}) {
+ if (outstr.length() == 32) {
+ break;
+ }
+
+ if (std::isalpha(c) || std::isdigit(c)) {
+ outstr.append(1, c);
+ continue;
+ }
+
+ if (c == '(' || c == ')' || c == ',') {
+ continue;
+ }
+
+ if (c == '.' || c == '-') {
+ outstr.append(1, c);
+ continue;
+ }
+
+ outstr.append(1, '-');
+ }
+
+ while (outstr.length() > 0 && !std::isalpha(outstr.back()) && !std::isdigit(outstr.back())) {
+ outstr.pop_back();
+ }
+
+ std::cout << outstr << std::endl;
+
+ return 0;
+}
diff --git a/snap/local/scripts/ghostscript-libraries b/snap/local/scripts/ghostscript-libraries
new file mode 100755
index 0000000..1184ce1
--- /dev/null
+++ b/snap/local/scripts/ghostscript-libraries
@@ -0,0 +1,7 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Make it so that Ghostscript can find itself in the snap directory
+
+export GS_LIB=`find ${SNAP}/usr/share/ghostscript -name gs_init.ps | head -1 | xargs dirname`
+
+exec "$@"
diff --git a/snap/local/scripts/private-fontcache b/snap/local/scripts/private-fontcache
new file mode 100755
index 0000000..964dfd6
--- /dev/null
+++ b/snap/local/scripts/private-fontcache
@@ -0,0 +1,39 @@
+#!/bin/bash
+# Ensure that we prioritize using the private font cache
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# ensure_dir_exists calls `mkdir -p` if the given path is not a directory.
+# This speeds up execution time by avoiding unnecessary calls to mkdir.
+#
+# Usage: ensure_dir_exists <path> [<mkdir-options>]...
+function ensure_dir_exists() {
+ [ -d "$1" ] || mkdir -p "$@"
+}
+
+# Set $REALHOME to the users real home directory
+REALHOME=$(getent passwd $UID | cut -d ':' -f 6)
+
+# Set config folder to local path
+export XDG_CONFIG_HOME="$SNAP_USER_DATA/.config"
+ensure_dir_exists "$XDG_CONFIG_HOME"
+chmod 700 "$XDG_CONFIG_HOME"
+
+function make_user_fontconfig {
+ echo "<fontconfig>"
+ echo " <dir>$REALHOME/.local/share/fonts</dir>"
+ echo " <dir>$REALHOME/.fonts</dir>"
+ echo " <cachedir prefix=\"xdg\">fontconfig</cachedir>"
+ echo " <cachedir>$SNAP_DATA/fontconfig</cachedir>"
+ echo " <include ignore_missing=\"yes\">/etc/fonts/fonts.conf</include>"
+ if [ ! -z $SNAP_DESTKOP_RUNTIME ]; then
+ echo " <include ignore_missing=\"yes\">${SNAP_DESKTOP_RUNTIME}/etc/fonts/fonts.conf</include>"
+ fi
+ echo "</fontconfig>"
+}
+
+ensure_dir_exists "$XDG_CONFIG_HOME/fontconfig"
+make_user_fontconfig > "$XDG_CONFIG_HOME/fontconfig/fonts.conf"
+
+export FONTCONFIG_FILE=${XDG_CONFIG_HOME}/fontconfig/fonts.conf
+
+exec "$@"
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
new file mode 100644
index 0000000..e4442c2
--- /dev/null
+++ b/snap/snapcraft.yaml
@@ -0,0 +1,175 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+name: inkscape
+adopt-info: inkscape
+summary: Vector Graphics Editor
+license: GPL-3.0
+description: >
+ An Open Source vector graphics editor, with capabilities similar to
+ Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector
+ Graphics (SVG) file format.
+
+ Inkscape supports many advanced SVG features (markers, clones, alpha blending,
+ etc.) and great care is taken in designing a streamlined interface.
+ It is very easy to edit nodes, perform complex path operations, trace
+ bitmaps and much more.
+
+ We also aim to maintain a thriving user and developer community by using
+ open, community-oriented development.
+confinement: strict
+grade: stable
+base: core18
+
+plugs:
+ dot-config-inkscape:
+ interface: personal-files
+ write: [ $HOME/.config/inkscape ]
+
+slots:
+ inkscape-dbus:
+ interface: dbus
+ bus: session
+ name: org.inkscape.Inkscape
+
+parts:
+ inkscape:
+ plugin: cmake
+ source: .
+ configflags:
+ - '-DWITH_DBUS=ON'
+ - '-DWITH_JEMALLOC=ON'
+ build-packages:
+ - cmake
+ - intltool
+ - libart-2.0-dev
+ - libaspell-dev
+ - libboost-dev
+ - libcdr-dev
+ - libdbus-glib-1-dev
+ - libdouble-conversion-dev
+ - libgc-dev
+ - libgdl-3-dev
+ - libglib2.0-dev
+ - libgnomevfs2-dev
+ - libgsl-dev
+ - libgtk-3-dev
+ - libgtkmm-3.0-dev
+ - libgtkspell3-3-dev
+ - libharfbuzz-dev
+ - libjemalloc-dev
+ - liblcms2-dev
+ - libmagick++-dev
+ - libpango1.0-dev
+ - libpoppler-glib-dev
+ - libpoppler-private-dev
+ - libpotrace-dev
+ - librevenge-dev
+ - libsigc++-2.0-dev
+ - libsoup2.4-dev
+ - libtool
+ - libvisio-dev
+ - libwpg-dev
+ - libxml-parser-perl
+ - libxml2-dev
+ - libxslt1-dev
+ - pkg-config
+ - zlib1g-dev
+ stage-packages:
+ - libaspell15
+ - libatkmm-1.6-1v5
+ - libcairomm-1.0-1v5
+ - libcdr-0.1-1
+ - libdouble-conversion1
+ - libgc1c2
+ - libgdk-pixbuf2.0-0
+ - libgdl-3-5
+ - libglibmm-2.4-1v5
+ - libglib2.0-bin
+ - libgnomevfs2-0
+ - libgsl23
+ - libgslcblas0
+ - libgtkmm-3.0-1v5
+ - libgtkspell3-3-0
+ - liblcms2-2
+ - libjemalloc1
+ - libmagick++-6.q16-7
+ - libpangomm-1.4-1v5
+ - libpoppler-glib8
+ - libpotrace0
+ - librevenge-0.0-0
+ - libvisio-0.1-1
+ - libwpg-0.3-3
+ - libxslt1.1
+ - aspell
+ - imagemagick
+ - libimage-magick-perl
+ - libwmf-bin
+ - transfig
+ - libsvg-perl
+ - libxml-xql-perl
+ - ruby
+ - python3-gi
+ - python3-gi-cairo
+ prime:
+ - -lib/inkscape/*.a
+ override-build: |
+ sed -i.bak -e 's|Icon=${INKSCAPE_ICONPATH}|Icon=${SNAP}/share/inkscape/branding/inkscape.svg|g' $SNAPCRAFT_PART_SRC/org.inkscape.Inkscape.desktop.template
+ snapcraftctl build
+ INKSCAPE_VERSION=`g++ -I${SNAPCRAFT_PART_SRC}/src ${SNAPCRAFT_PART_BUILD}/src/inkscape-version.cpp ${SNAPCRAFT_PROJECT_DIR}/snap/local/print-inkscape-version.cpp -o print-inkscape-version && ./print-inkscape-version`
+ echo "Inkscape Version: ${INKSCAPE_VERSION}"
+ snapcraftctl set-version "${INKSCAPE_VERSION}"
+ python-deps:
+ plugin: python
+ python-version: python3
+ python-packages:
+ - lxml
+ - numpy
+ - scour
+ - pyserial
+ stage-packages:
+ - pstoedit
+ snap-helpers:
+ plugin: dump
+ source: snap/local/scripts
+
+apps:
+ inkscape:
+ command: bin/inkscape
+ command-chain: [ private-fontcache, ghostscript-libraries ]
+ plugs:
+ - home
+ - gsettings
+ - unity7
+ - cups-control
+ - removable-media
+ - dot-config-inkscape
+ - raw-usb # plotter support
+ slots:
+ - inkscape-dbus
+ desktop: share/applications/org.inkscape.Inkscape.desktop
+ environment:
+ AAREALHOME: ${SNAP_USER_DATA}/../../..
+ INKSCAPE_PROFILE_DIR: ${AAREALHOME}/.config/inkscape
+ INKSCAPE_LOCALEDIR: ${SNAP}/share/locale
+ INKSCAPE_DATADIR: ${SNAP}/share
+ extensions: [ gnome-3-28 ]
+ completer: share/bash-completion/completions/inkscape
+ viewer:
+ command: bin/inkview
+ command-chain: [ private-fontcache ]
+ plugs:
+ - home
+ - gsettings
+ - unity7
+ - removable-media
+ - dot-config-inkscape
+ environment:
+ AAREALHOME: ${SNAP_USER_DATA}/../../..
+ INKSCAPE_PROFILE_DIR: ${AAREALHOME}/.config/inkscape
+ INKSCAPE_LOCALEDIR: ${SNAP}/share/locale
+ INKSCAPE_DATADIR: ${SNAP}/share
+ extensions: [ gnome-3-28 ]
+
+hooks:
+ configure:
+ plugs:
+ - desktop