Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions build/linux/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

# modified AppRun script from https://github.com/develar/app-builder/blob/master/pkg/package-format/appimage/templates/AppRun.sh

set -e

if [ ! -z "$DEBUG" ] ; then
env
set -x
fi

THIS="$0"
# http://stackoverflow.com/questions/3190818/
args=("$@")
NUMBER_OF_ARGS="$#"

if [ -z "$APPDIR" ] ; then
# Find the AppDir. It is the directory that contains AppRun.
# This assumes that this script resides inside the AppDir or a subdirectory.
# If this script is run inside an AppImage, then the AppImage runtime likely has already set $APPDIR
path="$(dirname "$(readlink -f "${THIS}")")"
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
done
APPDIR="$path"
fi

export PATH="${APPDIR}:${APPDIR}/usr/sbin:${PATH}"
export XDG_DATA_DIRS="./share/:/usr/share/gnome:/usr/local/share/:/usr/share/:${XDG_DATA_DIRS}"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${LD_LIBRARY_PATH}"
export XDG_DATA_DIRS="${APPDIR}"/usr/share/:"${XDG_DATA_DIRS}":/usr/share/gnome/:/usr/local/share/:/usr/share/
export GSETTINGS_SCHEMA_DIR="${APPDIR}/usr/share/glib-2.0/schemas:${GSETTINGS_SCHEMA_DIR}"

BIN="$APPDIR/HelloPear"

if [ -z "$APPIMAGE_EXIT_AFTER_INSTALL" ] ; then
trap atexit EXIT
fi

isEulaAccepted=1

atexit()
{
if [ $isEulaAccepted == 1 ] ; then
if [ $NUMBER_OF_ARGS -eq 0 ] ; then
exec "$BIN" --no-sandbox
else
exec "$BIN" --no-sandbox "${args[@]}"
fi
fi
}

error()
{
if [ -x /usr/bin/zenity ] ; then
LD_LIBRARY_PATH="" zenity --error --text "${1}" 2>/dev/null
elif [ -x /usr/bin/kdialog ] ; then
LD_LIBRARY_PATH="" kdialog --msgbox "${1}" 2>/dev/null
elif [ -x /usr/bin/Xdialog ] ; then
LD_LIBRARY_PATH="" Xdialog --msgbox "${1}" 2>/dev/null
else
echo "${1}"
fi
exit 1
}

yesno()
{
TITLE=$1
TEXT=$2
if [ -x /usr/bin/zenity ] ; then
LD_LIBRARY_PATH="" zenity --question --title="$TITLE" --text="$TEXT" 2>/dev/null || exit 0
elif [ -x /usr/bin/kdialog ] ; then
LD_LIBRARY_PATH="" kdialog --title "$TITLE" --yesno "$TEXT" || exit 0
elif [ -x /usr/bin/Xdialog ] ; then
LD_LIBRARY_PATH="" Xdialog --title "$TITLE" --clear --yesno "$TEXT" 10 80 || exit 0
else
echo "zenity, kdialog, Xdialog missing. Skipping ${THIS}."
exit 0
fi
}

check_dep()
{
DEP=$1
if [ -z $(which "$DEP") ] ; then
echo "$DEP is missing. Skipping ${THIS}."
exit 0
fi
}

if [ -z "$APPIMAGE" ] ; then
APPIMAGE="$APPDIR/AppRun"
# not running from within an AppImage; hence using the AppRun for Exec=
fi

3 changes: 2 additions & 1 deletion electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const appName = productName ?? name
const cmd = command(
appName,
flag('--storage', 'pass custom storage to pear-runtime'),
flag('--no-updates', 'start without OTA updates')
flag('--no-updates', 'start without OTA updates'),
flag('--no-sandbox', 'disable Chromium sandboxing')
)

cmd.parse(app.isPackaged ? process.argv.slice(1) : process.argv.slice(2))
Expand Down
14 changes: 12 additions & 2 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ if (process.env.MAC_CODESIGN_IDENTITY) {

module.exports = {
packagerConfig,

hooks: {
packageAfterCopy: async (forgeConfig, buildPath) => {
if (process.platform === 'linux') {
const path = await import('path')
const fs = await import('fs')
const customAppRun = path.resolve('build', 'linux', 'AppRun')
const targetPath = path.join(buildPath, '..', '..', 'AppRun')
fs.copyFileSync(customAppRun, targetPath)
}
}
},
makers: [
{
name: '@electron-forge/maker-dmg',
platforms: ['darwin'],
config: {}
},
{
name: '@forkprince/electron-forge-maker-appimage',
name: 'electron-forge-maker-appimage',
platforms: ['linux']
}
],
Expand Down
95 changes: 64 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"@electron-forge/maker-dmg": "^7.11.1",
"@electron-forge/maker-rpm": "^7.11.1",
"@electron-forge/maker-zip": "^7.11.1",
"@forkprince/electron-forge-maker-appimage": "^1.0.11",
"app-builder-lib": "^26.8.1",
"electron": "^40.2.1",
"electron-forge-maker-appimage": "^26.8.1",
"electron-forge-plugin-prune-prebuilds": "^1.0.0",
"electron-forge-plugin-universal-prebuilds": "^1.0.0",
"lunte": "^1.6.0",
Expand Down