Skip to content

Commit

Permalink
add appimage script with runimage base
Browse files Browse the repository at this point in the history
  • Loading branch information
Samueru-sama authored Feb 4, 2025
1 parent 08fc9d6 commit 73dac1b
Showing 1 changed file with 144 additions and 0 deletions.
144 changes: 144 additions & 0 deletions steam-runimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/usr/bin/env bash
set -e

# An example of steam packaging in a RunImage container

if [ ! -x 'runimage' ]; then
echo '== download base RunImage'
curl -o runimage -L "https://github.com/VHSgunzo/runimage/releases/download/continuous/runimage-$(uname -m)"
chmod +x runimage
fi

run_install() {
set -e

INSTALL_PKGS=(
steam egl-wayland vulkan-radeon lib32-vulkan-radeon vulkan-tools
vulkan-intel lib32-vulkan-intel vulkan-nouveau lib32-vulkan-nouveau
vulkan-swrast lib32-vulkan-swrast lib32-libpipewire libpipewire pipewire
lib32-libpipewire libpulse lib32-libpulse vkd3d lib32-vkd3d wget
vulkan-mesa-layers lib32-vulkan-mesa-layers freetype2 lib32-freetype2 fuse2
yad mangohud lib32-mangohud gamescope gamemode zenity-gtk3 steam-screensaver-fix
)

echo '== checking for updates'
rim-update

echo '== install packages'
pac --needed --noconfirm -S "${INSTALL_PKGS[@]}"

echo '== install glibc with patches for Easy Anti-Cheat (optionally)'
yes|pac -S glibc-eac lib32-glibc-eac

echo '== install debloated llvm for space saving (optionally)'
LLVM=$(wget --retry-connrefused --tries=30 https://api.github.com/repos/Samueru-sama/llvm-libs-debloated/releases -O - \
| sed 's/[()",{} ]/\n/g' | grep -oi "https.*minimal.pkg.tar.zst$" | head -1)
wget --retry-connrefused --tries=30 "$LLVM" -O ./llvm-libs.pkg.tar.zst
pac -U --noconfirm ./llvm-libs.pkg.tar.zst
rm -f ./llvm-libs.pkg.tar.zst

echo '== shrink (optionally)'
pac -Rsndd --noconfirm wget gocryptfs adobe-source-code-pro-fonts jq \
gnupg webkit2gtk-4.1 perl vulkan-tools
rim-shrink --all
pac -Rsndd --noconfirm binutils


pac -Qi | awk -F': ' '/Name/ {name=$2}
/Installed Size/ {size=$2}
name && size {print name, size; name=size=""}' \
| column -t | grep MiB | sort -nk 2

VERSION=$(pacman -Q steam | awk 'NR==1 {print $2; exit}')
echo "$VERSION" > ~/version
cp /usr/share/icons/hicolor/256x256/apps/steam.png ~/
cp /usr/share/applications/steam.desktop ~/

echo '== create RunImage config for app (optionally)'
cat <<- 'EOF' > "$RUNDIR/config/Run.rcfg"
RIM_CMPRS_LVL="${RIM_CMPRS_LVL:=22}"
RIM_CMPRS_BSIZE="${RIM_CMPRS_BSIZE:=24}"
RIM_SYS_NVLIBS="${RIM_SYS_NVLIBS:=1}"
RIM_SHARE_ICONS="${RIM_SHARE_ICONS:=1}"
RIM_SHARE_FONTS="${RIM_SHARE_FONTS:=1}"
RIM_SHARE_THEMES="${RIM_SHARE_THEMES:=1}"
RIM_AUTORUN=steam-screensaver-fix-runtime
EOF

echo '== Build new DwarFS runimage with zstd 22 lvl and 24 block size'
rim-build -s steam.RunImage
}
export -f run_install

##########################

# enable OverlayFS mode, disable Nvidia driver check and run install steps
RIM_OVERFS_MODE=1 RIM_NO_NVIDIA_CHECK=1 ./runimage bash -c run_install
./steam.RunImage --runtime-extract
rm -f ./steam.RunImage

mv ./RunDir ./AppDir
mv ./AppDir/Run ./AppDir/AppRun

mv ~/steam.desktop ./AppDir
mv ~/steam.png ./AppDir
sed -i '30i\StartupWMClass=steam' ./AppDir/steam.desktop

# debloat
rm -rfv ./AppDir/sharun/bin/chisel \
./AppDir/rootfs/usr/lib*/libgo.so* \
./AppDir/rootfs/usr/lib*/libgphobos.so* \
./AppDir/rootfs/usr/lib*/libgfortran.so* \
./AppDir/rootfs/usr/bin/rsvg-convert \
./AppDir/rootfs/usr/bin/rav1e \
./AppDir/rootfs/usr/bin/rsvg-convert \
./AppDir/rootfs/usr/*/*pacman* \
./AppDir/rootfs/usr/share/gir-1.0 \
./AppDir/rootfs/var/lib/pacman \
./AppDir/rootfs/etc/pacman* \
./AppDir/rootfs/usr/share/licenses \
./AppDir/rootfs/usr/share/terminfo \
./AppDir/rootfs/usr/share/icons/AdwaitaLegacy

VERSION="$(cat ~/version)"
ARCH="$(uname -m)"
UPINFO="gh-releases-zsync|$(echo "$GITHUB_REPOSITORY" | tr '/' '|')|latest|*$ARCH.AppImage.zsync"

# make appimage with type2-runtime
# remove this if libappimage ever adopts support for dwarfs
APPIMAGETOOL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
wget --retry-connrefused --tries=30 "$APPIMAGETOOL" -O ./appimagetool
chmod +x ./appimagetool
./appimagetool --comp zstd \
--mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 \
--mksquashfs-opt -b --mksquashfs-opt 1M \
-n -u "$UPINFO" "$PWD"/AppDir "$PWD"/Steam-"$VERSION"-anylinux.squashfs-"$ARCH".AppImage

# make appimage with uruntime
URUNTIME=$(wget --retry-connrefused --tries=30 \
https://api.github.com/repos/VHSgunzo/uruntime/releases -O - \
| sed 's/[()",{} ]/\n/g' | grep -oi "https.*appimage.*dwarfs.*$ARCH$" | head -1)

wget --retry-connrefused --tries=30 "$URUNTIME" -O ./uruntime
chmod +x ./uruntime

# Add udpate info to runtime
echo "Adding update information \"$UPINFO\" to runtime..."
printf "$UPINFO" > data.upd_info

llvm-objcopy --update-section=.upd_info=data.upd_info \
--set-section-flags=.upd_info=noload,readonly ./uruntime
printf 'AI\x02' | dd of=./uruntime bs=1 count=3 seek=8 conv=notrunc

echo "Generating AppImage..."
./uruntime --appimage-mkdwarfs -f \
--set-owner 0 --set-group 0 \
--no-history --no-create-timestamp \
--compression zstd:level=22 -S24 -B16 \
--header uruntime \
-i ./AppDir -o Steam-"$VERSION"-anylinux.dwarfs-"$ARCH".AppImage

zsyncmake *dwarfs*.AppImage -u *dwarfs*.AppImage
echo "All Done!"

0 comments on commit 73dac1b

Please sign in to comment.