Blame tests/test-demo-buildsystem.sh

Packit Service 2a3f3d
#!/bin/bash
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# Copyright (C) 2016 Colin Walters <walters@verbum.org>
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# SPDX-License-Identifier: LGPL-2.0+
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# This library is free software; you can redistribute it and/or
Packit Service 2a3f3d
# modify it under the terms of the GNU Lesser General Public
Packit Service 2a3f3d
# License as published by the Free Software Foundation; either
Packit Service 2a3f3d
# version 2 of the License, or (at your option) any later version.
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# This library is distributed in the hope that it will be useful,
Packit Service 2a3f3d
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2a3f3d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 2a3f3d
# Lesser General Public License for more details.
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# You should have received a copy of the GNU Lesser General Public
Packit Service 2a3f3d
# License along with this library; if not, write to the
Packit Service 2a3f3d
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit Service 2a3f3d
# Boston, MA 02111-1307, USA.
Packit Service 2a3f3d
Packit Service 2a3f3d
set -euo pipefail
Packit Service 2a3f3d
Packit Service 2a3f3d
. $(dirname $0)/libtest.sh
Packit Service 2a3f3d
Packit Service 2a3f3d
skip_without_fuse
Packit Service 2a3f3d
skip_without_user_xattrs
Packit Service 2a3f3d
Packit Service 2a3f3d
echo "1..1"
Packit Service 2a3f3d
Packit Service 2a3f3d
# Run "triggers" like ldconfig, gtk-update-icon-cache, etc.
Packit Service 2a3f3d
demo_triggers() {
Packit Service 2a3f3d
    root=$1
Packit Service 2a3f3d
    shift
Packit Service 2a3f3d
    mkdir -p ${root}/usr/lib
Packit Service 2a3f3d
    echo updated ldconfig at $(date) > ${root}/usr/lib/ld.so.cache.new
Packit Service 2a3f3d
    mv ${root}/usr/lib/ld.so.cache{.new,}
Packit Service 2a3f3d
}
Packit Service 2a3f3d
Packit Service 2a3f3d
# Make a binary in /usr/bin/$pkg which contains $version
Packit Service 2a3f3d
exampleos_build_commit_package() {
Packit Service 2a3f3d
    pkg=$1
Packit Service 2a3f3d
    version=$2
Packit Service 2a3f3d
    mkdir -p ${pkg}-package/usr/bin/
Packit Service 2a3f3d
    echo "${pkg}-content ${version}" > ${pkg}-package/usr/bin/${pkg}
Packit Service 2a3f3d
    # Use a dummy subject for this.
Packit Service 2a3f3d
    ${CMD_PREFIX} ostree --repo=build-repo commit -b exampleos/x86_64/${pkg} -s '' --tree=dir=${pkg}-package
Packit Service 2a3f3d
    rm ${pkg}-package -rf
Packit Service 2a3f3d
}
Packit Service 2a3f3d
Packit Service 2a3f3d
exampleos_recompose() {
Packit Service 2a3f3d
    rm exampleos-build -rf
Packit Service 2a3f3d
    for pkg in ${packages}; do
Packit Service 2a3f3d
	${CMD_PREFIX} ostree --repo=build-repo checkout -U --union exampleos/x86_64/${pkg} exampleos-build
Packit Service 2a3f3d
    done
Packit Service 2a3f3d
Packit Service 2a3f3d
    # Now that we have our rootfs, run triggers
Packit Service 2a3f3d
    rofiles-fuse exampleos-build mnt
Packit Service 2a3f3d
    demo_triggers mnt/
Packit Service 2a3f3d
    fusermount -u mnt
Packit Service 2a3f3d
    
Packit Service 2a3f3d
    # Then we commit it, using --link-checkout-speedup to effectively
Packit Service 2a3f3d
    # only re-checksum the ldconfig file.  We also have dummy commit
Packit Service 2a3f3d
    # message here.
Packit Service 2a3f3d
    ${CMD_PREFIX} ostree --repo=build-repo commit -b exampleos/x86_64/standard -s 'exampleos build' --link-checkout-speedup exampleos-build
Packit Service 2a3f3d
}
Packit Service 2a3f3d
Packit Service 2a3f3d
packages="bash systemd"
Packit Service 2a3f3d
Packit Service 2a3f3d
mkdir build-repo
Packit Service 2a3f3d
ostree_repo_init build-repo --mode=bare-user
Packit Service 2a3f3d
mkdir repo
Packit Service 2a3f3d
ostree_repo_init repo --mode=archive
Packit Service 2a3f3d
# Our FUSE mount point
Packit Service 2a3f3d
mkdir mnt
Packit Service 2a3f3d
Packit Service 2a3f3d
# "Build" some packages which are really just files with
Packit Service 2a3f3d
# the version number inside.
Packit Service 2a3f3d
exampleos_build_commit_package bash 0.4.7
Packit Service 2a3f3d
exampleos_build_commit_package systemd 224
Packit Service 2a3f3d
Packit Service 2a3f3d
# Now union the packages and commit
Packit Service 2a3f3d
exampleos_recompose
Packit Service 2a3f3d
Packit Service 2a3f3d
# This is our first commit - let's publish it.
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo pull-local build-repo exampleos/x86_64/standard
Packit Service 2a3f3d
Packit Service 2a3f3d
# Now, update the bash package - this is a new commit on the branch
Packit Service 2a3f3d
# exampleos/x86_64/bash.
Packit Service 2a3f3d
exampleos_build_commit_package bash 0.5.0
Packit Service 2a3f3d
Packit Service 2a3f3d
# We now have two commits
Packit Service 2a3f3d
exampleos_recompose
Packit Service 2a3f3d
Packit Service 2a3f3d
# Publish again:
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo pull-local build-repo exampleos/x86_64/standard
Packit Service 2a3f3d
# Optional: Generate a static delta vs the previous build
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo static-delta generate exampleos/x86_64/standard
Packit Service 2a3f3d
# Optional: Regenerate the summary file
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo summary -u
Packit Service 2a3f3d
Packit Service 2a3f3d
# Try: ostree --repo=demo-repo ls -R exampleos/x86_64/standard
Packit Service 2a3f3d
Packit Service 2a3f3d
echo "ok demo buildsystem"