From 35b748c46c57e553b526ae4b106270f752b4acf3 Mon Sep 17 00:00:00 2001 From: rejbasket <39080670+rejbasket@users.noreply.github.com> Date: Mon, 18 Apr 2022 10:59:42 +0200 Subject: [PATCH] Pkg inkscape check (#1622) * add warning if Inkscape not installed (mac) enable local build with arm linux and mac Authored-by: rejbasket --- .github/workflows/build.yml | 2 +- bin/build-distribution-archives | 23 +++++++++++++++++------ bin/build-electron | 11 ++++++++++- bin/build-python | 13 ++++++------- electron/package.json | 26 +++++++++++++++++++------- installer_scripts/scripts/preinstall | 24 ++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9a0018aa..74fe8f6bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -171,7 +171,7 @@ jobs: # with --no-binary argument may fix notary issues as well shapely speedups error issue pip install -U lxml --no-binary lxml pip uninstall --yes shapely - pip install -U Shapely==1.8.0 --no-binary Shapely + pip install -v -U Shapely --no-binary Shapely pip install pyinstaller echo "${{ env.pythonLocation }}/bin" >> $GITHUB_PATH diff --git a/bin/build-distribution-archives b/bin/build-distribution-archives index d20a9a173..a4129e839 100755 --- a/bin/build-distribution-archives +++ b/bin/build-distribution-archives @@ -1,5 +1,6 @@ VERSION="$(echo ${GITHUB_REF} | sed -e 's|refs/heads/||' -e 's|refs/tags/||' -e 's|/|-|g')" OS="${BUILD:-$(uname)}" +ARCH="$(uname -m)" mkdir artifacts if [ "$BUILD" = "osx" ]; then @@ -7,9 +8,19 @@ if [ "$BUILD" = "osx" ]; then # adding version to Info.plist sed -i '' 's/0.0.0/'${VERSION}'/' dist/inkstitch.app/Contents/Info.plist rm -rf dist/inkstitch/ - temp_path="/tmp/inkstitch/" + # Install location for pkgbuild + PKG_INSTALL_PATH="/tmp/inkstitch/" + # Checking arch of macos and setting path of electron for arm64 or intel + echo "Checking for macOS arch." + if [ "${ARCH}" = "arm64" ]; then + ELECTRON_BUILD_PATH="electron/build/mac-arm64" + echo "found arm64" + else + ELECTRON_BUILD_PATH="electron/build/mac" + echo "found intel" + fi # inside the scripts folder are: - # - preinstaller (checks for previously installed inkstitch and deletes it) and + # - preinstaller (checks for previously installed inkstitch and deletes it, Inkscape check with error message) and # - postinstaller (moves inkstitch folder from /tmp to user Inkscape extensions folder in $HOME) # The postinstaller is a workaround for a proper way to install in user $HOME space @@ -23,7 +34,7 @@ if [ "$BUILD" = "osx" ]; then DEV_IDENT="Developer ID Application: Lex Neva (929A568N58)" echo "Signing of inkstitch.app" # Coyping inkstitch-gui.app into inkstitch - ditto electron/build/mac dist/inkstitch.app/Contents/MacOS/electron + ditto "${ELECTRON_BUILD_PATH}" dist/inkstitch.app/Contents/MacOS/electron # signing the binary may fix notary issue /usr/bin/codesign -s "${DEV_IDENT}" \ --deep \ @@ -49,7 +60,7 @@ if [ "$BUILD" = "osx" ]; then --identifier org.inkstitch.installer \ --version ${VERSION} \ --scripts installer_scripts/scripts \ - --install-location ${temp_path}inkstitch.app \ + --install-location ${PKG_INSTALL_PATH}inkstitch.app \ artifacts/inkstitch-${VERSION}-${OS}.pkg if [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9.]+$ || $NOTARIZE_DEVELOPMENT_BUILDS == true ]]; then echo "Notary starting" @@ -61,14 +72,14 @@ if [ "$BUILD" = "osx" ]; then fi else # local builds will not be signed or notarized - cp -a electron/build/mac dist/inkstitch.app/Contents/MacOS/electron + cp -a "${ELECTRON_BUILD_PATH}" dist/inkstitch.app/Contents/MacOS/electron pkgbuild --root dist/inkstitch.app \ --component-plist installer_scripts/inkstitch.plist \ --ownership recommended \ --identifier org.inkstitch.installer \ --version ${VERSION} \ --scripts installer_scripts/scripts \ - --install-location ${temp_path}inkstitch.app \ + --install-location ${PKG_INSTALL_PATH}inkstitch.app \ artifacts/inkstitch-${VERSION}-${OS}.pkg fi # Creating the zip for Drag n' Drop install diff --git a/bin/build-electron b/bin/build-electron index 9fdb88ae9..b0e935728 100755 --- a/bin/build-electron +++ b/bin/build-electron @@ -2,11 +2,20 @@ set -e set -x +ARCH="$(uname -m)" +# Check for cpu arch to build mac and linux electron arch +if [[ "$ARCH" = "arm64" ]] || [[ "$ARCH" = "aarch64" ]]; then + echo "Found ARM" + sed -i'' -e 's/CPU_ARCH/'arm64'/' electron/package.json +else + echo "Found x64" + sed -i'' -e 's/CPU_ARCH/'x64'/' electron/package.json +fi if [ "$BUILD" = "windows" ]; then args="-w --ia32" elif [ "$BUILD" = "linux" ]; then - args="-l --x64" + args="-l" elif [ "$BUILD" = "osx" ]; then cp installer_scripts/electron-entitlements.plist electron/build/ args="-m" diff --git a/bin/build-python b/bin/build-python index e84e84a52..195248c34 100755 --- a/bin/build-python +++ b/bin/build-python @@ -3,13 +3,12 @@ set -e info_year=$( date "+%Y" ) site_packages="$(python -c "import os; print(os.path.dirname(os.__file__) + '/site-packages')")" - +arch=$(uname -m) if [ "$BUILD" = "linux" ]; then - # pyinstaller misses these - pyinstaller_args+="--add-binary /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so:. " - pyinstaller_args+="--add-binary /usr/lib/x86_64-linux-gnu/libproxy.so.1:. " - pyinstaller_args+="--add-binary /lib/x86_64-linux-gnu/libnsl.so.1:. " - pyinstaller_args+="--add-binary /usr/lib/x86_64-linux-gnu/libxcb.so.1:. " + pyinstaller_args+="--add-binary /usr/lib/"$arch"-linux-gnu/gio/modules/libgiolibproxy.so:. " + pyinstaller_args+="--add-binary /usr/lib/"$arch"-linux-gnu/libproxy.so.1:. " + pyinstaller_args+="--add-binary /lib/"$arch"-linux-gnu/libnsl.so.1:. " + pyinstaller_args+="--add-binary /usr/lib/"$arch"-linux-gnu/libxcb.so.1:. " fi # This one's tricky. ink/stitch doesn't actually _use_ gi.repository.Gtk, @@ -41,7 +40,7 @@ if [ "$BUILD" = "osx" ]; then pyinstaller_args+="--osx-bundle-identifier org.inkstitch.app " pyinstaller_args+="-i electron/build/icons/mac/inkstitch.icns" if [[ -z ${GITHUB_REF} ]]; then - : + echo "Dev or Local Build" else bash bin/import-macos-keys fi diff --git a/electron/package.json b/electron/package.json index 5c905c637..43b785bb3 100644 --- a/electron/package.json +++ b/electron/package.json @@ -20,7 +20,14 @@ ], "linux": { "icon": "build/icons", - "target": "dir" + "target": [ + { + "target": "dir", + "arch": [ + "CPU_ARCH" + ] + } + ] }, "win": { "icon": "build/icons/win/inkstitch.ico", @@ -28,7 +35,14 @@ }, "mac": { "icon": "build/icons/mac/inkstitch.icns", - "target": "dir", + "target": [ + { + "target": "dir", + "arch": [ + "CPU_ARCH" + ] + } + ], "hardenedRuntime": true, "gatekeeperAssess": false, "entitlements": "build/electron-entitlements.plist", @@ -47,7 +61,6 @@ "@svgdotjs/svg.js": "^3.0.16", "@svgdotjs/svg.panzoom.js": "https://github.com/inkstitch/svg.panzoom.js", "axios": "^0.19.0", - "electron-compile": "^6.4.4", "lodash.throttle": "^4.1.1", "mousetrap": "^1.6.3", "query-string": "^6.8.2", @@ -80,11 +93,10 @@ "del": "^3.0.0", "devtron": "^1.4.0", "easygettext": "^2.7.0", - "electron": "4.1.3", + "electron": "11.2.0", "electron-builder": "22.8.0", - "electron-debug": "^1.5.0", - "electron-devtools-installer": "^2.2.4", - "electron-prebuilt-compile": "4.0.0", + "electron-debug": "^3.0.0", + "electron-devtools-installer": "^3.2.0", "eslint": "^4.19.1", "eslint-config-standard": "^11.0.0", "eslint-friendly-formatter": "^4.0.1", diff --git a/installer_scripts/scripts/preinstall b/installer_scripts/scripts/preinstall index 40187fb35..165128a7f 100755 --- a/installer_scripts/scripts/preinstall +++ b/installer_scripts/scripts/preinstall @@ -1,6 +1,30 @@ #!/bin/bash set -e inkstitch_folder=($HOME/Library/Application\ Support/org.inkscape.Inkscape/config/inkscape/extensions/inkstitch) +location_inkscape=(/Applications/Inkscape.app) + +# Checking if Inkscape is installed +if [[ -d "${location_inkscape}" ]]; then + echo "Inkscape is found and installed "${location_Inkscape}"." +else + osascript <<-AppleScript + set theDialogText to "Ink/Stich is an Inkscape plugin. Please install and run Inkscape before installing Ink/Stitch." + display dialog theDialogText buttons {"Okay"} default button "Okay" + AppleScript + exit 1 +fi + +# Checking if Inkscape configuration folders are created +if [[ -d "${inkstitch_folder%config*}" ]]; then + echo "Inkscape configs are found and installed "${inkstitch_folder%config*}"." +else + osascript <<-AppleScript + set theDialogText to "Please run Inkscape before installing Ink/Stitch." + display dialog theDialogText buttons {"Okay"} default button "Okay" + AppleScript + exit 1 +fi + if [[ -L "${inkstitch_folder}" ]]; then unlink "${inkstitch_folder}" echo "Unlinking manual install, to avoid damaging user local repository."