summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2022-01-10 12:20:15 -0500
committerGitHub <noreply@github.com>2022-01-10 18:20:15 +0100
commit5cf0519928a99fa976623981991a4b8d1b0b3eb9 (patch)
tree426ed91efad90a39acdacacc935f1b8498d8447d
parent5dce5c14e410c595e53869d6d595d88db1dbf474 (diff)
add deb and rpm building (#1501)
-rw-r--r--.github/workflows/build.yml10
-rw-r--r--Makefile2
-rwxr-xr-xbin/after-install11
-rwxr-xr-xbin/before-remove9
-rwxr-xr-xbin/build-distribution-archives52
-rw-r--r--bin/linux-sh-installer117
6 files changed, 195 insertions, 6 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7b7e6d6d..b03df905 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -19,7 +19,9 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: '16.x'
-
+ - uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: 3.1
- uses: actions/cache@v2
id: pip-cache
with:
@@ -79,6 +81,7 @@ jobs:
make dist
env:
BUILD: linux
+ INKSTITCH_GPG_KEY: ${{ secrets.INKSTITCH_GPG_KEY }}
- uses: actions/upload-artifact@v2
with:
name: inkstitch-linux
@@ -236,6 +239,9 @@ jobs:
prerelease: "${{env.prerelease}}"
title: "${{env.title}}"
files: |
- artifacts/*.zip
artifacts/*.exe
artifacts/*.pkg
+ artifacts/*.deb
+ artifacts/*.rpm
+ artifacts/*.tar.xz
+ artifacts/*.sh
diff --git a/Makefile b/Makefile
index 23ff6f4f..56ec8b13 100644
--- a/Makefile
+++ b/Makefile
@@ -49,4 +49,4 @@ version:
.PHONY: style
style:
- flake8 . --count --max-complexity=10 --max-line-length=150 --statistics --exclude=pyembroidery,__init__.py,electron,build,src
+ flake8 . --count --max-complexity=10 --max-line-length=150 --statistics --exclude=pyembroidery,__init__.py,electron,build,src,dist
diff --git a/bin/after-install b/bin/after-install
new file mode 100755
index 00000000..10857314
--- /dev/null
+++ b/bin/after-install
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+inkscape_dir="$(inkscape --system-data-directory)"
+
+if [ "$?" != 0 ]; then
+ echo "ERROR: Cannot find inkscape system data directory. Is inkscape installed and in root's PATH?"
+ exit 1
+fi
+
+rm -f "${inkscape_dir}/extensions/inkstitch"
+ln -s /opt/inkstitch "${inkscape_dir}/extensions/inkstitch"
diff --git a/bin/before-remove b/bin/before-remove
new file mode 100755
index 00000000..ad500703
--- /dev/null
+++ b/bin/before-remove
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+inkscape_dir="$(inkscape --system-data-directory)"
+
+if [ -n "$inkscape_dir" ]; then
+ if [ -L "${inkscape_dir}/extensions/inkstitch" ]; then
+ rm -f "${inkscape_dir}/extensions/inkstitch"
+ fi
+fi
diff --git a/bin/build-distribution-archives b/bin/build-distribution-archives
index 2373c23a..584c0579 100755
--- a/bin/build-distribution-archives
+++ b/bin/build-distribution-archives
@@ -84,7 +84,53 @@ if [ "$BUILD" = "windows" ]; then
fi
if [ "$BUILD" = "linux" ]; then
- cd dist
- python -m zipfile -c ../artifacts/inkstitch-${VERSION}-${OS}.zip *;
- cd ..
+ gem install fpm
+
+ if [[ "$VERSION" =~ ^v[0-9][.0-9]+$ ]]; then
+ VERSION=${VERSION#v}
+ else
+ # dpkg requires versions to start with a number, so we have to add
+ # 0.0.1 for development builds
+ VERSION="0.0.1-${VERSION}"
+ fi
+
+ echo -n "$INKSTITCH_GPG_KEY" | base64 -d | gpg --import
+ cat <<EOF > $HOME/.rpmmacros
+%_gpg_name EA93BCE2CCD0FB2E77B2CC29E8120E50709E5C44
+%_signature gpg
+EOF
+
+ fpm -s dir \
+ -t deb \
+ -n inkstitch \
+ -v "$VERSION" \
+ -d "inkscape >= 1.0.0" \
+ --license "GPL-3.0" \
+ --description "An open-source machine embroidery design platform based on Inkscape" \
+ --url "https://inkstitch.org" \
+ --maintainer "maintainer@inkstitch.org" \
+ --after-install bin/after-install \
+ --before-remove bin/before-remove \
+ --verbose \
+ dist/inkstitch=/opt
+
+ fpm -s dir \
+ -t rpm \
+ -n inkstitch \
+ -v "$VERSION" \
+ -d "inkscape >= 1.0.0" \
+ --license "GPL-3.0" \
+ --description "An open-source machine embroidery design platform based on Inkscape" \
+ --url "https://inkstitch.org" \
+ --maintainer "maintainer@inkstitch.org" \
+ --after-install bin/after-install \
+ --before-remove bin/before-remove \
+ --verbose \
+ dist/inkstitch=/opt
+
+ rpmsign --addsign inkstitch*.rpm
+ mv inkstitch*.deb inkstitch*.rpm artifacts/
+
+ tar -C dist -Jcf artifacts/inkstitch-${VERSION}-${OS}.tar.xz inkstitch
+ cat "$(dirname "$0")/linux-sh-installer" artifacts/inkstitch-${VERSION}-${OS}.tar.xz > artifacts/inkstitch-${VERSION}-${OS}.sh
fi
diff --git a/bin/linux-sh-installer b/bin/linux-sh-installer
new file mode 100644
index 00000000..59bdf8d0
--- /dev/null
+++ b/bin/linux-sh-installer
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# This is a self-extracting archive that installs Ink/Stitch on your Linux
+# system. This first part is an installer, and after that is a .tar.zx file
+# containing Ink/Stitch itself.
+#
+# To install, simply run this script:
+#
+# sh inkstitch-<version>.sh
+#
+#
+# EXPERT STUFF BELOW:
+#
+# If you'd rather install it yourself, run this script with --extract to
+# produce the original inkstitch-<version>.tar.xz file in the current
+# directory.
+#
+# This script will attempt to determine where to install Inkscape user
+# extensions automatically. If it gets it wrong, you can set one of these
+# environment variables:
+#
+# INKSCAPE_PATH (ex: /usr/bin/inkscape)
+# The path to the inkscape executable program. This script will ask that program
+# where to install extensions by passing it the --user-data-directory argument.
+#
+# INKSCAPE_EXTENSIONS_PATH (ex: $HOME/.config/inkscape/extensions)
+# The path to the inkscape extensions directory. Use this to bypass the
+# --user-data-directory method and specify a directory yourself.
+
+die() {
+ echo "$*"
+ exit 1
+}
+
+extract() {
+ ( grep -m1 '^__ARCHIVE__$' > /dev/null; cat ) < "$0"
+}
+
+find_inkscape() {
+ # allow expert user override
+ if [ -n "$INKSCAPE_PATH" ]; then
+ echo "$INKSCAPE_PATH"
+ return
+ fi
+
+ inkscape="$(which inkscape)"
+
+ if [ -z "$inkscape" ]; then
+ read -p "Please enter the path to the inkscape program executable (example: /usr/bin/inkscape): " inkscape
+ fi
+
+ if [ ! -x "$inkscape" ]; then
+ die "Inkscape not found or not executable ($inkscape)"
+ fi
+
+ echo "$inkscape"
+}
+
+find_extensions_dir() {
+ # allow expert user override
+ if [ -n "$INKSCAPE_EXTENSIONS_PATH" ]; then
+ echo "$INKSCAPE_EXTENSIONS_PATH"
+ return
+ fi
+
+ inkscape="$(find_inkscape)"
+
+ if [ -x "$inkscape" ]; then
+ extensions_dir="$(inkscape --user-data-directory)/extensions"
+ fi
+
+ if [ -z "$extensions_dir" ]; then
+ read -p "Please enter the inkscape user extensions directory (example: $HOME/.config/inkscape/extensions): " extensions_dir
+ fi
+
+ if [ -z "$extensions_dir" ]; then
+ die "Aborting."
+ fi
+
+ mkdir -p "$extensions_dir" || die "unable to create $extensions_dir"
+
+ echo "$extensions_dir"
+}
+
+remove_existing() {
+ if [ -e "${1}/inkstitch" ]; then
+ read -p "${1}/inkstitch exists already. It must be removed in order to install $(basename ${0%.sh}). Delete? [y/N] " yesno
+ if [ "$yesno" != "y" -a "$yesno" != "Y" -a "$yesno" != "yes" ]; then
+ die "Aborting."
+ fi
+
+ rm -rf "${1}/inkstitch"
+ fi
+}
+
+install_inkstitch() {
+ extensions_dir="$(find_extensions_dir)"
+ echo "Installing Ink/Stitch to ${extensions_dir}/inkstitch"
+
+ remove_existing "$extensions_dir"
+
+ extract | tar -C "$extensions_dir" -Jxf - || die "error while extracting Ink/Stitch"
+
+ echo "Ink/Stitch has been successfully installed. Please restart Inkscape if it is already running."
+}
+
+if [ "$1" = "--extract" ]; then
+ dest="${0%.sh}.tar.xz"
+ extract > "$dest"
+ echo "Ink/Stitch extracted to $dest"
+else
+ install_inkstitch
+fi
+
+exit 0
+
+__ARCHIVE__