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

Add support to Toolpacks #1082

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion APP-MANAGER
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ available_options="about add apikey backup clean config disable downgrade downlo
home icons info install install-appimage launcher list lock neodb newrepo nolibfuse off on overwrite \
purge query remove sandbox select sync template test unlock update --all --appimages --apps --byname \
--config --convert --debug --devmode-disable --devmode-enable --force-latest --home --icons --launcher \
--less --pkg --rollback --disable-sandbox --sandbox --system --user"
--less --pkg --rollback --disable-sandbox --sandbox --system --toolpack --user"

function _completion_lists() {
# Remove existing lists and download new ones
Expand Down
12 changes: 11 additions & 1 deletion modules/database.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ _about_show_markdown() {
| sed '1,${ /^\s*#/ d; /^\s*!/ d; /\[Applications]/d; /\ --- /d; /\ | - | /d; /\!\[/d; }' \
| sed '$!N;s/^\s*\n\s*$//;P;D')
echo "$markdown_page" | fold -sw 72 | sed 's/^ //g; s/^/ /g'
elif echo "$package_name" | grep -q ".toolpack"; then
toolpack_appimage_name=$(echo "$arg" | sed 's/\.toolpack//g')
if curl -o /dev/null -sIf "https://pkg.pkgforge.dev/$ARCH/$toolpack_appimage_name.AppImage.repology.json"; then
toolpack_readme="https://raw.githubusercontent.com/pkgforge/pkgcache/refs/heads/main/$ARCH-Linux/README.md"
toolpack_description=$(curl -Ls "$toolpack_readme" | grep -i "$toolpack_appimage_name" | sed 's/ | /\n/g' | head -5 | tail -1)
toolpack_site=$(curl -Ls "$toolpack_readme" | grep -i "$toolpack_appimage_name" | sed 's/ | /\n/g' | tr '[()]' '\n' | grep "^http" | head -2 | tail -1)
printf "\n%b\n\nSOURCE: %b\n" "$toolpack_description" "$toolpack_site" | fold -sw 72 | sed 's/^ //g; s/^/ /g'
fi
else
printf ' "%s" IS NOT A VALID ARGUMENT\n' "$package_name"
fi
Expand All @@ -22,7 +30,7 @@ _about_page() {
package_name="${Green}$1\033[0m"
markdown_url="$AMCATALOGUEMARKDOWNS/${1}.md"
printf " PACKAGE: %b\n" "$package_name"
app_name=$(echo "$1" | sed 's/-appimage//g; s/debian-testing-//g')
app_name=$(echo "$1" | sed 's/-appimage//g; s/debian-testing-//g; s/\.toolpack//g')
argpath=$(echo "$ARGPATHS" | grep "/$app_name$")
if [ -f "$argpath/remove" ]; then
app_status="installed\033[0m"
Expand Down Expand Up @@ -351,6 +359,8 @@ case "$1" in
for arg in $entries; do
if curl -o /dev/null -sIf "$AMCATALOGUEMARKDOWNS/${arg}.md" 1>/dev/null; then
_about_page "$arg"
elif echo "$arg" | grep -q ".toolpack$"; then
_about_page "$arg"
else
printf " ERROR: %b not found\033[0m\n" "${RED}\"$arg\""
fi
Expand Down
18 changes: 18 additions & 0 deletions modules/install.am
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ _install_local_script() {
fi
}

# This function is needed to handle AppImages from https://github.com/pkgforge/pkgcache
_toolpack_handler() {
mkdir -p "$CACHEDIR/toolpack"
curl -Ls "$AMREPO"/templates/AM-SAMPLE-AppImage > "$CACHEDIR/toolpack/$arg.toolpack" || exit 1
sed -i "s#APP=SAMPLE#APP=$arg#g; \
s#FUNCTION#curl -Ls https://pkg.pkgforge.dev/$ARCH/$arg.AppImage.version#g; \
s#wget \"\$version\"#wget https://pkg.pkgforge.dev/$ARCH/$arg.AppImage#g" "$CACHEDIR/toolpack/$arg.toolpack"
chmod a+x "$CACHEDIR/toolpack/$arg.toolpack"
arg="$CACHEDIR/toolpack/$arg.toolpack"
}

# This is for scripts hosted on the official online database
_install_normally() {
mkdir -p "$AMCACHEDIR"/tmp && rm -f "$AMCACHEDIR"/tmp/* || return
Expand Down Expand Up @@ -370,6 +381,13 @@ case "$1" in
else
echo " 💀 ERROR: the file \"$arg\" does NOT exist"
fi
elif echo "$@" | grep -q -- "--toolpack"; then
if curl --output /dev/null --silent --head --fail "https://pkg.pkgforge.dev/$ARCH/$arg" 1>/dev/null; then
_toolpack_handler
_install_local_script
else
echo " 💀 ERROR: \"$arg\" does NOT exist in Toolpacks"
fi
elif curl --output /dev/null --silent --head --fail "$APPSDB"/"$arg" 1>/dev/null; then
_install_normally
else
Expand Down