#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
from . import testutils
if __name__ == "__main__":
import pkg5unittest
import os
pkgs = """
open A@1.0,5.11-0
add depend type=require fmri=liveroot
close
open B@1.0,5.11-0
add depend type=group fmri=liveroot
close
open Bobcats@1.0,5.11-0
close
open C@1.0,5.11-0
add depend type=group fmri=A
add depend type=group fmri=B
close
open D@1.0,5.11-0
add depend type=require fmri=B
close
open E@1.0,5.11-0
close
open E@2.0,5.11-0
add depend type=require fmri=A@1.0
close
open E@3.0,5.11-0
add depend type=require fmri=B@1.0
close
open E@4.0,5.11-0
close
open F@1.0,5.11-0
add depend type=group fmri=A@1.0
close
open F@2.0,5.11-0
add depend type=group fmri=A@1.0
add depend type=group fmri=B@1.0
close
open F@3.0,5.11-0
add depend type=group fmri=A@1.0
add depend type=group fmri=B@1.0
add depend type=group fmri=C@1.0
close
open F@4.0,5.11-0
add depend type=group fmri=A@1.0
add depend type=group fmri=B@1.0
add depend type=group fmri=C@1.0
add depend type=group fmri=D@1.0
close
open G@1.0,5.11-0
close
open G@2.0,5.11-0
add set name=pkg.obsolete value=true
close
open G@3.0,5.11-0
close
open H@1.0,5.11-0
add depend type=group fmri=G
close
open I@1.0,5.11-0
add depend type=incorporate fmri=G@1.0
close
open I@2.0,5.11-0
add depend type=incorporate fmri=G@2.0
close
open I@3.0,5.11-0
add depend type=incorporate fmri=G@3.0
close
open liveroot@1.0
add dir path=/etc mode=755 owner=root group=root
close
"""
"""Returns a tuple of (avoid, implicit_avoid, obsolete)
representing packages being avoided by image configuration or
due to package constraints (respectively)."""
implicit_avoid = set()
for stem in d:
if d[stem] == "avoid":
elif d[stem] == "implicit-avoid":
elif d[stem] == "obsolete":
msg="avoids")
msg="implicit avoids")
msg="obsolete avoids")
"""Make sure group dependencies work"""
# make sure that unavoiding a package which isn't avoided
# doesn't traceback.
# make sure group dependency brings in packages
# test that we don't avoid packages when we
# uninstall group at the same time
# avoid a package
# and then see if it gets brought in
# unavoiding it should fail because there
# is a group dependency on it...
# installing it should work
# B should no longer be in avoid list
# avoiding installed packages should fail
"""Show that require dependencies 'overpower' avoid state"""
# test require dependencies w/ avoid
# D will have forced in B
# check to make sure we're avoiding despite
# forced install of B
# Uninstall of D removes B as well
"""Test to make sure avoided packages
are removed when required dependency
goes away"""
# examine upgrade behavior
"""test aspects of reject."""
# make sure install w/ --reject
# places packages w/ group dependencies
# on avoid list
# install A and see it removed from avoid list
# remove A and see it added to avoid list
# update F and see A kept out, but B added
# update everything
# check 17264951
# break something so pkg fix will do some work
"""Make sure --reject places packages
on avoid list; insure that multiple
group dependencies don't overcome
avoid list, and that require dependencies
do."""
"""Make sure we're down w/ obsoletions, and that
they are automatically placed on the avoid list"""
# update I; this will force G to an obsolete
# version. This should place it on the
# avoid list
# update I again; this should bring G back
# as it is no longer obsolete.
"""Make sure pkg unavoid should always allow installed packages
that are a target of group dependencies to be unavoided."""
# Avoid package liveroot to put it on the avoid list.
# A has require dependency on liveroot and B has group
# dependency on liveroot. Since require dependency 'overpower'
# avoid state, liveroot is required to be installed.
self.get_img_path()))
# Make sure liveroot is still on the avoid list.
# Unable to uninstall A because the package system currently
# requires the avoided package liveroot to be uninstalled,
# which requires reboot.
# We need to remove liveroot from the avoid list, and pkg unvoid
# should allow installed packages that are a target of group
# dependencies to be unavoided.
# Uninstall A should succeed now because liveroot is not on the
# avoid list.
self.get_img_path()))
# test for empty avoid set file
f.truncate(0)
# test avoid set file having junk values
f.write('Some junk value\n')
"""Verify that trimmed group dependencies are placed on the
correct avoid list."""
exclude_pkgs = \
"""open bar@1.0
add depend type=group fmri=foo
close
open baz@1.0
add depend type=exclude fmri=foo
close
open foo@1.0
close"""
# Install bar; foo should also be installed.
)
# Install baz; should fail since foo is installed and it is
# excluded.
# Remove foo; foo should be placed on avoid list.
)
# Remove all packages.
)
# Foo should still be on the avoid list.
# Nothing should be installed.
# Install baz...
)
# ...and then try to install bar; it should fail because the
# installed 'baz' package has an 'exclude' dependency on foo.
# Currently, the solver only allows group dependencies to be
# satisfied if at least one fmri matches the group dependency or
# if the only matches are obsolete.
"""Verify that unused group-any dependencies are placed on the
implicit avoid list (invisible to administrator) and obsoletion
behavior."""
pkgs = [
"""open dbx@1.0
add depend type=group fmri=dbx-python
close""",
"""open dbx-python@1.0
add depend type=group-any fmri=python-26 fmri=python-27
close""",
"""open python-26@2.6
close""",
"""open python-27@2.7
close""",
"""open python-26@2.6.1
add set name=pkg.obsolete value=true
close""",
"""open python-27@2.7.1
add set name=pkg.obsolete value=true
close"""
]
# Install dbx; should succeed even though no dbx-python is
# available.
)
# Publish dbx-python; pkg verify should still succeed.
# Install dbx-python; should succeed even though no python-*
# package is available and should be removed from implicit avoid
# list automatically.
)
"python-27"]))
# Remove dbx-python; python-26 and python-27 should be removed
# from implicit avoid list.
)
# Publish python-26; pkg verify should still
# succeed.
# Install dbx-python; python-26 should also be installed.
)
# Publish python-27; pkg verify should still succeed.
# pkg update should do nothing since optimal solution is to
# simply leave python-26 installed and not install python-27.
# Publish obsolete python-26; pkg verify should still succeed.
# pkg update should remove python-26 and place it on the
# obsolete list, and install python-27 as we prefer newer
# versions of packages whenever possible.
)
# Publish obsolete python-27; pkg verify should still succeed.
# pkg update should remove python-27 and place it on the
# obsolete list as we prefer newer versions of packages whenever
# possible.
)
if __name__ == "__main__":