Skip to content

Commit 6bf8d86

Browse files
authored
refactor, use quick-sharun (#28)
1 parent 16d334b commit 6bf8d86

File tree

2 files changed

+67
-103
lines changed

2 files changed

+67
-103
lines changed

AppDir/AppRun renamed to AppDir/bin/photogimp.src.hook

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
CURRENTDIR="$(cd "${0%/*}" && echo "$PWD")"
44
CONFIGDIR="${XDG_CONFIG_HOME:-$HOME/.config}"
55
DATADIR="${XDG_DATA_HOME:-$HOME/.local/share}"
6-
ARGV0="${ARGV0:-$0}"
76

87
export GIMP3_DATADIR="$CURRENTDIR"/share/gimp/3.0
98
export GIMP3_SYSCONFDIR="$CURRENTDIR"/etc/gimp/3.0
@@ -51,15 +50,13 @@ _remove_photogimp() {
5150
fi
5251
}
5352

54-
if [ "$1" = "--photogimp" ]; then
55-
shift
56-
ENABLE_PHOTO_GIMP=1
57-
elif [ "$1" = "--remove-photogimp" ]; then
58-
shift
59-
_remove_photogimp
60-
elif basename "$ARGV0" | grep -qi "photogimp"; then
61-
ENABLE_PHOTO_GIMP=1
62-
fi
53+
case "$1" in
54+
--photogimp) shift; ENABLE_PHOTO_GIMP=1;;
55+
--remove-photogimp) shift; _remove_photogimp ;;
56+
esac
57+
case "$ARGV0" in
58+
*photogimp*|*Photogimp*|*PhotoGimp*|*PhotoGIMP*) ENABLE_PHOTO_GIMP=1;;
59+
esac
6360

6461
if [ "$ENABLE_PHOTO_GIMP" = 1 ]; then
6562
_install_photogimp
@@ -70,10 +67,3 @@ if [ "$ENABLE_PHOTO_GIMP" = 1 ]; then
7067
"$DATADIR"/applications/PhotoGIMP-AppImage.desktop
7168
fi
7269
fi
73-
74-
# needed for patched away hardcoded paths in gimp
75-
# this way we dont need to change the current working dir
76-
ln -sfn "$CURRENTDIR"/share /tmp/xdg69
77-
ln -sfn "$CURRENTDIR"/lib /tmp/o_0
78-
79-
exec "$CURRENTDIR"/bin/gimp "$@"

gimp-appimage.sh

Lines changed: 60 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,133 +2,107 @@
22

33
set -eux
44

5-
export ARCH="$(uname -m)"
6-
export APPIMAGE_EXTRACT_AND_RUN=1
7-
export VERSION="$(cat ~/version)"
8-
export STRACE_TIME=20
9-
export OUTNAME=GIMP-"$VERSION"-anylinux-"$ARCH".AppImage
10-
export OPTIMIZE_LAUNCH=1
11-
export DESKTOP=/usr/share/applications/gimp.desktop
12-
export ICON=/usr/share/icons/hicolor/256x256/apps/gimp.png
13-
export UPINFO="gh-releases-zsync|${GITHUB_REPOSITORY%/*}|${GITHUB_REPOSITORY#*/}|latest|*$ARCH.AppImage.zsync"
14-
15-
LIB4BN="https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin"
5+
ARCH="$(uname -m)"
6+
VERSION="$(cat ~/version)"
7+
SHARUN="https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/quick-sharun.sh"
168
URUNTIME="https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/uruntime2appimage.sh"
179
PHOTOGIMP="https://github.com/Diolinux/PhotoGIMP/releases/latest/download/PhotoGIMP-linux.zip"
1810

19-
# Prepare AppDir
20-
mkdir -p ./AppDir/etc ./AppDir/share/icons
21-
cd ./AppDir
11+
export ADD_HOOKS="self-updater.bg.hook"
12+
export STRACE_TIME=15
13+
export DEPLOY_OPENGL=1
14+
export DEPLOY_PYTHON=1
15+
export DEPLOY_LOCALE=1
16+
export DEPLOY_LIBHEIF=1
17+
export PYTHON_PACKAGES=PyGObject
18+
export DESKTOP=/usr/share/applications/gimp.desktop
19+
export ICON=/usr/share/icons/hicolor/256x256/apps/gimp.png
20+
export UPINFO="gh-releases-zsync|${GITHUB_REPOSITORY%/*}|${GITHUB_REPOSITORY#*/}|latest|*$ARCH.AppImage.zsync"
21+
export OUTNAME=GIMP-"$VERSION"-anylinux-"$ARCH".AppImage
22+
export OPTIMIZE_LAUNCH=1
2223

2324
# ADD LIBRARIES
24-
wget "$LIB4BN" -O ./lib4bin
25-
chmod +x ./lib4bin
26-
xvfb-run -a -- ./lib4bin -p -v -k -s -e -y \
27-
--python-pkg PyGObject \
28-
/usr/bin/gimp* \
29-
/usr/bin/gjs* \
30-
/usr/bin/gegl \
31-
/usr/lib/libgimp* \
32-
/usr/lib/gimp/*/modules/* \
33-
/usr/lib/gdk-pixbuf-*/*/*/* \
34-
/usr/lib/gtk-*/*/*/* \
35-
/usr/lib/gio/*/* \
36-
/usr/lib/babl-*/* \
37-
/usr/lib/gegl-*/* \
38-
/usr/lib/gvfs/* \
39-
/usr/lib/libcfitsio.so* \
40-
/usr/lib/libgthread-2.0.so* \
41-
/usr/lib/libheif/* \
42-
/usr/lib/libjbig2dec* \
43-
/usr/lib/libgpm* \
44-
/usr/lib/libpaper* \
45-
/usr/lib/libSDL* \
46-
/usr/lib/libXpm.so* \
47-
/usr/lib/libheif.so* \
48-
/usr/lib/libwmf* \
49-
/usr/lib/libudev.so* \
50-
/usr/lib/libaa.so* \
25+
wget --retry-connrefused --tries=30 "$SHARUN" -O ./quick-sharun
26+
chmod +x ./quick-sharun
27+
./quick-sharun \
28+
/usr/bin/gimp* \
29+
/usr/bin/gjs* \
30+
/usr/bin/gegl \
31+
/usr/lib/libgimp* \
32+
/usr/lib/gimp/*/modules/* \
33+
/usr/lib/gtk-*/*/*/* \
34+
/usr/lib/gvfs/* \
35+
/usr/lib/libcfitsio.so* \
36+
/usr/lib/libgthread-2.0.so* \
37+
/usr/lib/libjbig2dec* \
38+
/usr/lib/libXmu.so* \
39+
/usr/lib/libwebpdemux.so* \
40+
/usr/lib/libgs.so* \
41+
/usr/lib/libgpm* \
42+
/usr/lib/libpaper* \
43+
/usr/lib/libSDL* \
44+
/usr/lib/libXpm.so* \
45+
/usr/lib/libwmf* \
46+
/usr/lib/libudev.so* \
47+
/usr/lib/libaa.so* \
5148
/usr/lib/libmng.so*
5249

53-
cp -vr /usr/share/gimp ./share
54-
cp -vr /usr/share/locale ./share
55-
find ./share/locale -type f ! -name '*glib*' ! -name '*gimp*' ! -name '*gegl*' -delete
56-
cp -vr /usr/lib/locale ./shared/lib
57-
cp -vr /usr/share/pixmaps ./share
58-
cp -vr /usr/share/icons/hicolor ./share/icons
59-
cp -vr /etc/gimp ./etc
60-
cp -vr /usr/share/vala ./share
61-
cp -vr /usr/share/gir-1.0 ./share
62-
cp -vn /usr/lib/gegl-*/*.json ./shared/lib/gegl-*
63-
cp -rvn /usr/lib/gimp ./shared/lib
64-
50+
cp -vr /usr/lib/locale ./AppDir/shared/lib
51+
cp -vr /usr/share/pixmaps ./AppDir/share
52+
cp -vr /etc/gimp ./AppDir/etc
53+
cp -vr /usr/share/vala ./AppDir/share
54+
cp -vr /usr/share/gir-1.0 ./AppDir/share
55+
cp -rvn /usr/lib/gimp ./AppDir/shared/lib
6556

6657
# sharun the gimp plugins
6758
echo "Sharunning the gimp plugins..."
68-
bins_to_find="$(find ./lib/gimp -exec file {} \; | grep -i 'elf.*executable' | awk -F':' '{print $1}')"
59+
bins_to_find="$(find ./AppDir/lib/gimp -exec file {} \; | grep -i 'elf.*executable' | awk -F':' '{print $1}')"
6960
for plugin in $bins_to_find; do
70-
mv -v "$plugin" ./shared/bin && ln ./sharun "$plugin"
61+
mv -v "$plugin" ./AppDir/shared/bin && ln -f ./AppDir/sharun "$plugin"
7162
echo "Sharan $plugin"
7263
done
7364

74-
# HACK
75-
find ./lib -type f -name 'libgimpwidgets*' -exec sed -i 's|/usr/share|/tmp/xdg69|g' {} \;
76-
77-
# HACK2
78-
find ./lib -type f -name 'libgegl*' -exec sed -i 's|/usr/lib|/tmp/o_0|g' {} \;
79-
echo 'unset GEGL_PATH' > ./.env
80-
81-
# PREPARE SHARUN
82-
chmod +x ./AppRun
83-
./sharun -g
84-
8565
# ADD PHOTOGIMP
86-
wget "$PHOTOGIMP" -O ./PhotoGIMP.zip
66+
wget --retry-connrefused --tries=30 "$PHOTOGIMP" -O ./PhotoGIMP.zip
8767
unzip ./PhotoGIMP.zip
8868
rm -f ./PhotoGIMP.zip
89-
mv -v ./PhotoGIMP-linux ./PhotoGIMP
90-
mv -v ./PhotoGIMP/.local/share/applications/org.gimp.GIMP.desktop \
91-
./PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
69+
mv -v ./PhotoGIMP-linux ./AppDir/PhotoGIMP
70+
mv -v ./AppDir/PhotoGIMP/.local/share/applications/org.gimp.GIMP.desktop \
71+
./AppDir/PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
9272

93-
if ! grep -q 'StartupWMClass=' ./PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop; then
94-
echo 'StartupWMClass=gimp' >> ./PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
73+
if ! grep -q 'StartupWMClass=' ./AppDir/PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop; then
74+
echo 'StartupWMClass=gimp' >> ./AppDir/PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
9575
fi
96-
if ! grep -q 'TryExec=' ./PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop; then
97-
echo 'TryExec=gimp' >> ./PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
76+
if ! grep -q 'TryExec=' ./AppDir/PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop; then
77+
echo 'TryExec=gimp' >> ./AppDir/PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
9878
fi
9979

10080
sed -i -e 's|Exec=.*|Exec=env ENABLE_PHOTO_GIMP=1 gimp %U|g' \
10181
-e 's|StartupWMClass=.*|StartupWMClass=gimp|g' \
102-
-e 's|TryExec=.*|TryExec=gimp|g' ./PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
82+
-e 's|TryExec=.*|TryExec=gimp|g' ./AppDir/PhotoGIMP/.local/share/applications/PhotoGIMP-AppImage.desktop
10383

10484
# Fix wrong window class in .desktop
105-
sed -i 's|StartupWMClass=.*|StartupWMClass=gimp|' "$DESKTOP"
106-
107-
# TODO remove me once we migrate to quick-sharun
108-
cp -v "$DESKTOP" ./
109-
cp -v "$ICON" ./
110-
cp -v "$ICON" ./.DirIcon
85+
sed -i 's|StartupWMClass=.*|StartupWMClass=gimp|' ./AppDir/*.desktop
11186

11287
# MAKE APPIMAGE WITH URUNTIME
113-
cd ..
11488
wget --retry-connrefused --tries=30 "$URUNTIME" -O ./uruntime2appimage
11589
chmod +x ./uruntime2appimage
11690
./uruntime2appimage
11791

11892
UPINFO="$(echo "$UPINFO" | sed 's#.AppImage.zsync#*.AppBundle.zsync#g')"
119-
wget -O ./pelf "https://github.com/xplshn/pelf/releases/latest/download/pelf_$ARCH"
93+
wget -O ./pelf "https://github.com/xplshn/pelf/releases/latest/download/pelf_$ARCH"
12094
chmod +x ./pelf
12195
echo "Generating [dwfs]AppBundle...(Go runtime)"
12296
./pelf --add-appdir ./AppDir \
12397
--appbundle-id="org.gimp.GIMP#github.com/$GITHUB_REPOSITORY:$VERSION@$(date +%d_%m_%Y)" \
12498
--appimage-compat \
12599
--disable-use-random-workdir \
126100
--add-updinfo "$UPINFO" \
127-
--compression "-C zstd:level=22 -S25 -B8" \
128-
--output-to GIMP-"$VERSION"-anylinux-"$ARCH".dwfs.AppBundle
101+
--compression "-C zstd:level=22 -S26 -B8" \
102+
--output-to ./GIMP-"$VERSION"-anylinux-"$ARCH".dwfs.AppBundle
129103

130104
echo "Generating zsync file..."
131-
zsyncmake *.AppBundle -u *.AppBundle
105+
zsyncmake ./*.AppBundle -u ./*.AppBundle
132106

133107
mkdir -p ./dist
134108
mv -v ./*.AppImage* ./dist

0 commit comments

Comments
 (0)