Skip to content

Commit

Permalink
refactor and use new uruntime
Browse files Browse the repository at this point in the history
  • Loading branch information
Samueru-sama authored Nov 20, 2024
1 parent 387f24b commit 9fa6b27
Showing 1 changed file with 37 additions and 18 deletions.
55 changes: 37 additions & 18 deletions strawberry-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ export ARCH="$(uname -m)"
export APPIMAGE_EXTRACT_AND_RUN=1
export VERSION=$(pacman -Q $PACKAGE | awk 'NR==1 {print $2; exit}')

APPIMAGETOOL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage"
UPINFO="gh-releases-zsync|$(echo $GITHUB_REPOSITORY | tr '/' '|')|continuous|*$ARCH.AppImage.zsync"
LIB4BN="https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin"
URUNTIME=$(wget -q https://api.github.com/repos/VHSgunzo/uruntime/releases -O - \
| sed 's/[()",{} ]/\n/g' | grep -oi "https.*appimage.*dwarfs.*$ARCH$" | head -1)

# Prepare AppDir
mkdir -p ./"$PACKAGE"/AppDir/shared/lib \
./"$PACKAGE"/AppDir/usr/share/applications \
./"$PACKAGE"/AppDir/etc
cd ./"$PACKAGE"/AppDir

cp /usr/share/applications/$DESKTOP ./usr/share/applications
cp /usr/share/applications/$DESKTOP ./
cp /usr/share/icons/hicolor/128x128/apps/"$ICON" ./
cp -v /usr/share/applications/$DESKTOP ./usr/share/applications
cp -v /usr/share/applications/$DESKTOP ./
cp -v /usr/share/icons/hicolor/128x128/apps/"$ICON" ./
cp -v /usr/share/icons/hicolor/128x128/apps/"$ICON" ./.DirIcon

# ADD LIBRARIES
wget "$LIB4BN" -O ./lib4bin
Expand Down Expand Up @@ -54,39 +56,56 @@ cp -r /usr/lib/gstreamer-1.0 ./shared/lib
cp -nv /usr/lib/libgst* ./shared/lib

# Patch a relative interpreter for the gstreamer plugins
echo "Patching Gstreamer bins..."
rm -f ./shared/lib/gstreamer-1.0/gst-plugins-doc-cache-generator || true
echo "Sharunning Gstreamer bins..."
rm -f ./shared/lib/gstreamer-1.0/libgstopengl* || true
patchelf --set-interpreter "./shared/lib/ld-linux-x86-64.so.2" ./shared/lib/gstreamer-1.0/gst-*
for plugin in ./shared/lib/gstreamer-1.0/gst-*; do
if file "$plugin" | grep -i 'elf.*executable'; then
mv "$plugin" ./shared/bin && ln -s ../../../sharun "$plugin"
echo "Sharan $plugin"
else
echo "$plugin is not a binary, skipping..."
fi
done

# DEPLOY DEPENDENCIES OF EXTRA LIBS
echo "Deploying deps of Gstreamer..."
ldd ./shared/lib/libgst* \
./shared/lib/gstreamer-1.0/* 2>/dev/null \
| awk -F"[> ]" '{print $4}' | xargs -I {} cp -nv {} ./shared/lib || true
| awk -F"[> ]" '{print $4}' | xargs -I {} cp -nv {} ./shared/lib || true

echo "Stripping libs and bins..."
find ./shared/lib ./shared/bin -type f -exec strip -s -R .comment --strip-unneeded {} ';'

# Prepare sharun
echo "Preparing sharun..."
echo 'SHARUN_WORKING_DIR="${SHARUN_DIR}"
LD_LIBRARY_PATH="${SHARUN_DIR}/shared/lib:${SHARUN_DIR}/shared/lib/pulseaudio:${LD_LIBRARY_PATH}"' > ./.env
ln ./sharun ./AppRun
./sharun -g

# Remove bloats
echo "Removing bloats..."
rm -f ./shared/lib/libLLVM* ./shared/lib/libgallium* || true

# MAKE APPIAMGE WITH FUSE3 COMPATIBLE APPIMAGETOOL
# MAKE APPIMAGE WITH URUNTIME
cd ..
wget -q "$APPIMAGETOOL" -O ./appimagetool
chmod +x ./appimagetool

./appimagetool --comp zstd \
--mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 \
-n -u "$UPINFO" "$PWD"/AppDir "$PWD"/"$PACKAGE"-"$VERSION"-"$ARCH".AppImage
wget -q "$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 -S22 -B16 \
--header uruntime \
-i ./AppDir -o "$PACKAGE"-"$VERSION"-anylinux-"$ARCH".AppImage

echo "Generating zsync file..."
zsyncmake *.AppImage -u *.AppImage

mv ./*.AppImage* ../
cd ..
Expand Down

0 comments on commit 9fa6b27

Please sign in to comment.