2015-03-23 14:23:29 +03:00
#!/bin/bash
#
# Copyright (C) 2015 Red Hat Inc.
#
# 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
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -e
2016-06-06 19:46:48 +03:00
. ${ commondir } /libtest.sh
2015-03-23 14:23:29 +03:00
check_root_test
2016-06-06 23:32:37 +03:00
# Let's create a temporary pkglibdir and tell rpm-ostree to use that dir
# instead of the (non-existent) installed version
mkdir pkglibdir
2016-06-15 23:30:11 +03:00
ln -s ${ topsrcdir } /src/app/rpm-ostree-0-integration.conf pkglibdir/
2016-06-06 23:32:37 +03:00
export RPMOSTREE_UNINSTALLED_PKGLIBDIR = $PWD /pkglibdir
2015-03-23 14:23:29 +03:00
2016-06-06 19:46:48 +03:00
composedir = ${ commondir } /compose
2016-04-28 15:59:20 +03:00
arch = $( arch)
if ! test " ${ arch } " = x86_64; then
echo 1>& 2 " $0 can be run only on x86_64 " ; echo "1..0" ; exit 77
fi
testref = fedora/${ arch } /test
2015-03-23 14:23:29 +03:00
2016-04-04 19:12:27 +03:00
echo "1..4"
2015-03-23 14:23:29 +03:00
ostree init --repo= repo --mode= archive-z2
echo "ok setup"
2016-06-06 19:46:48 +03:00
rpm-ostree --repo= repo compose --dry-run tree ${ composedir } /test-repo.json
2016-03-01 23:38:45 +03:00
ostree --repo= repo refs >refs.txt
assert_file_empty refs.txt
rm refs.txt
echo "ok dry run"
2016-06-06 19:46:48 +03:00
rpm-ostree --repo= repo compose tree ${ composedir } /test-repo.json
2016-03-01 23:38:45 +03:00
ostree --repo= repo refs >refs.txt
2016-04-28 15:59:20 +03:00
assert_file_has_content refs.txt ${ testref }
2016-03-01 23:38:45 +03:00
echo "ok compose"
2016-04-04 19:12:27 +03:00
# bring them in the current context so we can modify exported_file
2016-06-06 19:46:48 +03:00
ln -s ${ composedir } /test-repo-add-files.json .
ln -s ${ composedir } /test-repo.repo .
2016-04-04 19:12:27 +03:00
echo hello > exported_file
rpm-ostree --repo= repo compose tree --touch-if-changed= $( pwd ) /touched test-repo-add-files.json
assert_has_file touched
old_mtime = $( stat -c %y touched)
ostree --repo= repo ls fedora/test /exports/exported_file | grep exported > exported.txt
assert_file_has_content exported.txt "/exports/exported_file"
assert_file_has_content exported.txt "0 0"
ostree --repo= repo rev-parse fedora/test > oldref.txt
rpm-ostree --repo= repo compose tree --touch-if-changed= $( pwd ) /touched test-repo-add-files.json
new_mtime = $( stat -c %y touched)
ostree --repo= repo rev-parse fedora/test > newref.txt
assert_streq $( cat oldref.txt) $( cat newref.txt)
assert_streq " $old_mtime " " $new_mtime "
echo . >> exported_file
rpm-ostree --repo= repo compose tree --touch-if-changed= $( pwd ) /touched test-repo-add-files.json
new_mtime = $( stat -c %y touched)
ostree --repo= repo rev-parse fedora/test > newref.txt
assert_not_streq $( cat oldref.txt) $( cat newref.txt)
assert_not_streq " $old_mtime " " $new_mtime "
echo "ok compose add files"