-
-
Save blackhalt/da5de0fcc13c105c4937bb907010a96e to your computer and use it in GitHub Desktop.
AppImage recipe for building GIMP from git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
FULL_BUNDLING=0 | |
UPDATE=1 | |
REBUILD=1 | |
PREFIX=/zzz | |
# Move blacklisted files to a special folder | |
move_blacklisted() | |
{ | |
mkdir -p ./usr/lib-blacklisted | |
if [ x"$FULL_BUNDLING" = "x1" ]; then | |
BLACKLISTED_FILES=$(cat $APPIMAGEBASE/AppImages/excludelist | sed '/^\s*$/d' | sed '/^#.*$/d') | |
else | |
BLACKLISTED_FILES=$(wget -q https://github.com/probonopd/AppImages/raw/master/excludelist -O - | sed '/^\s*$/d' | sed '/^#.*$/d') | |
fi | |
#echo $BLACKLISTED_FILES | |
for FILE in $BLACKLISTED_FILES ; do | |
FOUND=$(find . -type f -name "${FILE}" 2>/dev/null) | |
if [ ! -z "$FOUND" ] ; then | |
echo "Moving blacklisted ${FOUND}" | |
#rm -f "${FOUND}" | |
mv "${FOUND}" ./usr/lib-blacklisted | |
fi | |
done | |
} | |
export APPIMAGEBASE=$(pwd)/.. | |
wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh | |
. ./functions.sh | |
APP=gimp | |
VERSION=2.9.5 | |
LOWERAPP=${APP,,} | |
rm -rf out $APP | |
WD=$(pwd) | |
export PATH=$PREFIX/bin:$PATH | |
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH | |
export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS | |
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH | |
mkdir checkout | |
cd checkout | |
if [ x"$UPDATE" = "x1" ]; then | |
if [ -e babl ]; then | |
(cd babl; git_pull_rebase_helper) | |
if [ $? -ne 0 ]; then exit; fi | |
else | |
git clone https://github.com/GNOME/babl.git | |
fi | |
if [ -e gegl ]; then | |
(cd gegl; git_pull_rebase_helper) | |
if [ $? -ne 0 ]; then exit; fi | |
else | |
git clone https://github.com/GNOME/gegl.git | |
fi | |
if [ -e libmypaint ]; then | |
(cd libmypaint; git_pull_rebase_helper) | |
if [ $? -ne 0 ]; then exit; fi | |
else | |
git clone git://github.com/mypaint/libmypaint.git | |
fi | |
if [ -e mypaint ]; then | |
(cd mypaint; git_pull_rebase_helper) | |
if [ $? -ne 0 ]; then exit; fi | |
else | |
git clone git://github.com/mypaint/mypaint.git | |
fi | |
if [ -e gimp ]; then | |
(cd gimp; git_pull_rebase_helper) | |
if [ $? -ne 0 ]; then exit; fi | |
else | |
git clone https://github.com/GNOME/gimp.git -b master | |
fi | |
if [ -e resynthesizer ]; then | |
(cd resynthesizer; git_pull_rebase_helper) | |
if [ $? -ne 0 ]; then exit; fi | |
else | |
git clone https://github.com/bootchk/resynthesizer.git | |
fi | |
if [ -e liblqr ]; then | |
(cd liblqr; git_pull_rebase_helper) | |
else | |
git clone https://github.com/carlobaldassi/liblqr.git -b master | |
fi | |
if [ -e gimp-lqr-plugin ]; then | |
(cd gimp-lqr-plugin; git_pull_rebase_helper) | |
else | |
git clone https://github.com/carlobaldassi/gimp-lqr-plugin.git -b master | |
fi | |
if [ -e gmic-git ]; then | |
(cd gmic-git; git_pull_rebase_helper) | |
else | |
git clone https://github.com/dtschump/gmic.git -b master --single-branch gmic-git | |
fi | |
if [ ! -e libvips ]; then | |
# (cd libvips; git_pull_rebase_helper) | |
# else | |
wget http://www.vips.ecs.soton.ac.uk/supported/8.4/vips-8.4.1.tar.gz | |
tar xzvf vips-8.4.1.tar.gz | |
rm -f libvips | |
ln -s vips-8.4.1 libvips | |
#git clone https://github.com/jcupitt/libvips.git libvips | |
fi | |
if [ ! -e PhotoFlow ]; then | |
git clone https://github.com/aferrero2707/PhotoFlow.git --branch stable --single-branch PhotoFlow | |
if [ $? -ne 0 ]; then exit; fi | |
else | |
(cd PhotoFlow; git pull origin stable) | |
fi | |
fi | |
all=1 | |
if [ x"$REBUILD" = "x1" ]; then | |
if [ $all -eq 1 ]; then | |
rm -r $PREFIX/* | |
#cd glib-2.40.2 | |
#./configure --prefix=$PREFIX && make && make install-strip | |
#if [ $? -ne 0 ]; then exit; fi | |
#cd .. | |
#cd gdk-pixbuf-2.30.7 | |
#./configure --prefix=$PREFIX --enable-gio-sniffing=yes && make && make install-strip | |
#if [ $? -ne 0 ]; then exit; fi | |
#cd .. | |
cd lcms2-2.8 | |
./configure --prefix=$PREFIX && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd libpng-1.6.26 | |
./configure --prefix=$PREFIX && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
mkdir -p lensfun-build | |
cd lensfun-build | |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX ../lensfun-0.3.2 && make && make install | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd babl | |
./autogen.sh --prefix=$PREFIX --disable-mmx --disable-sse --disable-docs && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd gegl | |
./autogen.sh --prefix=$PREFIX --disable-docs --enable-gtk-doc=no --enable-gtk-doc-html=no --enable-gtk-doc-pdf=no --enable-workshop --without-libv4l2 --without-libavformat --without-sdl && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd libmypaint | |
./autogen.sh --prefix=$PREFIX; ./configure --prefix=$PREFIX && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd gimp | |
sed -i 's/m4_define(\[gdk_pixbuf_required_version\], \[2.30.8\])/m4_define(\[gdk_pixbuf_required_version\], \[2.30.7\])/g' configure.ac | |
sed -i 's/GDK_PIXBUF_REQUIRED_MICRO 8/GDK_PIXBUF_REQUIRED_MICRO 7/g' app/sanity.c | |
./autogen.sh --prefix=$PREFIX --disable-gtk-doc --enable-debug=no --with-gimpdir="GIMP-AppImage" && make clean && make && make install-strip | |
#make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd gutenprint-5.2.11 | |
./configure --prefix=$PREFIX && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
mkdir -p gmic-build | |
cd gmic-build | |
make clean | |
rm -f CMakeCache.txt; cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MAN=OFF -DBUILD_LIB=OFF -DBUILD_LIB_STATIC=OFF -DBUILD_CLI=OFF -DBUILD_PLUGIN=ON -DCMAKE_INSTALL_PREFIX=/zzz ../gmic-git && make clean && make VERBOSE=1 && make install | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd resynthesizer | |
./autogen.sh --prefix=$PREFIX && make clean && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd liblqr | |
./configure --prefix=$PREFIX && make clean && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd gimp-lqr-plugin | |
./configure --prefix=$PREFIX && make clean && make && make install-strip | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
cd libvips | |
./autogen.sh | |
FLAGS="-O2 -msse4.2 -ffast-math -ftree-vectorize" CFLAGS="${FLAGS}" CXXFLAGS="${FLAGS} -fpermissive" ./configure --prefix=${PREFIX} --disable-gtk-doc --disable-gtk-doc-html --disable-introspection --enable-debug=no --without-python --without-magick --without-libwebp --enable-pyvips8=no --enable-shared=yes --enable-static=no && make && make install | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
fi | |
mkdir -p phfbuild | |
cd phfbuild | |
cmake -DBABL_FLIPS_DISABLED=OFF -DBUNDLED_LENSFUN=OFF -DBUNDLED_GEXIV2=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DINSTALL_PREFIX=$PREFIX $(pwd)/../PhotoFlow && make && make install | |
if [ $? -ne 0 ]; then exit; fi | |
cd .. | |
fi | |
#exit | |
cd "$WD" | |
pwd | |
mkdir -p $APP/$APP.AppDir | |
cd $APP/$APP.AppDir | |
mkdir -p usr | |
cp -rL $PREFIX/* usr | |
mv usr/bin/gimp-2.9 usr/bin/$LOWERAPP.bin | |
rm -r usr/bin/photoflow | |
rm -r usr/bin/pfbatch | |
#cp -a ../../$LOWERAPP.launcher usr/bin/$LOWERAPP | |
cat > usr/bin/$LOWERAPP <<\EOF | |
#! /bin/bash | |
pwd | |
HERE="$(dirname "$(readlink -f "${0}")")" | |
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" | |
export XDG_DATA_DIRS=$HERE/../share-mime:$XDG_DATA_DIRS | |
echo "XDG_DATA_DIRS=$XDG_DATA_DIRS" | |
export GTK_PATH=$HERE/../lib/gtk-2.0:$GTK_PATH | |
echo "GTK_PATH=${GTK_PATH}" | |
GDK_PIXBUF_MODULEDIR=$HERE/../lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders | |
GDK_PIXBUF_MODULE_FILE=$HERE/../lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache | |
echo "GDK_PIXBUF_MODULEDIR: $GDK_PIXBUF_MODULEDIR" | |
echo "GDK_PIXBUF_MODULE_FILE: $GDK_PIXBUF_MODULE_FILE" | |
cat $GDK_PIXBUF_MODULE_FILE | |
export PF_DATA_DIR=$HERE/../share | |
export GIMP2_PLUGINDIR=$(readlink -f "$HERE/../lib/gimp/2.0") | |
echo "HERE: $HERE" | |
echo "GIMP2_PLUGINDIR: $GIMP2_PLUGINDIR" | |
echo "Input parameters: \"$@\"" | |
echo "" | |
echo "Input File: $1" | |
ldd $HERE/LOWERAPP.bin | |
echo "" | |
echo "$HERE/LOWERAPP.bin --pdb-compat-mode=on \"$@\"" | |
$HERE/LOWERAPP.bin --pdb-compat-mode=on "$@" | |
EOF | |
sed -i -e "s|LOWERAPP|$LOWERAPP|g" usr/bin/$LOWERAPP | |
chmod u+x usr/bin/$LOWERAPP | |
rm -f usr/lib/gimp/2.0/plug-ins/file-darktable | |
if [ x"$FULL_BUNDLING" = "x1" ]; then | |
mkdir -p usr/share-mime | |
cp -a /usr/share/mime usr/share-mime | |
cp -L /usr/lib/x86_64-linux-gnu/libgobject-2.0.so* usr/lib | |
#cp ./usr/share/applications/$LOWERAPP.desktop . | |
#sed -i -e "s|gimp-2.9|$LOWERAPP|g" $LOWERAPP.desktop | |
rm -rf ./usr/share/icons/48x48/apps || true | |
find ./usr/share/icons -path *256* -name gimp.png -exec cp {} $LOWERAPP.png \; || true | |
find ./usr/share/icons -path *512* -name gimp.png -exec cp {} $LOWERAPP.png \; || true | |
mkdir -p lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders | |
cp -L /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/* lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders | |
#cp -L /zzz/lib/gdk-pixbuf-2.0/2.10.0/loaders/* lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders | |
mkdir -p lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0 | |
gdk-pixbuf-query-loaders > lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache | |
mkdir -p ./usr/lib/gtk-2.0 | |
echo "cp -a $(pkg-config --variable=libdir gtk+-2.0)/gtk-2.0/* ./usr/lib/gtk-2.0" | |
cp -a $(pkg-config --variable=libdir gtk+-2.0)/gtk-2.0/* ./usr/lib/gtk-2.0 | |
#mkdir -p ./usr/lib/gtk-2.0/modules | |
#echo "cp $(pkg-config --variable=libdir gtk+-2.0)/gtk-2.0/modules/* ./usr/lib/gtk-2.0/modules" | |
#cp $(pkg-config --variable=libdir gtk+-2.0)/gtk-2.0/modules/* ./usr/lib/gtk-2.0/modules | |
#mkdir -p ./usr/lib/gtk-2.0/$(pkg-config --variable=gtk_binary_version gtk+-2.0)/engines | |
#echo "cp $(pkg-config --variable=libdir gtk+-2.0)/gtk-2.0/$(pkg-config --variable=gtk_binary_version gtk+-2.0)/engines/libpixmap.so ./usr/lib/gtk-2.0/$(pkg-config --variable=gtk_binary_version gtk+-2.0)/engines" | |
#cp $(pkg-config --variable=libdir gtk+-2.0)/gtk-2.0/$(pkg-config --variable=gtk_binary_version gtk+-2.0)/engines/libpixmap.so ./usr/lib/gtk-2.0/$(pkg-config --variable=gtk_binary_version gtk+-2.0)/engines | |
fi | |
get_apprun | |
# The original desktop file is a bit strange, hence we provide our own | |
cat > $LOWERAPP.desktop <<\EOF | |
[Desktop Entry] | |
Version=1.0 | |
Type=Application | |
Name=GIMP AppImage | |
GenericName=Image Editor | |
Comment=Create images and edit photographs | |
Exec=LOWERAPP %f | |
TryExec=LOWERAPP | |
Icon=LOWERAPP | |
Terminal=false | |
Categories=Graphics;2DGraphics;RasterGraphics;GTK; | |
StartupNotify=true | |
MimeType=image/bmp;image/g3fax;image/gif;image/x-fits;image/x-pcx;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-psd;image/x-sgi;image/x-tga;image/x-xbitmap;image/x-xwindowdump;image/x-xcf;image/x-compressed-xcf;image/x-gimp-gbr;image/x-gimp-pat;image/x-gimp-gih;image/tiff;image/jpeg;image/x-psp;image/png;image/x-icon;image/x-exr;image/svg+xml;image/x-wmf;image/jp2;image/jpeg2000;image/jpx;image/x-xcursor;image/x-3fr;image/x-adobe-dng;image/x-arw;image/x-bay;image/x-canon-cr2;image/x-canon-crw;image/x-cap;image/x-cr2;image/x-crw;image/x-dcr;image/x-dcraw;image/x-dcs;image/x-dng;image/x-drf;image/x-eip;image/x-erf;image/x-fff;image/x-fuji-raf;image/x-iiq;image/x-k25;image/x-kdc;image/x-mef;image/x-minolta-mrw;image/x-mos;image/x-mrw;image/x-nef;image/x-nikon-nef;image/x-nrw;image/x-olympus-orf;image/x-orf;image/x-panasonic-raw;image/x-pef;image/x-pentax-pef;image/x-ptx;image/x-pxn;image/x-r3d;image/x-raf;image/x-raw;image/x-rw2;image/x-rwl;image/x-rwz;image/x-sigma-x3f;image/x-sony-arw;image/x-sony-sr2;image/x-sony-srf;image/x-sr2;image/x-srf;image/x-x3f; | |
EOF | |
sed -i -e "s|LOWERAPP|$LOWERAPP|g" $LOWERAPP.desktop | |
# Copy in the indirect dependencies | |
copy_deps ; copy_deps ; copy_deps # Three runs to ensure we catch indirect ones | |
cp -a zzz/lib/* usr/lib | |
cp -a zzz/lib64/* usr/lib64 | |
rm -rf zzz | |
move_lib | |
#delete_blacklisted | |
move_blacklisted | |
mkdir -p usr/share/mypaint/brushes | |
for brush in classic deevad experimental kaerhon_v1 ramon tanda; do | |
cp -r ../../checkout/mypaint/brushes/$brush usr/share/mypaint/brushes | |
done | |
# patch_usr | |
# Patching only the executable files seems not to be enough for darktable | |
find usr/ -type f -exec sed -i -e "s|$PREFIX|././|g" {} \; | |
find usr/ -type f -exec sed -i -e "s|/usr|././|g" {} \; | |
# patch for using system-supplied python interpreter | |
cp $PREFIX/lib/gimp/2.0/interpreters/pygimp.interp usr/lib/gimp/2.0/interpreters/pygimp.interp | |
# Workaround for: | |
# GLib-GIO-ERROR **: Settings schema 'org.gtk.Settings.FileChooser' is not installed | |
# when trying to use the file open dialog | |
# AppRun exports usr/share/glib-2.0/schemas/ which might be hurting us here | |
( mkdir -p usr/share/glib-2.0/schemas/ ; cd usr/share/glib-2.0/schemas/ ; ln -s /usr/share/glib-2.0/schemas/gschemas.compiled . ) | |
# Workaround for: | |
# ImportError: /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0: undefined symbol: XRRGetMonitors | |
cp $(ldconfig -p | grep libgdk-x11-2.0.so.0 | cut -d ">" -f 2 | xargs) ./usr/lib/ | |
cp $(ldconfig -p | grep libgtk-x11-2.0.so.0 | cut -d ">" -f 2 | xargs) ./usr/lib/ | |
#VER1=$(pkg-config --modversion gimp-2.0)-test | |
VER1=$(pkg-config --modversion gimp-2.0)-$(date +%Y%m%d) | |
if [ x"$FULL_BUNDLING" = "x1" ]; then | |
VER1="${VER1}-full" | |
fi | |
GLIBC_NEEDED=$(glibc_needed) | |
VERSION=$VER1.glibc$GLIBC_NEEDED | |
echo $VERSION | |
get_desktopintegration $LOWERAPP | |
cp -a ../../$LOWERAPP.wrapper ./usr/bin/$LOWERAPP.wrapper | |
#cp -a ../../desktopintegration ./usr/bin/$LOWERAPP.wrapper | |
#chmod a+x ./usr/bin/$LOWERAPP.wrapper | |
#sed -i -e "s|Exec=$LOWERAPP|Exec=$LOWERAPP.wrapper|g" $LOWERAPP.desktop | |
# Go out of AppImage | |
cd .. | |
ARCH="x86_64" | |
generate_appimage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment