479406e6a5
Let's modernize and start supporting YAML treefiles. I'll dare make the sweeping generalization that most people would prefer reading and writing YAML over JSON. This takes bits from coreos-assembler[1] that know how to serialize a YAML file and spit it back out as a JSON and makes it into a shared lib that we can link against. We could use this eventually for JSON inputs as well to force a validation check before composing. If we go this route, we could then turn on `--enable-rust` in FAHC for now and drop the duplicate code in coreos-assembler. [1] https://github.com/cgwalters/coreos-assembler Closes: #1377 Approved by: cgwalters
63 lines
1.6 KiB
Bash
63 lines
1.6 KiB
Bash
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}
|
|
. ${dn}/../common/libtest.sh
|
|
|
|
export repo=$(pwd)/repo
|
|
export repobuild=$(pwd)/repo-build
|
|
|
|
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,}
|
|
}
|
|
|
|
pyappendjsonmember() {
|
|
pyeditjson "jd['"$1"'] += $2" < ${treefile} > ${treefile}.new && mv ${treefile}{.new,}
|
|
}
|
|
|
|
prepare_compose_test() {
|
|
name=$1
|
|
shift
|
|
ostree --repo=${repo} init --mode=archive
|
|
echo 'fsync=false' >> ${repo}/config
|
|
ostree --repo=${repobuild} init --mode=bare-user
|
|
echo 'fsync=false' >> ${repobuild}/config
|
|
mkdir -p ${test_compose_datadir}/cache
|
|
cp -r ${dn}/../composedata .
|
|
# 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
|
|
export treefile=composedata/fedora-${name}.json
|
|
pyeditjson "jd['ref'] += \"/${name}\"" < composedata/fedora-base.json > ${treefile}
|
|
pysetjsonmember "repos" '["fedora-local"]' ${treefile}
|
|
# FIXME extract from json
|
|
export treeref=fedora/stable/x86_64/${name}
|
|
}
|
|
|
|
compose_base_argv="--repo ${repobuild}"
|
|
runcompose() {
|
|
rpm-ostree compose tree ${compose_base_argv} ${treefile} "$@"
|
|
ostree --repo=${repo} pull-local ${repobuild}
|
|
}
|
|
|
|
prepare_run_compose() {
|
|
prepare_compose_test $1
|
|
runcompose
|
|
}
|