Skip to content

Commit dd5cac6

Browse files
authored
Merge pull request #831 from ivan-hc/dev
"AM" 7.6
2 parents bc6c818 + 731e80f commit dd5cac6

File tree

7 files changed

+176
-157
lines changed

7 files changed

+176
-157
lines changed

AM-INSTALLER

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ _install_am() {
2727
mkdir -p "$CACHEDIR" || true
2828
rm -f "$CACHEDIR"/INSTALL-AM.sh || true
2929
wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/INSTALL -O "$CACHEDIR"/INSTALL-AM.sh && chmod a+x "$CACHEDIR"/INSTALL-AM.sh
30-
sudo "$CACHEDIR"/INSTALL-AM.sh && rm -f "$CACHEDIR"/INSTALL-AM.sh
30+
if command -v sudo >/dev/null 2>&1; then
31+
SUDOCOMMAND="sudo"
32+
elif command -v doas >/dev/null 2>&1; then
33+
SUDOCOMMAND="doas"
34+
else
35+
echo 'ERROR: No sudo or doas found'
36+
exit 1
37+
fi
38+
$SUDOCOMMAND "$CACHEDIR"/INSTALL-AM.sh && rm -f "$CACHEDIR"/INSTALL-AM.sh
3139
}
3240

3341
# INSTALL "AM" LOCALLY, AS "APPMAN"
@@ -59,15 +67,15 @@ printf " Choose how to install \"AM\" and all its managed applications.
5967
1) As \"${RED}AM\033[0m\", command \"${Green}am\033[0m\", this is a system-wide installation:
6068
- the command is a symlink /usr/local/bin/am for /opt/am/APP-MANAGER
6169
- all programs will be installed in /opt, into dedicated directories
62-
- a \"sudo\" password is required both here and to install/remove apps
70+
- a \"sudo\"/\"doas\" password is required both here and to install/remove apps
6371
- you are the one with read-write permissions for \"AM\" and all programs
6472
- other users can only use programs you have installed, nothing else
6573
- other users can still use \"AppMan mode\" for their rootless configurations
6674
6775
2) As \"${LightBlue}AppMan\033[0m\", command \"${Green}appman\033[0m\", local installation:
6876
- the command is the script ~/.local/bin/appman
6977
- choose wherever you want to install all the apps, in your HOME
70-
- no \"sudo\" required at all
78+
- no \"sudo\"/\"doas\" required at all
7179
- you can replicate your configurations on every system you want
7280
- more storage space required, if more users use \"AppMan\"
7381

APP-MANAGER

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
AMVERSION="7.5"
3+
AMVERSION="7.6"
44

