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

won't run (fuse error) #3

Open
2011 opened this issue May 27, 2024 · 49 comments
Open

won't run (fuse error) #3

2011 opened this issue May 27, 2024 · 49 comments

Comments

@2011
Copy link

2011 commented May 27, 2024

I have about thirty other AppImages that all run without any issues, but (first time I tried this AppImage):

$ /tmp/Google-Chrome-Stable-125.0.6422.112-1-x86_64.AppImage 
fuse: failed to exec fusermount: Permission denied

Cannot mount AppImage, please check your FUSE setup.
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information
open dir error: No such file or directory

$ qlist -Iv fuse
sys-fs/fuse-3.16.2
sys-fs/fuse-2.9.9-r2
sys-fs/fuse-common-3.10.4

$ which fusermount
/usr/bin/fusermount

$ ls -al /usr/bin/fusermount*
-rws--x--x 1 root root 35424 2022-11-30 07:12:21 /usr/bin/fusermount*
-rws--x--x 1 root root 34760 2023-12-18 23:25:57 /usr/bin/fusermount3*

Any ideas about what might cause this?

@ivan-hc
Copy link
Owner

ivan-hc commented May 27, 2024

This is a kind of AppImage that don't needs libfuse2

This issue seems to be a known one AppImage/type2-runtime#15

I'm investigating, please wait.

@ivan-hc
Copy link
Owner

ivan-hc commented May 27, 2024

What is your distro?

I need to know how your fusermount installation is done.

For me /usr/bin/fusermount is a symlink to /usr/bin/fusermount3 (i use Debian)

$ ls -al /usr/bin/fusermount*
lrwxrwxrwx 1 root root    11 12 gen 16.46 /usr/bin/fusermount -> fusermount3
-rwsr-xr-x 1 root root 35128 12 gen 16.46 /usr/bin/fusermount3

@ivan-hc
Copy link
Owner

ivan-hc commented May 27, 2024

Just found a discussion with an Arch Linux user in one of my projects:

ivan-hc/AM#387

but the issue was been fixed.

In brief, on Arch Linux fusermount is a binary from the fuse2 package and fusermount3 is a binary from fuse3, while on Debian fusermount is a symlink to fusermount3.

@Samueru-sama was this been fixed in probonopd/go-appimage#278 ?

@ivan-hc
Copy link
Owner

ivan-hc commented May 27, 2024

EndeavourOS is based on Arch Linux, so fusermount is a binary from the fuse2 package and fusermount3 is a binary from fuse3, but this AppImage works for me

Istantanea_2024-05-27_19-27-36

@2011
Copy link
Author

2011 commented May 27, 2024

This is a kind of AppImage that don't needs libfuse2

This issue seems to be a known one AppImage/type2-runtime#15

I'm investigating, please wait.

Thank you for all of the quick replies.

