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 <jv@jviotti.com>
This commit is contained in:
Juan Cruz Viotti 2017-07-25 09:47:33 -03:00 committed by GitHub
parent 36664fb251
commit b64ef705e8
3 changed files with 224 additions and 3 deletions

View File

@ -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)

View File

@ -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 <application name>"
echo " -d <application description>"
echo " -p <application package>"
echo " -r <application architecture>"
echo " -b <application binary name>"
echo " -i <application icon (.png)>"
echo " -o <output>"
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" <<EOF
[Desktop Entry]
Name=$ARGV_APPLICATION_NAME
Exec=$ARGV_BINARY.wrapper
Comment=$ARGV_DESCRIPTION
Icon=$APPDIR_ICON_FILENAME
Type=Application
EOF
cp "$ARGV_ICON" "$ARGV_OUTPUT/$APPDIR_ICON_FILENAME.png"
mkdir -p "$ARGV_OUTPUT/usr/bin"
cp -rf "$ARGV_PACKAGE"/* "$ARGV_OUTPUT/usr/bin"
APPIMAGES_TAG=6
APPIMAGES_GITHUB_RAW_BASE_URL=https://raw.githubusercontent.com/probonopd/AppImageKit/$APPIMAGES_TAG
APPIMAGES_GITHUB_RELEASE_BASE_URL=https://github.com/probonopd/AppImageKit/releases/download/$APPIMAGES_TAG
./scripts/build/download-tool.sh -x \
-u "$APPIMAGES_GITHUB_RAW_BASE_URL/desktopintegration" \
-c "bf321258134fa1290b3b3c005332d2aa04ca241e65c21c16c0ab76e892ef6044" \
-o "$ARGV_OUTPUT/usr/bin/$ARGV_BINARY.wrapper"
if [ "$ARGV_ARCHITECTURE" == "x64" ]; then
APPIMAGES_ARCHITECTURE="x86_64"
APPRUN_CHECKSUM=28b9c59facd7d0211ef5d825cc00873324cc75163902c48e80e34bf314c910c4
elif [ "$ARGV_ARCHITECTURE" == "x86" ]; then
APPIMAGES_ARCHITECTURE="i686"
APPRUN_CHECKSUM=44a56d8a654891030bab57cee4670550ed550f6c63aa7d82377a25828671088b
else
echo "Invalid architecture: $ARGV_ARCHITECTURE" 1>&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"

View File

@ -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 <appdir>"
echo " -r <application architecture>"
echo " -w <download directory>"
echo " -o <output>"
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"