2016-03-04 05:17:53 +03:00
#!/bin/bash
#
# Copyright (C) 2016 Colin Walters <walters@verbum.org>
#
2018-01-30 22:26:26 +03:00
# SPDX-License-Identifier: LGPL-2.0+
#
2016-03-04 05:17:53 +03:00
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
2021-12-07 04:20:55 +03:00
# License along with this library. If not, see <https://www.gnu.org/licenses/>.
2016-03-04 05:17:53 +03:00
set -euo pipefail
. $( dirname $0 ) /libtest.sh
2016-03-31 15:44:27 +03:00
skip_without_fuse
2016-03-31 13:06:05 +03:00
skip_without_user_xattrs
2016-03-04 05:17:53 +03:00
echo "1..1"
# Run "triggers" like ldconfig, gtk-update-icon-cache, etc.
demo_triggers( ) {
root = $1
shift
mkdir -p ${ root } /usr/lib
echo updated ldconfig at $( date) > ${ root } /usr/lib/ld.so.cache.new
mv ${ root } /usr/lib/ld.so.cache{ .new,}
}
# Make a binary in /usr/bin/$pkg which contains $version
exampleos_build_commit_package( ) {
pkg = $1
version = $2
mkdir -p ${ pkg } -package/usr/bin/
echo " ${ pkg } -content ${ version } " > ${ pkg } -package/usr/bin/${ pkg }
# Use a dummy subject for this.
2016-04-07 10:55:54 +03:00
${ CMD_PREFIX } ostree --repo= build-repo commit -b exampleos/x86_64/${ pkg } -s '' --tree= dir = ${ pkg } -package
2016-03-04 05:17:53 +03:00
rm ${ pkg } -package -rf
}
exampleos_recompose( ) {
rm exampleos-build -rf
for pkg in ${ packages } ; do
2016-04-07 10:55:54 +03:00
${ CMD_PREFIX } ostree --repo= build-repo checkout -U --union exampleos/x86_64/${ pkg } exampleos-build
2016-03-04 05:17:53 +03:00
done
# Now that we have our rootfs, run triggers
rofiles-fuse exampleos-build mnt
demo_triggers mnt/
fusermount -u mnt
# Then we commit it, using --link-checkout-speedup to effectively
# only re-checksum the ldconfig file. We also have dummy commit
# message here.
2016-04-07 10:55:54 +03:00
${ CMD_PREFIX } ostree --repo= build-repo commit -b exampleos/x86_64/standard -s 'exampleos build' --link-checkout-speedup exampleos-build
2016-03-04 05:17:53 +03:00
}
packages = "bash systemd"
mkdir build-repo
2017-03-24 17:35:59 +03:00
ostree_repo_init build-repo --mode= bare-user
2016-03-04 05:17:53 +03:00
mkdir repo
2017-09-01 23:15:33 +03:00
ostree_repo_init repo --mode= archive
2016-03-04 05:17:53 +03:00
# Our FUSE mount point
mkdir mnt
# "Build" some packages which are really just files with
# the version number inside.
exampleos_build_commit_package bash 0.4.7
exampleos_build_commit_package systemd 224
# Now union the packages and commit
exampleos_recompose
# This is our first commit - let's publish it.
2016-04-07 10:55:54 +03:00
${ CMD_PREFIX } ostree --repo= repo pull-local build-repo exampleos/x86_64/standard
2016-03-04 05:17:53 +03:00
# Now, update the bash package - this is a new commit on the branch
# exampleos/x86_64/bash.
exampleos_build_commit_package bash 0.5.0
# We now have two commits
exampleos_recompose
# Publish again:
2016-04-07 10:55:54 +03:00
${ CMD_PREFIX } ostree --repo= repo pull-local build-repo exampleos/x86_64/standard
2016-03-04 05:17:53 +03:00
# Optional: Generate a static delta vs the previous build
2016-04-07 10:55:54 +03:00
${ CMD_PREFIX } ostree --repo= repo static-delta generate exampleos/x86_64/standard
2016-03-04 05:17:53 +03:00
# Optional: Regenerate the summary file
2016-04-07 10:55:54 +03:00
${ CMD_PREFIX } ostree --repo= repo summary -u
2016-03-04 05:17:53 +03:00
# Try: ostree --repo=demo-repo ls -R exampleos/x86_64/standard
echo "ok demo buildsystem"