probonopd / go-appimage

Go implementation of AppImage tools
MIT License
681 stars 69 forks source link

"patchelf": executable file not found in $PATH #208

Closed probonopd closed 2 years ago

probonopd commented 2 years ago
APPNAME=leafpad
URL=http://ftp.us.debian.org/debian/pool/main/l/leafpad/leafpad_0.8.18.1-5_amd64.deb
VERSION=$(echo "$URL" | cut -d / -f 9 | cut -d _ -f 2 | cut -d - -f 1)
wget -c "$URL"
mkdir -p "$APPNAME.AppDir"
cd "$APPNAME.AppDir"
dpkg -x ../$(basename "$URL") .
cd ..

wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases -O - | grep "appimagetool-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2)
chmod +x appimagetool-*.AppImage
./appimagetool-*.AppImage -s deploy $APPNAME.AppDir/usr/share/applications/*.desktop # Bundle EVERYTHING

ERROR Could not determine ELF interpreter: exec: "patchelf": executable file not found in $PATH

$ ./appimagetool-*.AppImage --version
appimagetool version 57
probonopd commented 2 years ago

Why do we have 2 very similar functions?

probonopd commented 2 years ago

This code has become non-linear and as a result, it is not easy to know what is running in which sequence.

For example, I am wondering why

https://github.com/probonopd/go-appimage/blob/eeb902e1acc9b94793d6d8630b378abed197c741/src/appimagetool/cli.go#L154-L164

does not seem to be running before we get

$ ./squashfs-root/usr/bin/appimagetool -s deploy $APPNAME.AppDir/usr/share/applications/*.desktop 2>&1 | more
AppDir path: leafpad.AppDir
Exec= key contains: leafpad
Icon= key contains: leafpad
2022/05/08 15:34:09 Gathering all required libraries for the AppDir...
patchelf --print-rpath leafpad.AppDir/usr/bin/leafpad
ERROR patchelf --print-rpath leafpad.AppDir/usr/bin/leafpad: : exec: "patchelf":
 executable file not found in $PATH

Would the program still be linear, one could read the code from top to bottom, ideally in one file. No functions.

This way, it is cumbersome!

I really don't like code that doesn't have a clear linear structure and is broken down into functions.

probonopd commented 2 years ago

This code has become non-linear and as a result, it is not easy to know what is running in which sequence.

For example, I am wondering why

does not seem to be running before we get

$ ./squashfs-root/usr/bin/appimagetool -s deploy $APPNAME.AppDir/usr/share/applications/*.desktop 2>&1 | more
AppDir path: leafpad.AppDir
Exec= key contains: leafpad
Icon= key contains: leafpad
2022/05/08 15:34:09 Gathering all required libraries for the AppDir...
patchelf --print-rpath leafpad.AppDir/usr/bin/leafpad
ERROR patchelf --print-rpath leafpad.AppDir/usr/bin/leafpad: : exec: "patchelf":
 executable file not found in $PATH

Would the program still be linear, one could read the code from top to bottom, ideally in one file. No functions.

This way, it is cumbersome!

I really don't like code that doesn't have a clear linear structure and is broken down into functions.

https://github.com/probonopd/go-appimage/blob/eeb902e1acc9b94793d6d8630b378abed197c741/src/appimagetool/cli.go#L154-L164

which is in func bootstrapAppImageBuild(c *cli.Context) error needs to run before func AppDirDeploy(path string). Is it? How to find out? This code is not easy to read anymore.

Each tool should have exactly 1 source code file which executes instructions in a linear way from top to bottom. So that you exactly know what runs in which order by looking at just this file.

The only thing that seems to "call"(?) bootstrapAppImageBuild is

https://github.com/probonopd/go-appimage/blob/eeb902e1acc9b94793d6d8630b378abed197c741/src/appimagetool/cli.go#L224-L236

What is a &cli.App{} and what does Action: bootstrapAppImageBuild mean?

This coding style makes things cumbersome, and as a result, it's not fun to work on.

this cli business seems to come from github.com/urfave/cli/v2 v2.2.0`.

It seems to have come in with https://github.com/probonopd/go-appimage/pull/91/files.

This restructuring took the simplicity out of things, and made it cumbersome to understand the execution flow because things that once were linear and simple are now broken into functions and complicated, and no one knows what runs in what order.

probonopd commented 2 years ago

What is a &cli.App{} and what does Action: bootstrapAppImageBuild mean?

Moved the code that sets the $PATH out of bootstrapAppImageBuild and now it seems to be working.