Yes, you have certainly found the issue. I run Gentoo, and as you can see from my description of the issue, the fusermount binaries have permissions 4711. Changing the permissions solves the problem (though I won't want to leave them as 4755 forever, and any updates will return them to 4711).

Thank you again.

@ivan-hc
Copy link
Owner

ivan-hc commented May 27, 2024

forgive my ignorance, can adding your user to some groups make a difference?

@Samueru-sama
Copy link

Samueru-sama commented May 27, 2024

The issue I had on archlinux was that I still needed fuse2 to run the furse3 appimages because the runtime was still looking for fusermount instead of fusermount3. On debian this issue didn't happen because fusermount is symlinked to fusermount3.

However the issue was fixed and I can now run fuse3 appimages without needing fuse2 installed.

The issue didn't have to do with permissions. On arch both fusermount and fusermount3 are 4755.

@2011 Do you have this issue when running the cemu appimage? that one also uses fuse3.

EDIT: Also I think this is something that needs to be reported to gentoo, all other distros use 4755 for fusermount, I even used voidlinux for a few days and didn't have this issue, although I didn't check if I had fuse3 installed in voidlinux and it was defaulting to fuse2.

@2011
Copy link
Author

2011 commented May 28, 2024

forgive my ignorance, can adding your user to some groups make a difference?

I can't think of any. The binaries (as shown in my original post) get installed as root:root, but with the suid bit set.

The issue I had on archlinux was that I still needed fuse2 to run the furse3 appimages because the runtime was still looking for fusermount instead of fusermount3.

Gentoo has different "slots" for fuse2 and fuse3 (meaning one can have both of them installed at the same time.

On debian this issue didn't happen because fusermount is symlinked to fusermount3.

However the issue was fixed and I can now run fuse3 appimages without needing fuse2 installed.

The issue didn't have to do with permissions. On arch both fusermount and fusermount3 are 4755.

On Gentoo, I renamed fusermount to fusermount2 and fusermount3 to fusermount, and neither the chrome AppImage nor the cemu AppImage would run with permissions set to 4711.

@2011 Do you have this issue when running the cemu appimage? that one also uses fuse3.

Yes (with permissions at 4711, it won't run - with the same error message as shown in my original post).

EDIT: Also I think this is something that needs to be reported to gentoo, all other distros use 4755 for fusermount, I even used voidlinux for a few days and didn't have this issue, although I didn't check if I had fuse3 installed in voidlinux and it was defaulting to fuse2.

I can mention this in their forums, but I would expect to get a lot of resistance for a change like that (it would require many more users to complain to make something happen). From reading the linked issue in the first reply by @ivan-hc, it appears that the test for the existence of fusermount consists of checking if the AppImage can read it (clearly wrong, as POSIX systems have never required the read permission to execute a file).

I see no activity on that issue over the past seven months. Not too surprising (things happen slowly in the AppImage world). I first brought up the issue of fuse 3 (to initial scorn, which soon changed to minor panic as distributions started dropping fuse 2) in AppImage/AppImageKit#1120 more than three years ago.

@Samueru-sama
Copy link

Yes (with permissions at 4711, it won't run - with the same error message as shown in my original post).

Can you now try the appimage of amdgpu_top as that one is built with cargo appimage, it is also fuse3 compatible.

This appimage didn't have the issue with the lack of symlink that I had before with go-appimage. Maybe it doesn't have this issue.

which soon changed to minor panic as distributions started dropping fuse 2

Also a bit off topic, but how much a small panic was this? On arch fuse2 is a dependency for ntfs-3g and mtpfs ,so I don't think any distro will remove fuse2 from their repos anytime soon.

@2011
Copy link
Author

2011 commented May 28, 2024

Can you now try the appimage of amdgpu_top as that one is built with cargo appimage, it is also fuse3 compatible.

Exact same behavior.

Also a bit off topic, but how much a small panic was this?

If you read the replies to that issue, you would have seen it start when Ubuntu 22.04 came out (with fuse 3 and without the ability to install fuse 2 simultaneously), leading to lots of "I can't run AppImages any more" reports.

Ubuntu did provide plenty of warning:

https://lists.ubuntu.com/archives/ubuntu-devel/2021-July/041530.html

On arch fuse2 is a dependency for ntfs-3g and mtpfs ,so I don't think any distro will remove fuse2 from their repos anytime soon.

Gentoo uses fuse 3 for both of those. I would assume that Gentoo has kept fuse 2 around only to run AppImages.

@Samueru-sama
Copy link

Exact same behavior.

Oh boy, this isn't gonna be easy then. I think there is another implementation of appimagetool written in shell but I don't have high hopes that it will work.

If you read the replies to that issue, you would have seen it start when Ubuntu 22.04 came out (with fuse 3 and without the ability to install fuse 2 simultaneously), leading to lots of "I can't run AppImages any more" reports.

Gentoo uses fuse 3 for both of those. I would assume that Gentoo has kept fuse 2 around only to run AppImages.

I see, I knew that fusermount2 didn't come by default on ubuntu, but I didn't know that you couldn't have both installed.

@ivan-hc
Copy link
Owner

ivan-hc commented May 28, 2024

I don't know if this would be useful, but in case you wish to maintain just fuse3, my package manager "AM" allows you to install also just libfuse2 from the official Debian package using the command am -i libfuse2

I don't really know how can I help you in ths case.

@Samueru-sama
Copy link

I don't really know how can I help you in ths case.

I don't either, it's a shame cargo appimage also has the issue, because I have no problem switching all my appimages to use it.

@2011
Copy link
Author

2011 commented May 28, 2024

I see, I knew that fusermount2 didn't come by default on ubuntu, but I didn't know that you couldn't have both installed.

You probably can (manually, by renaming files and changing install directories, but Ubuntu doesn't support installing both simultaneously with their package manager).

I don't know if this would be useful, but in case you wish to maintain just fuse3, my package manager "AM" allows you to install also just libfuse2 from the official Debian package using the command am -i libfuse2

As much as I override default behaviors in Gentoo, I feel comfortable simply having both versions around as long as Gentoo supports it (and just temporarily changing the file permissions on fusermount when required).

Edit to add:

The lists of files in each package suggests how Gentoo handles having both versions installed:

$ qlist fuse-2.9.9-r2 | sort
/sbin/mount.fuse
/usr/bin/fusermount
/usr/bin/ulockmgr_server
/usr/include/fuse.h
/usr/include/fuse/cuse_lowlevel.h
/usr/include/fuse/fuse.h
/usr/include/fuse/fuse_common.h
/usr/include/fuse/fuse_common_compat.h
/usr/include/fuse/fuse_compat.h
/usr/include/fuse/fuse_lowlevel.h
/usr/include/fuse/fuse_lowlevel_compat.h
/usr/include/fuse/fuse_opt.h
/usr/include/ulockmgr.h
/usr/lib64/libfuse.so
/usr/lib64/libfuse.so.2
/usr/lib64/libfuse.so.2.9.9
/usr/lib64/libulockmgr.so
/usr/lib64/libulockmgr.so.1
/usr/lib64/libulockmgr.so.1.0.1
/usr/lib64/pkgconfig/fuse.pc
/usr/share/doc/fuse-2.9.9-r2/AUTHORS.bz2
/usr/share/doc/fuse-2.9.9-r2/ChangeLog.bz2
/usr/share/doc/fuse-2.9.9-r2/NEWS.bz2
/usr/share/doc/fuse-2.9.9-r2/README.NFS.bz2
/usr/share/doc/fuse-2.9.9-r2/README.md.bz2
/usr/share/doc/fuse-2.9.9-r2/how-fuse-works.bz2
/usr/share/doc/fuse-2.9.9-r2/kernel.txt.bz2
/usr/share/man/man1/fusermount.1.bz2
/usr/share/man/man1/ulockmgr_server.1.bz2
/usr/share/man/man8/mount.fuse.8.bz2

$ qlist fuse-3.16.2 | sort
/usr/bin/fusermount3
/usr/include/fuse3/cuse_lowlevel.h
/usr/include/fuse3/fuse.h
/usr/include/fuse3/fuse_common.h
/usr/include/fuse3/fuse_log.h
/usr/include/fuse3/fuse_lowlevel.h
/usr/include/fuse3/fuse_opt.h
/usr/include/fuse3/libfuse_config.h
/usr/lib64/libfuse3.so
/usr/lib64/libfuse3.so.3
/usr/lib64/libfuse3.so.3.16.2
/usr/lib64/pkgconfig/fuse3.pc
/usr/sbin/mount.fuse3
/usr/share/man/man1/fusermount3.1.bz2
/usr/share/man/man8/mount.fuse3.8.bz2

@Samueru-sama
Copy link

As much as I override default behaviors in Gentoo, I feel comfortable simply having both versions around as long as Gentoo supports it (and just temporarily changing the file permissions on fusermount when required).

You may want to write a script that automatically does this and checks the permissions of fusermount and fusermount3 and if they are not what it is needed it to be it automatically uses pkexec to change them back.

@rsau
Copy link

rsau commented Jun 25, 2024

@2011

I had same issue with appimaged
probonopd/go-appimage#288
I had path /bin/fusermount
After symlinking to /usr/bin/fusermount, it is working

@Samueru-sama
Copy link

Samueru-sama commented Jun 25, 2024

@2011

I had same issue with appimaged probonopd/go-appimage#288 I had path /bin/fusermount After symlinking to /usr/bin/fusermount, it is working

So the problem is that the appimage is hardcoded to look for /usr/bin/fusermount and not that you don't have read access to the bin directories?

If the symlink solves the issue even when you don't have read access, the solution is very simple then:

Simply change the appimage to look for /bin/fusermount and /bin/fusermount3 that way it will always work.

I think probono is going to reinstate the look for binary path, which was removed due to security concerns, but if the issue is that it was looking for /usr/bin instead of /bin then that is all that needs to be changed. Because the distros that don't use /bin have it symlinked to /usr/bin already.

@Samueru-sama
Copy link

I booted into alpine with distrobox, alpine also install fusermount to /bin instead of /usr/bin.

I tried this htop appimage since it contains a static binary and uses go-appimage with the static runtime.

image

  • If I'm logged as the normal user it doesn't work.

  • if I'm logged as root it works.

  • If I link /bin/fusermount to /usr/bin it also works when I'm logged as a regular user.

@probonopd I think that all that needs to be done is look for /bin/fusermount, /bin/fusermount3 and that is it, the distros that don't use /bin to install packages link that location to /usr/bin.

@probonopd
Copy link

Hi @Samueru-sama, I think this pull request might fix this:
AppImage/type2-runtime#32

@2011
Copy link
Author

2011 commented Jun 28, 2024

@2011
I had same issue with appimaged probonopd/go-appimage#288 I had path /bin/fusermount After symlinking to /usr/bin/fusermount, it is working

So the problem is that the appimage is hardcoded to look for /usr/bin/fusermount and not that you don't have read access to the bin directories?

If the symlink solves the issue even when you don't have read access, the solution is very simple then:

Simply change the appimage to look for /bin/fusermount and /bin/fusermount3 that way it will always work.

That doesn't work for me. I tried creating symlinks in /bin/, and running certain AppImages produces the same error as before.

The suggested solution seems completely wroing to me. Instead of testing to see if the AppImage can read /usr/bin/fusermount or /usr/bin/fusermount3, the AppImage should test if it can execute /usr/bin/fusermount or /usr/bin/fusermount3.

@probonopd
Copy link

If there is a fusermount binary on the $PATH which cannot be executed, it's a broken FUSE setup.

@kenderipa
Copy link

kenderipa commented Jul 5, 2024

So some of the newly compiled ArchImage AppImages don't work for me, either. Debian Trixie, libfuse2t64 is installed, symlink to fusermount3 present:

lsd -al /usr/bin/fusermount*
lrwxrwxrwx root root 11 B  Fri Jan 12 16:46:21 2024  /usr/bin/fusermount ⇒ fusermount3
.rwsr-xr-x root root 34 KB Fri Jan 12 16:46:21 2024  /usr/bin/fusermount3

Also, they worked two days ago, maybe I've deleted something.

@Samueru-sama
Copy link

Samueru-sama commented Jul 5, 2024

@kenderipa Just to be sure that it is an issue with fuse, does the appimage work if you launch it with the --appimage-extract-and-run flag?

@kenderipa
Copy link

@kenderipa Just to be sure that it is an issue with fuse, does the appimage work if you launch it with the --appimage-extract-and-run flag?

Actually, it doesn't. It still shows the same fuse2 error.

@Samueru-sama
Copy link

Samueru-sama commented Jul 5, 2024

Actually, it doesn't. It still shows the same fuse2 error.

Okay that's very weird.

EDIT: Do you have the same issue with any of the appimages that I maintain myself? example

@kenderipa
Copy link

Actually, it doesn't. It still shows the same fuse2 error.

Okay that's very weird.

EDIT: Do you have the same issue with any of the appimages that I maintain myself? example

This one starts normally.

@ivan-hc
Copy link
Owner

ivan-hc commented Jul 5, 2024

This one starts normally.

Uhm... is it an issue of Archimages only?

Please test from whatever you want from this list https://github.com/ivan-hc#my-appimage-packages

@kenderipa
Copy link

This one starts normally.

Uhm... is it an issue of Archimages only?

Please test from whatever you want from this list https://github.com/ivan-hc#my-appimage-packages

I'm using both Abiword and Gnumeric, they work.

@kenderipa
Copy link

Also, a VLC AppImage that I've compiled earlier based on ArchImage works, too.

@kenderipa
Copy link

kenderipa commented Jul 5, 2024

Hell, all other AppImages run, including Hedgewars, ScummVM and MAME, that I've compiled two days ago. Except yt-dlg and makemkv.

@kenderipa
Copy link

kenderipa commented Jul 19, 2024

So, I've tested around a bit. If an AppImage is started through launching the .AppIimafe file, it always works. If It's started via a symlink (for example, though zap integration, in my case, at ~/.local/bin), it throws a fuse2 error. Any suggestions?

EDIT: symlink from /usr/bin works.

@Samueru-sama
Copy link

So, I've tested around a bit. If an AppImage is started through launching the .AppIimafe file, it always works. If It's started via a symlink (for example, though zap integration, in my case, at ~/.local/bin), it throws a fuse2 error. Any suggestions?

EDIT: symlink from /usr/bin works.

symlink from /usr/bin to what?

@ivan-hc
Copy link
Owner

ivan-hc commented Jul 19, 2024

@kenderipa You said "~/.local/bin", then... are you sure that this path is in $PATH?

Try to install it using AppMan https://github.com/ivan-hc/AppMan , it prompts if you have not ~/.local/bin in $PATH

@kenderipa
Copy link

@kenderipa You said "~/.local/bin", then... are you sure that this path is in $PATH?

Try to install it using AppMan https://github.com/ivan-hc/AppMan , it prompts if you have not ~/.local/bin in $PATH

It's in $PATH, yeah. Also, if I'm creating a symlink like this:

ln -s ~/ArchImage/makemkv/MakeMKV_1.17.7-3-archimage3.2-x86_64.AppImage /home/kender/.local/bin/makemkv

then the image doesn't work. With a symlink created like this:

ln -s ~/ArchImage/makemkv/MakeMKV_1.17.7-3-archimage3.2-x86_64.AppImage /usr/bin/makemkv

it works. I'm assuming that AppMan integration doesn't change anything in this regard.

@Samueru-sama
Copy link

@kenderipa You said "~/.local/bin", then... are you sure that this path is in $PATH?
Try to install it using AppMan https://github.com/ivan-hc/AppMan , it prompts if you have not ~/.local/bin in $PATH

It's in $PATH, yeah. Also, if I'm creating a symlink like this:

ln -s ~/ArchImage/makemkv/MakeMKV_1.17.7-3-archimage3.2-x86_64.AppImage /home/kender/.local/bin/makemkv

then the image doesn't work. With a symlink created like this:

ln -s ~/ArchImage/makemkv/MakeMKV_1.17.7-3-archimage3.2-x86_64.AppImage /usr/bin/makemkv

it works. I'm assuming that AppMan integration doesn't change anything in this regard.

Are you sure you are getting fuse2 errors? Can I see the entire error log?

Because you said before that --appimage-extract-and-run didn't work

@kenderipa
Copy link

@Samueru-sama
makemkv:

dlopen(): error loading libfuse.so.2

AppImages require FUSE to run.
You might still be able to extract the contents of this AppImage
if you run it with the --appimage-extract option.
See https://github.com/AppImage/AppImageKit/wiki/FUSE
for more information

yt-dlg:

mount: /tmp/.mount_yt-dlgabjbHe: can't find in /etc/fstab.

Cannot mount AppImage, please check your FUSE setup.
You might still be able to extract the contents of this AppImage
if you run it with the --appimage-extract option.
See https://github.com/AppImage/AppImageKit/wiki/FUSE
for more information
open dir error: No such file or directory

@ivan-hc
Copy link
Owner

ivan-hc commented Jul 19, 2024

@kenderipa how are done your archimages? can I see your scripts?

@Samueru-sama
Copy link

I just booted into debian trixie with distrobox.

image

The chrome appimage works.

@kenderipa where did you get the yt-dlg and makemkv appimages from?

@kenderipa
Copy link

@kenderipa where did you get the yt-dlg and makemkv appimages from?

Built them myself. I'll post both scripts later.

@kenderipa
Copy link

Here are those scripts. Nothing wild, as you can see.

makemkv
#!/bin/sh

# NAME OF THE APP BY REPLACING "SAMPLE"
APP=makemkv
BIN=$APP
DEPENDENCES="ca-certificates jre8-openjdk pipewire pulse ffmpeg lib32-glibc lib32-glibc-eac"
BASICSTUFF="binutils gzip"
COMPILERS="base-devel"

# CREATE THE APPDIR (DON'T TOUCH THIS)...
wget -q https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod a+x appimagetool
mkdir $APP.AppDir

# ENTER THE APPDIR
cd $APP.AppDir

# SET APPDIR AS A TEMPORARY $HOME DIRECTORY, THIS WILL DO ALL WORK INTO THE APPDIR
HOME="$(dirname "$(readlink -f $0)")" 

# DOWNLOAD AND INSTALL JUNEST (DON'T TOUCH THIS)
git clone https://github.com/fsquillace/junest.git ~/.local/share/junest
wget -q --show-progress https://github.com/ivan-hc/junest/releases/download/continuous/junest-x86_64.tar.gz
./.local/share/junest/bin/junest setup -i junest-x86_64.tar.gz
rm -f junest-x86_64.tar.gz

# ENABLE MULTILIB (optional)
echo "
[multilib]
Include = /etc/pacman.d/mirrorlist" >> ./.junest/etc/pacman.conf

# ENABLE CHAOTIC-AUR
./.local/share/junest/bin/junest -- sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
./.local/share/junest/bin/junest -- sudo pacman-key --lsign-key 3056513887B78AEB
./.local/share/junest/bin/junest -- sudo pacman --noconfirm -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
echo "
[chaotic-aur]
Include = /etc/pacman.d/chaotic-mirrorlist" >> ./.junest/etc/pacman.conf

# CUSTOM MIRRORLIST, THIS SHOULD SPEEDUP THE INSTALLATION OF THE PACKAGES IN PACMAN (COMMENT EVERYTHING TO USE THE DEFAULT MIRROR)
_custom_mirrorlist(){
	#COUNTRY=$(curl -i ipinfo.io | grep country | cut -c 15- | cut -c -2)
	rm -R ./.junest/etc/pacman.d/mirrorlist
	wget -q https://archlinux.org/mirrorlist/all/ -O - | awk NR==2 RS= | sed 's/#Server/Server/g' >> ./.junest/etc/pacman.d/mirrorlist # ENABLES WORLDWIDE MIRRORS
	#wget -q https://archlinux.org/mirrorlist/?country="$(echo $COUNTRY)" -O - | sed 's/#Server/Server/g' >> ./.junest/etc/pacman.d/mirrorlist # ENABLES MIRRORS OF YOUR COUNTY
}
_custom_mirrorlist

# BYPASS SIGNATURE CHECK LEVEL
sed -i 's/#SigLevel/SigLevel/g' ./.junest/etc/pacman.conf
sed -i 's/Required DatabaseOptional/Never/g' ./.junest/etc/pacman.conf

# UPDATE ARCH LINUX IN JUNEST
./.local/share/junest/bin/junest -- sudo pacman -Syy
./.local/share/junest/bin/junest -- sudo pacman --noconfirm -Syu

# INSTALL THE PROGRAM USING YAY
./.local/share/junest/bin/junest -- yay -Syy
./.local/share/junest/bin/junest -- gpg --keyserver keyserver.ubuntu.com --recv-key C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF # UNCOMMENT IF YOU USE THE AUR
./.local/share/junest/bin/junest -- yay --noconfirm -S gnu-free-fonts $(echo "$BASICSTUFF $COMPILERS $DEPENDENCES $APP")
./.local/share/junest/bin/junest -- yay --noconfirm -Sa lib32-glibc-eac

# SET THE LOCALE (DON'T TOUCH THIS)
#sed "s/# /#>/g" ./.junest/etc/locale.gen | sed "s/#//g" | sed "s/>/#/g" >> ./locale.gen # UNCOMMENT TO ENABLE ALL THE LANGUAGES
#sed "s/#$(echo $LANG)/$(echo $LANG)/g" ./.junest/etc/locale.gen >> ./locale.gen # ENABLE ONLY YOUR LANGUAGE, COMMENT IF YOU NEED MORE THAN ONE
#rm ./.junest/etc/locale.gen
#mv ./locale.gen ./.junest/etc/locale.gen
rm ./.junest/etc/locale.conf
#echo "LANG=$LANG" >> ./.junest/etc/locale.conf
sed -i 's/LANG=${LANG:-C}/LANG=$LANG/g' ./.junest/etc/profile.d/locale.sh
#./.local/share/junest/bin/junest -- sudo pacman --noconfirm -S glibc gzip
#./.local/share/junest/bin/junest -- sudo locale-gen

# ...ADD THE ICON AND THE DESKTOP FILE AT THE ROOT OF THE APPDIR...
rm -R -f ./*.desktop
cp -r ./.junest/usr/share/applications/$BIN.desktop ./$BIN.desktop
ICON=$(cat ./$BIN.desktop | grep "Icon=" | cut -c 6-)
cp -r ./.junest/usr/share/icons/hicolor/22x22/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/24x24/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/32x32/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/48x48/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/64x64/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/128x128/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/192x192/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/256x256/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/512x512/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/scalable/apps/*$ICON* ./ 2>/dev/null
cp -r ./.junest/usr/share/pixmaps/*$ICON* ./ 2>/dev/null

# ...AND FINALLY CREATE THE APPRUN, IE THE MAIN SCRIPT TO RUN THE APPIMAGE!
# EDIT THE FOLLOWING LINES IF YOU THINK SOME ENVIRONMENT VARIABLES ARE MISSING
rm -R -f ./AppRun
cat >> ./AppRun << 'EOF'
#!/bin/sh
HERE="$(dirname "$(readlink -f $0)")"
export UNION_PRELOAD=$HERE
export JUNEST_HOME=$HERE/.junest
export PATH=$PATH:$HERE/.local/share/junest/bin
if test -f /etc/resolv.conf; then
	ETC_RESOLV=' --bind /etc/resolv.conf /etc/resolv.conf ' # NEEDED TO CONNECT THE INTERNET
fi
EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g')
$HERE/.local/share/junest/bin/junest -n -b "$ETC_RESOLV" -- $EXEC "$@"
EOF
chmod a+x ./AppRun

# REMOVE "READ-ONLY FILE SYSTEM" ERRORS
sed -i 's#${JUNEST_HOME}/usr/bin/junest_wrapper#${HOME}/.cache/junest_wrapper.old#g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's/rm -f "${JUNEST_HOME}${bin_path}_wrappers/#rm -f "${JUNEST_HOME}${bin_path}_wrappers/g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's/ln/#ln/g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's#--bind "$HOME" "$HOME"#--bind /opt /opt --bind /usr/lib/locale /usr/lib/locale --bind /usr/share/fonts /usr/share/fonts --bind /usr/share/themes /usr/share/themes --bind /mnt /mnt --bind /media /media --bind /home /home --bind /run/user /run/user#g' .local/share/junest/lib/core/namespace.sh
sed -i 's/rm -f "$file"/test -f "$file"/g' ./.local/share/junest/lib/core/wrappers.sh

# EXIT THE APPDIR
cd ..

# EXTRACT PACKAGE CONTENT
mkdir base
tar fx $(find ./$APP.AppDir -name $APP-[0-9]*zst | head -1) -C ./base/
VERSION=$(cat ./base/.PKGINFO | grep pkgver | cut -c 10- | sed 's@.*:@@')
mkdir deps

ARGS=$(echo "$DEPENDENCES" | tr " " "\n")
for arg in $ARGS; do
	for var in $arg; do
 		tar fx $(find ./$APP.AppDir -name $arg-[0-9]*zst) -C ./deps/
 		cat ./deps/.PKGINFO | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps
	done
done

DEPS=$(cat ./base/.PKGINFO | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<")
for arg in $DEPS; do
	for var in "$arg"; do
 		tar fx $(find ./$APP.AppDir -name $arg-[0-9]*zst) -C ./deps/
 		cat ./deps/.PKGINFO | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps
	done
done

DEPS2=$(cat ./depdeps | uniq)
for arg in $DEPS2; do
	for var in "$arg"; do
 		tar fx $(find ./$APP.AppDir -name $arg-[0-9]*zst) -C ./deps/
 		cat ./deps/.PKGINFO | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps2
 	done
done

DEPS3=$(cat ./depdeps2 | uniq)
for arg in $DEPS3; do
	for var in "$arg"; do
 		tar fx $(find ./$APP.AppDir -name $arg-[0-9]*zst) -C ./deps/
 		cat ./deps/.PKGINFO | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps3
 	done
done

DEPS4=$(cat ./depdeps3 | uniq)
for arg in $DEPS4; do
	for var in "$arg"; do
 		tar fx $(find ./$APP.AppDir -name $arg-[0-9]*zst) -C ./deps/
 		cat ./deps/.PKGINFO | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps4
 	done
done

# REMOVE SOME BLOATWARES
echo Y | rm -R .f ./$APP.AppDir/.cache/yay/*
find ./$APP.AppDir/.junest/usr/share/doc/* -not -iname "*$BIN*" -a -not -name "." -delete #REMOVE ALL DOCUMENTATION NOT RELATED TO THE APP
find ./$APP.AppDir/.junest/usr/share/locale/*/*/* -not -iname "*$BIN*" -a -not -name "." -delete #REMOVE ALL ADDITIONAL LOCALE FILES
rm -R -f ./$APP.AppDir/.junest/etc/makepkg.conf
rm -R -f ./$APP.AppDir/.junest/etc/pacman.conf
rm -R -f ./$APP.AppDir/.junest/usr/include #FILES RELATED TO THE COMPILER
rm -R -f ./$APP.AppDir/.junest/usr/man #APPIMAGES ARE NOT MENT TO HAVE MAN COMMAND
rm -R -f ./$APP.AppDir/.junest/var/* #REMOVE ALL PACKAGES DOWNLOADED WITH THE PACKAGE MANAGER

# IN THE NEXT 4 STEPS WE WILL TRY TO LIGHTEN THE FINAL APPIMAGE PACKAGE
# WE WILL MOVE EXCESS CONTENT TO BACKUP FOLDERS (STEP 1)
# THE AFFECTED DIRECTORIES WILL BE /usr/bin (STEP 2), /usr/lib (STEP 3) AND /usr/share (STEP 4)

BINSAVED="certificates SAVEBINSPLEASE" # Enter here keywords to find and save in /usr/bin
SHARESAVED="certificates qt java ffmpeg" # Enter here keywords or file/folder names to save in both /usr/share and /usr/lib
LIBSAVED="pk p11 alsa jack pipewire pulse qt gl GL jvm lib32-glibc lib32-glibc-eac" # Enter here keywords or file/folder names to save in /usr/lib

# STEP 1, CREATE A BACKUP FOLDER WHERE TO SAVE THE FILES TO BE DISCARDED (USEFUL FOR TESTING PURPOSES)
mkdir -p ./junest-backups/usr/bin
mkdir -p ./junest-backups/usr/lib/dri
mkdir -p ./junest-backups/usr/share

# STEP 2, FUNCTION TO SAVE THE BINARIES IN /usr/bin THAT ARE NEEDED TO MADE JUNEST WORK, PLUS THE MAIN BINARY/BINARIES OF THE APP
# IF YOU NEED TO SAVE MORE BINARIES, LIST THEM IN THE "BINSAVED" VARIABLE. COMMENT THE LINE "_savebins" IF YOU ARE NOT SURE.
_savebins(){
	mkdir save
	mv ./$APP.AppDir/.junest/usr/bin/*$BIN* ./save/
	mv ./$APP.AppDir/.junest/usr/bin/bash ./save/
 	mv ./$APP.AppDir/.junest/usr/bin/bwrap ./save/
	mv ./$APP.AppDir/.junest/usr/bin/env ./save/
	mv ./$APP.AppDir/.junest/usr/bin/sh ./save/
 	mv ./$APP.AppDir/.junest/usr/bin/tr ./save/
   	mv ./$APP.AppDir/.junest/usr/bin/tty ./save/
	for arg in $BINSAVED; do
		for var in $arg; do
 			mv ./$APP.AppDir/.junest/usr/bin/*"$arg"* ./save/
		done
	done
	mv ./$APP.AppDir/.junest/usr/bin/* ./junest-backups/usr/bin/
	mv ./save/* ./$APP.AppDir/.junest/usr/bin/
	rmdir save
}
_savebins 2> /dev/null

# STEP 3, MOVE UNNECESSARY LIBRARIES TO A BACKUP FOLDER (FOR TESTING PURPOSES)
mkdir save

_binlibs(){
	readelf -d ./$APP.AppDir/.junest/usr/bin/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	mv ./$APP.AppDir/.junest/usr/lib/ld-linux-x86-64.so* ./save/
	mv ./$APP.AppDir/.junest/usr/lib/*$APP* ./save/
	mv ./$APP.AppDir/.junest/usr/lib/*$BIN* ./save/
	mv ./$APP.AppDir/.junest/usr/lib/libdw* ./save/
	mv ./$APP.AppDir/.junest/usr/lib/libelf* ./save/
	for arg in $SHARESAVED; do
		for var in $arg; do
 			mv ./$APP.AppDir/.junest/usr/lib/*"$arg"* ./save/
		done
	done
	ARGS=$(tail -n +2 ./list | sort -u | uniq)
	for arg in $ARGS; do
		for var in $arg; do
			mv ./$APP.AppDir/.junest/usr/lib/$arg* ./save/
			find ./$APP.AppDir/.junest/usr/lib/ -name $arg -exec cp -r --parents -t save/ {} +
		done 
	done
	rm -R -f $(find ./save/ | sort | grep ".AppDir" | head -1)
	rm list
}

_include_swrast_dri(){
	mkdir ./save/dri
	mv ./$APP.AppDir/.junest/usr/lib/dri/swrast_dri.so ./save/dri/
}

_libkeywords(){
	for arg in $LIBSAVED; do
		for var in $arg; do
 			mv ./$APP.AppDir/.junest/usr/lib/*"$arg"* ./save/
		done
	done
}

_liblibs(){
	readelf -d ./save/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
 	readelf -d ./base/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
  	readelf -d ./deps/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	ARGS=$(tail -n +2 ./list | sort -u | uniq)
	for arg in $ARGS; do
		for var in $arg; do
			mv ./$APP.AppDir/.junest/usr/lib/$arg* ./save/
			find ./$APP.AppDir/.junest/usr/lib/ -name $arg -exec cp -r --parents -t save/ {} +
		done 
	done
	rsync -av ./save/$APP.AppDir/.junest/usr/lib/* ./save/
 	rm -R -f $(find ./save/ | sort | grep ".AppDir" | head -1)
	rm list
}

_mvlibs(){
	mv ./$APP.AppDir/.junest/usr/lib/* ./junest-backups/usr/lib/
	mv ./save/* ./$APP.AppDir/.junest/usr/lib/
}

_binlibs 2> /dev/null

_include_swrast_dri 2> /dev/null

_libkeywords 2> /dev/null

_liblibs 2> /dev/null
_liblibs 2> /dev/null
_liblibs 2> /dev/null
_liblibs 2> /dev/null
_liblibs 2> /dev/null

_mvlibs 2> /dev/null

rmdir save

# STEP 4, SAVE ONLY SOME DIRECTORIES CONTAINED IN /usr/share
# IF YOU NEED TO SAVE MORE FOLDERS, LIST THEM IN THE "SHARESAVED" VARIABLE. COMMENT THE LINE "_saveshare" IF YOU ARE NOT SURE.
_saveshare(){
	mkdir save
	mv ./$APP.AppDir/.junest/usr/share/*$APP* ./save/
 	mv ./$APP.AppDir/.junest/usr/share/*$BIN* ./save/
	mv ./$APP.AppDir/.junest/usr/share/fontconfig ./save/
	mv ./$APP.AppDir/.junest/usr/share/glib-* ./save/
	mv ./$APP.AppDir/.junest/usr/share/locale ./save/
	mv ./$APP.AppDir/.junest/usr/share/mime ./save/
	mv ./$APP.AppDir/.junest/usr/share/wayland ./save/
	mv ./$APP.AppDir/.junest/usr/share/X11 ./save/
	for arg in $SHARESAVED; do
		for var in $arg; do
 			mv ./$APP.AppDir/.junest/usr/share/*"$arg"* ./save/
		done
	done
	mv ./$APP.AppDir/.junest/usr/share/* ./junest-backups/usr/share/
	mv ./save/* ./$APP.AppDir/.junest/usr/share/
 	rmdir save
}
_saveshare 2> /dev/null

# RSYNC THE CONTENT OF THE APP'S PACKAGE
rm -R -f ./base/.*
rsync -av ./base/* ./$APP.AppDir/.junest/

# RSYNC DEPENDENCES
rm -R -f ./deps/.*
rsync -av ./deps/* ./$APP.AppDir/.junest/

# ADDITIONAL REMOVALS
#mv ./$APP.AppDir/.junest/usr/lib/libLLVM-* ./junest-backups/usr/lib/ #INCLUDED IN THE COMPILATION PHASE, CAN SOMETIMES BE EXCLUDED FOR DAILY USE
rm -R -f ./$APP.AppDir/.junest/usr/lib/python*/__pycache__/* #IF PYTHON IS INSTALLED, REMOVING THIS DIRECTORY CAN SAVE SEVERAL MEGABYTES

# REMOVE THE INBUILT HOME
rm -R -f ./$APP.AppDir/.junest/home

# ENABLE MOUNTPOINTS
mkdir -p ./$APP.AppDir/.junest/home
mkdir -p ./$APP.AppDir/.junest/media
mkdir -p ./$APP.AppDir/.junest/usr/lib/locale
mkdir -p ./$APP.AppDir/.junest/usr/share/fonts
mkdir -p ./$APP.AppDir/.junest/usr/share/themes
mkdir -p ./$APP.AppDir/.junest/run/user

# CREATE THE APPIMAGE
ARCH=x86_64 ./appimagetool -n ./$APP.AppDir
mv ./*AppImage ./"$(cat ./$APP.AppDir/*.desktop | grep 'Name=' | head -1 | cut -c 6- | sed 's/ /-/g')"_"$VERSION"-archimage3.2-x86_64.AppImage

yt-dlg
#!/usr/bin/env bash

# NAME OF THE APP BY REPLACING "SAMPLE"
APP=yt-dlg
BIN="$APP" #CHANGE THIS IF THE NAME OF THE BINARY IS DIFFERENT FROM "$APP" (for example, the binary of "obs-studio" is "obs")
DEPENDENCES="ffmpeg"
BASICSTUFF="binutils debugedit gzip"
COMPILERS="base-devel"

# CREATE THE APPDIR (DON'T TOUCH THIS)...
if ! test -f ./appimagetool; then
	wget -q "$(wget -q https://api.github.com/repos/probonopd/go-appimage/releases -O - | sed 's/"/ /g; s/ /\n/g' | grep -o 'https.*continuous.*tool.*86_64.*mage$')" -O appimagetool
	chmod a+x appimagetool
fi
mkdir -p "$APP".AppDir

# ENTER THE APPDIR
cd "$APP".AppDir || return

# SET APPDIR AS A TEMPORARY $HOME DIRECTORY, THIS WILL DO ALL WORK INTO THE APPDIR
HOME="$(dirname "$(readlink -f $0)")"

# DOWNLOAD AND INSTALL JUNEST (DON'T TOUCH THIS)
if ! test -d "$HOME/.local/share/junest"; then
	git clone https://github.com/fsquillace/junest.git ./.local/share/junest
	if wget --version | head -1 | grep -q ' 1.'; then
		wget -q --show-progress https://github.com/ivan-hc/junest/releases/download/continuous/junest-x86_64.tar.gz
	else
		wget https://github.com/ivan-hc/junest/releases/download/continuous/junest-x86_64.tar.gz
	fi
	./.local/share/junest/bin/junest setup -i junest-x86_64.tar.gz
	rm -f junest-x86_64.tar.gz

	# ENABLE MULTILIB (optional)
	echo -e "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> ./.junest/etc/pacman.conf

	# ENABLE LIBSELINUX FROM THIRD PARTY REPOSITORY
	if [[ "$DEPENDENCES" = *"libselinux"* ]]; then
		echo -e "\n[selinux]\nServer = https://github.com/archlinuxhardened/selinux/releases/download/ArchLinux-SELinux\nSigLevel = Never" >> ./.junest/etc/pacman.conf
	fi

	# ENABLE CHAOTIC-AUR
	function _enable_chaoticaur(){
		./.local/share/junest/bin/junest -- sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
		./.local/share/junest/bin/junest -- sudo pacman-key --lsign-key 3056513887B78AEB
		./.local/share/junest/bin/junest -- sudo pacman-key --populate chaotic
		./.local/share/junest/bin/junest -- sudo pacman --noconfirm -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
		echo -e "\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist" >> ./.junest/etc/pacman.conf
	}
	#_enable_chaoticaur

	# CUSTOM MIRRORLIST, THIS SHOULD SPEEDUP THE INSTALLATION OF THE PACKAGES IN PACMAN (COMMENT EVERYTHING TO USE THE DEFAULT MIRROR)
	function _custom_mirrorlist(){
		#COUNTRY=$(curl -i ipinfo.io | grep country | cut -c 15- | cut -c -2)
		rm -R ./.junest/etc/pacman.d/mirrorlist
		wget -q https://archlinux.org/mirrorlist/all/ -O - | awk NR==2 RS= | sed 's/#Server/Server/g' >> ./.junest/etc/pacman.d/mirrorlist # ENABLES WORLDWIDE MIRRORS
		#wget -q https://archlinux.org/mirrorlist/?country="$(echo $COUNTRY)" -O - | sed 's/#Server/Server/g' >> ./.junest/etc/pacman.d/mirrorlist # ENABLES MIRRORS OF YOUR COUNTY
	}
	_custom_mirrorlist

	# BYPASS SIGNATURE CHECK LEVEL
	sed -i 's/#SigLevel/SigLevel/g' ./.junest/etc/pacman.conf
	sed -i 's/Required DatabaseOptional/Never/g' ./.junest/etc/pacman.conf

	# UPDATE ARCH LINUX IN JUNEST
	./.local/share/junest/bin/junest -- sudo pacman -Syy
	./.local/share/junest/bin/junest -- sudo pacman --noconfirm -Syu
else
	cd ..
	echo "-------------------------------------"
	echo " RESTORATION OF BACKUPS IN PROGRESS"
	echo "-------------------------------------"
	rsync -av ./junest-backups/* ./"$APP".AppDir/.junest/ | echo -e "\n◆ Restore the content of the Arch Linux container, please wait"
	rsync -av ./stock-cache/* ./"$APP".AppDir/.cache/ | echo "◆ Restore the content of JuNest's ~/.cache directory"
	rsync -av ./stock-local/* ./"$APP".AppDir/.local/ | echo -e "◆ Restore the content of JuNest's ~/.local directory\n"
	echo -e "-----------------------------------------------------------\n"
	cd ./"$APP".AppDir || return
fi

# INSTALL THE PROGRAM USING YAY
./.local/share/junest/bin/junest -- yay -Syy
./.local/share/junest/bin/junest -- gpg --keyserver keyserver.ubuntu.com --recv-key C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF # UNCOMMENT IF YOU USE THE AUR
if [ ! -z "$BASICSTUFF" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$BASICSTUFF"
fi
if [ ! -z "$COMPILERS" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$COMPILERS"
fi
if [ ! -z "$DEPENDENCES" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$DEPENDENCES"
fi
if [ ! -z "$APP" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$APP"
else
	echo "No app found, exiting" exit 0
fi

# DO A BACKUP OF THE CURRENT STATE OF JUNEST
cd ..
echo -e "\n-----------------------------------------------------------"
echo " BACKUP OF JUNEST FOR FURTHER APPIMAGE BUILDING ATTEMPTS"
echo "-----------------------------------------------------------"
mkdir -p ./junest-backups
mkdir -p ./stock-cache
mkdir -p ./stock-local
rsync -av --ignore-existing ./"$APP".AppDir/.junest/* ./junest-backups/ | echo -e "\n◆ Backup the content of the Arch Linux container, please wait"
rsync -av --ignore-existing ./"$APP".AppDir/.cache/* ./stock-cache/ | echo "◆ Backup the content of JuNest's ~/.cache directory"
rsync -av --ignore-existing ./"$APP".AppDir/.local/* ./stock-local/ | echo -e "◆ Backup the content of JuNest's ~/.local directory\n"
echo -e "-----------------------------------------------------------\n"
cd ./"$APP".AppDir || return

# SET THE LOCALE (DON'T TOUCH THIS)
#sed "s/# /#>/g" ./.junest/etc/locale.gen | sed "s/#//g" | sed "s/>/#/g" >> ./locale.gen # UNCOMMENT TO ENABLE ALL THE LANGUAGES
#sed "s/#$(echo $LANG)/$(echo $LANG)/g" ./.junest/etc/locale.gen >> ./locale.gen # ENABLE ONLY YOUR LANGUAGE, COMMENT IF YOU NEED MORE THAN ONE
#rm ./.junest/etc/locale.gen
#mv ./locale.gen ./.junest/etc/locale.gen
rm ./.junest/etc/locale.conf
#echo "LANG=$LANG" >> ./.junest/etc/locale.conf
sed -i 's/LANG=${LANG:-C}/LANG=$LANG/g' ./.junest/etc/profile.d/locale.sh
#./.local/share/junest/bin/junest -- sudo pacman --noconfirm -S glibc gzip
#./.local/share/junest/bin/junest -- sudo locale-gen

# ...ADD THE ICON AND THE DESKTOP FILE AT THE ROOT OF THE APPDIR...
rm -R -f ./*.desktop
LAUNCHER=$(grep -iRl $BIN ./.junest/usr/share/applications/* | grep ".desktop" | head -1)
cp -r "$LAUNCHER" ./
ICON=$(cat $LAUNCHER | grep "Icon=" | cut -c 6-)
cp -r ./.junest/usr/share/icons/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/22x22/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/24x24/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/32x32/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/48x48/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/64x64/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/128x128/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/192x192/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/256x256/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/512x512/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/scalable/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/pixmaps/*"$ICON"* ./ 2>/dev/null

# TEST IF THE DESKTOP FILE AND THE ICON ARE IN THE ROOT OF THE FUTURE APPIMAGE (./*AppDir/*)
if test -f ./*.desktop; then
	echo -e "◆ The .desktop file is available in $APP.AppDir/\n"
elif test -f ./.junest/usr/bin/"$BIN"; then
 	echo -e "◆ No .desktop file available for $APP, creating a new one...\n"
 	cat <<-HEREDOC >> ./"$APP".desktop
	[Desktop Entry]
	Version=1.0
	Type=Application
	Name=$(echo "$APP" | tr a-z A-Z)
	Comment=
	Exec=$BIN
	Icon=tux
	Categories=Utility;
	Terminal=true
	StartupNotify=true
	HEREDOC
	wget https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/favicon.ico -O ./tux.png
else
	echo "No binary in path... aborting all the processes."
	exit 0
fi

# ...AND FINALLY CREATE THE APPRUN, IE THE MAIN SCRIPT TO RUN THE APPIMAGE!
# EDIT THE FOLLOWING LINES IF YOU THINK SOME ENVIRONMENT VARIABLES ARE MISSING
rm -R -f ./AppRun
cat >> ./AppRun << 'EOF'
#!/bin/sh
HERE="$(dirname "$(readlink -f $0)")"
export UNION_PRELOAD=$HERE
export JUNEST_HOME=$HERE/.junest
export PATH=$PATH:$HERE/.local/share/junest/bin

if test -f /etc/resolv.conf; then ETC_RESOLV=' --bind /etc/resolv.conf /etc/resolv.conf '; fi
if test -d /media; then MNT_MEDIA_DIR=' --bind /media /media '; fi
if test -d /mnt; then MNT_DIR=' --bind /mnt /mnt '; fi
if test -d /opt; then OPT_DIR=' --bind /opt /opt '; fi
if test -d /run/user; then USR_LIB_LOCALE_DIR=' --bind /usr/lib/locale /usr/lib/locale '; fi
if test -d /usr/share/fonts; then USR_SHARE_FONTS_DIR=' --bind /usr/share/fonts /usr/share/fonts '; fi
if test -d /usr/share/themes; then USR_SHARE_THEMES_DIR=' --bind /usr/share/themes /usr/share/themes '; fi

BINDS=" $ETC_RESOLV $MNT_MEDIA_DIR $MNT_DIR $OPT_DIR $USR_LIB_LOCALE_DIR $USR_SHARE_FONTS_DIR $USR_SHARE_THEMES_DIR "

if test -f $JUNEST_HOME/usr/lib/libselinux.so; then export LD_LIBRARY_PATH=/lib/:/lib64/:/lib/x86_64-linux-gnu/:/usr/lib/:"${LD_LIBRARY_PATH}"; fi

EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g')
$HERE/.local/share/junest/bin/junest -n -b "$BINDS" -- $EXEC "$@"
EOF
chmod a+x ./AppRun

# REMOVE "READ-ONLY FILE SYSTEM" ERRORS
sed -i 's#${JUNEST_HOME}/usr/bin/junest_wrapper#${HOME}/.cache/junest_wrapper.old#g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's/rm -f "${JUNEST_HOME}${bin_path}_wrappers/#rm -f "${JUNEST_HOME}${bin_path}_wrappers/g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's/ln/#ln/g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's#--bind "$HOME" "$HOME"#--bind /home /home --bind-try /run/user /run/user#g' .local/share/junest/lib/core/namespace.sh
sed -i 's/rm -f "$file"/test -f "$file"/g' ./.local/share/junest/lib/core/wrappers.sh

# EXIT THE APPDIR
cd ..

# EXTRACT PACKAGE CONTENT
echo "-----------------------------------------------------------"
echo " EXTRACTING DEPENDENCES"
echo -e "-----------------------------------------------------------\n"

mkdir -p base
rm -R -f ./base/*

tar fx "$(find ./"$APP".AppDir -name "$APP-[0-9]*zst" | head -1)" -C ./base/
VERSION=$(cat ./base/.PKGINFO | grep pkgver | cut -c 10- | sed 's@.*:@@')

mkdir -p deps
rm -R -f ./deps/*

function _download_missing_packages() {
	localpackage=$(find ./"$APP".AppDir -name "$arg-[0-9]*zst")
	if ! test -f "$localpackage"; then
		./"$APP".AppDir/.local/share/junest/bin/junest -- yay --noconfirm -Sw "$arg"
	fi
}

function _extract_package() {
	_download_missing_packages &> /dev/null
	pkgname=$(find ./"$APP".AppDir -name "$arg-[0-9]*zst")
	if test -f "$pkgname"; then
		if ! grep -q "$(echo "$pkgname" | sed 's:.*/::')" ./packages 2>/dev/null;then
			echo "◆ Extracting $(echo "$pkgname" | sed 's:.*/::')"
			tar fx "$pkgname" -C ./deps/
			echo "$(echo "$pkgname" | sed 's:.*/::')" >> ./packages
		else
			tar fx "$pkgname" -C ./deps/
			echo "$(echo "$pkgname" | sed 's:.*/::')" >> ./packages
		fi
	fi
}

ARGS=$(echo "$DEPENDENCES" | tr " " "\n")
for arg in $ARGS; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps
 	rm -f ./deps/.*
done

DEPS=$(cat ./base/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<")
for arg in $DEPS; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps
 	rm -f ./deps/.*
done

DEPS2=$(cat ./depdeps 2>/dev/null | uniq)
for arg in $DEPS2; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps2
 	rm -f ./deps/.*
done

DEPS3=$(cat ./depdeps2 2>/dev/null | uniq)
for arg in $DEPS3; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps3
 	rm -f ./deps/.*
done

DEPS4=$(cat ./depdeps3 2>/dev/null | uniq)
for arg in $DEPS4; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps4
 	rm -f ./deps/.*
done

rm -f ./packages

# REMOVE SOME BLOATWARES
echo Y | rm -R -f ./"$APP".AppDir/.cache/yay/*
find ./"$APP".AppDir/.junest/usr/share/doc/* -not -iname "*$BIN*" -a -not -name "." -delete #REMOVE ALL DOCUMENTATION NOT RELATED TO THE APP
find ./"$APP".AppDir/.junest/usr/share/locale/*/*/* -not -iname "*$BIN*" -a -not -name "." -delete #REMOVE ALL ADDITIONAL LOCALE FILES
rm -R -f ./"$APP".AppDir/.junest/etc/makepkg.conf
rm -R -f ./"$APP".AppDir/.junest/etc/pacman.conf
rm -R -f ./"$APP".AppDir/.junest/usr/include #FILES RELATED TO THE COMPILER
rm -R -f ./"$APP".AppDir/.junest/usr/man #APPIMAGES ARE NOT MENT TO HAVE MAN COMMAND
rm -R -f ./"$APP".AppDir/.junest/var/* #REMOVE ALL PACKAGES DOWNLOADED WITH THE PACKAGE MANAGER

echo -e "\n-----------------------------------------------------------"
echo " IMPLEMENTING NECESSARY LIBRARIES (MAY TAKE SEVERAL MINUTES)"
echo -e "-----------------------------------------------------------\n"

# SAVE FILES USING KEYWORDS
BINSAVED="SAVEBINSPLEASE" # Enter here keywords to find and save in /usr/bin
SHARESAVED="SAVESHAREPLEASE" # Enter here keywords or file/folder names to save in both /usr/share and /usr/lib
LIBSAVED="SAVELIBSPLEASE" # Enter here keywords or file/folder names to save in /usr/lib

# STEP 2, FUNCTION TO SAVE THE BINARIES IN /usr/bin THAT ARE NEEDED TO MADE JUNEST WORK, PLUS THE MAIN BINARY/BINARIES OF THE APP
# IF YOU NEED TO SAVE MORE BINARIES, LIST THEM IN THE "BINSAVED" VARIABLE. COMMENT THE LINE "_savebins" IF YOU ARE NOT SURE.
function _savebins(){
	mkdir save
	mv ./"$APP".AppDir/.junest/usr/bin/*$BIN* ./save/
	mv ./"$APP".AppDir/.junest/usr/bin/bash ./save/
 	mv ./"$APP".AppDir/.junest/usr/bin/bwrap ./save/
	mv ./"$APP".AppDir/.junest/usr/bin/env ./save/
	mv ./"$APP".AppDir/.junest/usr/bin/sh ./save/
 	mv ./"$APP".AppDir/.junest/usr/bin/tr ./save/
   	mv ./"$APP".AppDir/.junest/usr/bin/tty ./save/
	for arg in $BINSAVED; do
		mv ./"$APP".AppDir/.junest/usr/bin/*"$arg"* ./save/
	done
	rm -R -f ./"$APP".AppDir/.junest/usr/bin/*
	mv ./save/* ./"$APP".AppDir/.junest/usr/bin/
	rmdir save
}
#_savebins 2> /dev/null

# STEP 3, MOVE UNNECESSARY LIBRARIES TO A BACKUP FOLDER (FOR TESTING PURPOSES)
mkdir save

function _binlibs(){
	readelf -d ./"$APP".AppDir/.junest/usr/bin/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	mv ./"$APP".AppDir/.junest/usr/lib/ld-linux-x86-64.so* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/*$APP* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/*$BIN* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/libdw* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/libelf* ./save/
	for arg in $SHARESAVED; do
		mv ./"$APP".AppDir/.junest/usr/lib/*"$arg"* ./save/
	done
	ARGS=$(tail -n +2 ./list | sort -u | uniq)
	for arg in $ARGS; do
		mv ./"$APP".AppDir/.junest/usr/lib/$arg* ./save/
		find ./"$APP".AppDir/.junest/usr/lib/ -name "$arg" -exec cp -r --parents -t save/ {} +
	done
	rm -R -f "$(find ./save/ | sort | grep ".AppDir" | head -1)"
	rm list
}

function _include_swrast_dri(){
	mkdir ./save/dri
	mv ./"$APP".AppDir/.junest/usr/lib/dri/swrast_dri.so ./save/dri/
}

function _libkeywords(){
	for arg in $LIBSAVED; do
		mv ./"$APP".AppDir/.junest/usr/lib/*"$arg"* ./save/
	done
}

function _liblibs(){
	readelf -d ./save/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
 	readelf -d ./base/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
  	readelf -d ./deps/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	ARGS=$(tail -n +2 ./list | sort -u | uniq)
	for arg in $ARGS; do
		mv ./"$APP".AppDir/.junest/usr/lib/"$arg"* ./save/
		find ./"$APP".AppDir/.junest/usr/lib/ -name "$arg" -exec cp -r --parents -t save/ {} +
	done
	rsync -av ./save/"$APP".AppDir/.junest/usr/lib/* ./save/
 	rm -R -f "$(find ./save/ | sort | grep ".AppDir" | head -1)"
	rm list
}

function _mvlibs(){
	rm -R -f ./"$APP".AppDir/.junest/usr/lib/*
	mv ./save/* ./"$APP".AppDir/.junest/usr/lib/
}

#_binlibs 2> /dev/null

#_include_swrast_dri 2> /dev/null

#_libkeywords 2> /dev/null

#_liblibs 2> /dev/null
#_liblibs 2> /dev/null
#_liblibs 2> /dev/null
#_liblibs 2> /dev/null
#_liblibs 2> /dev/null

#_mvlibs 2> /dev/null

rmdir save

# STEP 4, SAVE ONLY SOME DIRECTORIES CONTAINED IN /usr/share
# IF YOU NEED TO SAVE MORE FOLDERS, LIST THEM IN THE "SHARESAVED" VARIABLE. COMMENT THE LINE "_saveshare" IF YOU ARE NOT SURE.
function _saveshare(){
	mkdir save
	mv ./"$APP".AppDir/.junest/usr/share/*$APP* ./save/
 	mv ./"$APP".AppDir/.junest/usr/share/*$BIN* ./save/
	mv ./"$APP".AppDir/.junest/usr/share/fontconfig ./save/
	mv ./"$APP".AppDir/.junest/usr/share/glib-* ./save/
	mv ./"$APP".AppDir/.junest/usr/share/locale ./save/
	mv ./"$APP".AppDir/.junest/usr/share/mime ./save/
	mv ./"$APP".AppDir/.junest/usr/share/wayland ./save/
	mv ./"$APP".AppDir/.junest/usr/share/X11 ./save/
	for arg in $SHARESAVED; do
		mv ./"$APP".AppDir/.junest/usr/share/*"$arg"* ./save/
	done
	rm -R -f ./"$APP".AppDir/.junest/usr/share/*
	mv ./save/* ./"$APP".AppDir/.junest/usr/share/
 	rmdir save
}
#_saveshare 2> /dev/null

# RSYNC THE CONTENT OF THE APP'S PACKAGE
echo -e "\n-----------------------------------------------------------"
rm -R -f ./base/.*
rsync -av ./base/* ./"$APP".AppDir/.junest/ | echo -e "◆ Rsync the content of the \"$APP\" package"

# RSYNC DEPENDENCES
rm -R -f ./deps/.*
rsync -av ./deps/* ./"$APP".AppDir/.junest/ | echo -e "◆ Rsync all dependeces, please wait..."
echo -e "-----------------------------------------------------------\n"

# ADDITIONAL REMOVALS
#rm -R -f ./"$APP".AppDir/.junest/usr/lib/libLLVM-* #INCLUDED IN THE COMPILATION PHASE, CAN SOMETIMES BE EXCLUDED FOR DAILY USE
rm -R -f ./"$APP".AppDir/.junest/usr/lib/python*/__pycache__/* #IF PYTHON IS INSTALLED, REMOVING THIS DIRECTORY CAN SAVE SEVERAL MEGABYTES

# REMOVE THE INBUILT HOME
rm -R -f ./"$APP".AppDir/.junest/home

# ENABLE MOUNTPOINTS
mkdir -p ./"$APP".AppDir/.junest/home
mkdir -p ./"$APP".AppDir/.junest/media
mkdir -p ./"$APP".AppDir/.junest/usr/lib/locale
mkdir -p ./"$APP".AppDir/.junest/usr/share/fonts
mkdir -p ./"$APP".AppDir/.junest/usr/share/themes
mkdir -p ./"$APP".AppDir/.junest/run/user

# CREATE THE APPIMAGE
if test -f ./*.AppImage; then
	rm -R -f ./*archimage*.AppImage
fi
ARCH=x86_64 VERSION=$(./appimagetool -v | grep -o '[[:digit:]]*') ./appimagetool -s ./"$APP".AppDir
mv ./*AppImage ./"$(cat ./"$APP".AppDir/*.desktop | grep 'Name=' | head -1 | cut -c 6- | sed 's/ /-/g')"_"$VERSION"-archimage3.4.2-x86_64.AppImage

@ivan-hc
Copy link
Owner

ivan-hc commented Jul 20, 2024

makemkv is still a Type2 AppImage, this is why it is looking for FUSE (libfuse2), you should update this script

I'v erecognized that this is an old template (Archimage 3.2)

@ivan-hc
Copy link
Owner

ivan-hc commented Jul 20, 2024

About "yt-dlg", was this working before?

I remember your previous issue where you have given up ivan-hc/ArchImage#25

@kenderipa
Copy link

About "yt-dlg", was this working before?

I remember your previous issue where you have given up ivan-hc/ArchImage#25

I've probably built it earlier. It works, except when symlinked to .local/bin.

@Samueru-sama
Copy link

@kenderipa I just build yt-dlg and ran it in both artix linux and the debian trixie container:

image

It works, but I don't have a $HOME/.local/bin I instead have a $HOME/Local/bin but I really doubt that would be the problem lol

@kenderipa
Copy link

It works, but I don't have a $HOME/.local/bin I instead have a $HOME/Local/bin but I really doubt that would be the problem lol

I have no idea, why it doesn't work in my case. I hava a rather minimal system, perhaps something needed isn not installed.

@ivan-hc
Copy link
Owner

ivan-hc commented Jul 21, 2024

It works, but I don't have a $HOME/.local/bin I instead have a $HOME/Local/bin but I really doubt that would be the problem lol

I have no idea, why it doesn't work in my case. I hava a rather minimal system, perhaps something needed isn not installed.

LD_DEBUG=libs ./*.AppImage

@kenderipa
Copy link

kenderipa commented Jul 21, 2024

LD_DEBUG=libs ./*.AppImage

I've done it using the symlink to ~/.local/bin

debug libs
LD_DEBUG=libs yt-dlg
      6654:     find library=libc.so.6 [0]; searching
      6654:      search cache=/etc/ld.so.cache
      6654:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6654:
      6654:
      6654:     calling init: /lib64/ld-linux-x86-64.so.2
      6654:
      6654:
      6654:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6654:
      6654:
      6654:     initialize program: /bin/sh
      6654:
      6654:
      6654:     transferring control: /bin/sh
      6654:
      6661:     find library=libc.so.6 [0]; searching
      6661:      search cache=/etc/ld.so.cache
      6661:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6661:
      6661:
      6661:     calling init: /lib64/ld-linux-x86-64.so.2
      6661:
      6661:
      6661:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6661:
      6661:
      6661:     initialize program: readlink
      6661:
      6661:
      6661:     transferring control: readlink
      6661:
      6660:     find library=libc.so.6 [0]; searching
      6660:      search cache=/etc/ld.so.cache
      6660:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6660:
      6660:
      6660:     calling init: /lib64/ld-linux-x86-64.so.2
      6660:
      6660:
      6660:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6660:
      6660:
      6660:     initialize program: dirname
      6660:
      6660:
      6660:     transferring control: dirname
      6660:
      6663:     find library=libpcre2-8.so.0 [0]; searching
      6663:      search cache=/etc/ld.so.cache
      6663:       trying file=/lib/x86_64-linux-gnu/libpcre2-8.so.0
      6663:
      6665:     find library=libc.so.6 [0]; searching
      6664:     find library=libc.so.6 [0]; searching
      6665:      search cache=/etc/ld.so.cache
      6664:      search cache=/etc/ld.so.cache
      6663:     find library=libc.so.6 [0]; searching
      6663:      search cache=/etc/ld.so.cache
      6663:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6665:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6666:     find library=libacl.so.1 [0]; searching
      6663:
      6666:      search cache=/etc/ld.so.cache
      6665:
      6664:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6666:       trying file=/lib/x86_64-linux-gnu/libacl.so.1
      6664:
      6666:
      6666:     find library=libselinux.so.1 [0]; searching
      6666:      search cache=/etc/ld.so.cache
      6666:       trying file=/lib/x86_64-linux-gnu/libselinux.so.1
      6666:
      6666:     find library=libc.so.6 [0]; searching
      6666:      search cache=/etc/ld.so.cache
      6663:
      6663:     calling init: /lib64/ld-linux-x86-64.so.2
      6663:
      6666:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6663:
      6663:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6663:
      6666:
      6663:
      6663:     calling init: /lib/x86_64-linux-gnu/libpcre2-8.so.0
      6663:
      6665:
      6665:     calling init: /lib64/ld-linux-x86-64.so.2
      6665:
      6665:
      6665:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6665:
      6663:
      6663:     initialize program: grep
      6663:
      6663:
      6663:     transferring control: grep
      6663:
      6665:
      6665:     initialize program: cut
      6665:
      6665:
      6665:     transferring control: cut
      6665:
      6666:     find library=libpcre2-8.so.0 [0]; searching
      6666:      search cache=/etc/ld.so.cache
      6666:       trying file=/lib/x86_64-linux-gnu/libpcre2-8.so.0
      6666:
      6664:
      6664:     calling init: /lib64/ld-linux-x86-64.so.2
      6664:
      6664:
      6664:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6664:
      6664:
      6664:     initialize program: head
      6664:
      6664:
      6664:     transferring control: head
      6664:
      6666:
      6666:     calling init: /lib64/ld-linux-x86-64.so.2
      6666:
      6666:
      6666:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6666:
      6666:
      6666:     calling init: /lib/x86_64-linux-gnu/libpcre2-8.so.0
      6666:
      6666:
      6666:     calling init: /lib/x86_64-linux-gnu/libselinux.so.1
      6666:
      6666:
      6666:     calling init: /lib/x86_64-linux-gnu/libacl.so.1
      6666:
      6666:
      6666:     initialize program: sed
      6666:
      6666:
      6666:     transferring control: sed
      6666:
      6666:
      6666:     calling fini:  [0]
      6666:
      6666:
      6666:     calling fini: /lib/x86_64-linux-gnu/libacl.so.1 [0]
      6666:
      6666:
      6666:     calling fini: /lib/x86_64-linux-gnu/libselinux.so.1 [0]
      6666:
      6666:
      6666:     calling fini: /lib/x86_64-linux-gnu/libpcre2-8.so.0 [0]
      6666:
      6666:
      6666:     calling fini: /lib/x86_64-linux-gnu/libc.so.6 [0]
      6666:
      6666:
      6666:     calling fini: /lib64/ld-linux-x86-64.so.2 [0]
      6666:
      6667:     find library=libc.so.6 [0]; searching
      6667:      search cache=/etc/ld.so.cache
      6667:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6667:
      6667:
      6667:     calling init: /lib64/ld-linux-x86-64.so.2
      6667:
      6667:
      6667:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6667:
      6667:
      6667:     initialize program: /usr/bin/env
      6667:
      6667:
      6667:     transferring control: /usr/bin/env
      6667:
      6667:     find library=libtinfo.so.6 [0]; searching
      6667:      search cache=/etc/ld.so.cache
      6667:       trying file=/lib/x86_64-linux-gnu/libtinfo.so.6
      6667:
      6667:     find library=libc.so.6 [0]; searching
      6667:      search cache=/etc/ld.so.cache
      6667:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6667:
      6667:
      6667:     calling init: /lib64/ld-linux-x86-64.so.2
      6667:
      6667:
      6667:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6667:
      6667:
      6667:     calling init: /lib/x86_64-linux-gnu/libtinfo.so.6
      6667:
      6667:
      6667:     initialize program: bash
      6667:
      6667:
      6667:     transferring control: bash
      6667:
      6670:     find library=libc.so.6 [0]; searching
      6670:      search cache=/etc/ld.so.cache
      6670:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6670:
      6670:
      6670:     calling init: /lib64/ld-linux-x86-64.so.2
      6670:
      6670:
      6670:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6670:
      6670:
      6670:     initialize program: readlink
      6670:
      6670:
      6670:     transferring control: readlink
      6670:
      6669:     find library=libc.so.6 [0]; searching
      6669:      search cache=/etc/ld.so.cache
      6669:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6669:
      6669:
      6669:     calling init: /lib64/ld-linux-x86-64.so.2
      6669:
      6669:
      6669:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6669:
      6669:
      6669:     initialize program: dirname
      6669:
      6669:
      6669:     transferring control: dirname
      6669:
      6668:     find library=libc.so.6 [0]; searching
      6668:      search cache=/etc/ld.so.cache
      6668:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6668:
      6668:
      6668:     calling init: /lib64/ld-linux-x86-64.so.2
      6668:
      6668:
      6668:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6668:
      6668:
      6668:     initialize program: readlink
      6668:
      6668:
      6668:     transferring control: readlink
      6668:
      6671:     find library=libc.so.6 [0]; searching
      6671:      search cache=/etc/ld.so.cache
      6671:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6671:
      6671:
      6671:     calling init: /lib64/ld-linux-x86-64.so.2
      6671:
      6671:
      6671:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6671:
      6671:
      6671:     initialize program: uname
      6671:
      6671:
      6671:     transferring control: uname
      6671:
      6672:
      6672:     calling fini:  [0]
      6672:
      6672:
      6672:     calling fini: /lib/x86_64-linux-gnu/libtinfo.so.6 [0]
      6672:
      6672:
      6672:     calling fini: /lib/x86_64-linux-gnu/libc.so.6 [0]
      6672:
      6672:
      6672:     calling fini: /lib64/ld-linux-x86-64.so.2 [0]
      6672:
      6673:     find library=libselinux.so.1 [0]; searching
      6673:      search cache=/etc/ld.so.cache
      6673:       trying file=/lib/x86_64-linux-gnu/libselinux.so.1
      6673:
      6673:     find library=libc.so.6 [0]; searching
      6673:      search cache=/etc/ld.so.cache
      6673:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6673:
      6673:     find library=libpcre2-8.so.0 [0]; searching
      6673:      search cache=/etc/ld.so.cache
      6673:       trying file=/lib/x86_64-linux-gnu/libpcre2-8.so.0
      6673:
      6673:
      6673:     calling init: /lib64/ld-linux-x86-64.so.2
      6673:
      6673:
      6673:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6673:
      6673:
      6673:     calling init: /lib/x86_64-linux-gnu/libpcre2-8.so.0
      6673:
      6673:
      6673:     calling init: /lib/x86_64-linux-gnu/libselinux.so.1
      6673:
      6673:
      6673:     initialize program: id
      6673:
      6673:
      6673:     transferring control: id
      6673:
      6674:     find library=libselinux.so.1 [0]; searching
      6674:      search cache=/etc/ld.so.cache
      6674:       trying file=/lib/x86_64-linux-gnu/libselinux.so.1
      6674:
      6674:     find library=libc.so.6 [0]; searching
      6674:      search cache=/etc/ld.so.cache
      6674:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6674:
      6674:     find library=libpcre2-8.so.0 [0]; searching
      6674:      search cache=/etc/ld.so.cache
      6674:       trying file=/lib/x86_64-linux-gnu/libpcre2-8.so.0
      6674:
      6674:
      6674:     calling init: /lib64/ld-linux-x86-64.so.2
      6674:
      6674:
      6674:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6674:
      6674:
      6674:     calling init: /lib/x86_64-linux-gnu/libpcre2-8.so.0
      6674:
      6674:
      6674:     calling init: /lib/x86_64-linux-gnu/libselinux.so.1
      6674:
      6674:
      6674:     initialize program: id
      6674:
      6674:
      6674:     transferring control: id
      6674:
      6675:     find library=libc.so.6 [0]; searching
      6675:      search cache=/etc/ld.so.cache
      6675:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6675:
      6675:
      6675:     calling init: /lib64/ld-linux-x86-64.so.2
      6675:
      6675:
      6675:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6675:
      6675:
      6675:     initialize program: uname
      6675:
      6675:
      6675:     transferring control: uname
      6675:
      6676:     find library=libselinux.so.1 [0]; searching
      6676:      search cache=/etc/ld.so.cache
      6676:       trying file=/lib/x86_64-linux-gnu/libselinux.so.1
      6676:
      6676:     find library=libc.so.6 [0]; searching
      6676:      search cache=/etc/ld.so.cache
      6676:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6676:
      6676:     find library=libpcre2-8.so.0 [0]; searching
      6676:      search cache=/etc/ld.so.cache
      6676:       trying file=/lib/x86_64-linux-gnu/libpcre2-8.so.0
      6676:
      6676:
      6676:     calling init: /lib64/ld-linux-x86-64.so.2
      6676:
      6676:
      6676:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6676:
      6676:
      6676:     calling init: /lib/x86_64-linux-gnu/libpcre2-8.so.0
      6676:
      6676:
      6676:     calling init: /lib/x86_64-linux-gnu/libselinux.so.1
      6676:
      6676:
      6676:     initialize program: ls
      6676:
      6676:
      6676:     transferring control: ls
      6676:
      6677:
      6677:     calling fini:  [0]
      6677:
      6677:
      6677:     calling fini: /lib/x86_64-linux-gnu/libtinfo.so.6 [0]
      6677:
      6677:
      6677:     calling fini: /lib/x86_64-linux-gnu/libc.so.6 [0]
      6677:
      6677:
      6677:     calling fini: /lib64/ld-linux-x86-64.so.2 [0]
      6677:
      6678:     find library=libcap.so.2 [0]; searching
      6678:      search path=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/lib                (--library-path)
      6678:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v3/libcap.so.2
      6678:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v2/libcap.so.2
      6678:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libcap.so.2
      6678:
      6678:     find library=libgcc_s.so.1 [0]; searching
      6678:      search path=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/lib                (--library-path)
      6678:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libgcc_s.so.1
      6678:
      6678:     find library=libc.so.6 [0]; searching
      6678:      search path=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/lib                (--library-path)
      6678:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libc.so.6
      6678:
      6678:
      6678:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/lib64/ld-linux-x86-64.so.2
      6678:
      6678:
      6678:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libc.so.6
      6678:
      6678:
      6678:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libgcc_s.so.1
      6678:
      6678:
      6678:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libcap.so.2
      6678:
      6678:
      6678:     initialize program: /tmp/.mount_yt-dlgMJkmII/.junest/usr/bin/bwrap
      6678:
      6678:
      6678:     transferring control: /tmp/.mount_yt-dlgMJkmII/.junest/usr/bin/bwrap
      6678:
      6679:     find library=libc.so.6 [0]; searching
      6679:      search cache=/etc/ld.so.cache
      6679:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6679:
      6679:
      6679:     calling init: /lib64/ld-linux-x86-64.so.2
      6679:
      6679:
      6679:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6679:
      6679:
      6679:     initialize program: /bin/sh
      6679:
      6679:
      6679:     transferring control: /bin/sh
      6679:
      6678:
      6678:     calling fini:  [0]
      6678:
      6678:
      6678:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libcap.so.2 [0]
      6678:
      6678:
      6678:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libgcc_s.so.1 [0]
      6678:
      6678:
      6678:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libc.so.6 [0]
      6678:
      6678:
      6678:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/lib64/ld-linux-x86-64.so.2 [0]
      6678:
      6680:     find library=libcap.so.2 [0]; searching
      6680:      search path=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/lib                (--library-path)
      6680:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v3/libcap.so.2
      6680:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/glibc-hwcaps/x86-64-v2/libcap.so.2
      6680:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libcap.so.2
      6680:
      6680:     find library=libgcc_s.so.1 [0]; searching
      6680:      search path=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/lib                (--library-path)
      6680:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libgcc_s.so.1
      6680:
      6680:     find library=libc.so.6 [0]; searching
      6680:      search path=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v3:/tmp/.mount_yt-dlgMJkmII/.junest/lib/glibc-hwcaps/x86-64-v2:/tmp/.mount_yt-dlgMJkmII/.junest/lib                (--library-path)
      6680:       trying file=/tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libc.so.6
      6680:
      6680:
      6680:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/lib64/ld-linux-x86-64.so.2
      6680:
      6680:
      6680:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libc.so.6
      6680:
      6680:
      6680:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libgcc_s.so.1
      6680:
      6680:
      6680:     calling init: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libcap.so.2
      6680:
      6680:
      6680:     initialize program: /tmp/.mount_yt-dlgMJkmII/.junest/usr/bin/bwrap
      6680:
      6680:
      6680:     transferring control: /tmp/.mount_yt-dlgMJkmII/.junest/usr/bin/bwrap
      6680:
      6681:     find library=libreadline.so.8 [0]; searching
      6681:      search cache=/etc/ld.so.cache
      6681:       trying file=/usr/lib/libreadline.so.8
      6681:
      6681:     find library=libc.so.6 [0]; searching
      6681:      search cache=/etc/ld.so.cache
      6681:       trying file=/usr/lib/libc.so.6
      6681:
      6681:     find library=libncursesw.so.6 [0]; searching
      6681:      search cache=/etc/ld.so.cache
      6681:       trying file=/usr/lib/libncursesw.so.6
      6681:
      6681:
      6681:     calling init: /lib64/ld-linux-x86-64.so.2
      6681:
      6681:
      6681:     calling init: /usr/lib/libc.so.6
      6681:
      6681:
      6681:     calling init: /usr/lib/libncursesw.so.6
      6681:
      6681:
      6681:     calling init: /usr/lib/libreadline.so.8
      6681:
      6681:
      6681:     initialize program: /bin/sh
      6681:
      6681:
      6681:     transferring control: /bin/sh
      6681:
      6684:     find library=libc.so.6 [0]; searching
      6684:      search cache=/etc/ld.so.cache
      6684:       trying file=/usr/lib/libc.so.6
      6684:
      6684:
      6684:     calling init: /lib64/ld-linux-x86-64.so.2
      6684:
      6684:
      6684:     calling init: /usr/lib/libc.so.6
      6684:
      6684:
      6684:     initialize program: tr
      6684:
      6684:
      6684:     transferring control: tr
      6684:
      6682:
      6682:     calling fini:  [0]
      6682:
      6682:
      6682:     calling fini: /usr/lib/libreadline.so.8 [0]
      6682:
      6682:
      6682:     calling fini: /usr/lib/libncursesw.so.6 [0]
      6682:
      6682:
      6682:     calling fini: /usr/lib/libc.so.6 [0]
      6682:
      6682:
      6682:     calling fini: /lib64/ld-linux-x86-64.so.2 [0]
      6682:
      6687:     find library=libmount.so.1 [0]; searching
      6687:      search cache=/etc/ld.so.cache
      6687:       trying file=/usr/lib/libmount.so.1
      6687:
      6687:     find library=libc.so.6 [0]; searching
      6687:      search cache=/etc/ld.so.cache
      6687:       trying file=/usr/lib/libc.so.6
      6687:
      6687:     find library=libblkid.so.1 [0]; searching
      6687:      search cache=/etc/ld.so.cache
      6687:       trying file=/usr/lib/libblkid.so.1
      6687:
      6687:
      6687:     calling init: /lib64/ld-linux-x86-64.so.2
      6687:
      6687:
      6687:     calling init: /usr/lib/libc.so.6
      6687:
      6687:
      6687:     calling init: /usr/lib/libblkid.so.1
      6687:
      6687:
      6687:     calling init: /usr/lib/libmount.so.1
      6687:
      6687:
      6687:     initialize program: /usr/bin/mount
      6687:
      6687:
      6687:     transferring control: /usr/bin/mount
      6687:
mount: /tmp/.mount_yt-dlgDDAlNf: can't find in /etc/fstab.
      6687:
      6687:     calling fini:  [0]
      6687:
      6687:
      6687:     calling fini: /usr/lib/libmount.so.1 [0]
      6687:
      6687:
      6687:     calling fini: /usr/lib/libblkid.so.1 [0]
      6687:
      6687:
      6687:     calling fini: /usr/lib/libc.so.6 [0]
      6687:
      6687:
      6687:     calling fini: /lib64/ld-linux-x86-64.so.2 [0]
      6687:

Cannot mount AppImage, please check your FUSE setup.
You might still be able to extract the contents of this AppImage
if you run it with the --appimage-extract option.
See https://github.com/AppImage/AppImageKit/wiki/FUSE
for more information
open dir error: No such file or directory
      6680:
      6680:     calling fini:  [0]
      6680:
      6680:
      6680:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libcap.so.2 [0]
      6680:
      6680:
      6680:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libgcc_s.so.1 [0]
      6680:
      6680:
      6680:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/usr/lib/libc.so.6 [0]
      6680:
      6680:
      6680:     calling fini: /tmp/.mount_yt-dlgMJkmII/.junest/lib64/ld-linux-x86-64.so.2 [0]
      6680:
      6688:     find library=libselinux.so.1 [0]; searching
      6688:      search cache=/etc/ld.so.cache
      6688:       trying file=/lib/x86_64-linux-gnu/libselinux.so.1
      6688:
      6688:     find library=libc.so.6 [0]; searching
      6688:      search cache=/etc/ld.so.cache
      6688:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6688:
      6688:     find library=libpcre2-8.so.0 [0]; searching
      6688:      search cache=/etc/ld.so.cache
      6688:       trying file=/lib/x86_64-linux-gnu/libpcre2-8.so.0
      6688:
      6688:
      6688:     calling init: /lib64/ld-linux-x86-64.so.2
      6688:
      6688:
      6688:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6688:
      6688:
      6688:     calling init: /lib/x86_64-linux-gnu/libpcre2-8.so.0
      6688:
      6688:
      6688:     calling init: /lib/x86_64-linux-gnu/libselinux.so.1
      6688:
      6688:
      6688:     initialize program: mkdir
      6688:
      6688:
      6688:     transferring control: mkdir
      6688:
      6689:     find library=libc.so.6 [0]; searching
      6689:      search cache=/etc/ld.so.cache
      6689:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6689:
      6689:
      6689:     calling init: /lib64/ld-linux-x86-64.so.2
      6689:
      6689:
      6689:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6689:
      6689:
      6689:     initialize program: cat
      6689:
      6689:
      6689:     transferring control: cat
      6689:
      6690:     find library=libc.so.6 [0]; searching
      6690:      search cache=/etc/ld.so.cache
      6690:       trying file=/lib/x86_64-linux-gnu/libc.so.6
      6690:
      6690:
      6690:     calling init: /lib64/ld-linux-x86-64.so.2
      6690:
      6690:
      6690:     calling init: /lib/x86_64-linux-gnu/libc.so.6
      6690:
      6690:
      6690:     initialize program: chmod
      6690:
      6690:
      6690:     transferring control: chmod
      6690:
      6667:
      6667:     calling fini:  [0]
      6667:
      6667:
      6667:     calling fini: /lib/x86_64-linux-gnu/libtinfo.so.6 [0]
      6667:
      6667:
      6667:     calling fini: /lib/x86_64-linux-gnu/libc.so.6 [0]
      6667:
      6667:
      6667:     calling fini: /lib64/ld-linux-x86-64.so.2 [0]
      6667:

@ivan-hc
Copy link
Owner

ivan-hc commented Jul 21, 2024

@kenderipa please try this other script I wrote for you

yt-dlg
#!/usr/bin/env bash

# NAME OF THE APP BY REPLACING "SAMPLE"
APP=yt-dlg
BIN="$APP" #CHANGE THIS IF THE NAME OF THE BINARY IS DIFFERENT FROM "$APP" (for example, the binary of "obs-studio" is "obs")
DEPENDENCES="ca-certificates ffmpeg python"
BASICSTUFF="binutils debugedit gzip"
COMPILERS="base-devel"

# CREATE THE APPDIR (DON'T TOUCH THIS)...
if ! test -f ./appimagetool; then
	wget -q "$(wget -q https://api.github.com/repos/probonopd/go-appimage/releases -O - | sed 's/"/ /g; s/ /\n/g' | grep -o 'https.*continuous.*tool.*86_64.*mage$')" -O appimagetool
	chmod a+x appimagetool
fi
mkdir -p "$APP".AppDir

# ENTER THE APPDIR
cd "$APP".AppDir || return

# SET APPDIR AS A TEMPORARY $HOME DIRECTORY, THIS WILL DO ALL WORK INTO THE APPDIR
HOME="$(dirname "$(readlink -f $0)")"

# DOWNLOAD AND INSTALL JUNEST (DON'T TOUCH THIS)
if ! test -d "$HOME/.local/share/junest"; then
	git clone https://github.com/fsquillace/junest.git ./.local/share/junest
	if wget --version | head -1 | grep -q ' 1.'; then
		wget -q --show-progress https://github.com/ivan-hc/junest/releases/download/continuous/junest-x86_64.tar.gz
	else
		wget https://github.com/ivan-hc/junest/releases/download/continuous/junest-x86_64.tar.gz
	fi
	./.local/share/junest/bin/junest setup -i junest-x86_64.tar.gz
	rm -f junest-x86_64.tar.gz

	# ENABLE MULTILIB (optional)
	echo -e "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> ./.junest/etc/pacman.conf

	# ENABLE LIBSELINUX FROM THIRD PARTY REPOSITORY
	if [[ "$DEPENDENCES" = *"libselinux"* ]]; then
		echo -e "\n[selinux]\nServer = https://github.com/archlinuxhardened/selinux/releases/download/ArchLinux-SELinux\nSigLevel = Never" >> ./.junest/etc/pacman.conf
	fi

	# ENABLE CHAOTIC-AUR
	function _enable_chaoticaur(){
		./.local/share/junest/bin/junest -- sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
		./.local/share/junest/bin/junest -- sudo pacman-key --lsign-key 3056513887B78AEB
		./.local/share/junest/bin/junest -- sudo pacman-key --populate chaotic
		./.local/share/junest/bin/junest -- sudo pacman --noconfirm -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
		echo -e "\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist" >> ./.junest/etc/pacman.conf
	}
	###_enable_chaoticaur

	# CUSTOM MIRRORLIST, THIS SHOULD SPEEDUP THE INSTALLATION OF THE PACKAGES IN PACMAN (COMMENT EVERYTHING TO USE THE DEFAULT MIRROR)
	function _custom_mirrorlist(){
		#COUNTRY=$(curl -i ipinfo.io | grep country | cut -c 15- | cut -c -2)
		rm -R ./.junest/etc/pacman.d/mirrorlist
		wget -q https://archlinux.org/mirrorlist/all/ -O - | awk NR==2 RS= | sed 's/#Server/Server/g' >> ./.junest/etc/pacman.d/mirrorlist # ENABLES WORLDWIDE MIRRORS
		#wget -q https://archlinux.org/mirrorlist/?country="$(echo $COUNTRY)" -O - | sed 's/#Server/Server/g' >> ./.junest/etc/pacman.d/mirrorlist # ENABLES MIRRORS OF YOUR COUNTY
	}
	_custom_mirrorlist

	# BYPASS SIGNATURE CHECK LEVEL
	sed -i 's/#SigLevel/SigLevel/g' ./.junest/etc/pacman.conf
	sed -i 's/Required DatabaseOptional/Never/g' ./.junest/etc/pacman.conf

	# UPDATE ARCH LINUX IN JUNEST
	./.local/share/junest/bin/junest -- sudo pacman -Syy
	./.local/share/junest/bin/junest -- sudo pacman --noconfirm -Syu
else
	cd ..
	echo "-------------------------------------"
	echo " RESTORATION OF BACKUPS IN PROGRESS"
	echo "-------------------------------------"
	rsync -av ./junest-backups/* ./"$APP".AppDir/.junest/ | echo -e "\n◆ Restore the content of the Arch Linux container, please wait"
	rsync -av ./stock-cache/* ./"$APP".AppDir/.cache/ | echo "◆ Restore the content of JuNest's ~/.cache directory"
	rsync -av ./stock-local/* ./"$APP".AppDir/.local/ | echo -e "◆ Restore the content of JuNest's ~/.local directory\n"
	echo -e "-----------------------------------------------------------\n"
	cd ./"$APP".AppDir || return
fi

# INSTALL THE PROGRAM USING YAY
./.local/share/junest/bin/junest -- yay -Syy
./.local/share/junest/bin/junest -- gpg --keyserver keyserver.ubuntu.com --recv-key C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF # UNCOMMENT IF YOU USE THE AUR
if [ ! -z "$BASICSTUFF" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$BASICSTUFF"
fi
if [ ! -z "$COMPILERS" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$COMPILERS"
fi
if [ ! -z "$DEPENDENCES" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$DEPENDENCES"
fi
if [ ! -z "$APP" ]; then
	./.local/share/junest/bin/junest -- yay --noconfirm -S "$APP"
else
	echo "No app found, exiting" exit 0
fi

# DO A BACKUP OF THE CURRENT STATE OF JUNEST
cd ..
echo -e "\n-----------------------------------------------------------"
echo " BACKUP OF JUNEST FOR FURTHER APPIMAGE BUILDING ATTEMPTS"
echo "-----------------------------------------------------------"
mkdir -p ./junest-backups
mkdir -p ./stock-cache
mkdir -p ./stock-local
rsync -av --ignore-existing ./"$APP".AppDir/.junest/* ./junest-backups/ | echo -e "\n◆ Backup the content of the Arch Linux container, please wait"
rsync -av --ignore-existing ./"$APP".AppDir/.cache/* ./stock-cache/ | echo "◆ Backup the content of JuNest's ~/.cache directory"
rsync -av --ignore-existing ./"$APP".AppDir/.local/* ./stock-local/ | echo -e "◆ Backup the content of JuNest's ~/.local directory\n"
echo -e "-----------------------------------------------------------\n"
cd ./"$APP".AppDir || return

# SET THE LOCALE (DON'T TOUCH THIS)
#sed "s/# /#>/g" ./.junest/etc/locale.gen | sed "s/#//g" | sed "s/>/#/g" >> ./locale.gen # UNCOMMENT TO ENABLE ALL THE LANGUAGES
#sed "s/#$(echo $LANG)/$(echo $LANG)/g" ./.junest/etc/locale.gen >> ./locale.gen # ENABLE ONLY YOUR LANGUAGE, COMMENT IF YOU NEED MORE THAN ONE
#rm ./.junest/etc/locale.gen
#mv ./locale.gen ./.junest/etc/locale.gen
rm ./.junest/etc/locale.conf
#echo "LANG=$LANG" >> ./.junest/etc/locale.conf
sed -i 's/LANG=${LANG:-C}/LANG=$LANG/g' ./.junest/etc/profile.d/locale.sh
#./.local/share/junest/bin/junest -- sudo pacman --noconfirm -S glibc gzip
#./.local/share/junest/bin/junest -- sudo locale-gen

# ...ADD THE ICON AND THE DESKTOP FILE AT THE ROOT OF THE APPDIR...
rm -R -f ./*.desktop
LAUNCHER=$(grep -iRl $BIN ./.junest/usr/share/applications/* | grep ".desktop" | head -1)
cp -r "$LAUNCHER" ./
ICON=$(cat $LAUNCHER | grep "Icon=" | cut -c 6-)
cp -r ./.junest/usr/share/icons/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/22x22/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/24x24/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/32x32/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/48x48/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/64x64/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/128x128/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/192x192/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/256x256/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/512x512/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/icons/hicolor/scalable/apps/*"$ICON"* ./ 2>/dev/null
cp -r ./.junest/usr/share/pixmaps/*"$ICON"* ./ 2>/dev/null

# TEST IF THE DESKTOP FILE AND THE ICON ARE IN THE ROOT OF THE FUTURE APPIMAGE (./*AppDir/*)
if test -f ./*.desktop; then
	echo -e "◆ The .desktop file is available in $APP.AppDir/\n"
elif test -f ./.junest/usr/bin/"$BIN"; then
 	echo -e "◆ No .desktop file available for $APP, creating a new one...\n"
 	cat <<-HEREDOC >> ./"$APP".desktop
	[Desktop Entry]
	Version=1.0
	Type=Application
	Name=$(echo "$APP" | tr a-z A-Z)
	Comment=
	Exec=$BIN
	Icon=tux
	Categories=Utility;
	Terminal=true
	StartupNotify=true
	HEREDOC
	wget https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/favicon.ico -O ./tux.png
else
	echo "No binary in path... aborting all the processes."
	exit 0
fi

# ...AND FINALLY CREATE THE APPRUN, IE THE MAIN SCRIPT TO RUN THE APPIMAGE!
# EDIT THE FOLLOWING LINES IF YOU THINK SOME ENVIRONMENT VARIABLES ARE MISSING
rm -R -f ./AppRun
cat >> ./AppRun << 'EOF'
#!/bin/sh
HERE="$(dirname "$(readlink -f $0)")"
export UNION_PRELOAD=$HERE
export JUNEST_HOME=$HERE/.junest
export PATH=$PATH:$HERE/.local/share/junest/bin

if test -f /etc/resolv.conf; then ETC_RESOLV=' --bind /etc/resolv.conf /etc/resolv.conf '; fi
if test -d /media; then MNT_MEDIA_DIR=' --bind /media /media '; fi
if test -d /mnt; then MNT_DIR=' --bind /mnt /mnt '; fi
if test -d /opt; then OPT_DIR=' --bind /opt /opt '; fi
if test -d /run/user; then USR_LIB_LOCALE_DIR=' --bind /usr/lib/locale /usr/lib/locale '; fi
if test -d /usr/share/fonts; then USR_SHARE_FONTS_DIR=' --bind /usr/share/fonts /usr/share/fonts '; fi
if test -d /usr/share/themes; then USR_SHARE_THEMES_DIR=' --bind /usr/share/themes /usr/share/themes '; fi

BINDS=" $ETC_RESOLV $MNT_MEDIA_DIR $MNT_DIR $OPT_DIR $USR_LIB_LOCALE_DIR $USR_SHARE_FONTS_DIR $USR_SHARE_THEMES_DIR "

if test -f $JUNEST_HOME/usr/lib/libselinux.so; then export LD_LIBRARY_PATH=/lib/:/lib64/:/lib/x86_64-linux-gnu/:/usr/lib/:"${LD_LIBRARY_PATH}"; fi

EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g')
$HERE/.local/share/junest/bin/junest -n -b "$BINDS" -- $EXEC "$@"
EOF
chmod a+x ./AppRun

# REMOVE "READ-ONLY FILE SYSTEM" ERRORS
sed -i 's#${JUNEST_HOME}/usr/bin/junest_wrapper#${HOME}/.cache/junest_wrapper.old#g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's/rm -f "${JUNEST_HOME}${bin_path}_wrappers/#rm -f "${JUNEST_HOME}${bin_path}_wrappers/g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's/ln/#ln/g' ./.local/share/junest/lib/core/wrappers.sh
sed -i 's#--bind "$HOME" "$HOME"#--bind /home /home --bind-try /run/user /run/user#g' .local/share/junest/lib/core/namespace.sh
sed -i 's/rm -f "$file"/test -f "$file"/g' ./.local/share/junest/lib/core/wrappers.sh

# EXIT THE APPDIR
cd ..

# EXTRACT PACKAGE CONTENT
echo "-----------------------------------------------------------"
echo " EXTRACTING DEPENDENCES"
echo -e "-----------------------------------------------------------\n"

mkdir -p base
rm -R -f ./base/*

tar fx "$(find ./"$APP".AppDir -name "$APP-[0-9]*zst" | head -1)" -C ./base/
VERSION=$(cat ./base/.PKGINFO | grep pkgver | cut -c 10- | sed 's@.*:@@')

mkdir -p deps
rm -R -f ./deps/*

function _download_missing_packages() {
	localpackage=$(find ./"$APP".AppDir -name "$arg-[0-9]*zst")
	if ! test -f "$localpackage"; then
		./"$APP".AppDir/.local/share/junest/bin/junest -- yay --noconfirm -Sw "$arg"
	fi
}

function _extract_package() {
	_download_missing_packages &> /dev/null
	pkgname=$(find ./"$APP".AppDir -name "$arg-[0-9]*zst")
	if test -f "$pkgname"; then
		if ! grep -q "$(echo "$pkgname" | sed 's:.*/::')" ./packages 2>/dev/null;then
			echo "◆ Extracting $(echo "$pkgname" | sed 's:.*/::')"
			tar fx "$pkgname" -C ./deps/
			echo "$(echo "$pkgname" | sed 's:.*/::')" >> ./packages
		else
			tar fx "$pkgname" -C ./deps/
			echo "$(echo "$pkgname" | sed 's:.*/::')" >> ./packages
		fi
	fi
}

ARGS=$(echo "$DEPENDENCES" | tr " " "\n")
for arg in $ARGS; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps
 	rm -f ./deps/.*
done

DEPS=$(cat ./base/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<")
for arg in $DEPS; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps
 	rm -f ./deps/.*
done

DEPS2=$(cat ./depdeps 2>/dev/null | uniq)
for arg in $DEPS2; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps2
 	rm -f ./deps/.*
done

DEPS3=$(cat ./depdeps2 2>/dev/null | uniq)
for arg in $DEPS3; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps3
 	rm -f ./deps/.*
done

DEPS4=$(cat ./depdeps3 2>/dev/null | uniq)
for arg in $DEPS4; do
	_extract_package
 	cat ./deps/.PKGINFO 2>/dev/null | grep "depend = " | grep -v "makedepend = " | cut -c 10- | grep -v "=\|>\|<" > depdeps4
 	rm -f ./deps/.*
done

rm -f ./packages

# REMOVE SOME BLOATWARES
echo Y | rm -R -f ./"$APP".AppDir/.cache/yay/*
find ./"$APP".AppDir/.junest/usr/share/doc/* -not -iname "*$BIN*" -a -not -name "." -delete #REMOVE ALL DOCUMENTATION NOT RELATED TO THE APP
find ./"$APP".AppDir/.junest/usr/share/locale/*/*/* -not -iname "*$BIN*" -a -not -name "." -delete #REMOVE ALL ADDITIONAL LOCALE FILES
rm -R -f ./"$APP".AppDir/.junest/etc/makepkg.conf
rm -R -f ./"$APP".AppDir/.junest/etc/pacman.conf
rm -R -f ./"$APP".AppDir/.junest/usr/include #FILES RELATED TO THE COMPILER
rm -R -f ./"$APP".AppDir/.junest/usr/man #APPIMAGES ARE NOT MENT TO HAVE MAN COMMAND
rm -R -f ./"$APP".AppDir/.junest/var/* #REMOVE ALL PACKAGES DOWNLOADED WITH THE PACKAGE MANAGER

echo -e "\n-----------------------------------------------------------"
echo " IMPLEMENTING NECESSARY LIBRARIES (MAY TAKE SEVERAL MINUTES)"
echo -e "-----------------------------------------------------------\n"

# SAVE FILES USING KEYWORDS
BINSAVED="certificates SAVEBINSPLEASE" # Enter here keywords to find and save in /usr/bin
SHARESAVED="certificates SAVESHAREPLEASE" # Enter here keywords or file/folder names to save in both /usr/share and /usr/lib
LIBSAVED="pk p11 alsa jack pipewire pulse python" # Enter here keywords or file/folder names to save in /usr/lib

# STEP 2, FUNCTION TO SAVE THE BINARIES IN /usr/bin THAT ARE NEEDED TO MADE JUNEST WORK, PLUS THE MAIN BINARY/BINARIES OF THE APP
# IF YOU NEED TO SAVE MORE BINARIES, LIST THEM IN THE "BINSAVED" VARIABLE. COMMENT THE LINE "_savebins" IF YOU ARE NOT SURE.
function _savebins(){
	mkdir save
	mv ./"$APP".AppDir/.junest/usr/bin/*$BIN* ./save/
	mv ./"$APP".AppDir/.junest/usr/bin/bash ./save/
 	mv ./"$APP".AppDir/.junest/usr/bin/bwrap ./save/
	mv ./"$APP".AppDir/.junest/usr/bin/env ./save/
	mv ./"$APP".AppDir/.junest/usr/bin/sh ./save/
 	mv ./"$APP".AppDir/.junest/usr/bin/tr ./save/
   	mv ./"$APP".AppDir/.junest/usr/bin/tty ./save/
	for arg in $BINSAVED; do
		mv ./"$APP".AppDir/.junest/usr/bin/*"$arg"* ./save/
	done
	rm -R -f ./"$APP".AppDir/.junest/usr/bin/*
	mv ./save/* ./"$APP".AppDir/.junest/usr/bin/
	rmdir save
}
_savebins 2> /dev/null

# STEP 3, MOVE UNNECESSARY LIBRARIES TO A BACKUP FOLDER (FOR TESTING PURPOSES)
mkdir save

function _binlibs(){
	readelf -d ./"$APP".AppDir/.junest/usr/bin/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	mv ./"$APP".AppDir/.junest/usr/lib/ld-linux-x86-64.so* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/*$APP* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/*$BIN* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/libdw* ./save/
	mv ./"$APP".AppDir/.junest/usr/lib/libelf* ./save/
	for arg in $SHARESAVED; do
		mv ./"$APP".AppDir/.junest/usr/lib/*"$arg"* ./save/
	done
	ARGS=$(tail -n +2 ./list | sort -u | uniq)
	for arg in $ARGS; do
		mv ./"$APP".AppDir/.junest/usr/lib/$arg* ./save/
		find ./"$APP".AppDir/.junest/usr/lib/ -name "$arg" -exec cp -r --parents -t save/ {} +
	done
	rm -R -f "$(find ./save/ | sort | grep ".AppDir" | head -1)"
	rm list
}

function _include_swrast_dri(){
	mkdir ./save/dri
	mv ./"$APP".AppDir/.junest/usr/lib/dri/swrast_dri.so ./save/dri/
}

function _libkeywords(){
	for arg in $LIBSAVED; do
		mv ./"$APP".AppDir/.junest/usr/lib/*"$arg"* ./save/
	done
}

function _readelf_save(){
	readelf -d ./save/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./save/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	ARGS=$(tail -n +2 ./list | sort -u | uniq)
	for arg in $ARGS; do
		mv ./"$APP".AppDir/.junest/usr/lib/"$arg"* ./save/
		find ./"$APP".AppDir/.junest/usr/lib/ -name "$arg" -exec cp -r --parents -t save/ {} +
	done
	rsync -av ./save/"$APP".AppDir/.junest/usr/lib/* ./save/
 	rm -R -f "$(find ./save/ | sort | grep ".AppDir" | head -1)"
	rm list
}

function _readelf_base(){
	readelf -d ./base/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./base/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
}

function _readelf_deps(){
	readelf -d ./deps/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
	readelf -d ./deps/*/*/*/*/* | grep .so | sed 's:.* ::' | cut -c 2- | sed 's/\(^.*so\).*$/\1/' | uniq >> ./list
}

function _liblibs(){
 	_readelf_base
  	_readelf_deps
	ARGS=$(tail -n +2 ./list | sort -u | uniq)
	for arg in $ARGS; do
		mv ./"$APP".AppDir/.junest/usr/lib/"$arg"* ./save/
		find ./"$APP".AppDir/.junest/usr/lib/ -name "$arg" -exec cp -r --parents -t save/ {} +
	done
	rsync -av ./save/"$APP".AppDir/.junest/usr/lib/* ./save/
 	rm -R -f "$(find ./save/ | sort | grep ".AppDir" | head -1)"
	rm list
	_readelf_save
	_readelf_save
	_readelf_save
	_readelf_save
}

function _mvlibs(){
	rm -R -f ./"$APP".AppDir/.junest/usr/lib/*
	mv ./save/* ./"$APP".AppDir/.junest/usr/lib/
}

_binlibs 2> /dev/null

#_include_swrast_dri 2> /dev/null

_libkeywords 2> /dev/null

_liblibs 2> /dev/null

_mvlibs 2> /dev/null

rmdir save

# STEP 4, SAVE ONLY SOME DIRECTORIES CONTAINED IN /usr/share
# IF YOU NEED TO SAVE MORE FOLDERS, LIST THEM IN THE "SHARESAVED" VARIABLE. COMMENT THE LINE "_saveshare" IF YOU ARE NOT SURE.
function _saveshare(){
	mkdir save
	mv ./"$APP".AppDir/.junest/usr/share/*$APP* ./save/
 	mv ./"$APP".AppDir/.junest/usr/share/*$BIN* ./save/
	mv ./"$APP".AppDir/.junest/usr/share/fontconfig ./save/
	mv ./"$APP".AppDir/.junest/usr/share/glib-* ./save/
	mv ./"$APP".AppDir/.junest/usr/share/locale ./save/
	mv ./"$APP".AppDir/.junest/usr/share/mime ./save/
	mv ./"$APP".AppDir/.junest/usr/share/wayland ./save/
	mv ./"$APP".AppDir/.junest/usr/share/X11 ./save/
	for arg in $SHARESAVED; do
		mv ./"$APP".AppDir/.junest/usr/share/*"$arg"* ./save/
	done
	rm -R -f ./"$APP".AppDir/.junest/usr/share/*
	mv ./save/* ./"$APP".AppDir/.junest/usr/share/
 	rmdir save
}
_saveshare 2> /dev/null

# RSYNC THE CONTENT OF THE APP'S PACKAGE
echo -e "\n-----------------------------------------------------------"
rm -R -f ./base/.*
rsync -av ./base/* ./"$APP".AppDir/.junest/ | echo -e "◆ Rsync the content of the \"$APP\" package"

# RSYNC DEPENDENCES
rm -R -f ./deps/.*
rsync -av ./deps/* ./"$APP".AppDir/.junest/ | echo -e "◆ Rsync all dependeces, please wait..."
echo -e "-----------------------------------------------------------\n"

# ADDITIONAL REMOVALS
#rm -R -f ./"$APP".AppDir/.junest/usr/lib/libLLVM-* #INCLUDED IN THE COMPILATION PHASE, CAN SOMETIMES BE EXCLUDED FOR DAILY USE
rm -R -f ./"$APP".AppDir/.junest/usr/lib/python*/__pycache__/* #IF PYTHON IS INSTALLED, REMOVING THIS DIRECTORY CAN SAVE SEVERAL MEGABYTES

# REMOVE THE INBUILT HOME
rm -R -f ./"$APP".AppDir/.junest/home

# ENABLE MOUNTPOINTS
mkdir -p ./"$APP".AppDir/.junest/home
mkdir -p ./"$APP".AppDir/.junest/media
mkdir -p ./"$APP".AppDir/.junest/usr/lib/locale
mkdir -p ./"$APP".AppDir/.junest/usr/share/fonts
mkdir -p ./"$APP".AppDir/.junest/usr/share/themes
mkdir -p ./"$APP".AppDir/.junest/run/user

# CREATE THE APPIMAGE
if test -f ./*.AppImage; then
	rm -R -f ./*archimage*.AppImage
fi
ARCH=x86_64 VERSION=$(./appimagetool -v | grep -o '[[:digit:]]*') ./appimagetool -s ./"$APP".AppDir
mv ./*AppImage ./"$(cat ./"$APP".AppDir/*.desktop | grep 'Name=' | head -1 | cut -c 6- | sed 's/ /-/g')"_"$VERSION"-archimage3.4.3-x86_64.AppImage

its also a preview of a new improvement to my archimage project (the "liblibs" function is faster)

@kenderipa
Copy link

kenderipa commented Jul 21, 2024

@kenderipa please try this other script I wrote for you
yt-dlg

its also a preview of a new improvement to my archimage project (the "liblibs" function is faster)

Same as my version: works as long as it's not symlinked to ~/.local/bin.

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

No branches or pull requests

6 participants