2016-06-22 00:35:51 +03:00
#!/bin/bash
#
# Copyright (C) 2016 Jonathan Lebon <jlebon@redhat.com>
#
# 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
. ${ commondir } /libtest.sh
. ${ commondir } /libvm.sh
set -x
2016-07-04 18:43:02 +03:00
# SUMMARY: basic sanity check of package layering
# METHOD:
# Add a package, verify that it was added, then remove it, and verify that
# it was removed.
2016-06-22 00:35:51 +03:00
2016-07-04 18:43:02 +03:00
# make sure the package is not already layered
vm_assert_layered_pkg foo absent
2017-02-08 01:49:20 +03:00
vm_assert_status_jq \
'.deployments[0]["base-checksum"]|not' \
'.deployments[0]["pending-base-checksum"]|not'
2016-06-22 00:35:51 +03:00
2017-06-05 19:38:39 +03:00
# make sure installing in /opt fails
2017-06-29 17:11:25 +03:00
vm_build_rpm test-opt \
files /opt/app \
install " mkdir -p %{buildroot}/opt/app/bin
touch %{ buildroot} /opt/app/bin/foo"
2017-02-13 19:33:50 +03:00
if vm_rpmostree install test-opt-1.0 2>err.txt; then
assert_not_reached "Was able to install a package in /opt"
fi
assert_file_has_content err.txt "See https://github.com/projectatomic/rpm-ostree/issues/233"
echo "ok failed to install in opt"
2017-06-29 17:11:25 +03:00
vm_build_rpm foo
2017-01-17 21:29:48 +03:00
vm_rpmostree pkg-add foo-1.0
2017-02-08 18:11:10 +03:00
vm_cmd ostree --repo= /sysroot/ostree/repo/extensions/rpmostree/pkgcache refs | grep /foo/> refs.txt
pkgref = $( head -1 refs.txt)
vm_cmd ostree --repo= /sysroot/ostree/repo/extensions/rpmostree/pkgcache show --print-metadata-key rpmostree.repo ${ pkgref } >refdata.txt
assert_file_has_content refdata.txt 'id.*test-repo'
rm -f refs.txt refdata.txt
2016-06-22 00:35:51 +03:00
echo "ok pkg-add foo"
vm_reboot
2017-02-08 01:49:20 +03:00
vm_assert_status_jq \
'.deployments[0]["base-checksum"]' \
'.deployments[0]["pending-base-checksum"]|not'
2016-06-22 00:35:51 +03:00
2016-11-14 22:28:38 +03:00
vm_assert_layered_pkg foo-1.0 present
2016-07-04 18:43:02 +03:00
echo "ok pkg foo added"
2016-06-22 00:35:51 +03:00
2017-06-29 17:11:25 +03:00
output = $( vm_cmd /usr/bin/foo)
2017-07-04 20:04:07 +03:00
if [ [ $output != foo-1.0-1.x86_64 ] ] ; then
2016-06-22 00:35:51 +03:00
assert_not_reached "foo printed wrong output"
fi
echo "ok correct output"
2017-06-14 23:12:38 +03:00
# upgrade to a layer with foo already builtin
vm_cmd ostree commit -b vmcheck --tree= ref = $( vm_get_booted_csum)
vm_rpmostree upgrade
2017-06-29 17:11:25 +03:00
vm_build_rpm bar conflicts foo
2017-06-14 23:12:38 +03:00
if vm_rpmostree install bar & > err.txt; then
assert_not_reached "successfully layered conflicting pkg bar?"
fi
assert_file_has_content err.txt "The following base packages would be removed"
assert_file_has_content err.txt "foo-1.0-1.x86_64"
vm_rpmostree cleanup -p
vm_cmd ostree reset vmcheck $( vm_cmd ostree rev-parse "vmcheck^" )
echo "ok can't layer pkg that would remove base pkg"
2017-02-04 02:18:23 +03:00
# check that root is a shared mount
# https://bugzilla.redhat.com/show_bug.cgi?id=1318547
if ! vm_cmd "findmnt / -no PROPAGATION" | grep shared; then
assert_not_reached "root is not mounted shared"
fi
2017-01-17 21:29:48 +03:00
vm_rpmostree pkg-remove foo-1.0
2016-07-04 18:43:02 +03:00
echo "ok pkg-remove foo"
2016-06-22 00:35:51 +03:00
vm_reboot
2016-07-04 18:43:02 +03:00
vm_assert_layered_pkg foo absent
echo "ok pkg foo removed"
2017-02-09 01:38:49 +03:00
vm_rpmostree cleanup -b
vm_assert_status_jq '.deployments|length == 2'
echo "ok baseline cleanup"
2017-03-07 20:08:44 +03:00
2017-02-09 01:38:49 +03:00
vm_rpmostree cleanup -r
vm_assert_status_jq '.deployments|length == 1'
vm_rpmostree cleanup -pr
vm_assert_status_jq '.deployments|length == 1'
vm_rpmostree pkg-add foo-1.0
vm_assert_status_jq '.deployments|length == 2'
vm_rpmostree cleanup -pr
vm_assert_status_jq '.deployments|length == 1'
echo "ok cleanup"
2017-05-09 00:10:49 +03:00
# install foo and make sure it was imported
vm_rpmostree install foo | tee output.txt
assert_file_has_content output.txt '^Importing:'
# upgrade with same foo in repos --> shouldn't re-import
vm_cmd ostree commit -b vmcheck --tree= ref = vmcheck
vm_rpmostree upgrade | tee output.txt
assert_not_file_has_content output.txt '^Importing:'
# upgrade with different foo in repos --> should re-import
2017-06-29 17:11:25 +03:00
c1 = $( sha256sum ${ test_tmpdir } /yumrepo/packages/x86_64/foo-1.0-1.x86_64.rpm)
vm_build_rpm foo
c2 = $( sha256sum ${ test_tmpdir } /yumrepo/packages/x86_64/foo-1.0-1.x86_64.rpm)
2017-05-09 00:10:49 +03:00
if cmp -s c1 c2; then
assert_not_reached "RPM rebuild yielded same SHA256"
fi
vm_rpmostree upgrade | tee output.txt
assert_file_has_content output.txt '^Importing:'
echo "ok invalidate pkgcache from RPM chksum"