| 1 |
################################################################# |
| 2 |
# |
| 3 |
# AppImage specific functions. |
| 4 |
# |
| 5 |
# Author: Adrian Schroeter <[email protected]> |
| 6 |
# |
| 7 |
################################################################ |
| 8 |
# |
| 9 |
# Copyright (c) 2017 SUSE Linux Products GmbH |
| 10 |
# |
| 11 |
# This program is free software; you can redistribute it and/or modify |
| 12 |
# it under the terms of the GNU General Public License version 2 or 3 as |
| 13 |
# published by the Free Software Foundation. |
| 14 |
# |
| 15 |
# This program is distributed in the hope that it will be useful, |
| 16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
# GNU General Public License for more details. |
| 19 |
# |
| 20 |
# You should have received a copy of the GNU General Public License |
| 21 |
# along with this program (see the file COPYING); if not, write to the |
| 22 |
# Free Software Foundation, Inc., |
| 23 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
| 24 |
# |
| 25 |
################################################################ |
| 26 |
|
| 27 |
recipe_setup_appimage() { |
| 28 |
TOPDIR=/usr/src/packages |
| 29 |
test "$DO_INIT_TOPDIR" = false || rm -rf "$BUILD_ROOT$TOPDIR" |
| 30 |
for i in OTHER SOURCES APPIMAGE_ROOT ; do |
| 31 |
mkdir -p "$BUILD_ROOT$TOPDIR/$i" |
| 32 |
done |
| 33 |
chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR" |
| 34 |
if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then |
| 35 |
mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ |
| 36 |
else |
| 37 |
cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ |
| 38 |
fi |
| 39 |
|
| 40 |
rawcfgmacros=.rpmmacros |
| 41 |
test "$BUILDTYPE" = debbuild && rawcfgmacros=.debmacros |
| 42 |
queryconfig rawmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" > $BUILD_ROOT/root/$rawcfgmacros |
| 43 |
} |
| 44 |
|
| 45 |
recipe_prepare_appimage() { |
| 46 |
: |
| 47 |
} |
| 48 |
|
| 49 |
# Variables: |
| 50 |
# $BUILD_ROOT is the chroot |
| 51 |
# $TOPDIR/SOURCES includes the appimages sources |
| 52 |
# $TOPDIR/$APPIMAGE_ROOT where appimage will be called |
| 53 |
# $RECIPEFILE the name of the appimage.yml config file |
| 54 |
|
| 55 |
recipe_build_appimage() { |
| 56 |
local ARCH DEB |
| 57 |
if [ -x "$BUILD_ROOT/bin/rpm" ]; then |
| 58 |
ARCH=$(chroot $BUILD_ROOT su -c "rpm --eval '%{_target_cpu}'") |
| 59 |
else |
| 60 |
ARCH=$(chroot $BUILD_ROOT su -c "dpkg-architecture -qDEB_BUILD_ARCH") |
| 61 |
DEB=1 |
| 62 |
fi |
| 63 |
local DIST="OBS" |
| 64 |
|
| 65 |
test -z "${ARCH}" -o -z "${DIST}" && cleanup_and_exit 1 |
| 66 |
|
| 67 |
test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1 "missing $BUILD_ROOT/.build.binaries" |
| 68 |
|
| 69 |
if test "$DO_INIT" = true; then |
| 70 |
if test -n "$DEB" -a ! -d "$BUILD_ROOT/.build.binaries/dists" ; then |
| 71 |
echo "creating debian repository metadata..." |
| 72 |
createrepo_debian $BUILD_ROOT/.build.binaries ${ARCH} ${DIST} |
| 73 |
# setup /etc/apt/sources.list |
| 74 |
mkdir -p "$BUILD_ROOT/etc/apt" |
| 75 |
echo "deb [trusted=yes] file:/.build.binaries OBS main" >> "$BUILD_ROOT/etc/apt/sources.list" |
| 76 |
fi |
| 77 |
if test -z "$DEB" -a ! -d "$BUILD_ROOT/.build.binaries/repodata" ; then |
| 78 |
echo "creating repository metadata..." |
| 79 |
if chroot "$BUILD_ROOT" test -x /usr/bin/createrepo_c; then |
| 80 |
chroot "$BUILD_ROOT" /usr/bin/createrepo_c /.build.binaries |
| 81 |
elif chroot "$BUILD_ROOT" test -x /usr/bin/createrepo; then |
| 82 |
chroot "$BUILD_ROOT" /usr/bin/createrepo /.build.binaries |
| 83 |
else |
| 84 |
cleanup_and_exit 1 "No createrepo found in build root" |
| 85 |
fi |
| 86 |
fi |
| 87 |
fi |
| 88 |
|
| 89 |
release_option="" |
| 90 |
if test -n "$RELEASE" ; then |
| 91 |
release_option="--release $RELEASE" |
| 92 |
fi |
| 93 |
|
| 94 |
chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && ARCH=$ARCH /usr/lib/appimagetool/pkg2appimage $release_option" - root \ |
| 95 |
|| cleanup_and_exit 1 |
| 96 |
|
| 97 |
# extract build result basenames |
| 98 |
local build_results="" |
| 99 |
for i in $BUILD_ROOT/$TOPDIR/OTHER/* ; do |
| 100 |
test -f "$i" || continue |
| 101 |
case "${i##*/}" in |
| 102 |
*.AppImage|*.AppImage.digest|*.AppImage.zsync) |
| 103 |
build_results="${build_results}\n${i%%.snap}" |
| 104 |
;; |
| 105 |
*) |
| 106 |
;; |
| 107 |
esac |
| 108 |
done |
| 109 |
|
| 110 |
# Fail the build if no build results are found |
| 111 |
if [ -z "${build_results}" ] ; then |
| 112 |
cleanup_and_exit 1 "No live-build result found" |
| 113 |
fi |
| 114 |
|
| 115 |
BUILD_SUCCEEDED=true |
| 116 |
} |
| 117 |
|
| 118 |
recipe_resultdirs_appimage() { |
| 119 |
: |
| 120 |
} |
| 121 |
|
| 122 |
recipe_cleanup_appimage() { |
| 123 |
: |
| 124 |
} |
| 125 |
|
| 126 |
# Local Variables: |
| 127 |
# mode: Shell-script |
| 128 |
# End: |