Hello World

File build-recipe-flatpak of Package build

#################################################################
#
# 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
    "$DO_INIT_TOPDIR" && rm -rf "$BUILD_ROOT$TOPDIR"
    for i in OTHER SOURCES FLATPAK_ROOT ; do
	mkdir -p "$BUILD_ROOT$TOPDIR/$i"
    done
    if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
	mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
    else
	copy_sources "$MYSRCDIR" "$BUILD_ROOT$TOPDIR/SOURCES/"
    fi
    chown -hR "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
}

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
    for i in ../tars/*.tar.gz; do
      echo "Unpacking $i"
      pkg="$(basename $i)" pkg="${pkg/-*}"
      [[ -d $pkg ]] || tar xf $i
    done

#    env | sort

#    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_FILE_LOCAL="$TOPDIR/SOURCES/flatpak-local.yaml"
    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)
    # Rewrite http urls to file urls
    perl -I$BUILD_DIR -MBuild::Flatpak -e 'Build::Flatpak::rewrite' -- "$BUILD_ROOT$FLATPAK_FILE" > "$BUILD_ROOT$FLATPAK_FILE_LOCAL"
    FLATPAK_FILE="$FLATPAK_FILE_LOCAL"
    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
    export RELEASE

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

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


    set +e

    BUILD_SUCCEEDED=true
}

recipe_resultdirs_flatpak() {
    :
}

recipe_cleanup_flatpak() {
    :
}

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