forked from openSUSE/obs-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
call-flatpak-builder
executable file
·60 lines (48 loc) · 1.42 KB
/
call-flatpak-builder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
export BUILD_DIR=${BUILD_DIR:-/usr/lib/build}
IS_UNSHARED=
while test -n "$1" ; do
case "$1" in
--root)
BUILD_ROOT="$2"
shift 2
;;
--isunshared)
IS_UNSHARED=true
shift
;;
*)
break
;;
esac
done
if test -z "$BUILD_ROOT" ; then
echo "Usage: call-flatpak-builder --root <buildroot>"
exit 1
fi
if test -z "$IS_UNSHARED" ; then
echo "Unsharing environment"
# unshare mounts and network
exec unshare -m -n $BUILD_DIR/call-flatpak-builder --isunshared --root "$BUILD_ROOT" "$@"
exit 1
fi
if test -n "$IS_UNSHARED" ; then
# make mounts private
mount --make-rprivate /
fi
if test "$BUILD_ROOT" != '/' ; then
# make build root a mount point
mount --rbind --make-private "$BUILD_ROOT" "$BUILD_ROOT"
mount --make-rprivate "$BUILD_ROOT"
fi
# setup mounts
test -e "$BUILD_ROOT/proc/self" || mount -n -tproc none $BUILD_ROOT/proc
set -x
# Build into repo
chroot "$BUILD_ROOT" bash -c "cd /usr/src/packages/FLATPAK_ROOT && flatpak-builder --default-branch=$FLATPAK_APP_VERSION --force-clean --repo=$FLATPAK_REPO build-dir $FLATPAK_FILE"
# Create bundle from repo
VERSION_RELEASE="$FLATPAK_APP_VERSION"
if [[ -n $RELEASE ]]; then
VERSION_RELEASE+="-$RELEASE"
fi
chroot "$BUILD_ROOT" bash -c "flatpak build-bundle --runtime-repo=$FLATPAK_REMOTE $FLATPAK_REPO $TOPDIR/OTHER/$FLATPAK_APP-$VERSION_RELEASE.flatpak $FLATPAK_APP $FLATPAK_APP_VERSION"