Skip to content

Commit

Permalink
Merge pull request #528 from ivan-hc/dev
Browse files Browse the repository at this point in the history
Use "jq" to handle JSON files / check if wget 1.x is in use
  • Loading branch information
ivan-hc authored Apr 29, 2024
2 parents 0d45c25 + 2a888d6 commit 1d2ae92
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
19 changes: 14 additions & 5 deletions APP-MANAGER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

AMVERSION="6.6.3.1"
AMVERSION="6.6.4"

# Determine the name of this script and its working directory
DIR="$( cd "$( dirname "$0" )" && pwd )"
Expand Down Expand Up @@ -156,16 +156,25 @@ function _am_security_check() {
function _am_dependences_check() {
# Check for essential commands required by the application
missing_deps=()
for name in cat chmod chown curl grep sed wget; do
AMDEPENDENCES="cat chmod chown curl grep jq sed wget"
for name in $AMDEPENDENCES; do
if ! command -v "$name" &>/dev/null; then
printf "\nERROR: command \"%s\" not found, strongly needed by \"%s\"!\n" "$name" "$AMCLI"
missing_deps+=("$name")
missing_deps+=("$name")
fi
done

# Exit if any essential command is missing
if [ -n "$missing_deps" ]; then
printf "\nMissing essential commands: %s\nInstall the above and try again\n\n" "${missing_deps[*]}"
echo '--------------------------------------------------------------------------'
printf " ${RED}💀 ERROR! MISSING ESSENTIAL COMMANDS\033[0m: %s\n\n Install the above and try again! \n" "${missing_deps[*]}"
echo '--------------------------------------------------------------------------'
echo -e "\n ${Green}List of the $(echo "$AMCLI" | tr a-z A-Z) $AMVERSION core dependences\033[0m:\n"
echo $AMDEPENDENCES | tr ' ' ',' | sed 's/,/, /g' | sed 's/^/ /g'
echo -e '\n--------------------------------------------------------------------------'
echo " If this message appears it is because you are missing some dependency"
echo " and if its the first time its because something new has been introduced."
echo -e "\n See ${LightBlue}https://github.com/ivan-hc/AM#dependences\033[0m for more information"
echo '--------------------------------------------------------------------------'
exit 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ A warning message will prevent you from using "AM"/"AppMan" if the following pac
- "`coreutils`", is usually installed by default in all distributions as it contains basic commands ("`cat`", "`chmod`", "`chown`"...);
- "`curl`", to check URLs;
- "`grep`", to check files;
- "`jq`", to handle JSON files (some scripts need to check a download URL from api.github.com);
- "`sed`", to edit/adapt installed files;
- "`wget`" to download all programs and update "AM"/AppMan itself;
- "`xdg-user-dirs`" to download or manage files in well known local folders;
Expand Down
15 changes: 10 additions & 5 deletions modules/install.am
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ while [ -n "$1" ]; do
# Patch to apply to installation scripts
function _install_common_patch(){
if ! grep -q -- "--debug" $AMPATH/.cache/install-args; then
# Use curl instead of wget to manage github APIs
sed -i 's#$(wget -q#$(curl -Ls#g' ./$arg
sed -i 's#-O -##g' ./$arg
# Patch "wget" to have a progress bar and fix errors when applying patches
sed -i "s#wget #wget -q --no-verbose --show-progress --progress=dot -e dotbytes=500K #g" ./$arg
# Add "jq" to manage github APIs
if grep -q "api.github.com" ./$arg; then
sed -i "s#-O -#-O - | jq '.'#g" ./$arg
fi
# Patch "wget" (version 1.x) to have a progress bar and fix errors when applying patches
if wget --version | head -1 | grep -q ' 1.'; then
sed -i "s#wget #wget -q --no-verbose --show-progress --progress=dot -e dotbytes=500K #g" ./$arg
sed -i 's#$(wget -q --no-verbose --show-progress --progress=dot -e dotbytes=500K #$(wget -q #g' ./$arg
sed -i "s# -q -q # -q #g" ./$arg
fi
# Silence "rm" errors by adding "-f"
sed -i 's#^rm /#rm -f /#g' ./$arg; sed -i 's#^rm ./#rm -f ./#g' ./$arg
# Silence "mv", "sed" errors and "squashfs-root" messages
Expand Down
16 changes: 8 additions & 8 deletions modules/template.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ while [ -n "$1" ]; do
echo "-----------------------------------------------------------------------"
# CHECK THE DOWNLOAD LINK, THE ONE THAT POINTS TO THE LATEST RELEASE, NOTE THAT IT MAY BE A DEVELOPMENT VERSION, ADD "/latest" AFTER "/releases" TO POINT TO THE LAST STABLE VERSION
q="'"
FUNCTION='curl -Ls https://api.github.com/repos/'$RESPONSE'/releases | grep browser_download_url | grep -i appimage | cut -d '$q'"'$q' -f 4 | head -1'
FUNCTION='wget -q https://api.github.com/repos/'$RESPONSE'/releases -O - | grep browser_download_url | grep -i appimage | cut -d '$q'"'$q' -f 4 | head -1'
sed -i "s#FUNCTION#$FUNCTION#g" ./am-scripts/$arch/$arg

read -p ' Do you wish to check the link to the latest version (Y,n)?' yn

case $yn in
'N'|'n') ;;
'Y'|'y'|*)
echo ""; curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1
echo ""; wget -q $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases -O - | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1
echo -e "\n The URL above is an example of what both\n the install and update scripts will point to.\n";;
esac

Expand All @@ -91,7 +91,7 @@ while [ -n "$1" ]; do
case $yn in
'N'|'n') ;;
'Y'|'y'|*)
echo ""; curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases | grep browser_download_url | grep -i "$response" | grep -i appimage | cut -d '"' -f 4 | head -1
echo ""; wget -q $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases -O - | grep browser_download_url | grep -i "$response" | grep -i appimage | cut -d '"' -f 4 | head -1
echo -e "\n The URL above is an example of what both\n the install and update scripts will point to.\n";;
esac;;
esac;;
Expand All @@ -107,7 +107,7 @@ while [ -n "$1" ]; do
case $yn in
'N'|'n') ;;
'Y'|'y'|*)
echo ""; curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases | grep browser_download_url | grep -w -v "$response" | grep -i appimage | cut -d '"' -f 4 | head -1
echo ""; wget -q $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases -O - | grep browser_download_url | grep -w -v "$response" | grep -i appimage | cut -d '"' -f 4 | head -1
echo -e "\n The URL above is an example of what both\n the install and update scripts will point to.\n";;
esac;;
esac;;
Expand Down Expand Up @@ -239,15 +239,15 @@ while [ -n "$1" ]; do
echo "-----------------------------------------------------------------------"
# CHECK THE DOWNLOAD LINK, THE ONE THAT POINTS TO THE LATEST RELEASE, NOTE THAT IT MAY BE A DEVELOPMENT VERSION, ADD "/latest" AFTER "/releases" TO POINT TO THE LAST STABLE VERSION
q="'"
FUNCTION='curl -Ls https://api.github.com/repos/'$RESPONSE'/releases | grep browser_download_url | cut -d '$q'"'$q' -f 4 | head -1'
FUNCTION='wget -q https://api.github.com/repos/'$RESPONSE'/releases -O - | grep browser_download_url | cut -d '$q'"'$q' -f 4 | head -1'
sed -i "s#THISISTHEURL#$FUNCTION#g" ./am-scripts/$arch/$arg

