Skip to content

Commit 5c379c8

Browse files
committed
AppRun: add --mk-symlinks for symlinks create
for convenience to allow uv/hd-rum-transcode normally
1 parent a4097ba commit 5c379c8

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

  • data/scripts/Linux-AppImage

data/scripts/Linux-AppImage/AppRun

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ARGV0=${ARGV0-$0}
1111
bold=$(tput bold || true)
1212
red=$(tput setaf 1 || true)
1313
reset=$(tput sgr0 || true)
14+
bold_str=${bold}%s${reset}
1415

1516
DIR=$(dirname "$(realpath "$0")")
1617
readonly AI_LIB_PATH="$DIR"/usr/lib
@@ -48,7 +49,29 @@ get_tool_from_progname() {(
4849
done
4950
)}
5051

52+
# create convenience symlinks for the AppImage
53+
mk_symlinks() {(
54+
if [ "$APPIMAGE" = none ]; then
55+
abs_path=$(realpath "$0")
56+
dstdir=.
57+
else
58+
abs_path=$APPIMAGE
59+
dstdir=$(dirname "$APPIMAGE")
60+
fi
61+
printf "Creating symlinks for ${bold_str}in $bold_str pointing to \
62+
${bold_str}...\n" "$(get_tools)" "$dstdir" "$abs_path"
63+
cd "$dstdir"
64+
# shellcheck disable=SC2046 # intentional
65+
set -- $(get_tools)
66+
while [ $# -gt 0 ]; do
67+
ln -s "$abs_path" "$1" || true
68+
shift
69+
done
70+
)}
71+
72+
## @param $1 non-empty to show full help
5173
usage() {
74+
full=${1:+1}
5275
printf "usage:\n"
5376
printf "\t${bold}${red}%s${reset} ${bold}[--gui [args]]${reset}\n" "$ARGV0"
5477
printf "\t\tinvokes GUI\n"
@@ -75,12 +98,19 @@ usage() {
7598
printf "\t\tinvokes specified tool\n"
7699
printf "\t\ttool may be one of: ${bold}%s${reset}\n" "$(get_tools)"
77100
printf "\n"
101+
if [ "$full" ]; then
102+
printf "\t${bold}${red}%s${reset} ${bold}--mk-symlinks${reset}\n" "$ARGV0"
103+
printf "\t\tmake symlinks for the above tools to allow direct run\n"
104+
printf "\n"
105+
fi
78106
printf "\t${bold}${red}%s${reset} ${bold}args${reset}\n" "$ARGV0"
79107
printf "\t\tinvokes command-line UltraGrid\n"
80108
printf "\n"
81-
}
82109

83-
usage_aux() {
110+
if [ ! "$full" ]; then
111+
return
112+
fi
113+
84114
printf "environment variables:\n"
85115
printf "\tAPPIMAGE_DEBUG: print debug info + used Firejail options\n"
86116
printf "\tULTRAGRID_AUTOUPDATE: autoupdate interval in days (0 - check always); -1 - disable update advice\n"
@@ -438,8 +468,7 @@ elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
438468
elif [ "$1" = "--ug-help" ]; then
439469
run uv -h
440470
elif [ "$1" = "--fullhelp" ]; then
441-
usage
442-
usage_aux
471+
usage full
443472
exit 0
444473
elif { [ $# -eq 1 ] || [ $# -eq 2 ]; } && { [ "$1" = "-m" ] || [ "$1" = "--man" ]; }; then
445474
PAGE=${2:-uv}
@@ -451,6 +480,8 @@ elif [ "$1" = "-u" ] || [ "$1" = "--update" ]; then
451480
fi
452481
touch "$APPIMAGE" # update AppImage mtime to avoid update notices if there are no updates avalable but were checked for
453482
"$DIR/appimageupdatetool" ${1+"$@" }"$APPIMAGE"
483+
elif [ "$1" = "--mk-symlinks" ]; then
484+
mk_symlinks
454485
else
455486
handle_autoupdates "$@"
456487
run uv "$@"

0 commit comments

Comments
 (0)