diff options
author | Bignaux Ronan <ronan@aimao.org> | 2020-03-08 20:34:23 +0100 |
---|---|---|
committer | Bignaux Ronan <ronan@aimao.org> | 2020-03-08 20:34:23 +0100 |
commit | a3df64c8a7bd5e3e26c1cf469680d563c42103be (patch) | |
tree | b1668e52044c0ca84b5949004dadb92eda464c52 /pkgs/build-support/appimage | |
parent | 49e7871196ea43f6b8b6c81801f632f57ab892de (diff) |
appimage-exec.sh: simplify and improve getopts options
Diffstat (limited to 'pkgs/build-support/appimage')
-rwxr-xr-x | pkgs/build-support/appimage/appimage-exec.sh | 48 | ||||
-rw-r--r-- | pkgs/build-support/appimage/default.nix | 4 |
2 files changed, 30 insertions, 22 deletions
diff --git a/pkgs/build-support/appimage/appimage-exec.sh b/pkgs/build-support/appimage/appimage-exec.sh index ee952db0fd748..1273effe5fe23 100755 --- a/pkgs/build-support/appimage/appimage-exec.sh +++ b/pkgs/build-support/appimage/appimage-exec.sh @@ -4,6 +4,8 @@ if [ -n "$DEBUG" ] ; then fi PATH="@path@:$PATH" +apprun_opt=true + #DEBUG=0 # src : AppImage @@ -84,32 +86,35 @@ wrap() { } usage() { - echo "Usage: appimage-run [appimage-run options] <AppImage> [AppImage options]"; - echo - echo 'Options are passed on to the appimage.' - echo "If you want to execute a custom command in the appimage's environment, set the APPIMAGE_DEBUG_EXEC environment variable." + cat <<EOF +Usage: appimage-run [appimage-run options] <AppImage> [AppImage options] + +-h show this message +-d debug mode +-x <directory> : extract appimage in the directory then exit. +-w <directory> : run uncompressed appimage directory (used in appimageTools) + +[AppImage options]: Options are passed on to the appimage. +If you want to execute a custom command in the appimage's environment, set the APPIMAGE_DEBUG_EXEC environment variable. + +EOF exit 1 } -while getopts ":a:d:xrw" option; do +while getopts "x:w:dh" option; do case "${option}" in - a) #AppImage file - # why realpath? - APPIMAGE="$(realpath "${OPTARG}")" - break - ;; - d) #appimage Directory - export APPDIR=${OPTARG} + d) set -x ;; x) # eXtract unpack_opt=true - ;; - r) # appimage-Run - apprun_opt=true + APPDIR=${OPTARG} ;; w) # WrapAppImage + export APPDIR=${OPTARG} wrap_opt=true ;; + h) usage + ;; *) usage ;; @@ -117,6 +122,14 @@ while getopts ":a:d:xrw" option; do done shift $((OPTIND-1)) +if [[ $wrap_opt = true ]] && [[ -d "$APPDIR" ]]; then + wrap "$@" + exit +else + APPIMAGE="$(realpath "$1")" || usage + shift +fi + if [[ $unpack_opt = true ]] && [[ -f "$APPIMAGE" ]]; then unpack "$APPIMAGE" "$APPDIR" exit @@ -127,8 +140,3 @@ if [[ $apprun_opt = true ]] && [[ -f "$APPIMAGE" ]]; then wrap "$@" exit fi - -if [[ $wrap_opt = true ]] && [[ -d "$APPDIR" ]]; then - wrap "$@" - exit -fi diff --git a/pkgs/build-support/appimage/default.nix b/pkgs/build-support/appimage/default.nix index eb9a2a5ee0854..993032c5601f2 100644 --- a/pkgs/build-support/appimage/default.nix +++ b/pkgs/build-support/appimage/default.nix @@ -14,7 +14,7 @@ rec { extract = { name, src }: runCommand "${name}-extracted" { buildInputs = [ appimage-exec ]; } '' - appimage-exec.sh -x -d $out -a ${src} + appimage-exec.sh -x $out ${src} ''; # for compatibility, deprecated @@ -28,7 +28,7 @@ rec { targetPkgs = pkgs: [ appimage-exec ] ++ defaultFhsEnvArgs.targetPkgs pkgs ++ extraPkgs pkgs; - runScript = "appimage-exec.sh -w -d ${src}"; + runScript = "appimage-exec.sh -w ${src}"; } // (removeAttrs args (builtins.attrNames (builtins.functionArgs wrapAppImage)))); wrapType2 = args@{ name, src, extraPkgs ? pkgs: [], ... }: wrapAppImage (args // { |