summaryrefslogtreecommitdiff
path: root/build-recipe-appimage
diff options
context:
space:
mode:
authorAdrian Schröter <adrian@suse.de>2017-03-09 16:34:42 +0100
committerAdrian Schröter <adrian@suse.de>2017-03-09 16:38:12 +0100
commit5be3c81511bc84afb437184c1498b6ef1a96793f (patch)
treecde6139892088e7ca5817ec92a49e9ec877f3a3a /build-recipe-appimage
parent52c8ba3036531c63a09dd8d78f2f45b025b74260 (diff)
first attempt to support AppImage native builds
Diffstat (limited to 'build-recipe-appimage')
-rw-r--r--build-recipe-appimage121
1 files changed, 121 insertions, 0 deletions
diff --git a/build-recipe-appimage b/build-recipe-appimage
new file mode 100644
index 0000000..c27acad
--- /dev/null
+++ b/build-recipe-appimage
@@ -0,0 +1,121 @@
+#################################################################
+#
+# AppImage specific functions.
+#
+# Author: Adrian Schroeter <adrian@suse.de>
+#
+################################################################
+#
+# Copyright (c) 2016 SUSE Linux Products GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or 3 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program (see the file COPYING); if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+################################################################
+
+recipe_setup_appimage() {
+ TOPDIR=/usr/src/packages
+ test "$DO_INIT_TOPDIR" = false || rm -rf "$BUILD_ROOT$TOPDIR"
+ for i in OTHER SOURCES APPIMAGE_ROOT ; do
+ mkdir -p "$BUILD_ROOT$TOPDIR/$i"
+ done
+ chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
+ if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
+ mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
+ else
+ cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
+ fi
+}
+
+recipe_prepare_appimage() {
+ :
+}
+
+# Variables:
+# $BUILD_ROOT is the chroot
+# $TOPDIR/SOURCES includes the appimages sources
+# $TOPDIR/$APPIMAGE_ROOT where appimage will be called
+# $RECIPEFILE the name of the appimage.yaml config file
+
+recipe_build_appimage() {
+ local ARCH
+ if [ -x /bin/rpm ]; then
+ ARCH=$(chroot $BUILD_ROOT su -c "rpm --eval '%{_target_cpu}'")
+ unset DEB
+ else
+ ARCH=$(chroot $BUILD_ROOT su -c "dpkg-architecture -qDEB_BUILD_ARCH")
+ DEB=1
+ fi
+ local DIST="OBS"
+
+ [ -z "${ARCH}" -o -z "${DIST}" ] && cleanup_and_exit 1
+
+ test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1
+ if test "$DO_INIT" = true; then
+ if test -n "$DEB" -a ! -d "$BUILD_ROOT/.build.binaries/dists" ; then
+ echo "creating debian repository metadata..."
+ createrepo_debian $BUILD_ROOT/.build.binaries ${ARCH} ${DIST}
+ # setup /etc/apt/sources.list
+ mkdir -p "$BUILD_ROOT/etc/apt"
+ echo "deb [trusted=yes] file:/.build.binaries OBS main" >> "$BUILD_ROOT/etc/apt/sources.list"
+ fi
+ if test -z "$DEB" -a ! -d "$BUILD_ROOT/.build.binaries/repodata" ; then
+ echo "creating repository metadata..."
+ if [ -x /usr/bin/createrepo_c ]; then
+ createrepo_c $BUILD_ROOT/.build.binaries
+ else
+ createrepo $BUILD_ROOT/.build.binaries
+ fi
+ fi
+ fi
+
+ chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && /usr/lib/appimage/pkg2appimage" - root \
+ || cleanup_and_exit 1
+
+ # extract build result basenames
+ local build_results=""
+ for i in $BUILD_ROOT/$TOPDIR/SOURCES/* ; do
+ test -f "$i" || continue
+ case "${i##*/}" in
+ *.AppImage|*.AppImage.digest|*.AppImage.zsync)
+ build_results="${build_results}\n${i%%.snap}"
+ ;;
+ *)
+ ;;
+ esac
+ done
+
+ # Fail the build if no build results are found
+ if [ -z "${build_results}" ] ; then
+ cleanup_and_exit 1 "No live-build result found"
+ fi
+
+ # move created products (and their metadata files) to destination
+ local buildnum="${RELEASE:+-Build${RELEASE}}"
+ for prefix in $(echo -e ${build_results} | sort | uniq) ; do
+ for f in ${prefix}.* ; do
+ mv ${f} \
+ $BUILD_ROOT/$TOPDIR/OTHER/${prefix##*/}${buildnum}${f#${prefix}}
+ BUILD_SUCCEEDED=true
+ done
+ done
+}
+
+recipe_resultdirs_appimage() {
+ :
+}
+
+# Local Variables:
+# mode: Shell-script
+# End: