diff --git a/.gitignore b/.gitignore index d1bf3ff4bd..bb9fb32c82 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,10 @@ xcuserdata /packages/ /win32/distrib-* + +/*.snap +/poedit_source.tar.bz2 +/parts/ +/prime/ +/stage/ +/snap/.snapcraft/ diff --git a/snap/.editorconfig b/snap/.editorconfig new file mode 100644 index 0000000000..935630596d --- /dev/null +++ b/snap/.editorconfig @@ -0,0 +1,11 @@ +# EditorConfig for Snap Packaging +# http://EditorConfig.org + +## This config only applies to this folder +root = true + +[*.{yaml,yamllint}] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/snap/.yamllint b/snap/.yamllint new file mode 100644 index 0000000000..bbfceebd95 --- /dev/null +++ b/snap/.yamllint @@ -0,0 +1,17 @@ +# yamllint Configuration File for Snappy Packaging +# https://yamllint.readthedocs.io +# + +extends: default + +rules: + comments: + # Comments without starting space is disabled code + require-starting-space: false + min-spaces-from-content: 1 + comments-indentation: disable + document-start: disable + line-length: + # /parts/*/source key's value is URL + allow-non-breakable-inline-mappings: true + max: 100 diff --git a/snap/README b/snap/README new file mode 100644 index 0000000000..ed05b30891 --- /dev/null +++ b/snap/README @@ -0,0 +1,5 @@ + + Introduction +================ + +This is the snap package definition to build a snap package of Poedit diff --git a/snap/patches/enchant-fix-build.patch b/snap/patches/enchant-fix-build.patch new file mode 100644 index 0000000000..77dc95cb20 --- /dev/null +++ b/snap/patches/enchant-fix-build.patch @@ -0,0 +1,11 @@ +--- src/Makefile.am 2017-04-05 05:13:57.000000000 +0800 ++++ src/Makefile.am 2018-05-30 23:37:16.035641307 +0800 +@@ -6,6 +6,8 @@ + + libenchant_la_LIBADD= $(ENCHANT_LIBS) @ENCHANT_WIN32_RESOURCE@ + ++libenchant_la_LIBTOOLFLAGS = --tag=CC ++ + libenchant_la_LDFLAGS = -no-undefined -export-symbols-regex '^enchant_.*' + if OS_WIN32 + libenchant_la_LDFLAGS += -avoid-version diff --git a/snap/patches/postprocess-desktop-entries.sed b/snap/patches/postprocess-desktop-entries.sed new file mode 100644 index 0000000000..17e02985ae --- /dev/null +++ b/snap/patches/postprocess-desktop-entries.sed @@ -0,0 +1,28 @@ +# This sed script processes 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.png| diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000000..9ab1f8a72c --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,760 @@ +name: poedit +version: git +summary: Gettext translations editor for OS X, Windows and Unix. +description: > + This program is a GUI frontend to GNU Gettext utilities and a catalogs + editor/source code parser. It helps with translating applications into + other languages. + + By default Poedit can only open files under your home directory, to + allow Poedit access files under /media you must connect this snap to + the `removable-media` interface by running the following command as + superuser: + + # snap connect poedit:removable-media + + For Poedit to save credential data for Crowdin integration you must + connect this snap to the `password-manager-service` interface: + + # snap connect poedit:password-manager-service + +grade: stable +confinement: strict +icon: artwork/linux/appicon/256x256/apps/poedit.png + +apps: + poedit: + # WORKAROUND: Fix icon loading problem + # https://github.com/ubuntu/snapcraft-desktop-helpers/pull/121 + command: > + env + XDG_DATA_DIRS="$SNAP/share:$XDG_DATA_DIRS" + desktop-launch poedit + desktop: share/applications/poedit.desktop + plugs: + # The desktop interfaces + # https://forum.snapcraft.io/t/the-desktop-interfaces/2042 + # + Basic graphical resources + - desktop + # + Input method/a11y support + - desktop-legacy + # + Access to the X server + - x11 + - wayland + # + Access to Unity DE services(i.e. global menu support) + # FIXME: This breaks common menu options' localization + # https://forum.snapcraft.io/t/common-menu-option-localization-broken-after-connecting-to-unity7-interface/5792 + - unity7 + + # File access + - home + - removable-media + + # Crowdin access + - network + + # Secret Service access + - password-manager-service + + # Suggestions from snappy-debug + - gsettings + - mount-observe + + poedit-uri-handler: + command: desktop-launch poedit --handle-poedit-uri %u + desktop: share/applications/poedit-uri.desktop + plugs: + - desktop + - desktop-legacy + - x11 + - wayland + - home + - removable-media + - network + - password-manager-service + - gsettings + - mount-observe + +parts: + poedit: + after: + - boostlib + - ccache + - gtkspell + - patches + - wxwidgets + + source: git://github.com/vslavik/poedit.git + source-type: git + source-depth: 80 + override-pull: | + # There's no way we pull all the submodules down, we do this manually + git clone --depth=80 git://github.com/vslavik/poedit.git . + git submodule init \ + deps/json \ + deps/pugixml + git submodule update \ + --depth=200 \ + deps/json + git submodule update \ + --depth=50 \ + deps/pugixml + + build-packages: + # Boost libraries provided by Ubuntu 16.04 are too old, using + # installation from `boostlib` part instead + #- libboost-dev + #- libboost-iostreams-dev + #- libboost-regex-dev + #- libboost-system-dev + #- libboost-thread-dev + + # wxWidgets library provided by Ubuntu 16.04 is too old, using + # installation from `wxwidgets` part instead + #- libwxgtk3.0-dev + + # "JSON for Modern C++" is only provided by Ubuntu >= 17.10, + # using embedded submodule's version instead + #- nlohmann-json-dev + + # GCC(`g++` to be specific) provided by Ubuntu 16.04 is too + # old for the embedded submodule "JSON for Modern C++", use + # installation from `gcc-6` part instead. + #- gcc + #- g++ + + # Gtkspell3 requires patching to be relocatable + #- libgtkspell3-3-dev + + - asciidoc + - automake + - gettext + - libcld2-dev + - libcpprest-dev + - libicu-dev + - libjpeg-dev + - liblucene++-dev + - libnotify-dev + - libsecret-1-dev + - libtiff5-dev + - pkg-config + - xsltproc + - xmlto + - zlib1g-dev + + plugin: autotools + override-build: | + set -eu + + # Setup ccache + GCC-6 + PATH="${SNAPCRAFT_STAGE}/bin:${PATH}" + + ./bootstrap + ./configure \ + --with-wx-prefix="$SNAPCRAFT_STAGE" \ + CPPFLAGS="-I${SNAPCRAFT_STAGE}/include -I${SNAPCRAFT_PART_INSTALL}/../build/deps/json/src" \ + LDFLAGS="-Wl,--copy-dt-needed-entries -L${SNAPCRAFT_STAGE}/lib" \ + PKG_CONFIG_PATH="${SNAPCRAFT_STAGE}"/lib/pkgconfig + make \ + --jobs=$(nproc) + make \ + prefix="${SNAPCRAFT_PART_INSTALL}" \ + install + + sed \ + --in-place \ + --file "${SNAPCRAFT_STAGE}"/patches/postprocess-desktop-entries.sed \ + "${SNAPCRAFT_PART_INSTALL}"/share/applications/poedit*.desktop + + stage-packages: + # Called by Poedit + - gettext + + # Replaced by gtkspell part + #- libgtkspell3-3-0 + + # Required by Unity/GNOME? + - libcanberra-gtk3-module + + - libboost-iostreams1.58.0 + - libboost-regex1.58.0 + - libboost-thread1.58.0 + - libcld2-0 + - libcpprest2.8 + - libice6 + - liblucene++0v5 + - libsecret-1-0 + - libsm6 + - libxxf86vm1 + + filesets: + executables: + - bin/* + files-in-stage-packages: + - usr/* + freedesktop-desktop-entries: + - share/applications/* + icons: + - share/icons/* + localizations: + - share/locale/* + manpages: + - share/man/* + pixmaps: + - share/pixmaps/* + resources: + - share/poedit/* + + stage: + - $executables + - $files-in-stage-packages + - $freedesktop-desktop-entries + - $manpages + - $localizations + - $pixmaps + - $resources + + prime: + - $executables + - $files-in-stage-packages + - $freedesktop-desktop-entries + - $manpages + - $localizations + - $pixmaps + - $resources + + build-attributes: + - no-system-libraries + + boostlib: + after: + - ccache + + source: git://github.com/vslavik/poedit.git + source-type: git + source-depth: 1 + source-subdir: deps/boost + # NOTE: We override the entire pull step as submodule fetching is + # not optional + override-pull: | + git clone --depth=1 git://github.com/vslavik/poedit.git . + + build-packages: + # OPTIONAL: Use gcc installation from `gcc-6` part instead + #- gcc + #- g++ + - libbz2-dev + - libicu-dev + + plugin: dump + override-build: | + set -eu + + # Setup ccache + GCC-6 + PATH="${SNAPCRAFT_STAGE}/bin:${PATH}" + + cd deps/boost + ./bootstrap.sh \ + --prefix="${SNAPCRAFT_PART_INSTALL}" \ + --with-libraries=iostreams,regex,system,thread \ + --with-icu=/usr + ./b2 install \ + -j $(nproc) \ + --build-type=minimal \ + --layout=system \ + link=static \ + threading=multi + + filesets: + library-headers: + - include/* + libraries: + - lib/* + stage: + - $library-headers + - $libraries + override-prime: 'true' + + wxwidgets: + after: + - ccache + + source: git://github.com/vslavik/wxWidgets.git + source-type: git + source-depth: 1 + + build-packages: + # OPTIONAL: Use gcc installation from `gcc-6` part instead + #- gcc + #- g++ + + # Not used by Poedit + #- libgl1-mesa-dev + #- libglu1-mesa-dev + #- libgstreamer1.0-dev + #- libgstreamer-plugins-base1.0-dev + #- libwebkit2gtk-4.0-dev + + - gettext + - libcairo2-dev + - libexpat1-dev + - libgtk-3-dev + - libjpeg-dev + - libnotify-dev + - libpng-dev + - libsecret-1-dev + - libtiff5-dev + - libxtst-dev + - zlib1g-dev + + plugin: autotools + override-build: | + set -eu + + # Setup ccache + GCC-6 + PATH="${SNAPCRAFT_STAGE}/bin:${PATH}" + + ./autogen.sh + ./configure \ + --disable-shared \ + --disable-sound \ + --prefix="${SNAPCRAFT_STAGE}" \ + --with-gtk=3 \ + --without-opengl \ + --without-sdl \ + CC=gcc-6 \ + CPP=cpp-6 \ + CXX=g++-6 + make \ + --jobs=$(nproc) + make \ + prefix="${SNAPCRAFT_PART_INSTALL}" \ + install + + stage-packages: + # For addr2line, required by wxWidgets error dialog + - binutils + + filesets: + autoconf-macros: + - share/aclocal/* + bakefiles: + - share/bakefile/* + files-from-stage-packages: + - usr/* + executables: + - bin/* + headers: + - include/* + libraries: + - lib/* + localizations: + - share/locale/* + stage: + - $autoconf-macros + - $executables + - $files-from-stage-packages + - $headers + - $libraries + - $localizations + override-stage: | + set -eu + + snapcraftctl stage + + # Fixup wrong wx-config link + ln \ + --force \ + --relative \ + --symbolic \ + "${SNAPCRAFT_STAGE}"/lib/wx/config/gtk3-unicode-static-3.1 \ + "${SNAPCRAFT_STAGE}"/bin/wx-config + prime: + - $files-from-stage-packages + - $localizations + + desktop-gtk3: + after: + - ccache + + override-build: | + set -eu + + # Setup ccache + GCC-6 + PATH="${SNAPCRAFT_STAGE}/bin:${PATH}" + + snapcraftctl build + + # This pseudo part setups Compiler cache(ccache) to the stage dir. + # + # To use it simply add a dependency to this part and prepend + # "$SNAPCRAFT_STAGE"/bin to the command search PATHs + ccache: + after: + - gcc-6 + override-pull: 'true' + build-packages: + - ccache + plugin: nil + override-build: | + mkdir \ + --parents \ + "${SNAPCRAFT_PART_INSTALL}"/bin + ln \ + --force \ + --symbolic \ + "$(which ccache)" \ + "${SNAPCRAFT_PART_INSTALL}"/bin/gcc-6 + ln \ + --force \ + --symbolic \ + "$(which ccache)" \ + "${SNAPCRAFT_PART_INSTALL}"/bin/g++-6 + ln \ + --force \ + --symbolic \ + ./gcc-6 \ + "${SNAPCRAFT_PART_INSTALL}"/bin/gcc + ln \ + --force \ + --symbolic \ + ./g++-6 \ + "${SNAPCRAFT_PART_INSTALL}"/bin/g++ + filesets: + executables: + - bin/* + stage: + - $executables + override-prime: 'true' + + # This pseudo part setups version 6 of GCC, which is not available + # in Ubuntu 16.04 software source. + # To use it simply add a dependency to this part and prepend + # "$SNAPCRAFT_STAGE"/bin to the command search PATHs + gcc-6: + plugin: nil + # Poedit sources will be used when `source` is ommitted, avoid this + # behavior + override-pull: 'true' + override-build: | + sudo apt --yes install software-properties-common + + # Install newer GCC from Toolchain test builds PPA + sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test + sudo apt update + sudo apt --yes install cpp-6 gcc-6 g++-6 + + # Make fake executable search path for build systems that don't + # respect CC and CXX environmental variables + mkdir \ + --parents \ + "${SNAPCRAFT_PART_INSTALL}"/bin + # DISABLED: Replaced by ccache-gcc-6 + #ln \ + #--force \ + #--symbolic \ + #"$(which gcc-6)" \ + #"${SNAPCRAFT_PART_INSTALL}"/bin/gcc + #ln \ + #--force \ + #--symbolic \ + #"$(which g++-6)" \ + #"${SNAPCRAFT_PART_INSTALL}"/bin/g++ + ln \ + --force \ + --symbolic \ + "$(which cpp-6)" \ + "${SNAPCRAFT_PART_INSTALL}"/bin/cpp + + filesets: + executables: + - bin/* + stage: + - $executables + override-prime: 'true' + + spellcheck-dictionaries: + plugin: nil + # Poedit sources will be used when `source` is ommitted, avoid this + # behavior + override-pull: 'true' + override-build: | + set -eu + + # Download all dictionary packages, and extract to install prefix + apt download $( + apt-cache search '^hunspell-.*$' \ + | sort \ + | grep \ + --extended-regexp \ + --invert-match \ + '(myspell|dbgsym|tools|transitional|dependency)' \ + | cut --fields=1 --delimiter=' ' \ + | tr '\n' ' ' + ) + find -name '*.deb' \ + | xargs \ + --max-args=1 \ + --replace={} \ + --verbose \ + dpkg-deb --extract {} ../install + + filesets: + hunspell-dictionaries: + - usr/share/hunspell/* + myspell-dictionaries: + - usr/share/myspell/* + stage: + - $hunspell-dictionaries + prime: + - $hunspell-dictionaries + + # Self-built GtkSpell Part # + # This part provides a patched old version of the GtkSpell library + # to fix the non-relocatable iso-codes data path. + gtkspell: + after: + - ccache + - enchant + - iso-codes + + source: https://git.code.sf.net/p/gtkspell/gtkspell + source-type: git + source-depth: 1 + + plugin: autotools + configflags: + - --disable-shared + - LDFLAGS=-Wl,--copy-dt-needed-entries + - PKG_CONFIG_PATH=${SNAPCRAFT_STAGE}/usr/share/pkgconfig:${SNAPCRAFT_STAGE}/lib/pkgconfig + build-packages: + # Replaced by enchant part + #- libenchant-dev + + - autoconf + - autoconf-archive + - automake + - gobject-introspection + - libgirepository1.0-dev + - gtk-doc-tools + - intltool + - libgtk-3-dev + - libtool-bin + - valac + override-build: | + set -eu + + # Setup ccache + GCC-6 + PATH="${SNAPCRAFT_STAGE}/bin:${PATH}" + + # autogen.sh requires build directory to be created in advance + # https://sourceforge.net/p/gtkspell/gtkspell/merge-requests/1/ + mkdir -p build + + # GtkSpell's autogen runs configure by default + env NOCONFIGURE=yes ./autogen.sh + snapcraftctl build + + #stage-packages: + # Replaced by enchant part + #- libenchant1c2a + + filesets: + gir: + - share/gir-1.0/* + library-headers: + - include/* + libraries: + - lib/* + localization: + - share/locale/* + vala-bindings: + - share/vala/* + stage: + - $gir + - $library-headers + - $libraries + - $localization + prime: + - $localization + + # Self-built Enchant Part # + # This part provides a patched old version of the Enchant spell- + # checking library required by the GtkSpell library provided by + # Ubuntu 16.04. It workarounds the non-relocatable library to let + # it load the necessary backend plugins for each spellchecking + # dictionaries. + # + # NOTES: + # + # 1. Enchant requires its installation --prefix set to $SNAP + # in order to locate its spell checker backends plugins. + # 2. Static-linking(`--disable-shared`) is not possible as + # Enchant only support dynamically loading spell checker + # backends. + # 3. DESTDIR install method is used to avoid libtool error + # about library isn't installed under --prefix. + # 4. A patch is applied to avoid a libtool error, refer snap/ + # patches/enchant-fix-build.patch for details + enchant: + after: + - ccache + - patches + + source: https://github.com/AbiWord/enchant/releases/download/enchant-1-6-1/enchant-1.6.1.tar.gz + source-type: tar + + plugin: autotools + build-packages: + - autoconf + - automake + - libtool + - libglib2.0-dev + - libhunspell-dev + override-pull: | + set -eu + snapcraftctl pull + patch \ + --strip=0 \ + < "${SNAPCRAFT_STAGE}"/patches/enchant-fix-build.patch + + override-build: | + set -eu + + # Setup ccache + GCC-6 + PATH="${SNAPCRAFT_STAGE}/bin:${PATH}" + + env NOCONFIGURE=yes ./autogen.sh + ./configure \ + --prefix=/snap/poedit/current \ + --with-myspell-dir=/snap/poedit/current/usr/share/hunspell \ + PKG_CONFIG_PATH="${SNAPCRAFT_STAGE}"/lib/pkgconfig + make --jobs=$(nproc) + make DESTDIR="${SNAPCRAFT_PART_INSTALL}" \ + install + + stage-packages: + - libhunspell-1.3-0 + + organize: + snap/poedit/current/: / + filesets: + executables: + - bin/* + files-from-stage-packages: + - usr/* + library-headers: + - include/* + libtool-control-files: + - lib/*.la + - lib/enchant/*.la + pkgconfig: + - lib/pkgconfig/* + resources: + - share/enchant/* + shared-libraries: + - lib/*.so* + - lib/enchant/*.so* + static-libraries: + - lib/*.a + - lib/enchant/*.a + manpages: + - share/man/* + stage: + - $files-from-stage-packages + - $library-headers + - $libtool-control-files + - $pkgconfig + - $resources + - $shared-libraries + - $static-libraries + override-stage: | + set -eu + + snapcraftctl stage + + # Patch-up incorrect prefix set by snapcraft :-/ + # https://bugs.launchpad.net/snapcraft/+bug/1774254 + sed \ + --in-place \ + 's#^prefix=.*$#prefix=${pcfiledir}/../..#g' \ + "${SNAPCRAFT_STAGE}"/lib/pkgconfig/enchant.pc + prime: + - $files-from-stage-packages + - $resources + - $shared-libraries + + # Patched Ubuntu iso-codes installation + # This patch slightly patches iso-codes's pkg-config so that non- + # relocable GtkSpell part can locate its data + iso-codes: + override-pull: 'true' + + plugin: nil + override-build: | + set -eu + + apt download iso-codes + dpkg-deb \ + --extract \ + iso-codes_*_all.deb \ + "${SNAPCRAFT_PART_INSTALL}" + rm iso-codes_*_all.deb + + filesets: + data: + - usr/share/xml/iso-codes/* + documentation: + - usr/share/doc/iso-codes/* + localization: + - usr/share/locale/* + pkgconfig: + - usr/share/pkgconfig/* + stage: + - $data + - $localization + - $pkgconfig + override-stage: | + set -eu + + snapcraftctl stage + + # Fix installation prefix to $SNAP + sed \ + --in-place \ + 's#^prefix=.*$#prefix=/snap/poedit/current/usr#g' \ + "${SNAPCRAFT_STAGE}"/usr/share/pkgconfig/iso-codes.pc + prime: + - $data + - $localization + + # Patches to be applied in build + # This pseudo part installs the patches required for building other + # parts into the stage tree + patches: + source: snap/patches + plugin: dump + + # DISABLED: `organize:{ /: another-dir/ }` causes the items under host + # root directory to be copied in another-dir - snapcraft - snapcraft.io + # 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 + find \ + "${SNAPCRAFT_PART_INSTALL}" \ + -type f \ + -maxdepth 1 \ + -mindepth 1 \ + -exec \ + mv \ + {} \ + "${SNAPCRAFT_PART_INSTALL}"/patches \ + ';' + override-prime: 'true'