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

Make appimagetool run on Alpine/musl #21

Closed
probonopd opened this issue Dec 8, 2019 · 4 comments
Closed

Make appimagetool run on Alpine/musl #21

probonopd opened this issue Dec 8, 2019 · 4 comments

Comments

@probonopd
Copy link
Owner

probonopd commented Dec 8, 2019

Initial support is available, this allows us to package musl-based applications into AppImages:

#############################################
# Download and extract minimal Alpine system
#############################################

wget http://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/alpine-minirootfs-3.11_rc1-x86_64.tar.gz
mkdir -p ./miniroot
cd ./miniroot
tar xf ../alpine-minirootfs-*.tar.gz
cd -

#############################################
# Prepare chroot
#############################################

sudo mount -o bind /dev miniroot/dev
sudo mount -t proc none miniroot/proc
sudo mount -t sysfs none miniroot/sys
sudo cp -p /etc/resolv.conf miniroot/etc/
sudo chroot miniroot /bin/sh <<\EOF

#############################################
# Now inside chroot
#############################################

# Upgrade to Edge, the rolling Alpine release (if we don't have it already)
sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories
apk upgrade --update-cache --available

# Install dependencies and download appimagetool
apk add wget squashfs-tools desktop-file-utils curl appstream libc6-compat
wget -c https://raw.githubusercontent.com/probonopd/uploadtool/master/upload.sh -O uploadtool
chmod +x uploadtool 
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-x86_64
wget http://192.168.0.14/home/me/go/src/github.com/probonopd/go-appimage/src/appimagetool/appimagetool ; chmod +x appimagetool # Not the AppImage for now
export PATH=$(readlink -f .):$PATH

# Install patchelf 0.9 because 0.10 cripples files
apk add  --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main/ patchelf=0.9-r2
# or from source 
apk add alpine-sdk bash util-linux wget autoconf gettext automake
wget https://github.com/NixOS/patchelf/archive/0.9.tar.gz # 0.10 cripples my files
tar xf *.tar.gz 
cd patchelf-*/
./bootstrap.sh
./configure --prefix=/usr
make -j$(nproc)
sudo make install
cd -

# Get the application to be packaged
apk add kcalc
apk fetch kcalc
export VERSION=$(ls kcalc-*.apk | cut -d - -f 2)
mkdir -p appdir ; cd appdir
tar xfv ../kcalc*.apk
cd -

./appimagetool -s deploy appdir/usr/share/applications/*.desktop

./appimagetool appdir/

#############################################
# Exit chroot and clean up
#############################################

exit
EOF
sudo umount miniroot/proc miniroot/sys miniroot/dev
@probonopd
Copy link
Owner Author

So appimagetool itself is running on musl based systems like Alpine, and the resulting AppImages (that bundle everything) can run on glibc-based systems.

We are now blocked by AppImage/AppImageKit#1015.

@probonopd
Copy link
Owner Author

@s-zeid just confirmed that the appimagetool AppImage using the experimental static AppImage runtime works on Alpine Linux.

But appimaged is dynamically linked. Why? Can we make it static?

@probonopd
Copy link
Owner Author

probonopd commented Nov 6, 2022

Well, appimagetool runs on Alpine but not in -s deploy mode yet, because it assumes to be working on glibc. For musl, it's probably a matter of leaving a few things away?

VERSION=1 ./appimagetool-730-x86_64.AppImage -s deploy ./xterm.AppDir/usr/share/applications/
xterm.desktop 
AppDir path: xterm.AppDir
Exec= key contains: xterm
Icon= key contains: xterm-color_48x48
2022/11/06 20:14:46 Gathering all required libraries for the AppDir...
2022/11/06 20:14:46 len(allELFsUnderPath): 1
2022/11/06 20:14:46 libraryLocations: [xterm.AppDir/usr/bin /usr/lib64 /lib64 /usr/lib /lib /usr/lib/x86_64-linux-gnu/libfakeroot /usr/local/lib /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /lib32 /usr/lib32]
2022/11/06 20:14:46 len(allELFs): 25
2022/11/06 20:14:46 Deploying /lib/ld-musl-x86_64.so.1...
2022/11/06 20:14:46 Patching ld-linux...
2022/11/06 20:14:46 Determining gconv (for GCONV_PATH)...
ERROR Could not deploy the interpreter: did not find gconv
/ # 

@probonopd
Copy link
Owner Author

Disabled the fatal error on that check for now, and as a result I am able to deploy applications from Alpine Linux with ``-s deploy`.

Hence closing. Further improvements can be addressed in separate tickets.

References:

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

1 participant