read -p ' Do you wish to check the link to the available items (Y,n)?' yn

case $yn in
'N'|'n') ;;
'Y'|'y'|*)
echo ""; curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases | grep browser_download_url | cut -d '"' -f 4
echo ""; wget -q $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases -O - | grep browser_download_url | cut -d '"' -f 4
echo -e "\n The URLs above are an example of what both\n the install and update scripts will point to.\n";;
esac

Expand All @@ -266,7 +266,7 @@ while [ -n "$1" ]; do
case $yn in
'N'|'n') ;;
'Y'|'y'|*)
echo ""; curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases | grep browser_download_url | grep -i "$response" | cut -d '"' -f 4 | head -1
echo ""; wget -q $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases -O - | grep browser_download_url | grep -i "$response" | cut -d '"' -f 4 | head -1
echo -e "\n The URL above is an example of what both\n the install and update scripts will point to.\n";;
esac;;
esac;;
Expand All @@ -282,7 +282,7 @@ while [ -n "$1" ]; do
case $yn in
'N'|'n') ;;
'Y'|'y'|*)
echo ""; curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases | grep browser_download_url | grep -w -v "$response" | cut -d '"' -f 4 | head -1
echo ""; wget -q $HeaderAuthWithGITPAT https://api.github.com/repos/$RESPONSE/releases -O - | grep browser_download_url | grep -w -v "$response" | cut -d '"' -f 4 | head -1
echo -e "\n The URL above is an example of what both\n the install and update scripts will point to.\n";;
esac;;
esac;;
Expand Down

0 comments on commit 1d2ae92

Please sign in to comment.