Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert option "-ia"/"install-appimage" to a function under "-i" #1169

Merged
merged 3 commits into from
Nov 30, 2024
Merged
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
56 changes: 25 additions & 31 deletions modules/install.am
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,27 @@ _3rd_party_apps_handler() {
arg="$CACHEDIR/extra/$arg.toolpack"
}

_install_appimage() {
# This function is ment to select and install only AppImages
rm -f "$AMCACHEDIR"/install-args
_sync_appimages_list
for arg in $entries; do
if grep -q "^◆ $arg : " "$AMDATADIR/$ARCH-appimages"; then
echo "$arg" >> "$AMCACHEDIR"/install-args
else
arg="$arg-appimage"
if ! grep -q "^◆ $arg : " "$AMDATADIR/$ARCH-appimages"; then
echo "$DIVIDING_LINE"
echo " ✖ \"$(echo "$arg" | sed 's/-appimage//g')\" is not an Appimage"
echo "$DIVIDING_LINE"
else
echo "$arg" >> "$AMCACHEDIR"/install-args
fi
fi
done
entries=$(cat "$AMCACHEDIR"/install-args 2>/dev/null)
}

_install_local_script() {
# This function is for local installation scripts
path2arg="$arg"
Expand Down Expand Up @@ -339,7 +360,8 @@ case "$1" in
fi
;;

'-i'|'install')
'install'|'-i'|\
'install-appimage'|'-ia')
[ "$AMCLI" = "am" ] && echo "$@" | grep -q -- "--user" && _appman

case $2 in
Expand All @@ -366,6 +388,8 @@ case "$1" in
FLAGS=$(echo "$@" | tr ' ' '\n' | grep -- "--" | tr '\n ' ' ')
METAPACKAGES="kdegames kdeutils node platform-tools"

if [ "$1" = "-ia" ] || [ "$1" = "install-appimage" ]; then _install_appimage; fi

for arg in $entries; do
echo ""
cd "$REALDIR" || return 1
Expand Down Expand Up @@ -407,36 +431,6 @@ case "$1" in
exit 0
;;

'-ia'|'install-appimage')
[ "$AMCLI" = "am" ] && echo "$@" | grep -q -- "--user" && _appman

rm -f "$AMCACHEDIR"/install-args

entries="$(echo "$@" | cut -f2- -d ' ' | tr ' ' '\n' | grep -v -- "--")"
FLAGS=$(echo "$@" | tr ' ' '\n' | grep -- "--" | tr '\n ' ' ')
APPIMAGE_NAMES=$(curl -Ls https://portable-linux-apps.github.io/appimages.md | tr '/)' '\n' | grep -i ".md$" | uniq | sed 's/.md$//g' | grep -v "\[")

rm -f "$AMCACHEDIR/$ARCH-appimages"
for appimage in $APPIMAGE_NAMES; do
grep "◆ $appimage :" "$AMDATADIR/$ARCH-apps" >> "$AMCACHEDIR/$ARCH-appimages" &
done
for arg in $entries; do
if grep -q "^◆ $arg : " "$AMCACHEDIR/$ARCH-appimages"; then
echo "$arg" >> "$AMCACHEDIR"/install-args
else
arg="$arg-appimage"
if ! grep -q "^◆ $arg : " "$AMCACHEDIR/$ARCH-appimages"; then
echo " ✖ \"$(echo "$arg" | sed 's/-appimage//g')\" is not an Appimage"
else
echo "$arg" >> "$AMCACHEDIR"/install-args
fi
fi
done
APPIMAGES_ARGS=$(<"$AMCACHEDIR"/install-args sed 's/\n/ /g')
"$AMCLIPATH_ORIGIN" -i $FLAGS "$APPIMAGES_ARGS"
exit 1
;;

'-e'|'extra')
if [ -z "$2" ] || [ -z "$3" ]; then
echo " USAGE: $AMCLI $1 user/project [ARGUMENT]"
Expand Down