55
# Determine main repository and branch
66
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
@@ -54,7 +54,14 @@ _no_sudo
5454
function _am() {
5555
AMCLI="am"
5656
AMCLIPATH="$AMCLI"
57-
SUDOCOMMAND="sudo"
57+
if command -v sudo >/dev/null 2>&1; then
58+
SUDOCOMMAND="sudo"
59+
elif command -v doas >/dev/null 2>&1; then
60+
SUDOCOMMAND="doas"
61+
else
62+
echo 'ERROR: No sudo or doas found'
63+
exit 1
64+
fi
5865
COMPLETIONPATH="/etc/bash_completion.d"
5966
COMPLETIONFILE="am-completion.sh"
6067
APPSPATH="/opt"

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ _enable_bash_completion() {
7272
mv /opt/am/am-completion.sh /etc/bash_completion.d/
7373
else
7474
mkdir -p /etc/bash_completion.d
75-
sudo mv /opt/am/am-completion.sh /etc/bash_completion.d/
75+
mv /opt/am/am-completion.sh /etc/bash_completion.d/
7676
fi
7777
}
7878

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ You can consult the entire **list of managed apps** at [**portable-linux-apps.gi
7777
------------------------------------------------------------------------
7878
# Differences between "AM" and "AppMan"
7979
"AM" and "AppMan" differ in how they are installed, placed and renamed in the system and how/where they install apps:
80-
- "**AM**" is installed system-wide (requires `sudo`) in `/opt/am/` as "**APP-MANAGER**", with a symlink named "`am`" in `/usr/local/bin`.
80+
- "**AM**" is installed system-wide (requires `sudo` or `doas`) in `/opt/am/` as "**APP-MANAGER**", with a symlink named "`am`" in `/usr/local/bin`.
8181
- "**AppMan**" is portable, you need just to rename the "APP-MANAGER" script as "`appman`" and put it wherewer you want. I recommend to place it in `$HOME/.local/bin` to be used in $PATH, to be managed from other tools (see below).
8282

8383
Both can be updated using "[Topgrade](https://github.com/topgrade-rs/topgrade)".
@@ -94,7 +94,7 @@ Both can be updated using "[Topgrade](https://github.com/topgrade-rs/topgrade)".
9494
- "AppMan" can request the root password only in the very rare case in which you want to install a library;
9595
- "AM" requires the root password only to install, remove apps, enable a sandbox for an AppImage, or enable/disable bash completion.
9696

97-
All options cannot be executed with "`sudo`".
97+
All options cannot be executed with "`sudo`"/"`doas`".
9898

9999
------------------------------------------------------------------------
100100

@@ -259,7 +259,7 @@ wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/AM-INSTALLER
259259
chmod a+x ./AM-INSTALLER
260260
./AM-INSTALLER
261261
```
262-
Type "1" to install "AM" (requires "sudo" password), "2" to install "AppMan". Any other key will abort the installation.
262+
Type "1" to install "AM" (requires "sudo"/"doas" password), "2" to install "AppMan". Any other key will abort the installation.
263263

264264
| ![AM-INSTALLER](https://github.com/user-attachments/assets/82b21979-e99d-4bee-b466-716bac1e7e45) |
265265
| - |
@@ -276,9 +276,7 @@ Below are the **essential system dependencies** that you must install before pro
276276
- "`wget`" to download all programs and update "AM"/"AppMan" itself.
277277

278278
#### Dependency only for "AM"
279-
- "`sudo`", required by "AM" to install/remove programs, sandbox AppImages and enable/disable bash-completion.
280-
281-
NOTE: use "AppMan" for non privileged use or if you prefer to gain administration privileges using alternative commands such as `doas` or similar.
279+
- "`sudo`" or "`doas`", required by "AM" to install/remove programs, sandbox AppImages and enable/disable bash-completion.
282280

283281
#### Extra dependences (recommended)
284282
The following are optional dependencies that some programs may require:
@@ -1119,7 +1117,7 @@ __________________________________________________________________________
11191117
### How to update or remove apps manually
11201118
Inside each installed applications directory, there are two scripts called "AM-updater" and "remove", and their purpose is indicated in their name:
11211119
- To update an app manually, run the AM-updater script.
1122-
- To remove an application instead, run the "remove" script (with "`sudo`" if you are an "AM" user).
1120+
- To remove an application instead, run the "remove" script (with "`sudo`" or "`doas`" if you are an "AM" user).
11231121

11241122
__________________________________________________________________________
11251123
### Downgrade an installed app to a previous version
@@ -1299,7 +1297,7 @@ or
12991297
```
13001298
appman -i libfuse2
13011299
```
1302-
NOTE, in AppMan you still need to use your password (`sudo`) to install the library at system level, in /usr/local/lib
1300+
NOTE, in AppMan you still need to use your password (`sudo` or `doas`) to install the library at system level, in /usr/local/lib
13031301

13041302
Alternatively you can use the "`nolibfuse`" option to "try" to convert old Type2 AppImages to Type3, so as not to depend on `libfuse2`. In most cases it works, but sometimes it can give errors, depending on how the package was manufactured.
13051303

modules/database.am

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
############################################################################################
66

77
_clean_lists_and_queries() {
8-
# Remove references to URLs, "-a" elements and limit message length to a maximum of 80 characters in "-l" and "-q"
8+
# Remove references to URLs, "-a" elements in "-l" and "-q"
99
sed -E 's#(http|https|ftp)://[^ ]*##g; s#(SITE|SOURCE):##g'
1010
}
1111

1212
_download_markdown() {
13-
local disk_usage=""
14-
local app_version=""
15-
local markdown_url="$AMCATALOGUEMARKDOWNS/${1}.md"
16-
local cache_dir="$AMCACHEDIR/about"
17-
local app_status=" STATUS: NOT INSTALLED"
18-
local package_name=${1^^}
13+
disk_usage=""
14+
app_version=""
15+
markdown_url="$AMCATALOGUEMARKDOWNS/${1}.md"
16+
cache_dir="$AMCACHEDIR/about"
17+
app_status=" STATUS: NOT INSTALLED"
18+
package_name="$1"
1919
if curl -o /dev/null -sIf "$markdown_url"; then
2020
mkdir -p "$cache_dir" && wget -q "$markdown_url" -P "$cache_dir"
2121
sed -i '1,${ /^\s*#/ d; /^\s*!/ d; /\[Applications]/d; /\ --- /d; /\ | - | /d; /\!\[/d; }' "$cache_dir/$1.md"
2222
sed -i '$!N;s/^\s*\n\s*$//;P;D' "$cache_dir/$1.md"
23-
printf ' PACKAGE: %s\n' "$package_name"
23+
printf ' PACKAGE: %s\n' "$package_name" | tr '[:lower:]' '[:upper:]'
2424
if [ -f "$APPSPATH/$1/remove" ]; then
2525
disk_usage=$(du -sm "$APPSPATH/$1" | cut -f1)
2626
app_version=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | grep -w "$1 |" | sed 's:.*| ::')
27-
app_status=$(echo -e " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version")
27+
app_status=$(printf " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version")
2828
fi
2929
printf '%s\n' "$app_status"
3030
cat -s "$cache_dir/$1.md"
@@ -39,16 +39,16 @@ _download_markdown() {
3939
}
4040

4141
_generate_3rd_party() {
42-
local disk_usage=""
43-
local app_version=""
44-
local app_status=" STATUS: NOT INSTALLED"
45-
local package_name=${1^^}
42+
disk_usage=""
43+
app_version=""
44+
app_status=" STATUS: NOT INSTALLED"
45+
package_name="$1"
4646
if grep -q "$arg : " "$AMPATH/$arch-apps"; then
47-
printf ' PACKAGE: %s\n' "$arg" | tr a-z A-Z
47+
printf ' PACKAGE: %s\n' "$arg" | tr '[:lower:]' '[:upper:]'
4848
if [ -f "$APPSPATH/$1/remove" ]; then
4949
disk_usage=$(du -sm "$APPSPATH/$1" | cut -f1)
5050
app_version=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | grep -w "$1 |" | sed 's:.*| ::')
51-
app_status=$(echo -e " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version")
51+
app_status=$(printf " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version")
5252
fi
5353
printf '%s\n' "$app_status"
5454
grep "$arg : " < "$AMPATH/$arch-apps" | cut -d':' -f2- | sed 's/^./\n /' | sed 's# SOURCE:#\n\n SOURCE:#g'
@@ -58,32 +58,25 @@ _generate_3rd_party() {
5858
}
5959

6060
_download_lib() {
61-
local lib_name_upper=${1^^}
62-
printf "%s\n" " LIBRARY: $lib_name_upper"
63-
if [[ -f "$APPSPATH/$1/remove" ]]; then
64-
local lib_path=$(grep "usr/local/lib" "$APPSPATH/$1/remove" | head -1)
65-
local disk_usage=$(du -sm "$lib_path" | cut -f1)
66-
67-
if [[ "$disk_usage" -eq 0 ]]; then
68-
printf "%s\n" " STATUS: INSTALLED, LESS THAN 1 MB OF DISK SPACE IN USE"
69-
else
70-
printf "%s\n" " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE"
71-
fi
61+
printf "%s\n" " LIBRARY: $1" | tr '[:lower:]' '[:upper:]'
62+
if [ -f "$APPSPATH/$1/remove" ]; then
63+
disk_usage=$(find /usr/local/lib -type f -name "$(echo "$1" | sed -e "s/[0-9]//")*" -exec du -sm {} + | tr ' ' '\n' | head -1)
64+
printf "%s\n" " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE"
7265
else
7366
printf "%s\n" " STATUS: NOT INSTALLED"
7467
fi
7568
echo ""
7669
grep "$1 : " "$AMPATH/libs-list" | sed 's#.*:##' | sed 's/(/\n (/g'
7770
echo "" && echo " SITE/SOURCES:" && echo ""
78-
local site_source=$(wget -qO- "$APPSDB/$1" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | head -1)
71+
site_source=$(wget -qO- "$APPSDB/$1" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | head -1)
7972
echo " $site_source"
8073
echo ""
8174
}
8275

8376
_list() {
84-
LIBNUMBER=$(cat $APPSPATH/*/remove 2> /dev/null | grep "usr/local/lib" | wc -l)
85-
ITEMSNUMBER=$(cd $APPSPATH && find -name 'remove' -printf "%h\n" 2>/dev/null | sort -u | wc -l)
86-
if [ "$AMCLI" == am ]; then
77+
LIBNUMBER=$(cat "$APPSPATH/*/remove" 2> /dev/null | grep "usr/local/lib" | wc -l)
78+
ITEMSNUMBER=$(cd "$APPSPATH" && find -name 'remove' -printf "%h\n" 2>/dev/null | sort -u | wc -l)
79+
if [ "$AMCLI" = am ]; then
8780
ITEMSNUMBER=$(("$ITEMSNUMBER"-1))
8881
fi
8982
APPSNUMBER=$(echo "$(("$ITEMSNUMBER" - "$LIBNUMBER"))")
@@ -97,8 +90,8 @@ _list() {
9790
fi
9891

9992
wget -q --tries=10 --timeout=20 --spider https://github.com && _completion_lists
100-
if cat $APPSPATH/*/remove 2> /dev/null | grep -q "usr/local/lib"; then
101-
if [ "$LIBNUMBER" == 1 ]; then
93+
if cat "$APPSPATH/*/remove" 2> /dev/null | grep -q "usr/local/lib"; then
94+
if [ "$LIBNUMBER" = 1 ]; then
10295
MESSAGE=$(echo " YOU HAVE INSTALLED $APPSNUMBER APPLICATIONS OUT OF $(grep -e "$" -c $AMPATH/$arch-apps) AVAILABLE, AND $LIBNUMBER LIBRARY")
10396
else
10497
MESSAGE=$(echo " YOU HAVE INSTALLED $APPSNUMBER APPLICATIONS OUT OF $(grep -e "$" -c $AMPATH/$arch-apps) AVAILABLE, AND $LIBNUMBER LIBRARIES")
@@ -140,7 +133,7 @@ case "$1" in
140133
elif grep -q "$arg : " "$AMPATH/libs-list"; then
141134
_download_lib "$arg"
142135
else
143-
printf '%s is not a valid argument\n' " $arg" | tr a-z A-Z
136+
printf '%s is not a valid argument\n' " $arg" | tr '[:lower:]' '[:upper:]'
144137
fi
145138
printf "%s\n" "-----------------------------------------------------------------------"
146139
done
@@ -150,17 +143,17 @@ case "$1" in
150143
_list
151144
if [ "$2" = --appimages ]; then
152145
if test -f "$AMCACHEDIR/$arch-appimages"; then
153-
echo -e "\n$MESSAGE\n$MESSAGE2\n LIST OF THE $(grep -e "$" -c "$AMCACHEDIR/$arch-appimages") APPIMAGES AVAILABLE IN THE 'AM' REPOSITORY:\n\n$(cat "$AMCACHEDIR/$arch-appimages" | _clean_lists_and_queries)\n" | less -I
154-
echo -e "\n$MESSAGE\n$MESSAGE2"
146+
printf "\n$MESSAGE\n$MESSAGE2\n LIST OF THE $(grep -e "$" -c "$AMCACHEDIR/$arch-appimages") APPIMAGES AVAILABLE IN THE 'AM' REPOSITORY:\n\n$(fold -sw 81 "$AMCACHEDIR/$arch-appimages" | _clean_lists_and_queries)\n" | less -I
147+
printf "\n$MESSAGE\n$MESSAGE2\n"
155148
else
156149
_online_check
157150
curl -Ls "$AMREPO/programs/$arch-appimages" > "$AMCACHEDIR/$arch-appimages"
158-
echo -e "\n$MESSAGE\n$MESSAGE2\n LIST OF THE $(grep -e "$" -c "$AMCACHEDIR/$arch-appimages") APPIMAGES AVAILABLE IN THE 'AM' REPOSITORY:\n\n$(cat "$AMCACHEDIR/$arch-appimages" | _clean_lists_and_queries)\n" | less -I
159-
echo -e "\n$MESSAGE\n$MESSAGE2"
151+
printf "\n$MESSAGE\n$MESSAGE2\n LIST OF THE $(grep -e "$" -c "$AMCACHEDIR/$arch-appimages") APPIMAGES AVAILABLE IN THE 'AM' REPOSITORY:\n\n$(fold -sw 81 "$AMCACHEDIR/$arch-appimages" | _clean_lists_and_queries)\n" | less -I
152+
printf "\n$MESSAGE\n$MESSAGE2\n"
160153
fi
161154
else
162-
echo -e "\n$MESSAGE\n$MESSAGE2\n LIST OF THE $(grep -e "$" -c "$AMPATH/$arch-apps") APPLICATIONS AVAILABLE IN THE 'AM' REPOSITORY:\n\n$(cat "$AMPATH/$arch-apps" | _clean_lists_and_queries)\n" | less -I
163-
echo -e "\n$MESSAGE\n$MESSAGE2"
155+
printf "\n$MESSAGE\n$MESSAGE2\n LIST OF THE $(grep -e "$" -c "$AMPATH/$arch-apps") APPLICATIONS AVAILABLE IN THE 'AM' REPOSITORY:\n\n$(fold -sw 81 "$AMPATH/$arch-apps" | _clean_lists_and_queries)\n" | less -I
156+
printf "\n$MESSAGE\n$MESSAGE2\n"
164157
fi
165158
;;
166159

@@ -174,27 +167,27 @@ case "$1" in
174167
wget -q --tries=10 --timeout=20 --spider https://github.com && _completion_lists
175168
if [ "$2" = --pkg ]; then
176169
ARGS=$(echo "$@" | cut -f3- -d ' ' | sed 's/ /, /g')
177-
echo -e "\n Search results for packages: $ARGS\n" | tr a-z A-Z
178-
grep -i -E "$(echo "$@" | cut -f3- -d ' ' | tr -s ' ' '|')" "$AMPATH/$arch-apps" --color=always | _clean_lists_and_queries
179-
grep -i -E "$(echo "$@" | cut -f3- -d ' ' | tr -s ' ' '|')" "$AMPATH/libs-list" --color=always | _clean_lists_and_queries
170+
printf "\n Search results for packages: $ARGS\n\n" | tr '[:lower:]' '[:upper:]'
171+
grep -i -E "$(echo "$@" | cut -f3- -d ' ' | tr -s ' ' '|')" "$AMPATH/$arch-apps" --color=always | _clean_lists_and_queries | fold -sw 81
172+
grep -i -E "$(echo "$@" | cut -f3- -d ' ' | tr -s ' ' '|')" "$AMPATH/libs-list" --color=always | _clean_lists_and_queries | fold -sw 81
180173
echo ""
181174
exit 0
182175
fi
183176
if [ "$2" = --appimages ]; then
184177
ARGS=$(echo "$@" | cut -f3- -d ' ')
185-
echo -e "\n Search results for \"$ARGS\":\n" | tr a-z A-Z
178+
printf "\n Search results for \"$ARGS\":\n\n" | tr '[:lower:]' '[:upper:]'
186179
PATTERN="$(echo "$@" | cut -f3- -d ' ' | sed 's/ /(?=.*/g; s/$/)/g; s/(/)(/g; s/^/(?=.*/g;')"
187180
if ! test -f "$AMCACHEDIR/$arch-appimages"; then
188181
_online_check
189182
curl -Ls "$AMREPO/programs/$arch-appimages" > "$AMCACHEDIR/$arch-appimages"
190183
fi
191-
grep -P -i "$PATTERN" "$AMCACHEDIR/$arch-appimages" | _clean_lists_and_queries
184+
grep -P -i "$PATTERN" "$AMCACHEDIR/$arch-appimages" | _clean_lists_and_queries | fold -sw 81
192185
else
193186
ARGS=$(echo "$@" | cut -f2- -d ' ')
194-
echo -e "\n Search results for \"$ARGS\":\n" | tr a-z A-Z
187+
printf "\n Search results for \"$ARGS\":\n\n" | tr '[:lower:]' '[:upper:]'
195188
PATTERN="$(echo "$@" | cut -f2- -d ' ' | sed 's/ /(?=.*/g; s/$/)/g; s/(/)(/g; s/^/(?=.*/g;')"
196-
grep -P -i "$PATTERN" "$AMPATH/$arch-apps" | _clean_lists_and_queries
197-
grep -P -i "$PATTERN" "$AMPATH/libs-list" | _clean_lists_and_queries
189+
grep -P -i "$PATTERN" "$AMPATH/$arch-apps" | _clean_lists_and_queries | fold -sw 81
190+
grep -P -i "$PATTERN" "$AMPATH/libs-list" | _clean_lists_and_queries | fold -sw 81
198191
fi
199192
echo ""
200193
exit 0

0 commit comments

Comments
 (0)