Skip to content
Merged
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
55 changes: 48 additions & 7 deletions APP-MANAGER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

AMVERSION="6.7.1"
AMVERSION="6.8"

# Determine main repository and branch
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
Expand Down Expand Up @@ -476,6 +476,7 @@ cat <<-HEREDOC >> "$AMPATH/options"
--rollback
--sandbox
--silent
--system
--user
HEREDOC

Expand Down Expand Up @@ -512,20 +513,53 @@ function _completion_lists() {
# OTHER FUNCTIONS RELATED TO INTERNAL OPTIONS
#############################################

# Function for the option "appman" or "--user" that helps "AM" function like "AppMan", via alias
# Function for the option "appman" or "--user" that helps "AM" function like "AppMan"
function _appman_mode_enabled_message() {
if [ "$CLI" == am ] 2>/dev/null; then
echo '--------------------------------------------------------------------------'
#echo " \"AppMan Mode\" enabled!" | tr a-z A-Z
echo -e " \"AM\" is running as \"AppMan\", use ${Green}am --system\033[0m to switch it back to \"AM\""
echo '--------------------------------------------------------------------------'
fi
}

function _if_appman_mode_enabled() {
if [ "$CLI" == am ]; then
if test -f "$APPMANCONFIG"/appman-mode; then
_appman_mode_enabled_message
fi
fi
}

function _use_appman() {
_online_check
if [ "$AMCLI" == appman ] 2>/dev/null; then
if [ "$CLI" == appman ] 2>/dev/null; then
echo " This function only works for AM"
exit
fi
if test -f /opt/am/appman; then
if test -f "$APPMANCONFIG"/appman-mode; then
_appman
echo -e "Please run '${RED}alias am=/opt/am/appman\033[0m' to made 'AM' act exactly like 'AppMan' for\nthe current session or save this command to your '"'~/.bashrc'"' file to make the\nchanges permanent. Visit ${LightBlue}https://github.com/ivan-hc/appman\033[0m for more!"
_appman_mode_enabled_message
else
touch "$APPMANCONFIG"/appman-mode
_appman
wget -q "$AMREPO"/APP-MANAGER -O /opt/am/appman && chmod a+x /opt/am/appman
echo -e "Please run '${RED}alias am=/opt/am/appman\033[0m' to made 'AM' act exactly like 'AppMan' for\nthe current session or save this command to your '"'~/.bashrc'"' file to make the\nchanges permanent."
_appman_mode_enabled_message
fi
}

if [ "$AMCLI" == am ] 2>/dev/null; then
if test -f "$APPMANCONFIG"/appman-mode; then
_appman
AMCLIPATH="/opt/am/APP-MANAGER"
fi
fi

function _back_to_am() {
if test -f "$APPMANCONFIG"/appman-mode; then
rm -f "$APPMANCONFIG"/appman-mode
echo '--------------------------------------------------------------------------'
echo " \"AppMan Mode\" disabled!" | tr a-z A-Z
echo '--------------------------------------------------------------------------'
fi
}

Expand Down Expand Up @@ -554,6 +588,7 @@ case "$1" in
# OPTIONS BASED ON EXTERNAL MODULES
'-a'|'about'|'-l'|'list'|'-q'|'query')
MODULE="database.am"
_if_appman_mode_enabled
_use_module "$@"
;;
'-b'|'backup'|'-o'|'overwrite'|'lock'|'unlock')
Expand All @@ -571,11 +606,13 @@ case "$1" in
;;
'-f'|'files')
MODULE="files.am"
_if_appman_mode_enabled
_use_module "$@"
_betatester_message_on
;;
'-h'|'help')
MODULE="help.am"
_if_appman_mode_enabled
_use_module "$@"
;;
'-H'|'--home'|'--firejail'|'--sandbox')
Expand All @@ -585,6 +622,7 @@ case "$1" in
'-i'|'install')
MODULE="install.am"
_online_check
_if_appman_mode_enabled
_betatester_message_on
_portable_dependences_setup
_use_module "$@"
Expand Down Expand Up @@ -643,6 +681,9 @@ case "$1" in
'--enable-completion')
_use_enable_completion
;;
'--system')
_back_to_am
;;
'--user'|'appman')
_use_appman
;;
Expand Down
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ appman newrepo https://raw.githubusercontent.com/$USER/AM/dev

-----------------------------------------------

## Want to make code refactor?
“AM” is provided as-is, and each line has been tested to work as it should, based on user feedback and needs, as well as the aesthetic and practical preferences of the developer who created it, who provided it to you, and who constantly maintains it to make it work at its best.

Unfortunately, many contributors in the past, by relying exclusively on the logic of software such as "Shellcheck", without first verifying that the code worked, have caused more harm than good, both to the software and to its main developer, who ended up having to rewrite everything from scratch, losing time, mental health and trust towards their collaborators who had committed the mess.

