-
-
Notifications
You must be signed in to change notification settings - Fork 579
Bundling GTK3 apps
probonopd edited this page Aug 10, 2014
·
10 revisions
Use this to bundle a simple GTK app:
#!/bin/bash
function make_dirs {
mkdir -p "${1}"/"${1}.AppDir" || echo ""
}
function extract_rpms {
FILES=$(find ../ -name *rpm)
for FILE in $FILES ; do
rpm2cpio "${FILE}" | cpio -i --make-directories
done
}
function copy_desktop {
find . -name *desktop -exec cp {} . \;
}
function make_apprun_skel {
cat > ./AppRun <<\EOF
#!/bin/sh
HERE=$(dirname $(readlink -f "${0}"))
echo "${HERE}"
export PATH="${HERE}/usr/bin/":$PATH
export LD_LIBRARY_PATH="${HERE}/usr/lib/":$LD_LIBRARY_PATH
cd "${HERE}/usr"
EOF
chmod a+x ./AppRun
}
function patch_usr {
find . -type f -exec sed -i -e 's|/usr|././|g' {} \;
}
function get_assistant {
wget -c "https://downloads.sourceforge.net/project/portable/64bit/AppImageAssistant%200.9.3-64bit"
chmod a+x ./AppImageAssistant*
}
function make_appdir {
./AppImageAssistant* "${1}.AppDir" "${1}.AppImage"
}
APPNAME=Transmission
make_dirs "${APPNAME}"
cd "${APPNAME}"
wget -c -r -l1 -np "http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/" -A transmission-*.rpm -P download
find ./download/ -name *qt* -exec rm {} \;
cd "${APPNAME}.AppDir"
extract_rpms
patch_usr
copy_desktop
make_apprun_skel
echo "./bin/transmission-gtk $@" >> AppRun
cd -
get_assistant
make_appdir "${APPNAME}"
The following is likely outdated.
Pitivi uses the following AppRun script to run a bundle consisting of Pitivi and the entire GTK stack:
#!/bin/sh
# Base environment variables
export LD_LIBRARY_PATH=${APPDIR}/lib:${LD_LIBRARY_PATH}
export PATH=${APPDIR}/bin:${PATH}
export XDG_DATA_DIRS=${APPDIR}/share:${XDG_DATA_DIRS}
# GTK+/GIO/GdkPixbuf environment variables
# http://askubuntu.com/questions/251712/how-can-i-install-a-gsettings-schema-without-root-privileges
export GSETTINGS_SCHEMA_DIR=${APPDIR}/share/glib-2.0/schemas/:${GSETTINGS_SCHEMA_DIR}
export GDK_PIXBUF_MODULE_FILE=${APPDIR}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
export GTK_PATH=${APPDIR}/lib/gtk-3.0
export GTK_DATA_PREFIX=${APPDIR}
export GTK_THEME=Adwaita
# GStreamer environment variables
export GST_PLUGIN_SCANNER=${APPDIR}/libexec/gstreamer-1.0/gst-plugin-scanner
export GST_PLUGIN_SYSTEM_PATH=
# Try to discover plugins only once
PLUGINS_SYMLINK=${HOME}/.cache/gstreamer-1.0/pitivi-gstplugins
ln -s ${APPDIR}/lib/gstreamer-1.0/ ${PLUGINS_SYMLINK}
if [ $? -ne 0 ]; then
export GST_PLUGIN_PATH=${APPDIR}/lib/gstreamer-1.0/
else
export GST_PLUGIN_PATH=${PLUGINS_SYMLINK}
fi
export GST_REGISTRY=${HOME}/.cache/gstreamer-1.0/pitivi-bundle-registry
# Python
export PYTHONPATH=${APPDIR}/lib/python2.7/site-packages${PYTHONPATH:+:$PYTHONPATH}
export GI_TYPELIB_PATH=${APPDIR}/lib/girepository-1.0
# Currently we change into the APPDIR directory, this only because of gdk-pixbuf
# and pango cache files which need to specify relative paths.
cd ${APPDIR}
if test -z ${APP_IMAGE_TEST}; then
# Invoke the app with the arguments passed
${APPDIR}/bin/pitivi $*
else
# Run a shell in test mode
bash;
fi
# Cleaning up the link to gstplugins
rm ${PLUGINS_SYMLINK}