2017-03-07 20:08:44 +03:00
#!/bin/bash
#
# Copyright (C) 2017 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
. ${ commondir } /libtest.sh
. ${ commondir } /libvm.sh
set -x
vm_assert_layered_pkg foo absent
2017-05-19 16:44:57 +03:00
vm_cmd ostree refs $( vm_get_deployment_info 0 checksum) --create vmcheck_tmp/without_foo
2017-06-29 17:11:25 +03:00
vm_build_rpm foo version 1.2 release 3
vm_rpmostree install /tmp/vmcheck/yumrepo/packages/x86_64/foo-1.2-3.x86_64.rpm
2017-03-07 20:08:44 +03:00
echo "ok install foo locally"
vm_reboot
vm_assert_status_jq '.deployments[0]["packages"]|length == 0'
vm_assert_status_jq '.deployments[0]["requested-packages"]|length == 0'
vm_assert_status_jq '.deployments[0]["requested-local-packages"]|length == 1'
2017-06-29 17:11:25 +03:00
vm_has_local_packages foo-1.2-3.x86_64
vm_assert_layered_pkg foo-1.2-3.x86_64 present
2017-03-07 20:08:44 +03:00
echo "ok pkg foo added locally"
# check that we can still request foo and it's dormant
vm_rpmostree install foo
vm_assert_status_jq '.deployments[0]["packages"]|length == 0'
vm_assert_status_jq '.deployments[0]["requested-packages"]|length == 1'
vm_assert_status_jq '.deployments[0]["requested-local-packages"]|length == 1'
echo "ok request foo"
# check that uninstalling the local rpm makes us go back to repos
2017-06-29 17:11:25 +03:00
vm_rpmostree uninstall foo-1.2-3.x86_64
2017-03-07 20:08:44 +03:00
vm_assert_status_jq '.deployments[0]["packages"]|length == 1'
vm_assert_status_jq '.deployments[0]["requested-packages"]|length == 1'
vm_assert_status_jq '.deployments[0]["requested-local-packages"]|length == 0'
echo "ok layer foo back from repos"
# check that trying to install a package already in the base errors out
vm_cmd ostree refs $( vm_get_deployment_info 0 checksum) --create vmcheck_tmp/with_foo
vm_cmd ostree commit -b vmcheck --tree= ref = vmcheck_tmp/with_foo
vm_rpmostree uninstall foo
vm_rpmostree upgrade # upgrades to new base which has foo
2017-06-29 17:11:25 +03:00
if vm_rpmostree install /tmp/vmcheck/yumrepo/packages/x86_64/foo-1.2-3.x86_64.rpm; then
2017-03-07 20:08:44 +03:00
assert_not_reached "didn't error out when trying to install same pkg"
fi
echo "ok error on layering same pkg in base"
2017-05-19 16:44:57 +03:00
# check that installing local RPMs without any repos available works
vm_cmd ostree commit -b vmcheck --tree= ref = vmcheck_tmp/without_foo
vm_rpmostree upgrade
vm_cmd rm -rf /etc/yum.repos.d/
2017-06-29 17:11:25 +03:00
vm_rpmostree install /tmp/vmcheck/yumrepo/packages/x86_64/foo-1.2-3.x86_64.rpm
2017-05-19 16:44:57 +03:00
echo "ok layer local foo without repos"