ivan-hc / AM

AppImage package manager to install, update and manage ALL of them, system-wide or locally, thanks to its ever-growing AUR-inspired database listing 2500+ portable apps and programs for GNU/Linux. The first, real centralized repository to manage your AppImages with the ease of APT and the power of PacMan.
https://portable-linux-apps.github.io
GNU General Public License v3.0
523 stars 41 forks source link

Sometimes running am -i on a local script fails the first time #653

Closed Samueru-sama closed 4 months ago

Samueru-sama commented 5 months ago

Hey, this is an issue that I've noticed has been happening ever since I made the mpv appimage:

image

Sometimes am tires to pull from the database instead of using the script I'm telling it use, if I didn't rename the script to have the .sh at the end of the name, it would have used the existing cpu-x script on the database instead of the local one that I'm telling it to use.

(am is appman btw).

Samueru-sama commented 5 months ago

@ivan-hc I'm testing cpu-x again because the dev said to have fixed the issue, but it doesn't look like it works 😭

ivan-hc commented 5 months ago

have you tried to use the whole path?

ivan-hc commented 5 months ago

I'm testing this ar appman in normal mode, no issue here

Istantanea_2024-06-11_17-05-15 png

Samueru-sama commented 5 months ago

I'm testing this ar appman in normal mode, no issue here

Istantanea_2024-06-11_17-05-15 png

The issue happens when I give it a relative path instead of a full path:

image

But it only happens the first time after I give it the ./cpu-x.sh the second time it does pick up the file.

(btw that ln error in the screenshot is because I removed the cpu-x directory instead of running am -r)

ivan-hc commented 5 months ago

what if you name it cpu-x instead of cpu-x.sh?

Samueru-sama commented 5 months ago

what if you name it cpu-x instead of cpu-x.sh?

It will pull the cpu-x script from the database instead of using the local one.

This is why I ran into this issue with mpv back then: https://github.com/ivan-hc/AM/pull/605

The icons dir wasn't being created because it was pulling the script with the issue from the database instead of using the local one that already had the mkdir /opt/"$APP"/icons

Samueru-sama commented 5 months ago

How does am -i know when to use a local file vs pulling from the repo?

ivan-hc commented 5 months ago
            # Various cases that may occur during installation (for example if you use a third-party repository)
            if test -f $APPSPATH/$arg/remove; then
                echo " â—† $(echo '"'$arg'"' | tr a-z A-Z): app already installed previously! Try removing it."
            else
                if test -f ./$arg 2> /dev/null; then
                    mkdir -p "$AMCACHEDIR"/tmp; cp ./$arg "$AMCACHEDIR"/tmp/$arg; cd "$AMCACHEDIR" || return; mv ./tmp/$arg ./$arg; rmdir ./tmp
                    _install_arg
                elif test -f $arg 2> /dev/null; then
                    path2arg=$(echo "$arg")
                    arg=$(echo "$path2arg" | sed 's:.*/::')
                    cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; cp $path2arg ./$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp
                    _install_arg
                elif test -f "$AMPATH/neodb"; then
                    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" >> "$AMCACHEDIR/multirepo-args"
                        fi
                    done
                    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" >> "$AMCACHEDIR/multirepo-args"
                            fi
                            anyrepoargall=$(cat "$AMCACHEDIR/multirepo-args" 2>/dev/null | wc -l)
                            if [ $anyrepoargall == 1 ]; then
                                cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q "$(cat "$AMCACHEDIR/multirepo-args" | head -1)/$arg"; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp
                                rm -R -f "$AMCACHEDIR/multirepo-args"
                                _install_arg
                            else
                                echo -e "\n â—† 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 "$AMCACHEDIR/multirepo-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done
                                cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q "$d/$arg"; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp
                                rm -R -f "$AMCACHEDIR/multirepo-args"
                                _install_arg
                            fi
                        elif curl --output /dev/null --silent --head --fail $APPSDB/$arg  1>/dev/null; then
                            cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp
                            rm -R -f "$AMCACHEDIR/multirepo-args"
                            _install_arg
                        else
                            echo ' 💀 ERROR: "'$arg'" does NOT exist in the database, see "'$AMCLI' -l"'
                        fi
                    elif curl --output /dev/null --silent --head --fail $APPSDB/$arg  1>/dev/null; then
                        cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp
                        _install_arg
                    else
                        echo ' 💀 ERROR: "'$arg'" does NOT exist in the database, see "'$AMCLI' -l"'
                    fi
                elif curl --output /dev/null --silent --head --fail $APPSDB/$arg  1>/dev/null; then
                    cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp
                    _install_arg
                else
                    echo ' 💀 ERROR: "'$arg'" does NOT exist in the database, see "'$AMCLI' -l"'
                fi
            fi
ivan-hc commented 5 months ago

it should work exactly as first choice

            # Various cases that may occur during installation (for example if you use a third-party repository)
            if test -f $APPSPATH/$arg/remove; then
                echo " â—† $(echo '"'$arg'"' | tr a-z A-Z): app already installed previously! Try removing it."
            else
                if test -f ./$arg 2> /dev/null; then
                    mkdir -p "$AMCACHEDIR"/tmp; cp ./$arg "$AMCACHEDIR"/tmp/$arg; cd "$AMCACHEDIR" || return; mv ./tmp/$arg ./$arg; rmdir ./tmp
                    _install_arg
Samueru-sama commented 5 months ago

I really don't know why this happens then:

image

I thought that the issue was that I was using ./cpu-x.sh and am interpreted that as ././cpu-x.sh so I tested just putting cpu-x.sh without the ./ and it still fails the first time for some reason.

Samueru-sama commented 5 months ago

Alright I began testing all the releases from the last 2 weeks.

So I removed appman and replaced it for version 6.7 and up.

After I did this the issue no longer happens, even with the latest version 💀 so likely I fucked some module, or something got borked when appman updated back then.

I'll be closing this, hopefully the issue doesn't show up again.

Samueru-sama commented 4 months ago

Reopening this.

I took this screenshot when I was editing the brave scripts:

bug

ivan-hc commented 4 months ago

brave? were they not ok?

Samueru-sama commented 4 months ago

It happens with any script:

image

I add the .sh because otherwise am will pull the existing script instead of the local one.

ivan-hc commented 4 months ago

I cannot reproduce the issue... also I see that "AM" suggests appman -l, so I supposed you were working in AppMan Mode... but I can't see the message

This is ./adb.sh installed with normal AM

Istantanea_2024-07-16_17-00-24

and this is AM in AppMan mode

Istantanea_2024-07-16_17-00-56

I've no ideaon why this happens to you.

ivan-hc commented 4 months ago

I'm not sure on why all tests in the PR are a failure, however to drag/drop the script always works in this case.

I think I give up this time.

Samueru-sama commented 4 months ago

Thats ok, I will have a look at how the whole install module works

ivan-hc commented 4 months ago

if not to solve this issue, function will help to understand more how this module works.

ivan-hc commented 4 months ago

@Samueru-sama a tip: since the module uses the "select" command, SHELL have not an alternative for that.

This is why this, but also the script to install "wine" are BASH scripts.