The priority of this project is only one: **"AM" must work and that's it!**

Not out of malice, but if you got here and you like "AM" and how it works, you liked the work that the main developer did for you.

If you intend to carry out a "sensible" refactoring that doesn't risk breaking everything as it has already happened, you are welcome. But at the slightest mistake, you will be rejected, no ifs or buts. You are warned. Further errors will no longer be tolerated in this project and will be seen as attempts at sabotage!

If you believe that something needs improvement, let us know, but it is better for the refactoring to be carried out by someone who already knows the commands he wrote. It is certainly the best way to prevent everything from breaking and avoid irreversible damage.

-----------------------------------------------

## Want to contribute to the Development Branch and test newer features?
Enter the developer mode using the command
```
Expand Down
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ For everything else, the controls and operation are always the same for both com
<details>
<summary></summary>

If you usa "AM" and have the needing of installing apps at system level and locally, use the option `--user` that allows you to create an alias to install and manage apps in your $HOME folder. When executing the `am --user` command you will be suggested an alias to use temporarily or if you want you can add it in your ~/.bashrc to make it permanent. "AppMan" will be used while still using the usual `am` command.

The `--user` option does not immediately enable "AppMan Mode", instead it will show you an alias to use temporarily in the current session or to add to your ~/.bashrc to make it permanent:
If you use "AM" and have the needing of installing apps at system level and locally, use the option `--user` that allows to run "AM" in "AppMan Mode":
```
am --user
```
To switch "AM" back to "AM" from "AppMan Mode", use the option `--system`:
```
alias am=/opt/am/appman
am --system
```
AppMan is downloaded to the AM's installation folder, but without affecting the existing installation.
To perform a test and see if you are in "AppMan Mode" or not, run for example the command `am -f` to see the list of the installed apps.

***NOTE: using AM with the `--user` option enabled and the alias for AppMan, "sudo" allows normal use of AM, absence allows use of AppMan.***

Expand Down Expand Up @@ -605,7 +607,16 @@ to have a list of the installed programs use the option `-f` or `files` (syntax
___________________________________________________________________________

## EXTRA OPTIONS
___________________________________________________________________________
__________________________________________________________________________

`--system`

SYNOPSIS:

`--system`

DESCRIPTION: Switch "AM" back to "AM" from "AppMan Mode" (see --user).
__________________________________________________________________________

`--user`, `appman` (only available for "AM")

Expand Down
4 changes: 1 addition & 3 deletions modules/database.am
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ case "$1" in
_completion_lists
fi
ARGS=$(echo "$@" | sed 's/-q //')
echo ""
printf ' Search results for %s:' "$ARGS" | tr a-z A-Z
echo ""
echo -e "\n Search results for \"$ARGS\":\n" | tr a-z A-Z
grep -i -E "$2" "$AMPATH/$arch-apps" | grep -i -E "$3" | grep -i -E "$4" | grep -i -E "$5" | grep -i -E "$6" | grep -i -E "$7" | grep -i -E "$8" | grep -i -E "$9" | _clean_lists_and_queries
grep -i -E "$2" "$AMPATH/libs-list" | grep -i -E "$3" | grep -i -E "$4" | grep -i -E "$5" | grep -i -E "$6" | grep -i -E "$7" | grep -i -E "$8" | grep -i -E "$9" | _clean_lists_and_queries
echo ""
Expand Down
7 changes: 7 additions & 0 deletions modules/help.am
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@ function _help_body() {
EXTRA OPTIONS
__________________________________________________________________________

--system

SYNOPSIS: --system

DESCRIPTION: Switch "AM" back to "AM" from "AppMan Mode" (see --user).
__________________________________________________________________________

--user, appman ( only works with "AM" )

SYNOPSIS: --user
Expand Down
24 changes: 12 additions & 12 deletions modules/sync.am
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ fi
function _sync_amcli() {
echo "-----------------------------------------------------------------------------"
_completion_lists
CURRENT_AM_VERSION=$($AMCLIPATH -v)
echo -ne '\n ◆ SYNCHRONIZING "'"$(echo $AMCLI | tr a-z A-Z)"'" VERSION '"$CURRENT_AM_VERSION"'...\r'; sleep 1
rm -R -f $AMPATH/.cache/* 1>/dev/null; cd $AMPATH/.cache || return
if [ $AMCLI == am ] 2>/dev/null; then
wget -q $AMREPO/APP-MANAGER && chmod a+x ./APP-MANAGER
CURRENT_AM_VERSION=$("$AMCLIPATH" -v)
echo -ne '\n ◆ SYNCHRONIZING "'"$(echo "$AMCLI" | tr a-z A-Z)"'" VERSION '"$CURRENT_AM_VERSION"'...\r'; sleep 1
rm -R -f "$AMPATH"/.cache/* 1>/dev/null; cd "$AMPATH"/.cache || return
if [ "$CLI" == am ] 2>/dev/null; then
wget -q "$AMREPO"/APP-MANAGER && chmod a+x ./APP-MANAGER
cd ..
mv $AMPATH/.cache/APP-MANAGER $AMPATH; chmod 777 $AMPATH
mv "$AMPATH"/.cache/APP-MANAGER /opt/am/APP-MANAGER; chmod 777 "$AMPATH"
else
wget -q $AMREPO/APP-MANAGER -O appman && chmod a+x ./$AMCLI
wget -q "$AMREPO"/APP-MANAGER -O appman && chmod a+x ./"$AMCLI"
cd ..
mv $AMPATH/.cache/$AMCLI $AMCLIPATH
mv "$AMPATH"/.cache/"$AMCLI" "$AMCLIPATH"
fi
if [ ! "$CURRENT_AM_VERSION" == "$($AMCLIPATH -v)" ] ; then
echo -ne ' A new release of "'"$(echo $AMCLI | tr a-z A-Z)"'" is available, please wait...\r'
echo -e ' ◆ "'"$(echo $AMCLI | tr a-z A-Z)"'" IS NOW UPDATED TO THE BRAND NEW '"$($AMCLIPATH -v)"' VERSION! \n\n Replacement of version '"$CURRENT_AM_VERSION"' currently in use, COMPLETED!'
if [ ! "$CURRENT_AM_VERSION" == "$("$AMCLIPATH" -v)" ] ; then
echo -ne ' A new release of "'"$(echo "$AMCLI" | tr a-z A-Z)"'" is available, please wait...\r'
echo -e ' ◆ "'"$(echo "$AMCLI" | tr a-z A-Z)"'" IS NOW UPDATED TO THE BRAND NEW '"$("$AMCLIPATH" -v)"' VERSION! \n\n Replacement of version '"$CURRENT_AM_VERSION"' currently in use, COMPLETED!'
echo -e "\n See https://github.com/ivan-hc/AM/commits/main\n"
else
echo -e ' ◆ "'"$(echo $AMCLI | tr a-z A-Z)"'" IS ALREADY UPDATED, CURRENT VERSION '"$CURRENT_AM_VERSION"''
echo -e ' ◆ "'"$(echo "$AMCLI" | tr a-z A-Z)"'" IS ALREADY UPDATED, CURRENT VERSION '"$CURRENT_AM_VERSION"''
echo -e "\n See https://github.com/ivan-hc/AM/commits/$AMBRANCH\n"
fi
}
Expand Down
1 change: 1 addition & 0 deletions programs/x86_64-apps
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@
◆ lepton : Democratizing Code Snippets Management (macOS/Win/Linux).
◆ lescovex : Lescovex decentralized exchange, wallet and contract issuer.
◆ levior : Converts web pages on-the-fly to the gemtext format.
◆ lf : lf (as in "list files") is a terminal file manager written in Go.
◆ libassist : Library Assistant.
◆ libertem : Pixelated scanning transmission electron microscopy.
◆ librecad : 2D CAD program written in C++11 using the Qt framework.
Expand Down
53 changes: 53 additions & 0 deletions programs/x86_64/lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh

APP=lf
SITE="gokcehan/lf"

# CREATE THE FOLDER
mkdir /opt/$APP
cd /opt/$APP

# ADD THE REMOVER
echo '#!/bin/sh' >> /opt/$APP/remove
echo "rm -R -f /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove
chmod a+x /opt/$APP/remove

# DOWNLOAD THE ARCHIVE
mkdir tmp
cd ./tmp

version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*lf-linux-amd64.*gz$' | head -1)
wget $version
echo "$version" >> /opt/$APP/version
tar fx ./*tar*; rm -R -f ./*tar*
cd ..
mv --backup=t ./tmp/* ./$APP
rm -R -f ./tmp

# LINK
ln -s /opt/$APP/$APP /usr/local/bin/$APP

# SCRIPT TO UPDATE THE PROGRAM
cat >> /opt/$APP/AM-updater << 'EOF'
#!/bin/sh
APP=lf
SITE="gokcehan/lf"
version0=$(cat /opt/$APP/version)
version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*lf-linux-amd64.*gz$' | head -1)
if [ $version = $version0 ]; then
echo "Update not needed!"
else
notify-send "A new version of $APP is available, please wait"
mkdir /opt/$APP/tmp
cd /opt/$APP/tmp
wget $version
tar fx ./*tar*; rm -R -f ./*tar*
cd ..
mv --backup=t ./tmp/* ./$APP
rm ./version
echo $version >> ./version
rm -R -f ./tmp ./*~
notify-send "$APP is updated!"
fi
EOF
chmod a+x /opt/$APP/AM-updater