File: build-recipe-flatpak

package info (click to toggle)
obs-build 20210120-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,080 kB
  • sloc: perl: 11,428; sh: 3,340; ansic: 285; makefile: 172
file content (118 lines) | stat: -rw-r--r-- 3,244 bytes parent folder | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#################################################################
#
# Flatpak specific functions.
#
# Author: Tina Müller <tina.mueller@suse.com>
#
################################################################
#
# Copyright © 2020 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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; if not, see <http://www.gnu.org/licenses/>.
#
################################################################


recipe_setup_flatpak() {
    echo $BUILD_ROOT
    pwd
    TOPDIR=/usr/src/packages
    set -x
    "$DO_INIT_TOPDIR" && rm -rf "$BUILD_ROOT$TOPDIR"
    for i in OTHER SOURCES FLATPAK_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
    set +x

}

recipe_prepare_flatpak() {
    :
}

# Variables:
# $BUILD_ROOT is the chroot
# $TOPDIR/SOURCES includes the sources
# $RECIPEFILE the name of the flatpak.(yaml|json) config file

recipe_build_flatpak() {
    echo "===================== recipe_build_flatpak ($@)"
    set -e

    mkdir -p "$BUILD_ROOT/var/lib/flatpak/runtime"
    cd "$BUILD_ROOT/var/lib/flatpak/runtime"
    # Unpack the tarfiles installed by the rpms
    local pkg
    set -x
    for i in ../tars/*.tar.gz; do
      echo "Unpacking $i"
      pkg="$(basename $i)" pkg="${pkg/-*}"
      [[ -d $pkg ]] || tar xf $i
    done

#    env | sort

    set -x
#    perl -v
#    perl -wE'use JSON::PP 99' || true
#    perl -wE'use YAML::XS 99' || true
#    perl -wE'use YAML::PP 99' || true
#    perl -wE'use URI 99' || true

    ls -l $BUILD_ROOT$TOPDIR/SOURCES
    cd "$BUILD_ROOT$TOPDIR/FLATPAK_ROOT"
    cp $BUILD_ROOT$TOPDIR/SOURCES/* .

    local FLATPAK_FILE="$TOPDIR/SOURCES/$RECIPEFILE"
    local FLATPAK_APP=$(perl -I$BUILD_DIR -MBuild::Flatpak -e 'Build::Flatpak::show' -- "$BUILD_ROOT$FLATPAK_FILE" name)
    local FLATPAK_APP_VERSION=$(perl -I$BUILD_DIR -MBuild::Flatpak -e 'Build::Flatpak::show' -- "$BUILD_ROOT$FLATPAK_FILE" version)
    FLATPAK_APP_VERSION="${FLATPAK_APP_VERSION:-0}"
    local FLATPAK_REPO=/tmp/flatpakrepo
    local FLATPAK_REMOTE=https://dl.flathub.org/repo/flathub.flatpakrepo
    export FLATPAK_REPO
    export FLATPAK_REMOTE
    export FLATPAK_APP
    export FLATPAK_APP_VERSION
    export FLATPAK_FILE
    export TOPDIR

    modprobe fuse
    chroot "$BUILD_ROOT" su -c "flatpak list"

    $BUILD_DIR/call-flatpak-builder --root "$BUILD_ROOT"

    set +x

    set +e

    BUILD_SUCCEEDED=true
}

recipe_resultdirs_flatpak() {
    :
}

recipe_cleanup_flatpak() {
    :
}

# Local Variables:
# mode: Shell-script
# End: