2016-12-03 02:07:08 +03:00
dn = $( cd $( dirname $0 ) && pwd )
test_tmpdir = $( mktemp -d /var/tmp/rpm-ostree-compose-test.XXXXXX)
touch ${ test_tmpdir } /.test
trap _cleanup_tmpdir EXIT
cd ${ test_tmpdir }
2018-01-09 23:38:09 +03:00
. ${ dn } /../common/libtest.sh
2016-12-03 02:07:08 +03:00
2018-05-31 23:31:22 +03:00
export repo = $( pwd ) /repo
export repobuild = $( pwd ) /repo-build
2016-12-03 02:07:08 +03:00
pyeditjson( ) {
cat >editjson.py <<EOF
import sys,json
jd = json.load( sys.stdin)
${ 1 }
json.dump( jd,sys.stdout)
EOF
python ./editjson.py && rm -f ./editjson.py
}
pysetjsonmember( ) {
pyeditjson "jd['" $1 " '] = $2 " < ${ treefile } > ${ treefile } .new && mv ${ treefile } { .new,}
}
2016-12-09 01:31:20 +03:00
pyappendjsonmember( ) {
pyeditjson "jd['" $1 " '] += $2 " < ${ treefile } > ${ treefile } .new && mv ${ treefile } { .new,}
}
2016-12-03 02:07:08 +03:00
prepare_compose_test( ) {
name = $1
shift
2017-11-30 22:32:49 +03:00
ostree --repo= ${ repo } init --mode= archive
2017-12-01 19:06:11 +03:00
echo 'fsync=false' >> ${ repo } /config
2017-11-30 22:32:49 +03:00
ostree --repo= ${ repobuild } init --mode= bare-user
2017-12-01 19:06:11 +03:00
echo 'fsync=false' >> ${ repobuild } /config
2017-11-30 22:32:49 +03:00
mkdir -p ${ test_compose_datadir } /cache
2016-12-03 02:07:08 +03:00
cp -r ${ dn } /../composedata .
2017-11-30 22:32:49 +03:00
# We use the local RPM package cache
rm -f composedata/*.repo
cat > composedata/fedora-local.repo <<EOF
[ fedora-local]
baseurl = ${ test_compose_datadir } /cache
enabled = 1
gpgcheck = 0
EOF
2016-12-03 02:07:08 +03:00
export treefile = composedata/fedora-${ name } .json
pyeditjson " jd['ref'] += \"/ ${ name } \" " < composedata/fedora-base.json > ${ treefile }
2017-11-30 22:32:49 +03:00
pysetjsonmember "repos" '["fedora-local"]' ${ treefile }
2016-12-03 02:07:08 +03:00
# FIXME extract from json
2017-07-17 20:40:25 +03:00
export treeref = fedora/stable/x86_64/${ name }
2016-12-03 02:07:08 +03:00
}
2017-11-30 22:32:49 +03:00
compose_base_argv = " --repo ${ repobuild } "
2016-12-03 02:07:08 +03:00
runcompose( ) {
2018-07-31 16:55:31 +03:00
echo " $( date) : starting compose "
bin/compose: Expose phases as [install, postprocess, commit] cmds
Right now `rpm-ostree compose tree` is very prescriptive about how things work.
Trying to add anything that isn't an RPM is absolutely fighting the system. Our
postprocessing system *enforces* no network access (good for reproducibilty, but
still prescriptive).
There's really a logical split between three phases:
- install: "build a rootfs that installs packages"
- postprocess: "run magical ostree postprocessing like kernel"
- commit: "commit result to ostree"
So there are two high level flows I'd like to enable here. First is to allow
people to do *arbitrary* postprocessing between `install` and `commit`. For
example, run Ansible and change `/etc`. This path basically is like what we have
today with `postprocess-script.sh`, except the builder can do anything they want
with network access enabled.
Going much farther, this helps us support a "build with Dockerfile" style flow.
We can then provide tooling to extract the container image, and combine
`postprocess` and `commit`.
Or completely the other way - if for example someone wants to use `rpm-ostree
compose install`, they could tar up the result as a Docker/OCI image. That's now
easier; an advantage of this flow over e.g. `yum --installroot` is the "change
detection" code we have.
Related issues/PRs:
- https://github.com/projectatomic/rpm-ostree/pull/96
- https://github.com/projectatomic/rpm-ostree/issues/471
One disadvantage of this approach right now is that if one *does* go for
the split approach, we lose the "input hash" metadata for example. And
down the line, I'd like to add even more metadata, like the input rpm repos,
which could also be rendered on the client side.
But, I think we can address that later by e.g. caching the metadata in a file in
the install root and picking it back up or something.
Closes: #1039
Approved by: jlebon
2017-10-12 21:56:08 +03:00
rpm-ostree compose tree ${ compose_base_argv } ${ treefile } " $@ "
2016-12-03 02:07:08 +03:00
ostree --repo= ${ repo } pull-local ${ repobuild }
2018-07-31 16:55:31 +03:00
echo " $( date) : finished compose "
2016-12-03 02:07:08 +03:00
}
prepare_run_compose( ) {
prepare_compose_test $1
runcompose
}