Skip to content

Emergency fix part 1#648

Merged
ivan-hc merged 3 commits intoivan-hc:devfrom
Samueru-sama:dev
Jun 10, 2024
Merged

Emergency fix part 1#648
ivan-hc merged 3 commits intoivan-hc:devfrom
Samueru-sama:dev

Conversation

@Samueru-sama
Copy link
Contributor

There was an error in the other zsync condition as well lel.

@ivan-hc can you give me a more detailed explanation as to what the issue with --rollback is? I tried to rollback the gimp appimage but the updater script didn't change at all?

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Jun 10, 2024

I added this:

[ -e /opt/"$APP"/*.zsync ] || notify-send "A new version of $APP is available, please wait"

Which will only send the notification if there is no *.zsync file. because those apps with zsync always update themselves every time. And the libreoffice update script didn't have such notification @ivan-hc

EDIT:

These changes can be merged now, but I haven't been able to fix the --rollback issue because I'm not sure what the problem is lol

@Samueru-sama Samueru-sama changed the title Emergency fix part 1 (DO NOT MERGE YET) Emergency fix part 1 Jun 10, 2024
@ivan-hc ivan-hc merged commit 75c8e2f into ivan-hc:dev Jun 10, 2024
@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

I've solved the --rollback thing!

Strange fact, it seems that the brave-appimage .zsync file is broken.

Also I receive the notify about "zsync failed to update brave-appimage". I was not aware about notify on "zsync" action... thanks... but the above is really strange.

Can you create and test installing/updating brave-appimage?

I use this version in the script:

version=$(curl -Ls https://api.github.com/repos/srevinsaju/Brave-AppImage/releases/latest?per_page=100 | jq '.' | grep browser_download_url | grep -i stable  | grep -i appimage | cut -d '"' -f 4 | head -1)

@Samueru-sama
Copy link
Contributor Author

Strange fact, it seems that the brave-appimage .zsync file is broken.

Heh, is that really strange at this point? 😆

I already use the brave-appimage as my main web browser, will test it soon.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

try both the new script with your new template and manually zsync ./brave-appimage.zsync, its really weird

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

PS: the notification about "update not needed" is.... not needed. Really. Why you should receive a notification for that?

@Samueru-sama
Copy link
Contributor Author

try both the new script with your new template and manually zsync ./brave-appimage.zsync, its really weird

I am getting this:

~/.local/opt/brave-appimage/ zsync ./brave-appimage.zsync 
Rejected filename specified in ./brave-appimage.zsync - prefix brave differed from filename �%��.
No relevent local data found - I will be downloading the whole file. If that's not what you want, CTRL-C out. You should specify the local file is the old version of the file to download with -i (you might have to decompress it with gzip -d first). Or perhaps you just have no data that helps download the file
URL 'Brave-nightly-v1.69.8-x86_64.AppImage' from the .zsync file is relative, but I don't know the referer URL (you probably downloaded the .zsync separately and gave it to me as a file). I need to know the referring URL (the URL of the .zsync) in order to locate the download. You can specify this with -u (or edit the URL line(s) in the .zsync file you have).
failed to retrieve from Brave-nightly-v1.69.8-x86_64.AppImage
Aborting, download available in brave.part
~/.local/opt/brave-appimage/ zsync ./brave-appimage.zsync                                                                                                                                                                             433ms 
Rejected filename specified in ./brave-appimage.zsync - prefix brave differed from filename ��c!.
reading seed file brave.part: ***********

And yeah right now one of my CPU cores is at 100% while it is going thru that, it will then fail.

cpu-x has the same exact problem.

PS: the notification about "update not needed" is.... not needed. Really. Why you should receive a notification for that?

We talked about this before. It is very useful when I'm testing the AM-updater script manually.

@Samueru-sama
Copy link
Contributor Author

In the meantime what can be done is comment out the line that downloads the zsync file (line 17) and since the updater will no longer download the zsync file if it doesn't exist, that is all that needs to be done.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

PS: the notification about "update not needed" is.... not needed. Really. Why you should receive a notification for that?

We talked about this before. It is very useful when I'm testing the AM-updater script manually.

as a developer, I understand... but what about common users?

I suggest to comment that reference and uncomment it manually when you're testing. Not anyone care about all these notifications.

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Jun 11, 2024

PS: the notification about "update not needed" is.... not needed. Really. Why you should receive a notification for that?

We talked about this before. It is very useful when I'm testing the AM-updater script manually.

as a developer, I understand... but what about common users?

I suggest to comment that reference and uncomment it manually when you're testing. Not anyone care about all these notifications.

Wasn't part of AM that the scripts could be run on their own without needing AM or appman?

That notification is very useful in that case for common users as well.

On the other hand I don't like the notification that gets send when there is an update, because I already showed you the video of what happens when multiple apps update.

Is the last echo causing an issue that didn't exist before? I didn't implement that either.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

I think that as a normal user, I'm only interested in knowing "via notification" if something has been updated, otherwise I'm not interested.

I don't care if "update not needed". Its an additional message.

On the contrary, its useful what you added about broken zsync file error... and app updated is an useful info as well.

Not "update not needed".

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Jun 11, 2024

I think that as a normal user, I'm only interested in knowing "via notification" if something has been updated, otherwise I'm not interested.

I don't care if "update not needed". Its an additional message.

On the contrary, its useful what you added about broken zsync file error... and app updated is an useful info as well.

Not "update not needed".

Once again that was always part of the updater scripts (here is part of the librewolf script):

image

It used to be a condition that if "$version" = "$version0 it was echoed.

Later on when I wanted to add the actualversion I added the && exit 0 because actualversion was going to be an operation to be done after the last fi in the updater script, that never happened. So I simplified the updater script to what it is today.

I don't know why you now want to remove it.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

sorry, its really strange... but before I received the message "Update not needed!" as notification on the desktop, as it was launched with notify-send...also a strange notification since I had to click it to remove it.

Now this is not happening anymore, in my tests 👀

Why all this??

@Samueru-sama
Copy link
Contributor Author

sorry, its really strange... but before I received the message "Update not needed!" as notification on the desktop, as it was launched with notify-send...also a strange notification since I had to click it to remove it.

Now this is not happening anymore, in my tests 👀

Why all this??

Are you sure you are not confusing the notify-send "$APP is updated!" with echo "Update not needed!"?

You were not getting notify-send "$APP is updated!" before because I forgot to add it to the script, you told me it was missing and I added it back, even though I don't like it because it causes a explosion of notifications when updating several apps.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

However, I'm testing the --rollback using the new AM-updater. This is the one of brave-appimage (after nolibfuse)

#!/bin/sh
set -u
APP=brave-appimage
SITE="srevinsaju/Brave-AppImage"
version0=$(cat "/opt/$APP/version")
version=$(curl -Ls https://api.github.com/repos/srevinsaju/Brave-AppImage/releases/latest?per_page=100 | jq '.' | grep browser_download_url | grep -i stable  | grep -i appimage | cut -d '"' -f 4 | head -1)
[ -n "$version" ] || { echo "Error getting link"; exit 1; }
if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then
	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
	[ -e /opt/"$APP"/*.zsync ] || notify-send "A new version of $APP is available, please wait"
	[ -e /opt/"$APP"/*.zsync ] && wget -q --no-verbose --show-progress --progress=bar "$version.zsync" 2>/dev/null || { wget -q --no-verbose --show-progress --progress=bar "$version" || exit 1; }
	# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
	cd ..
	mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP"
	[ -e /opt/"$APP"/*.zsync ] && { zsync "/opt/$APP/$APP.zsync" || notify-send -u critical "zsync failed to update $APP"; }
	chmod a+x "/opt/$APP/$APP" || exit 1
	echo "$version" > ./version
	rm -R -f ./*zs-old ./*.part ./tmp ./*~
	notify-send "$APP is updated!"
	exit 0
fi
echo "Update not needed!"

echo y | am nolibfuse $APP

and this is the AM-rollback file. It works... but... I don't know how:

#!/bin/sh
set -u
APP=brave-appimage
SITE="srevinsaju/Brave-AppImage"
#version0=$(cat "/opt/$APP/version")
version=$(curl -Ls https://api.github.com/repos/srevinsaju/Brave-AppImage/releases/latest?per_page=100 | jq '.' | grep browser_download_url | grep -i stable  | grep -i appimage | cut -d '"' -f 4 | head -1)
[ -n "$version" ] || { echo "Error getting link"; exit 1; }
if [ "$version" != "$#version0" ] || [ -e /opt/"$APP"/*.zsync ]; then
	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
	[ -e /opt/"$APP"/*.zsync ] || notify-send "A new version of $APP is available, please wait"
wget -q --show-progress https://github.com/srevinsaju/Brave-AppImage/releases/download/v1.67.86/Brave-beta-v1.67.86-x86_64.AppImage
	# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
	cd ..
	mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP"
	[ -e /opt/"$APP"/*.zsync ] && { zsync "/opt/$APP/$APP.zsync" || notify-send -u critical "zsync failed to update $APP"; }
	chmod a+x "/opt/$APP/$APP" || exit 1
	echo "$version" > ./version
	rm -R -f ./*zs-old ./*.part ./tmp ./*~
	notify-send "$APP is updated!"
	exit 0
fi
echo "Update not needed!"

echo y | am nolibfuse $APP

in brief, all version0 references are commented, also I noticed that the line that contains wget -q --no-verbose --show-progress has been replaced with the download URL

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

Are you sure you are not confusing the notify-send "$APP is updated!" with echo "Update not needed!"?

you're right, it was a decline in vision that distracted me

@Samueru-sama
Copy link
Contributor Author

What are you trying to achieve in the second script? that it doesn't update?

The condition [ "$version" != "$#version0" ] now has a $#. You might want to not add the g (global) at the end of the sed so that it only does the replacement once.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

What are you trying to achieve in the second script? that it doesn't update?

The condition [ "$version" != "$#version0" ] now has a $#. You might want to not add the g (global) at the end of the sed so that it only does the replacement once.

The AM-rollback script is a script generated automatically by copying and patching the AM-updater, this happens with --rollback

Right now I'm working on the function that takes care of this. This is the draft of my edit:

######################################
# FUNCTION TO DOWNGRADE INSTALLED APPS
######################################

function _do_rollback() {
	if test -f "$APPSPATH"/"$2"/AM-updater; then
		if test -f "$APPSPATH"/"$2"/"$2"-rollback; then
			cd "$APPSPATH"/"$2" || return
			./"$2"-rollback
			exit
		elif test -f "$APPSPATH"/"$2"/*.zsync; then
			echo " AppImage packages updatable with zsync have not previous versions."; exit
		elif test -f "$APPSPATH"/"$2"/updater; then
			echo ' When an executable called "updater" is available, the app is only updateable.'; exit
		elif grep -q "api.github.com" "$APPSPATH"/"$2"/AM-updater; then
			rm -f "$AMCACHEDIR/rollback-args";
			extension=$(cat "$APPSPATH"/"$2"/version | tr '.' '\n' | tail -1)
			if grep -q "^REPO=" "$APPSPATH"/"$2"/AM-updater; then
				REPO=$(grep -i "REPO=" "$APPSPATH"/"$2"/AM-updater | grep -o -P '(?<=").*(?=")')
			elif grep -q "^SITE=" "$APPSPATH"/"$2"/AM-updater; then
				REPO=$(grep -i "SITE=" "$APPSPATH"/"$2"/AM-updater | grep -o -P '(?<=").*(?=")')
			fi
			printf "%s\n" "$(curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$REPO/releases?per_page=100 \
				| grep browser_download_url | cut -d '"' -f 4)" | tr ' ' '\n' | grep -i "$extension$" >> "$AMCACHEDIR/rollback-args"
			if ! grep -q "[0-9]" "$AMCACHEDIR"/rollback-args; then
				echo " ERROR: No valid links found, sorry!"
				exit
			else
				echo "-----------------------------------------------------------------------"
				echo "You have chosen to roll back $2."
				echo "Rollback will be done from https://github.com/$REPO"
				echo "-----------------------------------------------------------------------"
				printf "Select a URL from this menu (read carefully) or press CTRL+C to abort:\n-----------------------------------------------------------------------\n"; sleep 1;
				select d in $(cat "$AMCACHEDIR/rollback-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done
				cp "$APPSPATH"/"$2"/AM-updater "$APPSPATH"/"$2"/AM-rollback
				sed -i 's/version0/#version0/g' "$APPSPATH"/"$2"/AM-rollback
				sed -i '/show-progress/c\wget -q --show-progress '$d'' "$APPSPATH"/"$2"/AM-rollback
				if test -f ./AM-rollback; then
					if grep -q '/$APP/*.zsync' ./AM-rollback; then
						mv "$APPSPATH"/"$2"/AM-rollback "$APPSPATH"/"$2"/AM-rollback.old
						sed -n '1,6p' "$APPSPATH"/"$2"/AM-rollback.old >> "$APPSPATH"/"$2"/AM-rollback
						sed -n '17,36p' "$APPSPATH"/"$2"/AM-rollback.old >> "$APPSPATH"/"$2"/AM-rollback
						rm -f "$APPSPATH"/"$2"/AM-rollback.old
						sed -i 's/	//g' "$APPSPATH"/"$2"/AM-rollback
						chmod a+x "$APPSPATH"/"$2"/AM-rollback
					fi
				fi
				"$APPSPATH"/"$2"/AM-rollback
				rm -f "$APPSPATH"/"$2"/AM-rollback
				rm -f "$APPSPATH"/"$2"/version
				echo $d >> "$APPSPATH"/"$2"/version
				_clean_amcachedir
				_list_updatable_apps
				echo -e "\nROLLBACK SUCCESSFUL!"
				exit
			fi
		else
			echo " The option \"$1\" only works for https://github.com"; exit
		fi
	else
		echo " No AM-updater available for \"$2\", cannot detect any URL!"; exit
	fi
}

I'm also refactoring it right now

@Samueru-sama
Copy link
Contributor Author

Ok but what is the end result? how should the AM-updater script look after --rollback was used?

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

https://github.com/ivan-hc/AM/blob/dev/modules/management.am

Ok but what is the end result? how should the AM-updater script look after --rollback was used?

Give me the time I upload the video

simplescreenrecorder-2024-06-11_02.55.44.mkv.mp4

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

Only works for apps hosted on github... and without a .zsync file... but I think I'll try to change the latter.

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Jun 11, 2024

Only works for apps hosted on github... and without a .zsync file... but I think I'll try to change the latter.

I watched the video and now I have more questions, why are you showing the version file in video? that is where the problem is?

Btw the --rollback function has this.

rm -f "$APPSPATH"/"$2"/version
echo $d >> "$APPSPATH"/"$2"/version

You can replace that for a single: echo $d > "$APPSPATH"/"$2"/version with a single > and that will replace the file.

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Jun 11, 2024

Only works for apps hosted on github... and without a .zsync file... but I think I'll try to change the latter.

I think the line that downloads the .zsync in the new script needs to be disabled btw, because zsync is more often broken than not. And before zsync wouldn't even work because the test -f had a "*" inside quotes meaning that it would never find the file to use zsync with.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

I show you the version file to let you see that the version changes.

I've replaced the latest stable version of brave-appimage with a "beta" version at number 86.

The list has until 100 URLs, I've added this limit because Brave and Brave-Appimage repositories... they have too many pre-releases.

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Jun 11, 2024

I show you the version file to let you see that the version changes.

I've replaced the latest stable version of brave-appimage with a "beta" version at number 86.

The list has until 100 URLs, I've added this limit because Brave and Brave-Appimage repositories... they have too many pre-releases.

Ok, I still don't know what the problem is exactly 😅

But if the issue is that the version is the wrong one, I don't think that has to do with the new template?

If the issue is an issue inside the AM-updater just let me know how you want the updater to look (how the code should look like) and I can fix it.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

No problem here 😄 I just wanted to show and tell what --rollback does, since you didn't know we have it

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 11, 2024

I'm still waiting the day that someone says that "this package manager is AM...azing!"

@zen0bit
Copy link
Contributor

zen0bit commented Jun 12, 2024

I'm still waiting the day that someone says that "this package manager is AM...azing!"

We already said that, multiple times...
🤗

@Samueru-sama
Copy link
Contributor Author

@zen0bit I want your opinion on this: https://github.com/ivan-hc/AM/issues/659

@zen0bit
Copy link
Contributor

zen0bit commented Jun 12, 2024

Just quickly read
not sure what question is..

definetly NOT sandbox everything.
What if user trust apps..

--sandbox 👍 (I asked for this feature)
What to use and how, need more thinking.
Aisap is in early development and subject to change. So not good idea depend on it (yet)

@Samueru-sama
Copy link
Contributor Author

not sure what question is.

Just your opinion on it.

RIght now the only sandbox we have is with firejail, which not only has a bunch of security issues, it is broken with most apps lol.

definetly NOT sandbox everything.

Yeah it is going to be an option

Aisap is in early development and subject to change. So not good idea depend on it (yet)

I'm waiting for input from the dev as well.

@ivan-hc
Copy link
Owner

ivan-hc commented Jun 12, 2024

@Samueru-sama What if instead of implementing little-known/used sandboxes, we used something widely used?

AppImage/AppImageKit#152

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Jun 12, 2024

@Samueru-sama What if instead of implementing little-known/used sandboxes, we used something widely used?

AppImage/AppImageKit#152

aisap uses bubblewrap. It is the only solution as far as I know.

firejail is bad, even probono understood that when alpine dropped it from their repos, and you know when even probono gets it, it is really bad 🤣

edit: In fact the aisap dev is commenting on that thread.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants