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

Replace ".cache" references with the "$AMCACHEDIR" variable / added write control on installed app directories / conversion in functions of the processes to update apps and generate the options list #622

Merged
merged 26 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
139b4cf
Move ".cache" from "$AMPATH" to "$HOME"
ivan-hc Jun 3, 2024
af2bba0
Merge pull request #621 from ivan-hc/main
ivan-hc Jun 3, 2024
ff747fa
Change the working directory for module updates
ivan-hc Jun 3, 2024
bd29601
Confirm moving the modules
ivan-hc Jun 3, 2024
01b166f
Assign privileges to modules upon download
ivan-hc Jun 3, 2024
731795a
Keep "$AMPATH/.cache" as common directory for all users (in "AM")
ivan-hc Jun 3, 2024
53b978a
Give "$AMCACHEDIR" a chmod 777 to be used by more users
ivan-hc Jun 3, 2024
4740182
Update management.am: reconstruct info for "-f" after using "-o"
ivan-hc Jun 3, 2024
d36c611
Update INSTALL
ivan-hc Jun 3, 2024
5dd5f93
Change permissions for all files and directories in /opt/am
ivan-hc Jun 3, 2024
5d35e06
Update INSTALL
ivan-hc Jun 3, 2024
2ee826e
Add rw permissions for all files and directories in /opt/am
ivan-hc Jun 3, 2024
0789744
Add function to update all the apps
ivan-hc Jun 3, 2024
a590ad4
While updating, check if AM-updater is read-only
ivan-hc Jun 4, 2024
d019016
Message "$APPNAME is read-only, cannot update it!"
ivan-hc Jun 4, 2024
e09d034
Add files via upload
Samueru-sama Jun 4, 2024
721772c
Add files via upload
Samueru-sama Jun 4, 2024
8440b79
Update x86_64-apps
Samueru-sama Jun 4, 2024
72d2b44
Update aarch64-apps
Samueru-sama Jun 4, 2024
8d39198
Merge pull request #624 from Samueru-sama/dev
ivan-hc Jun 4, 2024
77e96b5
Update INSTALL
ivan-hc Jun 4, 2024
607f3e8
The one that installs "AM" is the owner
ivan-hc Jun 4, 2024
73474ed
Add function to check if /opt/am is read-only
ivan-hc Jun 4, 2024
6f35206
Create function to generate a list of the options for bash completion
ivan-hc Jun 4, 2024
c00aedb
Revert https://github.com/ivan-hc/AM/pull/622/commits/73474edbff70c40…
ivan-hc Jun 4, 2024
4559357
Update APP-MANAGER
ivan-hc Jun 4, 2024
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
241 changes: 133 additions & 108 deletions APP-MANAGER

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ _check_dependency() {
_check_dependency 'wget'
_check_dependency 'curl'

web_get() {
wget -q "$@"
}

# CREATING THE MAIN DIRECTORY FOR "AM"
mkdir -p /opt/am/.cache /opt/am/modules || exit 1
cd /opt/am || exit 1
Expand All @@ -36,14 +32,14 @@ rm -R -f /usr/local/bin/am /opt/am /etc/bash_completion.d/am-completion.sh' >> /
chmod a+x /opt/am/remove || exit 1

# DOWNLOAD THE MAIN SCRIPT
web_get https://raw.githubusercontent.com/ivan-hc/AM/main/APP-MANAGER
wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/APP-MANAGER
chmod a+x /opt/am/APP-MANAGER || exit 1

# LINK THE MAIN SCRIPT TO A KNOWN PATH
ln -s /opt/am/APP-MANAGER /usr/local/bin/am || echo "WARNING: Something went wrong!"

# DOWNLOAD THE LIST OF THE AVAILABLE PROGRAMS
web_get "https://raw.githubusercontent.com/ivan-hc/AM/main/programs/$arch-apps" || exit 1
wget -q "https://raw.githubusercontent.com/ivan-hc/AM/main/programs/$arch-apps" || exit 1

# DOWNLOAD MODULES
MODULES=$(curl -Ls https://api.github.com/repos/ivan-hc/AM/contents/modules | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*raw.*modules.*am$' | grep -v "sync\|update")
Expand Down
14 changes: 7 additions & 7 deletions modules/database.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function download_markdown() {
local disk_usage=""
local app_version=""
local markdown_url="$AMCATALOGUEMARKDOWNS/${1}.md"
local cache_dir="$AMPATH/.cache/about"
local cache_dir="$AMCACHEDIR/about"
local app_status=" STATUS: NOT INSTALLED"
local package_name=${1^^}
if curl -o /dev/null -sIf "$markdown_url"; then
Expand All @@ -23,7 +23,7 @@ function download_markdown() {
printf ' PACKAGE: %s\n' "$package_name"
if [ -f "$APPSPATH/$1/remove" ]; then
disk_usage=$(du -sm "$APPSPATH/$1" | cut -f1)
app_version=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::')
app_version=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::')
app_status=$(echo -e " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version")
fi
printf '%s\n' "$app_status"
Expand All @@ -43,7 +43,7 @@ function generate_3rd_party() {
printf ' PACKAGE: %s\n' "$arg" | tr a-z A-Z
if [ -f "$APPSPATH/$1/remove" ]; then
disk_usage=$(du -sm "$APPSPATH/$1" | cut -f1)
app_version=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::')
app_version=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::')
app_status=$(echo -e " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version")
fi
printf '%s\n' "$app_status"
Expand Down Expand Up @@ -83,12 +83,12 @@ function _list() {
ITEMSNUMBER=$(("$ITEMSNUMBER"-1))
fi
APPSNUMBER=$(echo "$(("$ITEMSNUMBER" - "$LIBNUMBER"))")
if test -f "$AMPATH"/.cache/version-args; then
INSTALLED=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ")
if test -f "$AMCACHEDIR"/version-args; then
INSTALLED=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ")
MESSAGE2="\n$INSTALLED\n"
else
_check_version
INSTALLED=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ")
INSTALLED=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ")
MESSAGE2="\n$INSTALLED\n"
fi

Expand Down Expand Up @@ -123,7 +123,7 @@ case "$1" in
exit
;;
esac
if ! test -f "$AMPATH"/.cache/version-args; then
if ! test -f "$AMCACHEDIR"/version-args; then
_check_version
fi

Expand Down
30 changes: 15 additions & 15 deletions modules/download.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#####################################################################################

function _convert_to_appman_compatible_script() {
if grep -q -- "--convert" "$AMPATH"/.cache/download-args; then
if grep -q -- "--convert" "$AMCACHEDIR"/download-args; then
if test -f "$APPMANCONFIG"/appman-config; then
APPSPATH=$(cat "$APPMANCONFIG"/appman-config)
sed -i "s# /usr/local/bin# $HOME/.local/bin#g" ./$arg
Expand Down Expand Up @@ -36,34 +36,34 @@ function _download() {
'--convert') ;;
*)
if test -f "$AMPATH/neodb"; then
rm -R -f "$AMPATH/.cache/multirepo-args"
rm -R -f "$AMCACHEDIR/multirepo-args"
MULTIREPO=$(cat "$AMPATH/neodb" | grep "Source=" | sed 's/Source=//g')
for anyrepo in $MULTIREPO; do
if curl --output /dev/null --silent --head --fail $anyrepo/$arg 1>/dev/null; then
echo "$anyrepo" >> "$AMPATH/.cache/multirepo-args"
echo "$anyrepo" >> "$AMCACHEDIR/multirepo-args"
fi
done
if test -f "$AMPATH/.cache/multirepo-args"; then
anyrepoargs=$(cat "$AMPATH/.cache/multirepo-args" 2>/dev/null | wc -l)
if test -f "$AMCACHEDIR/multirepo-args"; then
anyrepoargs=$(cat "$AMCACHEDIR/multirepo-args" 2>/dev/null | wc -l)
if [ $anyrepoargs -gt 0 ]; then
if curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then
echo "$APPSDB" >> "$AMPATH/.cache/multirepo-args"
echo "$APPSDB" >> "$AMCACHEDIR/multirepo-args"
fi
anyrepoargall=$(cat "$AMPATH/.cache/multirepo-args" 2>/dev/null | wc -l)
anyrepoargall=$(cat "$AMCACHEDIR/multirepo-args" 2>/dev/null | wc -l)
if [ $anyrepoargall == 1 ]; then
cd "$SCRIPTDIR" || return; wget -q "$(cat "$AMPATH/.cache/multirepo-args" | head -1)/$arg"; _convert_to_appman_compatible_script
rm -R -f "$AMPATH/.cache/multirepo-args"
cd "$SCRIPTDIR" || return; wget -q "$(cat "$AMCACHEDIR/multirepo-args" | head -1)/$arg"; _convert_to_appman_compatible_script
rm -R -f "$AMCACHEDIR/multirepo-args"
echo ' ◆ "'$arg'" third-party installation script downloaded! '
else
echo -e " ◆ FOUND $(echo '"'$arg'"' | tr a-z A-Z) FROM MULTIPLE SOURCES:\n" &&
printf " Select a URL from this menu (read carefully) or press CTRL+C to abort:\n\n"; sleep 1;
select d in $(cat "$AMPATH/.cache/multirepo-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done
rm -R -f "$AMPATH/.cache/multirepo-args"
select d in $(cat "$AMCACHEDIR/multirepo-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done
rm -R -f "$AMCACHEDIR/multirepo-args"
cd "$SCRIPTDIR" || return; wget -q $d/$arg; _convert_to_appman_compatible_script
echo ' ◆ "'$arg'" installation script downloaded! '
fi
elif curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then
rm -R -f "$AMPATH/.cache/multirepo-args"
rm -R -f "$AMCACHEDIR/multirepo-args"
cd "$SCRIPTDIR" || return; wget -q $APPSDB/$arg; _convert_to_appman_compatible_script
echo ' ◆ "'$arg'" installation script downloaded! '
else
Expand Down Expand Up @@ -93,9 +93,9 @@ case $2 in
esac

while [ -n "$1" ]; do
rm -f $AMPATH/.cache/download-args
echo "$@" | tr ' ' '\n' >> $AMPATH/.cache/download-args && echo STOP >> $AMPATH/.cache/download-args
ARGS=$(tail -n +2 $AMPATH/.cache/download-args)
rm -f "$AMCACHEDIR"/download-args
echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/download-args && echo STOP >> "$AMCACHEDIR"/download-args
ARGS=$(tail -n +2 "$AMCACHEDIR"/download-args)

for arg in $ARGS; do
if [ $arg == STOP ]; then
Expand Down
52 changes: 26 additions & 26 deletions modules/files.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ function _files_sizes() {
}

function _files_if_binary_executable() {
echo " ◆ $arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
}

function _files_if_unknown() {
echo " ◆ $arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
}

function _files_if_other() {
echo " ◆ $arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
}

function _files_if_launcher() {
echo " ◆ $arg | $APPVERSION | launcher | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | launcher | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
}

function _files_if_set_tools() {
echo " ◆ $arg | $APPVERSION | set/tools | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | set/tools | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
}

function _files_if_library() {
echo " ◆ $arg | $APPVERSION | library | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | library | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
}

function _files_if_script() {
Expand All @@ -56,20 +56,20 @@ function _files_if_script() {
elif test -f $APPSPATH/$arg/$arg-bin; then
_files_if_binary_executable
else
echo " ◆ $arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
fi
}

function _files_if_appimage() {
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'AppImages require FUSE to run')" ] 2>/dev/null; then
echo " ◆ $arg | $APPVERSION | appimage-type3 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | appimage-type3 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
else
echo " ◆ $arg | $APPVERSION | appimage-type2 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
echo " ◆ $arg | $APPVERSION | appimage-type2 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
fi
}

function _files_type() {
APPVERSION=$(cat "$AMPATH"/.cache/version-args | grep -w " ◆ $arg |" | sed 's:.*| ::')
APPVERSION=$(cat "$AMCACHEDIR"/version-args | grep -w " ◆ $arg |" | sed 's:.*| ::')
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'if you run it with the --appimage-extract option')" ] 2>/dev/null; then
string=$(strings -d "./$arg/$arg" 2>/dev/null | head -1 )
if grep -q "usr/local/lib" ./$arg/remove; then
Expand Down Expand Up @@ -118,10 +118,10 @@ function _files_type() {
}

function _files() {
rm -f "$AMPATH"/.cache/files-args*
rm -f "$AMCACHEDIR"/files-args*
cd $APPSPATH &&
INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@')
if ! test -f "$AMPATH"/.cache/version-args; then
if ! test -f "$AMCACHEDIR"/version-args; then
_check_version
fi
for arg in $INSTALLED_APPS; do
Expand All @@ -140,31 +140,31 @@ function _files_show_only_number() {

function _files_sort_by_name() {
_files_header
rm -f "$AMPATH"/.cache/files-args-byname
if test -f "$AMPATH"/.cache/files-args; then
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-byname
cat "$AMPATH"/.cache/files-args 2>/dev/null | sort >> "$AMPATH"/.cache/files-args-byname
rm -f "$AMCACHEDIR"/files-args-byname
if test -f "$AMCACHEDIR"/files-args; then
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname
cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname
else
_files
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-byname
cat "$AMPATH"/.cache/files-args 2>/dev/null | sort >> "$AMPATH"/.cache/files-args-byname
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname
cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname
fi
cat "$AMPATH"/.cache/files-args-byname | column -t
cat "$AMCACHEDIR"/files-args-byname | column -t
echo ""
}

function _files_sort_by_size() {
_files_header
rm -f "$AMPATH"/.cache/files-args-bysize
if test -f "$AMPATH"/.cache/files-args; then
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-bysize
cat "$AMPATH"/.cache/files-args >> "$AMPATH"/.cache/files-args-bysize 2>/dev/null
rm -f "$AMCACHEDIR"/files-args-bysize
if test -f "$AMCACHEDIR"/files-args; then
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize
cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null
else
_files
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-bysize
cat "$AMPATH"/.cache/files-args >> "$AMPATH"/.cache/files-args-bysize 2>/dev/null
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize
cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null
fi
cat "$AMPATH"/.cache/files-args-bysize | column -t
cat "$AMCACHEDIR"/files-args-bysize | column -t
echo ""
}

Expand Down
Loading