From b64ef705e8b3528f19566668b0e8cdb64f8cf6df Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 25 Jul 2017 09:47:33 -0300 Subject: [PATCH] chore: use old custom build system to create AppImages (#1625) electron-builder seems to ship with an older AppImages version that doesn't play very well with the custom AppImages elevation system we created. More particularly, we can't execute custom binaries inside the mounted AppImage given that the mount point seems to lose permissions, owner, and group file information. This commit goes back to our old custom build system just for AppImages, until we properly solve the problem, which will likely involve updating the AppImages version in electron-builder. Signed-off-by: Juan Cruz Viotti --- Makefile | 33 +++++- scripts/build/electron-create-appdir.sh | 109 ++++++++++++++++++ .../build/electron-create-appimage-linux.sh | 85 ++++++++++++++ 3 files changed, 224 insertions(+), 3 deletions(-) create mode 100755 scripts/build/electron-create-appdir.sh create mode 100755 scripts/build/electron-create-appimage-linux.sh diff --git a/Makefile b/Makefile index f3d32f5c..a61601a3 100644 --- a/Makefile +++ b/Makefile @@ -307,12 +307,39 @@ $(BUILD_DIRECTORY)/$(APPLICATION_NAME_ELECTRON)_$(APPLICATION_VERSION_DEBIAN)_$( --extraMetadata.packageType=deb \ $(DISABLE_UPDATES_ELECTRON_BUILDER_OPTIONS) -$(BUILD_DIRECTORY)/$(APPLICATION_NAME_LOWERCASE)-$(APPLICATION_VERSION)-$(TARGET_ARCH_APPIMAGE).AppImage: \ - | $(BUILD_DIRECTORY) - $(NPX) build --linux AppImage $(ELECTRON_BUILDER_OPTIONS) \ +ifeq ($(TARGET_ARCH),x64) +ELECTRON_BUILDER_LINUX_UNPACKED_DIRECTORY = linux-unpacked +else +ELECTRON_BUILDER_LINUX_UNPACKED_DIRECTORY = linux-$(TARGET_ARCH_ELECTRON_BUILDER)-unpacked +endif + +$(BUILD_DIRECTORY)/$(ELECTRON_BUILDER_LINUX_UNPACKED_DIRECTORY): + $(NPX) build --dir --linux $(ELECTRON_BUILDER_OPTIONS) \ + --extraMetadata.name=$(APPLICATION_NAME_ELECTRON) \ --extraMetadata.version=$(APPLICATION_VERSION) \ --extraMetadata.packageType=AppImage +$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-$(PLATFORM).AppDir: \ + $(BUILD_DIRECTORY)/$(ELECTRON_BUILDER_LINUX_UNPACKED_DIRECTORY) \ + | $(BUILD_DIRECTORY) + ./scripts/build/electron-create-appdir.sh \ + -n $(APPLICATION_NAME) \ + -d "$(APPLICATION_DESCRIPTION)" \ + -p $< \ + -r $(TARGET_ARCH) \ + -b $(APPLICATION_NAME_ELECTRON) \ + -i assets/icon.png \ + -o $@ + +$(BUILD_DIRECTORY)/$(APPLICATION_NAME_LOWERCASE)-$(APPLICATION_VERSION)-$(TARGET_ARCH_APPIMAGE).AppImage: \ + $(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-$(PLATFORM).AppDir \ + | $(BUILD_DIRECTORY) $(BUILD_TEMPORARY_DIRECTORY) + ./scripts/build/electron-create-appimage-linux.sh \ + -d $< \ + -r $(TARGET_ARCH) \ + -w $(BUILD_TEMPORARY_DIRECTORY) \ + -o $@ + $(BUILD_DIRECTORY)/$(APPLICATION_NAME_LOWERCASE)-$(APPLICATION_VERSION)-linux-$(TARGET_ARCH).zip: \ $(BUILD_DIRECTORY)/$(APPLICATION_NAME_LOWERCASE)-$(APPLICATION_VERSION)-$(TARGET_ARCH_APPIMAGE).AppImage \ | $(BUILD_DIRECTORY) diff --git a/scripts/build/electron-create-appdir.sh b/scripts/build/electron-create-appdir.sh new file mode 100755 index 00000000..bb4e210f --- /dev/null +++ b/scripts/build/electron-create-appdir.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +### +# Copyright 2016 resin.io +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +### + +set -u +set -e + +function usage() { + echo "Usage: $0" + echo "" + echo "Options" + echo "" + echo " -n " + echo " -d " + echo " -p " + echo " -r " + echo " -b " + echo " -i " + echo " -o " + exit 1 +} + +ARGV_APPLICATION_NAME="" +ARGV_DESCRIPTION="" +ARGV_PACKAGE="" +ARGV_ARCHITECTURE="" +ARGV_BINARY="" +ARGV_ICON="" +ARGV_OUTPUT="" + +while getopts ":n:d:p:r:b:i:o:" option; do + case $option in + n) ARGV_APPLICATION_NAME="$OPTARG" ;; + d) ARGV_DESCRIPTION="$OPTARG" ;; + p) ARGV_PACKAGE="$OPTARG" ;; + r) ARGV_ARCHITECTURE="$OPTARG" ;; + b) ARGV_BINARY="$OPTARG" ;; + i) ARGV_ICON="$OPTARG" ;; + o) ARGV_OUTPUT="$OPTARG" ;; + *) usage ;; + esac +done + +if [ -z "$ARGV_APPLICATION_NAME" ] \ + || [ -z "$ARGV_DESCRIPTION" ] \ + || [ -z "$ARGV_PACKAGE" ] \ + || [ -z "$ARGV_ARCHITECTURE" ] \ + || [ -z "$ARGV_BINARY" ] \ + || [ -z "$ARGV_ICON" ] \ + || [ -z "$ARGV_OUTPUT" ] +then + usage +fi + +# Create AppDir +mkdir -p "$ARGV_OUTPUT" +APPDIR_ICON_FILENAME=icon + +cat >"$ARGV_OUTPUT/$ARGV_APPLICATION_NAME.desktop" <&2 + exit 1 +fi + +./scripts/build/download-tool.sh -x \ + -u "$APPIMAGES_GITHUB_RELEASE_BASE_URL/AppRun_$APPIMAGES_TAG-$APPIMAGES_ARCHITECTURE" \ + -c "$APPRUN_CHECKSUM" \ + -o "$ARGV_OUTPUT/AppRun" diff --git a/scripts/build/electron-create-appimage-linux.sh b/scripts/build/electron-create-appimage-linux.sh new file mode 100755 index 00000000..01eccd3a --- /dev/null +++ b/scripts/build/electron-create-appimage-linux.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +### +# Copyright 2016 resin.io +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +### + +set -u +set -e + +OS=$(uname) +if [[ "$OS" != "Linux" ]]; then + echo "This script is only meant to be run in GNU/Linux" 1>&2 + exit 1 +fi + +function usage() { + echo "Usage: $0" + echo "" + echo "Options" + echo "" + echo " -d " + echo " -r " + echo " -w " + echo " -o " + exit 1 +} + +ARGV_APPDIR="" +ARGV_ARCHITECTURE="" +ARGV_DOWNLOAD_DIRECTORY="" +ARGV_OUTPUT="" + +while getopts ":d:r:w:o:" option; do + case $option in + d) ARGV_APPDIR="$OPTARG" ;; + r) ARGV_ARCHITECTURE="$OPTARG" ;; + w) ARGV_DOWNLOAD_DIRECTORY="$OPTARG" ;; + o) ARGV_OUTPUT="$OPTARG" ;; + *) usage ;; + esac +done + +if [ -z "$ARGV_APPDIR" ] \ + || [ -z "$ARGV_ARCHITECTURE" ] \ + || [ -z "$ARGV_DOWNLOAD_DIRECTORY" ] \ + || [ -z "$ARGV_OUTPUT" ] +then + usage +fi + +if [ "$ARGV_ARCHITECTURE" == "x64" ]; then + APPIMAGES_ARCHITECTURE="x86_64" + APPIMAGEASSISTANT_CHECKSUM=e792fa6ba1dd81de6438844fde39aa12d6b6d15238154ec46baf01da1c92d59f +elif [ "$ARGV_ARCHITECTURE" == "x86" ]; then + APPIMAGES_ARCHITECTURE="i686" + APPIMAGEASSISTANT_CHECKSUM=0faade0c009e703c221650e414f3b4ea8d03abbd8b9f1f065aef46156ee15dd0 +else + echo "Invalid architecture: $ARGV_ARCHITECTURE" 1>&2 + exit 1 +fi + +APPIMAGES_TAG=6 +APPIMAGES_GITHUB_RELEASE_BASE_URL=https://github.com/probonopd/AppImageKit/releases/download/$APPIMAGES_TAG +APPIMAGEASSISTANT_PATH=$ARGV_DOWNLOAD_DIRECTORY/AppImageAssistant-$ARGV_ARCHITECTURE.AppImage +mkdir -p "$ARGV_DOWNLOAD_DIRECTORY" +./scripts/build/download-tool.sh -x \ + -u "$APPIMAGES_GITHUB_RELEASE_BASE_URL/AppImageAssistant_$APPIMAGES_TAG-$APPIMAGES_ARCHITECTURE.AppImage" \ + -c "$APPIMAGEASSISTANT_CHECKSUM" \ + -o "$APPIMAGEASSISTANT_PATH" + +# Generate AppImage +mkdir -p "$(dirname "$ARGV_OUTPUT")" +$APPIMAGEASSISTANT_PATH "$ARGV_APPDIR" "$ARGV_OUTPUT"