# -*- coding: utf-8 -*-
#
# 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 errno
import hashlib
import os
import platform
import re
import shutil
import socket
import subprocess
import stat
import struct
import sys
import tempfile
import time
import unittest
try:
except ImportError:
"""Private helper class for shared functionality between test
classes."""
updated=[]):
"""Private helper function that verifies that expected editables
are listed in parsable output. If no editable of a given type
is specified, then no editable files are expected."""
changed = []
if moved:
if removed:
if installed:
if updated:
include=["change-editables"],
foo10 = """
open foo@1.0,5.11-0
close """
foo11 = """
open foo@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
add file tmp/libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1 timestamp="20080731T024051Z"
close """
foo12 = """
open foo@1.2,5.11-0
close """
afoo10 = """
close """
boring10 = """
open boring@1.0,5.11-0
close """
boring11 = """
open boring@1.1,5.11-0
close """
bar10 = """
open bar@1.0,5.11-0
add depend type=require fmri=pkg:/foo@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
bar11 = """
open bar@1.1,5.11-0
add depend type=require fmri=pkg:/foo@1.2
add dir mode=0755 owner=root group=bin path=/bin
close """
xfoo10 = """
open xfoo@1.0,5.11-0
close """
xbar10 = """
open xbar@1.0,5.11-0
add depend type=require fmri=pkg:/xfoo@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
xbar11 = """
open xbar@1.1,5.11-0
add depend type=require fmri=pkg:/xfoo@1.2
add dir mode=0755 owner=root group=bin path=/bin
close """
bar12 = """
open bar@1.2,5.11-0
add depend type=require fmri=pkg:/foo@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
baz10 = """
open baz@1.0,5.11-0
add depend type=require fmri=pkg:/foo@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
deep10 = """
open deep@1.0,5.11-0
add depend type=require fmri=pkg:/bar@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
xdeep10 = """
open xdeep@1.0,5.11-0
add depend type=require fmri=pkg:/xbar@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
ydeep10 = """
open ydeep@1.0,5.11-0
add depend type=require fmri=pkg:/ybar@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
a6018_1 = """
open a6018@1.0,5.11-0
close """
a6018_2 = """
open a6018@2.0,5.11-0
close """
b6018_1 = """
open b6018@1.0,5.11-0
add depend type=optional fmri=a6018@1
close """
badfile10 = """
open badfile@1.0,5.11-0
close """
baddir10 = """
open baddir@1.0,5.11-0
close """
a16189 = """
open a16189@1.0,5.11-0
add depend type=require fmri=pkg:/b16189@1.0
close """
b16189 = """
open b16189@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
fuzzy = """
open fuzzy@1.0,5.11-0
close
open fuzzy@2.0,5.11-0
close """
ffoo10 = """
open ffoo@1.0,5.11-0
close """
ffoo11 = """
open ffoo@1.1,5.11-0
close """
fbar10 = """
open fbar@1.0,5.11-0
add depend type=require fmri=pkg:/ffoo@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
fbar11 = """
open fbar@1.1,5.11-0
add depend type=require fmri=pkg:/ffoo@1.0
add dir mode=0755 owner=root group=bin path=/bin
close """
secret1 = """
open secret1@1.0-0
add dir mode=0755 owner=root group=bin path=/p1
close """
secret2 = """
open secret2@1.0-0
add dir mode=0755 owner=root group=bin path=/p2
close """
secret3 = """
open secret3@1.0-0
add dir mode=0755 owner=root group=bin path=/p3
close """
secret4 = """
open secret4@1.0-0
add dir mode=0755 owner=root group=bin path=/p3
close """
secret5 = """
open secret5@1.0-0
add dir mode=0755 owner=root group=bin path=/p3
close """
secret6 = """
open secret6@1.0-0
add dir mode=0755 owner=root group=bin path=/p3
add file tmp/cat mode=0555 owner=root group=bin sysattr=hidden,sensitive sysattr=system path=/p4/cat
close """
rofiles = """
open rofilesdir@1.0-0
add dir mode=0755 owner=root group=bin path=rofdir
close
open rofiles@1.0-0
close """
filemissing = """
open filemissing@1.0,5.11:20160426T084036Z
close
"""
manimissing = """
open manimissing@1.0,5.11:20160426T084036Z
close
"""
fhashes = {
}
"""Given an FMRI, return the path to its manifest in our
repository."""
usepub = "test"
if pub:
usepub, "pkg"]
"""Returns the path to a file in the repository. The path name
must be present in self.fhashes."""
"test", "file"])
return fpath
"""Test bad cli options"""
"""Send empty package foo@1.0, install and uninstall """
""" Send empty package foo@1.0, exact-install and uninstall """
# Exact-install the same version should do nothing.
""" Send package foo@1.1, containing a directory and a file,
install or exact-install, search, and uninstall. """
# This test needs to use the depot to be able to test the
# download cache.
# Verify that content cache is empty after successful install
# or exact-install.
cache_dirs = []
# check to make sure timestamp was set to correct value
# check that verify finds changes
"""Exact-install or Install foo@1.0, upgrade to foo@1.1,
uninstall. """
# This test needs to use the depot to be able to test the
# download cache.
# Verify that content cache is empty before install or
# exact-install.
cache_dirs = []
# Verify that content cache is not empty after successful
# install or exact_install (since
# flush-content-cache-on-success is True by default) for
# packages that have content.
cache_dirs = []
""" Add bar@1.0, dependent on foo@1.0, exact-install or
install, uninstall. """
# This test needs to use the depot to be able to test the
# download cache.
# Set content cache to not be flushed on success.
# Verify that content cache is empty before install or
# exact-install.
cache_dirs = []
# Verify that content cache is not empty after successful
# install or exact-install (since
# flush-content-cache-on-success is False)
# for packages that have content.
cache_dirs = []
# foo and bar should not be installed at this point
"""Install bar@1.0, upgrade to bar@1.1,
downgrade to bar@1.0.
Boring should be left alone, while
foo gets upgraded as needed"""
"""exact-install bar@1.0, upgrade to bar@1.1.
Boring should be left alone, while
foo gets upgraded as needed"""
"""Verify that '@latest' will install the latest version
of a package."""
# Create a repository for the test publisher.
"prefix": "test" } })
# Create a repository for a different publisher for at
# least one of the packages so that we can verify that
# publisher search order is accounted for by @latest.
# The second publisher is called 'pub2' here so that
# it comes lexically before 'test' (see bug 18180) to
# ensure that latest version ordering works correctly
# when the same stem is provided by different publishers.
"prefix": "pub2" } })
# 1.0 of bar should be installed here since pub2 is a
# lower-ranked publisher.
# 1.1 of bar should be installed here since pub2 is a
# higher-ranked publisher and test is non-sticky.
# Cleanup.
"""Verify that '@latest' will install the latest version
of a package."""
# Create a repository for the test publisher.
"prefix": "test" } })
# Create a repository for a different publisher for at
# least one of the packages so that we can verify that
# publisher search order is accounted for by @latest.
# The second publisher is called 'pub2' here so that
# it comes lexically before 'test' (see bug 18180) to
# ensure that latest version ordering works correctly
# when the same stem is provided by different publishers.
"prefix": "pub2" } })
# 1.0 of bar should be installed here since pub2 is a
# lower-ranked publisher.
# 1.1 of bar should be installed here since pub2 is a
# higher-ranked publisher and test is non-sticky.
# Cleanup.
"""Add xbar@1.1, install xbar@1.0."""
"""Add bar@1.1, exact-install bar@1.0."""
"""Try to exact-install two versions of the same package."""
"""Verify downgrade will work with exact-install."""
"""Verify frozen packages can be relaxed with exact_install.
Which means we can ignore the frozen list with exact_install.
"""
# Freeze bar@1.0.
# Freeze both bar@1.0 and foo@1.0.
""" Send empty package foo@1.0, install and uninstall """
"""Verify package operations can be performed using a depot
server being addressed via IPv6."""
# This test needs to use the depot to be able to test
# IPv6 connectivity.
""" Send package bar@1.1, dependent on foo@1.2. Install
or exact-install bar@1.0. List all packages. Upgrade image.
"""
"""Trying to remove a package that's a dependency of another
package should fail since uninstall isn't recursive."""
""" Add bar@1.1, dependent on foo@1.2, install bar@1.1. """
""" Add bar@1.1, dependent on foo@1.2, and baz@1.0, dependent
on foo@1.0, install baz@1.0 and bar@1.1. """
""" Add xdeep@1.0, xbar@1.0. xDeep@1.0 depends on xbar@1.0 which
depends on xfoo@1.0, install xdeep@1.0. """
""" Add ydeep@1.0. yDeep@1.0 depends on ybar@1.0 which depends
on xfoo@1.0, install ydeep@1.0. """
""" Try to install two versions of the same package """
""" From original comment in bug report:
Consider a repository that contains:
a@1 and a@2
b@1 that contains an optional dependency on package a@1
If a@1 and b@1 are installed in an image, the "pkg update" command
produces the following output:
$ pkg update
No updates available for this image.
However, "pkg install a@2" works.
"""
# Test the parsable output of update.
""" Try to [un]install or exact-install packages matching a
pattern """
# don't specify versions here; we have many
# different versions of foo, bar & baz in repo
# when entire class is run w/ one repo instance.
# first case should fail since multiple patterns
# match the same pacakge
# However, multiple forms of the same pattern should simply be
# coalesced and allowed.
"pkg:///foo")
"""Test the install of packages that have actions that are
invalid."""
# First, publish the package that will be corrupted and create
# an image for testing.
# This should succeed and cause the manifest to be cached.
# While the manifest is cached, get a copy of its contents.
for p in plist:
src_mode = "mode=755"
else:
src_mode = "mode=644"
# Now remove the package so corrupt case can be tested.
# Now attempt to corrupt the client's copy of the
# manifest in various ways to check if the client
# handles missing mode and invalid mode cases for
# file and directory actions.
exit=1)
# Now attempt to corrupt the client's copy of the
# manifest in various ways to check if the client
# handles missing or invalid owners and groups.
exit=1)
exit=1)
# Now attempt to corrupt the client's copy of the
# manifest such that actions are malformed.
for bad_act in (
'set name=description value="" \" my desc ""',
"set name=com.sun.service.escalations value="):
exit=1)
""" Try to install a package from a publisher with an
unavailable repository. """
# Depot hasn't been started, so client can't connect.
"""Make sure that we can uninstall a package that already
has its contents on disk even when the repository isn't
accessible."""
# Depot required for this test since client doesn't cache
# files from a file repository by default.
# Stop depot, so client can't connect.
"""Create a repository with a pair of manifests. Have
pkg A depend upon pkg B. Rename pkg B on the depot-side
and attempt to install. This should fail, but not traceback.
Then, modify the manifest on the serverside, ensuring that
the contents don't match the hash. Then try the install again.
This should also fail, but not traceback."""
new_dirname = "potato"
"""Verify that packages delivering files with whitespace in
their paths can be installed or exact-installed, updated, and
uninstalled."""
for name in (
):
name)))
"""Test install with setting system attributes."""
raise pkg5unittest.TestSkippedException(
"System attributes unsupported on this platform.")
# Try to install in /tmp which does not support system
# attributes. Just make sure we fail gracefully.
# in tmpfs.
# test without permission for setting sensitive system attribute
# now some tests which should succeed
# sensitive attr is not in 11 FCS, so no closing }
expected = b"{AH-S---m----"
# sensitive attr is not in 11 FCS, so no closing }
expected = b"{AH-S---m----"
# test some packages with invalid sysattrs
# test package with a file action that has multiple sysattr tags
"""Ensure installation of new actions will fail when the delivered
files target reserved filesystem locations."""
b1 = """
open b1@1.0-0
close
"""
b2 = """
open b2@1.0-0
add link path=var/pkg/pkg5.image target=tmp/cat
close
"""
b3 = """
open b3@1.0-0
close
"""
b4 = """
open b4@1.0-0
close
"""
b5 = """
open b5@1.0-0
close
"""
return
"""Ensure installation of new actions will fail when the delivered
files target reserved filesystem locations."""
b1 = """
open b1@1.0-0
close
"""
b2 = """
open b1@2.0-0
close
"""
b3 = """
open b1@3.0-0
close
"""
"""Ensure that packages containing files found in a read-only
directory or read-only files can be uninstalled."""
# First, install parent directory package.
# Next, install the package. Note that this test intentionally
# does not cover the case of *installing* files to a read-only
# directory.
# chmod parent directory to read-only and then verify that the
# package can still be uninstalled
# Finally, verify directory mode was restored to 555.
try:
finally:
# Ensure directory can be cleaned up.
"""Verify that error messages for installing a package with a
file or manifest that cannot be retrieved include the package
FMRI."""
# publish a single package and break it
foo11 = """
open foo@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
add file tmp/libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1 timestamp="20080731T024051Z"
close """
upgrade_np10 = """
open upgrade-np@1.0,5.11-0
close"""
"""Make sure the client can detect corrupt content being served
to it from a corrupt web cache, modifying its requests to
retrieve correct content."""
# we need to record just the version string of foo in order
# to properly quote it later.
# we use the system repository as a convenient way to setup
# a caching proxy
# ensure pkg5srv can write cache content
# create an image, installing a package, to warm up the webcache
# now recreate the image. image_create calls image_destroy,
# thereby cleaning any cached content in the image.
"""Given a path, corrupt its contents."""
if rename:
else:
"""Given an apache cache, corrupt it's contents."""
".data")
# corrupt our web cache
urls = [
# we need to quote the version carefully to use exactly the
# format pkg(1) uses - two logically identical urls that
# differ only by the way they're quoted are treated by
# Apache as separate cacheable resources.
foo_version)),
]
# validate that our cache is returning corrupt urls.
# we should get clean content when we don't use the
# cache
# content from urlopen is bytes
"Unexpected content from depot")
# get the corrupted version, and verify it is broken
# the following should work, as pkg should retry requests
# where it has detected corrupt contents with a
# "Cache-Control: no-cache" header.
# since the cache has been refreshed, we should see valid
# contents when going through the proxy now.
"Unexpected content from depot")
# ensure that when we actually corrupt the repository
# as well as the cache, we do detect the errors properly.
# When we corrupt the files in the repository, we intentionally
# corrupt them with different contents than the the cache,
# allowing us to check the error messages being printed by the
# transport subsystem.
"{0}/file/85/8535c15c49cbe1e7cb1a0bf8ff87e512abed66f8".format(
prefix))
quote(foo_version)))
prefix))
try:
# first corrupt the file
# we should be getting two hash errors, one from the
# cache, one from the repo. The one from the repo should
# repeat
# now corrupt the manifest (we have to re-corrupt the
# cache, since attempting to install foo above would
# have caused the cache to refetch the valid manifest
# from the repo) and remove the version of the manifest
# cached in the image.
# we should get two hash errors, one from the cache, one
# from the repo - the one from the repo should repeat.
"1: Invalid content: manifest hash failure" in
# finally, corrupt the catalog. Given we've asked for a
# full refresh, we retrieve the upstream version only.
finally:
# make sure we clean up any corrupt repo contents.
"""Tests that images can use the set-publisher --proxy argument
to selectively proxy requests."""
# we use the system repository as a convenient way to setup
# a caching proxy. Since the image doesn't have the property
# 'use-system-repo=True', the configuration of the sysrepo
# will remain static.
# ensure pkg5srv can write cache content
# with our proxy offline, and with no other origins
# available, we should be unable to install
# we cannot add another origin with the same url
# we cannot add another proxied origin with that url
exit=1)
# Now add a second, unproxied publisher, ensuring we
# can install packages from there. Since the proxy
# isn't configured to proxy that resource, this tests
# that the proxy for self.durl1 isn't being used.
"pkg://test2/upgrade-np@1.0")
# check that runtime proxies are being used - we
# set a bogus proxy, then ensure our $http_proxy value
# gets used.
# check that $all_proxy works
# now check that no_proxy works
# Tests in this suite use the read only data directory.
foo10 = """
open foo@1.0,5.11-0
close """
disappear10 = """
open disappear@1.0,5.11-0
close """
disappear11 = """
open disappear@1.1,5.11-0
close """
"""Test that if a manifest that is being installed is cached
locally has been changed on the repo is updated, the new
manifest is used."""
# Use pkg contents to cache the manifest.
# Specify location as filesystem path.
# Ensure that the image requires signed manifests.
# Install the package
"""Test that if a manifest that has been installed is changed on
the server is updated, the installed manifest is not changed."""
# Install the package
for l in fmri_lines:
continue
"""Test package actuators"""
pkgs = (
"""
open A@0.5,5.11-0
close """,
"""
open A@1.0,5.11-0
close """,
"""
open A@2.0,5.11-0
close """,
"""
open B@1.0,5.11-0
close """,
"""
open B@2.0,5.11-0
close """,
"""
open C@1.0,5.11-0
add depend type=require fmri=trigger
close """,
"""
open trigger@1.0,5.11-0
add set name=pkg.additional-update-on-uninstall value=A@2
close """,
"""
open trigger@2.0,5.11-0
add set pkg.additional-update-on-uninstall=A@1
close """,
"""
open trigger@3.0,5.11-0
add set name=pkg.additional-uninstall-on-uninstall value=A
close """,
"""
open trigger@4.0,5.11-0
add set pkg.additional-uninstall-on-uninstall=A
close """,
"""
open trigger@5.0,5.11-0
add set name=pkg.additional-uninstall-on-uninstall value=A@2 value=B@2
close """,
"""
open trigger@6.0,5.11-0
add set name=pkg.additional-uninstall-on-uninstall value=A@1
close """,
"""
open trigger@7.0,5.11-0
add set name=pkg.additional-uninstall-on-uninstall value=C
close """,
"""
open evil@1.0,5.11-0
add set name=pkg.additional-update-on-uninstall value=evil@2
close """,
"""
open evil@2.0,5.11-0
close """,
)
"""Test that pkg actuators work as expected."""
# prepare image
# update on uninstall
# uninstall on uninstall
# verify unversioned actuator triggers
# verify correct version is uninstalled
# verify non-matching version is not installed
# multiple values
# multiple values but at different versions
# removal pkg depends on trigger
# test that uninstall actuators also work when pkg is rejected
# install with reject
# update with reject
# self-referencing (evil) pkgs
# solver will complain about passing same pkg to reject and
# proposed dict
# try workaround
# Test overlapping user and actuator pkg requests.
# Since actuators are treated like user requests, the solver
# will pick the latest one.
# update with reject
pkgs = (
"""
open A@1.0,5.11-0
add depend type=require-any fmri=pkg:/B@1.0 fmri=pkg:/C@1.0
close """,
"""
open A@2.0,5.11-0
add depend type=require-any fmri=pkg:/B@1.0 fmri=pkg:/C@1.0
close """,
"""
open B@1.0,5.11-0
add depend type=exclude fmri=pkg:/C
close """,
"""
open C@1.0,5.11-0
add depend type=exclude fmri=pkg:/B
close """,
"""
open kernel@1.0,5.11-0.1
add depend type=require fmri=pkg:/incorp
close """,
"""
open kernelX@1.0,5.11-0.1
add depend type=require fmri=pkg:/incorp
close """,
"""
open kernel@1.0,5.11-0.2
add depend type=require fmri=pkg:/incorp
close """,
"""
open incorp@1.0,5.11-0.1
add depend type=incorporate fmri=kernel@1.0,5.11-0.1
close """,
"""
open incorp@1.0,5.11-0.2
add depend type=incorporate fmri=kernel@1.0,5.11-0.2
close """,
"""
open kernel@1.0,5.11-0.1.1.0
add depend type=require fmri=pkg:/incorp
add depend type=require fmri=pkg:/idr1
close """,
"""
open kernel@1.0,5.11-0.1.1.1
add depend type=require fmri=pkg:/incorp
add depend type=require fmri=pkg:/idr1
close """,
"""
open kernel@1.0,5.11-0.1.2.0
add depend type=require fmri=pkg:/incorp
add depend type=require fmri=pkg:/idr2
close """,
"""
open kernelX@1.0,5.11-0.1.1.0
add depend type=require fmri=pkg:/incorp
add depend type=require fmri=pkg:/idrX
close """,
"""
open idr1@1.0,5.11-0.1.1.0
add depend type=incorporate fmri=kernel@1.0,5.11-0.1.1.0
add depend type=require fmri=idr1_entitlement
close """,
"""
open idr1@1.0,5.11-0.1.1.1
add depend type=incorporate fmri=kernel@1.0,5.11-0.1.1.1
add depend type=require fmri=idr1_entitlement
close """,
"""
open idr2@1.0,5.11-0.1.2.0
add depend type=incorporate fmri=kernel@1.0,5.11-0.1.2.0
add depend type=require fmri=idr2_entitlement
close """,
"""
open idrX@1.0,5.11-0.1.1.0
add set name=pkg.additional-update-on-uninstall value=kernelX@1.0,5.11-0.1
add depend type=incorporate fmri=kernelX@1.0,5.11-0.1.1.0
add depend type=require fmri=idr1_entitlement
close """,
"""
open idr1_entitlement@1.0,5.11-0
add depend type=exclude fmri=no-idrs
close """,
"""
open idr2_entitlement@1.0,5.11-0
add depend type=exclude fmri=no-idrs
close """,
# hack to prevent idrs from being installed from repo...
"""
open no-idrs@1.0,5.11-0
close """,
"""
add depend type=exclude fmri=A
add depend type=require fmri=bogus1
add depend type=require fmri=bogus2
close """,
"""
add depend type=exclude fmri=B
close """,
"""
add depend type=exclude fmri=C
close """
)
# simple test of reject
# test swapping XOR'd pkgs B & C w/o uninstalling A
# test that solver picks up on impossible cases
# test that publisher matching works
# verify that matching accounts for reject.
"--reject B '*'")
"""Test that the --reject option performs as expected."""
# test basic usage of --reject
# test swapping XOR'd pkgs B & C.
# test that solver picks up on impossible cases fails
# test that publisher matching works.
"'pkg://contrib/*' A")
# verify that matching accounts for reject with --exact option.
"--reject B '*'")
# install kernel pkg; remember version so we can reinstall it later
# upgrade to next version w/o encountering idrs
# try installing idr1; testing wild card support as well
# switch to idr2, which affects same package
# switch back to base version of kernel
# reinstall idr1, then update to version 2 of base kernel
# Wildcards are purposefully used here for both patterns to
# ensure pattern matching works as expected for update.
"""IDR removal with pkg actuators."""
# try installing idr
# check if IDR pkgs got installed
# uninstall IDR
# try with reject
# Test update reject without wildcards.
# Reinstall kernel package, install A, and test update again using
# wildcards.
# An "ambiguous" package name pattern is one which, because of the
# pattern matching rules, might refer to more than one package. This
# may be as obvious as the pattern "SUNW*", but also like the pattern
afoo10 = """
close """
bfoo10 = """
close """
bar10 = """
open bar@1.0,5.11-0
close """
foo10 = """
open foo@1.0,5.11-0
close """
foo11 = """
open foo@1.1,5.11-0
close """
anotherfoo11 = """
close """
depender10 = """
open depender@1.0,5.11-0
add depend type=require fmri=foo@1.0
close """
depender11 = """
open depender@1.1,5.11-0
add depend type=require fmri=foo@1.1
close """
"""Don't stack trace when printing a PlanCreationException with
"multiple_matches" populated (on uninstall)."""
"""Don't stack trace when printing a PlanCreationException with
"multiple_matches" populated (on install and update)."""
"""An update should never get confused about an existing
package being part of an ambiguous set of package names."""
"""A dependency on a package should pull in an exact name
match."""
"""We should be able to refer to a package by its "basename", if
that component is unique."""
# Right now, this is not exact, but still unambiguous
# Create ambiguity
# This is unambiguous, should succeed
# This is now ambiguous, should fail
a_1 = """
open a@1.0,5.11-0
close """
pub2_a_1 = """
open pkg://pub2/a@1.0,5.11-0
close """
a_11 = """
open a@1.1,5.11-0
close """
a_2 = """
open a@2.0,5.11-0
close """
pub2_a_2 = """
open pkg://pub2/a@2.0,5.11-0
close """
a_3 = """
open a@3.0,5.11-0
close """
aa_1 = """
open aa@1.0,5.11-0
close """
afoo_1 = """
close """
bfoo_1 = """
close """
fooa_1 = """
open foo/a@1.0,5.11-0
close """
foob_1 = """
open foo/b@1.0,5.11-0
close """
# This fails because a*@2 matches no patterns on its own.
# This is allowed because a*@1 matches published packages, even
# though the packages it matches aren't installed in the image.
exit=1)
exit=1)
["pkg://test/a@1", "pkg://pub2/*@2"])
# This intentionally doesn't use api_install to check for
# special handling of '*' in client.py.
pkg10 = """
open pkg1@1.0,5.11-0
add depend type=require fmri=pkg:/pkg2
close
"""
pkg20 = """
open pkg2@1.0,5.11-0
add depend type=require fmri=pkg:/pkg3
close
"""
pkg30 = """
open pkg3@1.0,5.11-0
add depend type=require fmri=pkg:/pkg1
close
"""
pkg11 = """
open pkg1@1.1,5.11-0
add depend type=require fmri=pkg:/pkg2@1.1
close
"""
pkg21 = """
open pkg2@1.1,5.11-0
add depend type=require fmri=pkg:/pkg3@1.1
close
"""
pkg31 = """
open pkg3@1.1,5.11-0
add depend type=require fmri=pkg:/pkg1@1.1
close
"""
""" check to make sure we can install or exact-install
circular dependencies w/o versions
"""
# Send 1.0 versions of packages.
""" check to make sure we can install or exact-install
circular dependencies w/ versions
"""
# Send 1.1 versions of packages.
octo10 = """
open octo@1.0,5.11-0
close
"""
octo20 = """
open octo@2.0,5.11-0
close
"""
incorp = """
open incorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/octo@2.0
close
"""
""" ^^^ hard to find a good name for this, it tests for bug
21130996.
In case one pkg triggers two or more issues, one of which is not
considered print-worthy, we wouldn't print anything at all."""
# Check that the root cause for the issue is shown;
# the incorporation does not allow the older version.
"Excluding incorporation not shown in solver error.")
# Check that the notice about a newer version already installed
# is ommited (it's not relevant).
"Newer version should not be shown in solver error.")
incorp10 = """
open incorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/amber@1.0
add depend type=incorporate fmri=pkg:/bronze@1.0
close
"""
incorp20 = """
open incorp@2.0,5.11-0
add depend type=incorporate fmri=pkg:/amber@2.0
add depend type=incorporate fmri=pkg:/bronze@2.0
close
"""
incorp30 = """
open incorp@3.0,5.11-0
add depend type=incorporate fmri=pkg:/amber@2.0
close
"""
incorpA = """
open incorpA@1.0,5.11-0
add depend type=incorporate fmri=pkg:/amber@1.0
add depend type=incorporate fmri=pkg:/bronze@1.0
close
"""
incorpB = """
open incorpB@1.0,5.11-0
add depend type=incorporate fmri=pkg:/amber@2.0
add depend type=incorporate fmri=pkg:/bronze@2.0
close
"""
iridium10 = """
open iridium@1.0,5.11-0
add depend fmri=pkg:/amber@2.0 type=require
close
"""
amber10 = """
open amber@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
add dir mode=0755 owner=root group=bin path=/etc
add link path=/lib/libc.symlink target=/lib/libc.so.1
add hardlink path=/lib/libc.hardlink target=/lib/libc.so.1
add license tmp/copyright1 license=copyright_ä
close
"""
brass10 = """
open brass@1.0,5.11-0
add depend fmri=pkg:/bronze type=require
close
"""
bronze10 = """
open bronze@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/usr
add hardlink path=/lib/libc.bronze target=/lib/libc.so.1
add depend fmri=pkg:/amber@1.0 type=require
add license tmp/copyright2 license=copyright
close
"""
amber20 = """
open amber@2.0,5.11-0
add dir mode=0755 owner=root group=bin path=/usr
add link path=/lib/libc.symlink target=/lib/libc.so.1
add hardlink path=/lib/libc.amber target=/lib/libc.bronze
add hardlink path=/lib/libc.hardlink target=/lib/libc.so.1
add depend fmri=pkg:/bronze@2.0 type=require
add license tmp/copyright2 license=copyright
close
"""
bronze20 = """
open bronze@2.0,5.11-0
add dir mode=0755 owner=root group=bin path=/etc
add dir mode=0755 owner=root group=bin path=/lib
add file tmp/libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.bronze
add hardlink path=/lib/libc.bronze2.0.hardlink target=/lib/libc.so.1
add license tmp/copyright3 license=copyright
add depend fmri=pkg:/amber@2.0 type=require
close
"""
bronze30 = """
open bronze@3.0,5.11-0
add dir mode=0755 owner=root group=bin path=/etc
add dir mode=0755 owner=root group=bin path=/lib
add file tmp/libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.bronze
add hardlink path=/lib/libc.bronze2.0.hardlink target=/lib/libc.so.1
add license tmp/copyright3 license=copyright
add depend fmri=pkg:/amber@2.0 type=require
close
"""
gold10 = """
open gold@1.0,5.11-0
add file tmp/gold-passwd1 mode=0644 owner=root group=bin path=etc/passwd preserve=true
add file tmp/gold-group mode=0644 owner=root group=bin path=etc/group preserve=true
add file tmp/gold-shadow mode=0600 owner=root group=bin path=etc/shadow preserve=true
add file tmp/gold-ftpusers mode=0644 owner=root group=bin path=etc/ftpd/ftpusers preserve=true
add file tmp/gold-silly mode=0644 owner=root group=bin path=etc/silly
add file tmp/gold-silly mode=0644 owner=root group=bin path=etc/silly2
close
"""
gold20 = """
open gold@2.0,5.11-0
add file tmp/config2 mode=0644 owner=root group=bin path=etc/config2 original_name="gold:etc/passwd" preserve=true
close
"""
gold30 = """
open gold@3.0,5.11-0
close
"""
golduser10 = """
open golduser@1.0
close
"""
golduser20 = """
open golduser@2.0
close
"""
silver10 = """
open silver@1.0,5.11-0
close
"""
silver20 = """
open silver@2.0,5.11-0
add file tmp/gold-passwd2 mode=0644 owner=root group=bin path=etc/passwd original_name="gold:etc/passwd" preserve=true
add file tmp/gold-group mode=0644 owner=root group=bin path=etc/group original_name="gold:etc/group" preserve=true
add file tmp/gold-shadow mode=0600 owner=root group=bin path=etc/shadow original_name="gold:etc/shadow" preserve=true
add file tmp/gold-ftpusers mode=0644 owner=root group=bin path=etc/ftpd/ftpusers original_name="gold:etc/ftpd/ftpusers" preserve=true
add file tmp/gold-silly mode=0644 owner=root group=bin path=etc/silly
add file tmp/silver-silly mode=0644 owner=root group=bin path=etc/silly2
close
"""
silver30 = """
open silver@3.0,5.11-0
add file tmp/config2 mode=0644 owner=root group=bin path=etc/config2 original_name="gold:etc/passwd" preserve=true
close
"""
silveruser = """
open silveruser@1.0
close
"""
iron10 = """
open iron@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=etc
add license tmp/copyright1 license=copyright
close
"""
iron20 = """
open iron@2.0,5.11-0
add dir mode=0755 owner=root group=bin path=etc
add license tmp/copyright2 license=copyright
close
"""
concorp10 = """
open concorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/amber@2.0
add depend type=incorporate fmri=pkg:/bronze@2.0
close
"""
dricon1 = """
open dricon@1
add dir path=var mode=755 owner=root group=root
add dir mode=0755 owner=root group=root path=system
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
close
"""
dricon2 = """
open dricon@2
add dir path=var mode=755 owner=root group=root
add dir mode=0755 owner=root group=root path=system
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon2_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add driver name=zigit alias=pci8086,1234
close
"""
dricon3 = """
open dricon@3
add dir path=var mode=755 owner=root group=root
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon2_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add driver name=zigit alias=pci8086,1234
add driver name=figit alias=pci8086,1234
close
"""
dripol1 = """
open dripol@1
add dir path=var mode=755 owner=root group=root
add dir mode=0755 owner=root group=root path=system
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon2_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add file tmp/dripol1_dp path=/etc/security/device_policy mode=644 owner=root group=sys preserve=true
add driver name=frigit policy="read_priv_set=net_rawaccess write_priv_set=net_rawaccess tpd_member=true"
close
"""
dripol2 = """
open dripol@2
add dir path=var mode=755 owner=root group=root
add dir mode=0755 owner=root group=root path=system
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon2_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add file tmp/dripol1_dp path=/etc/security/device_policy mode=644 owner=root group=sys preserve=true
add driver name=frigit
close
"""
dripol3 = """
open dripol@3
add dir path=var mode=755 owner=root group=root
add dir mode=0755 owner=root group=root path=system
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon2_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add file tmp/dripol1_dp path=/etc/security/device_policy mode=644 owner=root group=sys preserve=true
add driver name=frigit policy="tpd_member=true"
close
"""
dripol4 = """
open dripol@4
add dir path=var mode=755 owner=root group=root
add dir mode=0755 owner=root group=root path=system
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon2_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add file tmp/dripol1_dp path=/etc/security/device_policy mode=644 owner=root group=sys preserve=true
add driver name=frigit
close
"""
dripol5 = """
open dripol@5
add dir path=var mode=755 owner=root group=root
add dir mode=0755 owner=root group=root path=system
add dir path=/tmp mode=755 owner=root group=root
add dir path=/etc mode=755 owner=root group=root
add file tmp/dricon2_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file tmp/dricon_n2m path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add file tmp/dripol1_dp path=/etc/security/device_policy mode=644 owner=root group=sys preserve=true
add driver name=frigit perms="node1 0666 root sys" policy="node1 read_priv_set=all write_priv_set=all tpd_member=true"
close
"""
liveroot10 = """
open liveroot@1.0
add dir path=/etc mode=755 owner=root group=root
close
"""
liveroot20 = """
open liveroot@2.0
add dir path=/etc mode=755 owner=root group=root
close
"""
renameold1 = """
open renold@1.0
close
"""
renameold2 = """
open renold@2.0
close
"""
renameold3 = """
open renold@3.0
close
"""
renamenew1 = """
open rennew@1.0
close
"""
renamenew2 = """
open rennew@2.0
close
"""
renamenew3 = """
open rennew@3.0
close
"""
preserve1 = """
open preserve@1.0
close
"""
preserve2 = """
open preserve@2.0
close
"""
preserve3 = """
open preserve@3.0
close
"""
preslegacy = """
open preslegacy@1.0
close
open preslegacy@2.0
close
open preslegacy@3.0
close
"""
renpreslegacy = """
open orig_preslegacy@1.0
close
open orig_preslegacy@1.1
add set pkg.renamed=true
add depend type=require fmri=ren_preslegacy@2.0
close
open ren_preslegacy@2.0
add file tmp/preserve2 path=newme mode=0444 owner=root group=root preserve=legacy original_name=orig_preslegacy:testme
close
"""
presabandon = """
open presabandon@1.0
close
open presabandon@2.0
close
open presabandon@3.0
close
open presabandon@4.0
close
"""
presinstallonly = """
open presinstallonly@0.0
close
open presinstallonly@1.0
close
open presinstallonly@2.0
close
open presinstallonly@3.0
close
open presinstallonly@4.0
close
"""
renpreserve = """
open orig_pkg@1.0
close
open orig_pkg@1.1
add set pkg.renamed=true
add depend type=require fmri=new_pkg@1.0
close
open new_pkg@2.0
add file tmp/foo2 path=foo2 mode=0644 owner=root group=root original_name=orig_pkg:foo1 preserve=true
close
"""
linkpreserve = """
open linkpreserve@1.0
add file tmp/preserve1 path=etc/ssh/sshd_config mode=0644 owner=root group=root preserve=true
close
open linkpreserve@2.0
add file tmp/preserve2 path=etc/sunssh/sshd_config mode=0644 owner=root group=root preserve=true original_name=linkpreserve:etc/ssh/sshd_config
add link path=etc/ssh/sshd_config target=../sunssh/sshd_config
close """
salvage = """
open salvage@1.0
add dir path=var mode=755 owner=root group=root
add dir path=var/persistent mode=755 owner=root group=root
close
open salvage@2.0
add dir path=var mode=755 owner=root group=root
add dir path=var/.migrate-to-shared mode=755 owner=root group=root
add dir path=var/.migrate-to-shared/mail salvage-from=var/mail mode=755 owner=root group=root
add dir path=var/.migrate-to-shared/log salvage-from=var/log mode=755 owner=root group=root
add dir path=var/persistent mode=755 owner=root group=root salvage-from=var/noodles
close
open salvage@3.0
add dir path=var mode=755 owner=root group=root
add dir path=var/.migrate-to-shared mode=755 owner=root group=root
add dir path=var/.migrate-to-shared/mail salvage-from=var/mail mode=755 owner=root group=root
add dir path=var/.migrate-to-shared/log salvage-from=var/log mode=755 owner=root group=root
add dir path=var/persistent mode=755 owner=root group=root salvage-from=var/noodles salvage-from=var/spaghetti
close
"""
salvage_special = """
open salvage-special@1.0
add dir path=salvage mode=755 owner=root group=root
close
"""
salvage_nested = """
open salvage-nested@1.0
add dir path=var mode=755 owner=root group=root
owner=root group=root mode=644 preserve=true
close
open salvage-nested@1.1
add dir path=var mode=755 owner=root group=root
owner=root group=root mode=644 preserve=abandon
close
open salvage-nested@2.0
add dir path=var mode=755 owner=root group=root
add dir path=var/.migrate mode=755 owner=root group=root
owner=root group=root
owner=root group=root
mode=755 owner=root group=root
close
open salvage-nested@3.0
add dir path=var mode=755 owner=root group=root
add dir path=var/.migrate mode=755 owner=root group=root
owner=root group=root
open salvage-nested@4.0
add dir path=var mode=755 owner=root group=root
add dir path=var/.migrate mode=755 owner=root group=root
owner=root group=root
mode=755 owner=root group=root
close
"""
dumdir10 = """
open dumdir@1.0
add dir path=etc mode=0755 owner=root group=bin
close
"""
dumdir20 = """
open dumdir@2.0
add dir path=etc mode=0700 owner=root group=bin
close
"""
dumdir30 = """
open dumdir@3.0
add dir path=etc mode=0700 owner=bin group=bin
close
"""
elfhash10 = """
open elfhash@1.0
add file ro_data/elftest.so.1 mode=0755 owner=root group=bin path=bin/true
close
"""
elfhash20 = """
open elfhash@2.0
add file ro_data/elftest.so.1 mode=0755 owner=root group=bin path=bin/true
close
"""
misc_files1 = [
"tmp/copyright1", "tmp/copyright2",
"tmp/copyright3", "tmp/copyright4",
]
misc_files2 = {
wigit "pci8086,1234"
wigit "pci8086,4321"
# someother "pci8086,1234"
foobar "pci8086,9999"
""",
"tmp/dricon2_da": """\
zigit "pci8086,1234"
wigit "pci8086,4321"
# someother "pci8086,1234"
foobar "pci8086,9999"
""",
"tmp/dricon_n2m": """\
wigit 1
foobar 2
""",
"tmp/dripol1_dp": """\
* read_priv_set=none write_priv_set=none
""",
"tmp/gold-passwd1": """\
daemon:x:1:1::/:
sys:x:3:3::/:
""",
"tmp/gold-passwd2": """\
daemon:x:1:1::/:
sys:x:3:3::/:
bogus:x:10001:10001:Bogus User:/:
""",
"tmp/gold-group": """\
root::0:
other::1:root
bin::2:root,daemon
sys::3:root,bin,adm
adm::4:root,daemon
""",
"tmp/gold-shadow": """\
root:9EIfTNBp9elws:13817::::::
daemon:NP:6445::::::
bin:NP:6445::::::
sys:NP:6445::::::
adm:NP:6445::::::
""",
"tmp/gold-ftpusers": """\
root
bin
sys
adm
""",
}
foo10 = """
open foo@1.0,5.11-0
close """
only_attr10 = """
open only_attr@1.0,5.11-0
add set name=foo value=bar
close """
salvaged = [
]
"""Make sure we don't round up packages we specify on
install"""
# create image
# install incorp2
# try to install version 1
# install earliest version bronze@2.0
content-hash attributes."""
# load manifest, change content-hash attr and store back
# to disk
# Upgrade case: action that doesn't use pkg.content-hash upgrade
# to action that uses pkg.content-hash.
for a in mani.gen_actions():
del a.attrs["pkg.content-hash"]
# rebuild repo catalog since manifest digest changed
# should not see pkg.content-hash
# should update to the new hash attr name
# Upgrade case: action that uses SHA-2 hash upgrade to action
# that uses SHA-3 hash.
for a in mani.gen_actions():
for a in mani2.gen_actions():
a.attrs["pkg.content-hash"] = \
["file:sha3_384:abcd", "gelf:sha3_384:wxyz", "gelf.unsigned:sha3_384:wxyz"]
# Redo the test again with upgrading to action that uses both
# hashes.
for a in mani2.gen_actions():
a.attrs["pkg.content-hash"] = \
["gelf:sha512t_256:abcd", "gelf:sha3_384:wxyz"]
# Upgrade case: action that uses gelf and file extraction method
# upgrade to action that only uses file extraction method.
for a in mani2.gen_actions():
a.attrs["pkg.content-hash"] = \
["file:sha512t_256:2374db2dfb4968baad246ab37afc560cc9d278b6104a889a2727d9bcf6a20b17"]
# Redo the test again with upgrading to action uses both
# methods.
for a in mani2.gen_actions():
a.attrs["pkg.content-hash"] = \
["gelf:sha512t_256:abcd", "file:sha512t_256:2374db2dfb4968baad246ab37afc560cc9d278b6104a889a2727d9bcf6a20b17"]
# we update the file's content-hash attributes.
""" Upgrade torture test.
Send package amber@1.0, bronze1.0; install bronze1.0, which
should cause amber to also install.
Send 2.0 versions of packages which contains a lot of
complex transactions between amber and bronze, then do
an update, and try to check the results.
"""
# Send 1.0 versions of packages.
#
# In version 2.0, several things happen:
#
# Amber and Bronze swap a file with each other in both
# directions. The dependency flips over (Amber now depends
# on Bronze). Amber and Bronze swap ownership of various
# directories.
#
# Bronze's 1.0 hardlink to amber's libc goes away and is
# replaced with a file of the same name. Amber hardlinks
# to that.
#
# create image and install version 1
# demonstrate that incorp@1.0 prevents package movement
# ...again, but using @latest.
# Now update to get new versions of amber and bronze
# Try to verify that it worked.
# make sure old implicit directories for bronzeA1 were removed
"A")))
# Remove packages
# Make sure all directories are gone save /var in test image.
""" test incorporations:
1) install files that conflict w/ existing incorps
2) install package w/ dependencies that violate incorps
3) install incorp that violates existing incorp
4) install incorp that would force package backwards
"""
# Send all pkgs
# install files that conflict w/ existing incorps
# install package w/ dependencies that violate incorps
# install package w/ unspecified dependency that pulls
# in bronze
# attempt to install conflicting incorporation
# attempt to force downgrade of package w/ older incorp
# upgrade pkg that loses incorp. deps. in new version
# perform explicit update of incorp; should not update bronze
])
])
# perform a general update; should upgrade incorp and bronze
])
"""Test for editable files moving between packages or locations
or both."""
install_cmd = "install"
# test 1: move an editable file between packages
]
)
# modify config file
test_str = "this file has been modified 1"
# update packages
removed=[
],
)
# test 2: change an editable file's path within a package
# modify config file
test_str = "this file has been modified test 2"
removed=[
],
)
)
# test 3: move an editable file between packages and change its path
# modify config file
test_str = "this file has been modified test 3"
removed=[
],
)
# can still uninstall a user at the same time.
# add a user
# make local changes to the user
if l.startswith("Kermit"):
"Kermit loves Miss Piggy")
# update packages
# make sure Kermie is still installed and still has our local
# changes
# again, even though it wasn't marked specially
"""Test to make sure hardlinks are correctly restored when file
they point to is updated."""
"""Test manually removed directory and files will be restored
during update, if mode are different."""
"""Test to make sure upgrade of package fails if on live root
and reboot is needed."""
exit=5)
# "break" liveroot@1
"""Test to make sure driver_aliases conflicts don't cause
add_drv to fail."""
# This one should comment out the wigit entry in driver_aliases
"etc/driver_aliases")) as f:
da_contents = f.readlines()
# This one should fail
"""Test for bug #9568 - that removing a policy for a
driver where there is no minor node associated with it,
works successfully.
"""
# Should install the frigit driver with a policy.
# Check that there is a policy entry for this
# device in /etc/security/device_policy
"etc/security/device_policy")) as f:
dp_contents = f.readlines()
"write_priv_set=net_rawaccess\ttpd_member=true\n"
in dp_contents)
# Should reinstall the frigit driver without a policy.
# Check that there is no longer a policy entry for this
# device in /etc/security/device_policy
"etc/security/device_policy")) as f:
dp_contents = f.readlines()
"write_priv_set=net_rawaccess\ttpd_member=true\n"
not in dp_contents)
"etc/security/device_policy")) as f:
dp_contents = f.readlines()
in dp_contents)
"etc/security/device_policy")) as f:
dp_contents = f.readlines()
"\twrite_priv_set=all\ttpd_member=true\n"
in dp_contents)
"etc/security/device_policy")) as f:
dp_contents = f.readlines()
"""Verify that file preserve=true works as expected during
package install, update, upgrade, and removal."""
install_cmd = "install"
# If there are no local modifications, no preservation should be
# done. First with no content change ...
installed=['testme'],
)
updated=['testme'],
)
updated=['testme'],
)
# ... and again with content change.
installed=['testme'],
)
updated=['testme'],
)
updated=['testme'],
)
# Modify the file locally and update to a version where the
# content changes.
# Modify the file locally and downgrade to a version where
# the content changes.
installed=['testme'],
)
# Modify the file locally and update to a version where just the
# mode changes.
updated=['testme'],
)
updated=['testme'],
)
updated=['testme'],
)
# Remove the file locally and update the package; this should
# simply replace the missing file.
installed=['testme'],
)
# Remove the file locally and downgrade the package; this should
# simply replace the missing file.
installed=['testme'],
)
# Verify preserved files will have their mode changed on update.
# Verify that a package with a missing file that is marked with
# the preserve=true won't cause uninstall failure.
# Verify preserve works across package rename with and without
# original_name use and even when the original file is missing.
# Update across the rename boundary, then verify that the files
# were installed with their new name and the old ones were
# removed.
)
# Update across the rename boundary, then truncate each of the
# preserved files. They should remain empty even though one is
# changing names and the other is simply being preserved across
# a package rename.
)
)
# Update across the rename boundary, then verify that a change
# in file name will cause re-delivery of preserved files, but
# unchanged, preserved files will not be re-delivered.
)
# Ensure directory is empty before testing.
# Verify that unmodified, preserved files will not be salvaged
# on uninstall.
salvaged = [
if n.startswith("testme-")
]
# Verify that modified, preserved files will be salvaged
# on uninstall.
"""Make sure that file upgrade with preserve=renameold works."""
install_cmd = "install"
# If there are no local modifications, no preservation should be
# done. First with no content change ...
# ... and again with content change.
# Modify the file locally and update to a version where the
# content changes.
installed=['testme'],
)
# Modify the file locally and update to a version where just the
# mode changes.
installed=['testme'],
)
# Remove the file locally and update the package; this should
# simply replace the missing file.
installed=['testme'],
)
"""Make sure that file ugprade with preserve=renamenew works."""
install_cmd = "install"
# If there are no local modifications, no preservation should be
# done. First with no content change ...
updated=['testme'],
)
# ... and again with content change
updated=['testme'],
)
# Modify the file locally and update to a version where the
# content changes.
installed=['testme.new'],
)
"testme.new")
# Modify the file locally and update to a version where just the
# mode changes.
installed=['testme.new'],
)
# The original file won't be touched on update, so verify fails.
# Ensure that after fixing mode, verify passes.
# Remove the file locally and update the package; this should
# simply replace the missing file.
installed=['testme'],
)
"""Verify that preserve=legacy works as expected."""
install_cmd = "install"
# Ensure directory is empty before testing.
# Verify that unpackaged files will be salvaged on initial
# install if a package being installed delivers the same file
# and that the new file will be installed.
installed=['testme'],
)
# Verify that a package transitioning to preserve=legacy from
# some other state will have the existing file renamed using
# .legacy as an extension.
installed=['testme'],
)
# Verify that if an action with preserve=legacy is upgraded
# and its payload changes that the new payload is delivered
# but the old .legacy file is not modified.
updated=['testme'],
)
# Verify that if the file for an action marked with
# preserve=legacy is removed that the package still
# verifies.
# Verify that a file removed for an action marked with
# preserve=legacy can be reverted.
# Verify that an initial install of an action with
# preserve=legacy will not install the payload of the action.
# Verify that if the original preserved file is missing during
# a transition to preserve=legacy from some other state that
# the new action is still delivered and the operation succeeds.
installed=['testme'],
)
installed=['testme'],
)
# Verify that a preserved file can be moved from one package to
# another and transition to preserve=legacy at the same time.
installed=['testme'],
)
installed=['newme'],
)
"""Verify that preserve=abandon works as expected."""
install_cmd = "install"
# Ensure directory is empty before testing.
# Verify that unpackaged files will not be salvaged on initial
# install if a package being installed delivers the same file
# and that the new file will not be installed.
# Verify that an initial install of an action with
# preserve=abandon will not install the payload of the action.
# If an action delivered by the upgraded version of the package
# has a preserve=abandon, the new file will not be installed and
# the existing file will not be modified.
# First with no content change ...
installed=['testme'],
)
# The currently installed version of the package has a preserve
# value of abandon, so the file will not be removed.
# If an action delivered by the downgraded version of the package
# has a preserve=abandon, the new file will not be installed and
# the existing file will not be modified.
installed=['testme'],
)
# ... and again with content change.
installed=['testme'],
)
# Modify the file locally and upgrade to a version where the
# file has a preserve=abandon attribute and the content changes.
# Modify the file locally and downgrade to a version where the
# file has a preserve=abandon attribute and the content changes.
# Modify the file locally and upgrade to a version where the
# file has a preserve=abandon attribute and just the mode changes.
# Modify the file locally and downgrade to a version where the
# file has a preserve=abandon attribute and just the mode changes.
# Remove the file locally and update the package where the
# file has a preserve=abandon attribute; this will not replace
# the missing file.
# Remove the file locally and downgrade the package where the
# file has a preserve=abandon attribute; this will not replace
# the missing file.
# Verify that a package with a missing file that is marked with
# the preserve=abandon won't cause uninstall failure.
# Verify that if the file for an action marked with
# preserve=abandon is removed that the package still
# verifies.
# Verify that a file removed for an action marked with
# preserve=abandon can be reverted.
"""Verify that preserve=install-only works as expected."""
# Ensure directory is empty before testing.
# Verify that unpackaged files will not be modified or salvaged
# on initial install if a package being installed delivers the
# same file and that the new file will not be installed.
# Verify uninstall of the package will not remove the file.
# Verify that an initial install of an action with
# preserve=install-only will install the payload of the action
# if the file does not already exist.
installed=['testme']
)
# Verify that an upgrade that initially delivers the action will
# install it.
installed=['testme']
)
# If an action delivered by the upgraded version of the package
# has a preserve=install-only, the new file will not be
# installed and the existing file will not have its content
# modified (the mode is being updated though).
# First with no content change ...
installed=['testme'],
)
updated=['testme'],
)
# The currently installed version of the package has a preserve
# value of install-only, so the file will not be removed.
# If an action delivered by the downgraded version of the
# package has a preserve=install-only, the new file will not be
# installed and the existing file will not be modified.
installed=['testme'],
)
updated=['testme'],
)
# ... and again with content change.
installed=['testme'],
)
# Modify the file locally and upgrade to a version where the
# file has a preserve=install-only attribute and the content
# changes; it should not be modified.
# Modify the file locally and downgrade to a version where the
# file has a preserve=install-only attribute and the content
# changes.
# Modify the file locally and upgrade to a version where the
# file has a preserve=install-only attribute and just the mode
# changes.
updated=['testme'],
)
# Modify the file locally and downgrade to a version where the
# file has a preserve=install-only attribute and just the mode
# changes.
updated=['testme'],
)
# Remove the file locally and update the package where the file
# has a preserve=install-only attribute; this will not replace
# the missing file.
# Remove the file locally and downgrade the package where the
# file has a preserve=install-only attribute; this will not
# replace the missing file.
# Verify that a package with a missing file that is marked with
# the preserve=install-only won't cause uninstall failure.
# Verify that if the file for an action marked with
# preserve=install-only is removed that the package fails
# verify.
# Verify that fix will restore it.
# Verify that a file removed for an action marked with
# preserve=install-only can be reverted.
"""Make sure basic directory salvage works as expected"""
"""Make sure directory salvage works as expected when salvaging
content to an existing packaged directory."""
# we salvage content from two directories,
# subsequent updates.
# ensure that we can jump from 1.0 to 3.0 directly.
"""Make sure salvaging directories with special files works as
expected."""
# This could hang reading fifo, or keel over reading socket.
"""Make sure salvaging from nested packaged directories
works as expected. We test four scenarios, abandoning an
editable file (since that's a scenario ON will use for
23743369), a direct upgrade with no user edits,
salvaging all unpackaged contents despite nested dirs
not being delivered to var/.migrate, and splitting the
salvaged contents of a previously delivered directory to
two new directories."""
# We salvage to several places as part of the upgrade
# operation.
# add some unpackaged directories & contents
"var", "user", "webui", "timf"))
# modify a packaged editable file
"var/user/evsuser/.ssh/authorized_keys", "foo")
# abandon our editable file
# Check negative cases first. This first location was where
# files would get salvaged to incorrectly prior to the fix
# for 23739095
# these weren't known failures, but let's check anyway,
# since this is a useful safety net.
"var/.migrate/user/evsuser/authorized_keys")
# now verify we salvaged everything correctly
"var/.migrate/user/evsuser/.ssh/authorized_keys",
"foo")
"var/.migrate/user/webui/user-pref.conf", "ook")
# now try without the initial non-editable file
# an abandoned file shouldn't be installed
"var/user/evsuser/.ssh/authorized_keys", "ook")
"var/.migrate/user/evsuser/.ssh/authorized_keys",
"ook")
# now try with no user edits
"var/.migrate/user/evsuser/.ssh/authorized_keys")
# Now try without delivering the evsuser dir and subdirs
# in the updated package
"var", "user", "webui", "timf"))
"var", "user", "noodles"))
"var/.migrate/user/webui/timf/user-pref.conf", "ook")
# Finally try splitting the salvaged contents from a
# previously delivered directory into two new directories.
"var", "user", "webui", "timf"))
"var", "user", "noodles"))
"var/.migrate/user/webui/timf/user-pref.conf", "ook")
"""Used to verify that the dest item's mode, attrs, timestamp,
etc. match the src items's matching action as expected."""
for p in plist:
continue
for a in m.gen_actions():
if a.name != "file":
# Only want file actions that have
# preserve attribute.
continue
# Only want actions with matching path.
continue
"""Ensure that files transitioning to a link still follow
original_name preservation rules."""
# Install package with original config file location.
# Modify the file.
# Install new package version, verify file replaced with link
# and modified version was moved to new location.
)
# Uninstall, then install original version again.
# Install new package version and verify that unmodified file is
# replaced with new configuration file.
)
"""Test that when upgrading actions where the new action
contains more hash attributes than the old action, that the
upgrade works."""
if sha512_supported:
# We have not enabled SHA2 hash publication yet.
# publish with SHA1 and SHA2 hashes
# verify that a non-SHA2 aware client can install these bits
# This also tests package retrieval: we always retrieve packages
# with the least-preferred hash, but verify with the
# most-preferred hash.
# publish with only SHA-2 hashes
# verify that a non-SHA2 aware client cannot install these bits
# since there are no SHA1 hashes present
"No file could be found for the specified hash name: "
# Make sure we've been publishing only with SHA2 by removing
# those known attributes, then checking for the presence of
# the SHA-1 attributes.
"""Test that pkgs with gelf content-hash attributes are ignored
for install and verify by default if file hash matches."""
elfpkg_1 = """
open elftest@1.0
close """
# load manifest, add content-hash attr and store back to disk
for a in mani.gen_actions():
# rebuild repo catalog since manifest digest changed
# Test that pkgrecv, pkgrepo verify, pkg install and pkg verify
# do not complain about unknown gelf content-hash.
# Note that we pass verification if any of the hashes match, but
# we require by default that the content hash matches.
for a in mani.gen_actions():
# rebuild repo catalog since manifest digest changed
# Test that pkgrecv, pkgrepo verify, pkg install complains about
# the unknown file hash.
# We pass verification if any of the hashes match.
misc_files = {
"ftpusers" :
"""# ident "@(#)ftpusers 1.6 06/11/21 SMI"
#
# List of users denied access to the FTP server, see ftpusers(4).
#
root
bin
sys
adm
""",
"group" :
"""root::0:
other::1:root
bin::2:root,daemon
sys::3:root,bin,adm
adm::4:root,daemon
+::::
""",
"passwd" :
daemon:x:1:1::/:
sys:x:3:3::/:
+::::::
""",
"shadow" :
"""root:9EIfTNBp9elws:13817::::::
daemon:NP:6445::::::
bin:NP:6445::::::
sys:NP:6445::::::
adm:NP:6445::::::
+::::::::
""",
"cat" : " ",
"empty" : ""
}
foo10 = """
open foo@1.0,5.11-0
close """
only_attr10 = """
open only_attr@1.0,5.11-0
add set name=foo value=bar
close """
only_depend10 = """
open only_depend@1.0,5.11-0
add depend type=require fmri=foo@1.0,5.11-0
close """
only_directory10 = """
open only_dir@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
only_driver10 = """
open only_driver@1.0,5.11-0
add driver name=zerg devlink="type=ddi_pseudo;name=zerg\\t\D"
close """
only_group10 = """
open only_group@1.0,5.11-0
add group groupname=Kermit gid=28
close """
only_group_file10 = """
open only_group_file@1.0,5.11-0
close """
only_hardlink10 = """
open only_hardlink@1.0,5.11-0
add hardlink path=/cat.hardlink target=/cat
close """
only_legacy10 = """
open only_legacy@1.0,5.11-0
add legacy category=system desc="GNU make - A utility used to build software (gmake) 3.81" hotline="Please contact your local service provider" name="gmake - GNU make" pkg=SUNWgmake vendor="Sun Microsystems, Inc." version=11.11.0,REV=2008.04.29.02.08
close """
only_link10 = """
open only_link@1.0,5.11-0
close """
only_user10 = """
open only_user@1.0,5.11-0
close """
only_user_file10 = """
open only_user_file@1.0,5.11-0
close """
csu1 = """
open csu1@1.0,5.11-0
add legacy category=system desc="core software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris, (Usr)" pkg=SUNWcsu vendor="Oracle Corporation" version=11.11,REV=2009.11.11
close
"""
csu1_2 = """
open csu1@2.0,5.11-0
add legacy category=system desc="core software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris, (Usr)" pkg=SUNWcsu vendor="Oracle Corporation" version=11.11,REV=2010.11.11
close
"""
csu2 = """
open csu2@1.0,5.11-0
add legacy category=system desc="core software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris, (Usr)" pkg=SUNWcsu vendor="Oracle Corporation" version=11.11,REV=2009.11.11
close
"""
csu2_2 = """
open csu2@2.0,5.11-0
add legacy category=system desc="core software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris, (Usr)" pkg=SUNWcsu vendor="Oracle Corporation" version=11.11,REV=2010.11.11
close
"""
csu3 = """
open csu3@1.0,5.11-0
add legacy category=system desc="core software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris, (Usr)" pkg=SUNWcsu vendor="Oracle Corporation" version=11.11,REV=2009.11.11
close
"""
csu3_2 = """
open csu3@2.0,5.11-0
add legacy category=system desc="core software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris, (Usr)" pkg=SUNWcsu vendor="Oracle Corporation" version=11.11,REV=2010.11.11
close
"""
# some of these are subsets-- "always" and "at-end"-- for performance;
# we assume that e.g. if a and z work, that bcdef, etc. will too.
"never": " `~!@#$%^&*()=[{]}\\|;:\",<>?",
"always": "09azAZ",
"after-first": "_-.+",
"at-end": "09azAZ_-.+",
}
open only_file@1.0,5.11-0
add file cat mode=0555 owner=root group=bin path=/cat
close """
open only_license@1.0,5.11-0
add license cat license=copyright
close """
add dir path=etc mode=0755 owner=root group=sys
add user username=root password=9EIfTNBp9elws uid=0 group=root home-dir=/root gcos-field=Super-User login-shell=/usr/bin/bash ftpuser=false lastchg=13817 group-list=other group-list=bin group-list=sys group-list=adm
add group gid=0 groupname=root
add group gid=3 groupname=sys
close """
open singleuser@0,5.11
add user group=fozzie uid=16 username=fozzie
add group groupname=fozzie gid=16
close
"""
open basics@1.0,5.11-0
add dir mode=0755 owner=root group=sys path=etc
close """
open basics1@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=lib
add dir mode=0755 owner=root group=sys path=var
add dir mode=0755 owner=root group=bin path=usr
close """
open grouptest@1.0,5.11-0
add file empty mode=0755 owner=root group=Kermit path=/usr/local/bin/do_group_nothing
add group groupname=lp gid=8
add group groupname=staff gid=10
add group groupname=Kermit
add depend fmri=pkg:/basics@1.0 type=require
close """
open usertest@1.0,5.11-0
add file empty mode=0755 owner=Kermit group=Kermit path=/usr/local/bin/do_user_nothing
add depend fmri=pkg:/basics@1.0 type=require
add depend fmri=pkg:/grouptest@1.0 type=require
add depend fmri=pkg:/basics@1.0 type=require
close """
open usertest@1.1,5.11-0
add file empty mode=0755 owner=Kermit group=Kermit path=/usr/local/bin/do_user_nothing
add depend fmri=pkg:/basics@1.0 type=require
add user username=Kermit group=Kermit home-dir=/export/home/Kermit2 group-list=lp group-list=staff group-list=root ftpuser=false
add depend fmri=pkg:/grouptest@1.0 type=require
add depend fmri=pkg:/basics@1.0 type=require
close """
open ugidtest@1.0,5.11-0
add user username=dummy group=root
add group groupname=dummy
close """
open silver@1.0,5.11-0
add depend fmri=pkg:/basics@1.0 type=require
add depend fmri=pkg:/basics1@1.0 type=require
close """
open silver@2.0,5.11-0
add depend fmri=pkg:/basics@1.0 type=require
add depend fmri=pkg:/basics1@1.0 type=require
add depend fmri=pkg:/grouptest@1.0 type=require
close """
open devicebase@1.0,5.11-0
add dir mode=0755 owner=root group=sys path=/var
add dir mode=0755 owner=root group=root path=system
add dir mode=0755 owner=root group=sys path=/tmp
add dir mode=0755 owner=root group=sys path=/etc
add file empty mode=0600 owner=root group=sys path=/etc/devlink.tab preserve=true
add file empty mode=0644 owner=root group=sys path=/etc/name_to_major preserve=true
add file empty mode=0644 owner=root group=sys path=/etc/driver_aliases preserve=true
add file empty mode=0644 owner=root group=sys path=/etc/driver_classes preserve=true
add file empty mode=0644 owner=root group=sys path=/etc/minor_perm preserve=true
add file empty mode=0644 owner=root group=sys path=/etc/security/device_policy preserve=true
add file empty mode=0644 owner=root group=sys path=/etc/security/extra_privs preserve=true
close
"""
open devlinktest@1.0,5.11-0
add driver name=zerg devlink="type=ddi_pseudo;name=zerg\\t\D"
add driver name=borg devlink="type=ddi_pseudo;name=borg\\t\D" devlink="type=ddi_pseudo;name=warg\\t\D"
add depend type=require fmri=devicebase
close
"""
open devlinktest@2.0,5.11-0
add driver name=zerg devlink="type=ddi_pseudo;name=zerg2\\t\D" devlink="type=ddi_pseudo;name=zorg\\t\D"
add driver name=borg devlink="type=ddi_pseudo;name=borg\\t\D" devlink="type=ddi_pseudo;name=zork\\t\D"
add depend type=require fmri=devicebase
close
"""
open devalias@1,5.11
add driver name=zerg alias=pci8086,1234 alias=pci8086,4321
close
"""
open devalias@2,5.11
add driver name=zerg alias=pci8086,5555
close
"""
open devaliasmove@1,5.11
add driver name=zerg alias=pci8086,5555
close
"""
open devaliasmove@2,5.11
add driver name=zerg
add driver name=borg alias=pci8086,5555
close
"""
open badhardlink1@1.0,5.11-0
add hardlink path=foo target=bar
close
"""
open badhardlink2@1.0,5.11-0
close
"""
"""Send basic infrastructure, install and uninstall."""
"""Send basic infrastructure, exact-install and uninstall."""
"""Ensure that we can install user and group actions in the same
"""Ensure that we can exact-install user and group actions in
notftpuser = """
open notftpuser@1
add user username=animal group=root ftpuser=false
close"""
ftpuserexp = """
open ftpuserexp@1
add user username=fozzie group=root ftpuser=true
close"""
ftpuserimp = """
open ftpuserimp@1
add user username=gonzo group=root
close"""
# Add a user with ftpuser=false. Make sure the user is added to
# the file, and that the user verifies.
# Add a user with an explicit ftpuser=true. Make sure the user
# is not added to the file, and that the user verifies.
# Add a user with an implicit ftpuser=true. Make sure the user
# is not added to the file, and that the user verifies.
# Put a user into the ftpusers file as shipped, then add that
# user, with ftpuser=false. Make sure the user remains in the
# file, and that the user verifies.
f.write("animal\n")
# Put a user into the ftpusers file as shipped, then add that
# user, with an explicit ftpuser=true. Make sure the user is
# stripped from the file, and that the user verifies.
f.write("fozzie\n")
# Put a user into the ftpusers file as shipped, then add that
# user, with an implicit ftpuser=true. Make sure the user is
# stripped from the file, and that the user verifies.
f.write("gonzo\n")
"""Make sure we correctly verify group actions when users have
been added."""
simplegroups = """
open simplegroup@1
add group groupname=muppets gid=100
close
open simplegroup2@1
add group groupname=muppets2 gid=101
close"""
# add additional members to group & verify
f.writelines(gdata)
# verify that groups appear in gid order.
"""Make sure we correct any errors in pre-existing group actions"""
simplegroup = """
open simplegroup@0
add group groupname=muppets
close
open simplegroup@1
add group groupname=muppets gid=70
close
open simplegroup@2
add group groupname=muppets gid=70
close"""
f.writelines(gdata)
# properly install group w/o a gid
# install w/ different gid
# check # lines beginning w/ 'muppets' in group file
# make sure we can add new version of same package
"""test what happens when a owner or group is missing"""
missing = """
open missing_group@1
close
open missing_owner@1
close
open muppetsuser@1
add user username=muppets group=bozomuppets uid=777
close
open muppetsuser@2
add user username=muppets group=muppets uid=777
close
open muppetsgroup@1
add group groupname=muppets gid=777
close
"""
# try installing directory w/ a non-existing group
# try installing directory w/ a non-existing owner
# try installing user w/ unknown group
# install group
# install working user & see if it all works.
# edit group file to remove muppets group
# verify that we catch missing group
# in both group and user actions
# try installing w/ broken group
"""Make sure we correctly verify user actions when the on-disk
databases have been modified."""
simpleusers = """
open simpleuser@1
close
open simpleuser2@1
add user username=kermit group=root gcos-field="& loves mspiggy" login-shell=/bin/sh password=UP uid=6
close
open simpleuser2@2
open simpleuser3@1
add user username=wombat group=root gcos-field="& has explict password" login-shell=/bin/bash uid=99 password=$5$FuMX5tH9$MJkmx3wE5MFHtHhGNBlimwHtqPUdTVWs6VAjfQcCKS5
close
open simpleuser3@2
add user username=wombat group=root gcos-field="& has explict password" login-shell=/bin/bash uid=99 password=$5$C6451mtT$PDg63UKGtFr7FHkMSxUhdTcd0XBtHTnKXNN7RpJe/h1 shell-change-ok=true
close"""
# change a provided, empty-default field to something else
f.writelines(pdata)
# change a provided, non-empty-default field to the default
f.writelines(pdata)
finderr("gcos-field: '& User' should be '& loves Kermie'")
# change a non-provided, non-empty-default field to something
# other than the default
f.writelines(pdata)
finderr("home-dir: '/misspiggy' should be '/'")
# add a non-provided, empty-default field
f.writelines(pdata)
f.writelines(sdata)
finderr("min: '7' should be '<empty>'")
# we now fix entries w/ non-mutable passwords
# remove a non-provided, non-empty-default field
f.writelines(pdata)
f.writelines(sdata)
finderr("home-dir: '' should be '/'")
# remove a provided, non-empty-default field
f.writelines(pdata)
finderr("gcos-field: '' should be '& loves Kermie'")
# remove a provided, empty-default field
f.writelines(pdata)
f.writelines(pdata)
finderr("gcos-field: '<missing>' should be '& loves Kermie'")
finderr("group: '<missing>' should be 'root'")
# remove the user completely
f.writelines(pdata)
f.writelines(sdata)
finderr("username: '<missing>' should be 'misspiggy'")
# change the password and show an error
f.writelines(sdata)
finderr("password: 'NP' should be '*LK*'")
# verify that passwords set to UP
# do not cause verify errors if changed.
f.writelines(sdata)
# verify that upgrading package to version that implicitly
# uses *LK* default causes password to change and that it
# verifies correctly
# ascertain that users are added in uid order when
# installed at the same time.
# verify that entry w/ explicit password fails verify when that entry is changed
f.writelines(sdata)
# restore password
f.writelines(sdata)
# change shell and make sure error occurs
f.writelines(pdata)
finderr("login-shell")
# upgrade pkg so shell change is ok
f.writelines(pdata)
unused."""
# This will lay down the sample passwd file, group file, etc.
if install_cmd == "install":
else:
for line in passwd_file:
for line in group_file:
"""Ensure that we can add a user and change file ownership to
that user in the same delta (mysql tripped over this early on
in IPS development)."""
# install or exact-install, uninstall a user, and preserve the
# garbage line. Once with a blank line in the middle, once
# with a non-blank line with too few fields, once with a
# non-blank line with too many fields, and once with a blank
# line at the end.
(3, ":::::::::"), (100, "")):
garbage += "\n"
if install_cmd == "install":
else:
"""If a user is present in a secondary group list when the user
is installed, the client shouldn't crash."""
if install_cmd == "install":
else:
"""Send invalid package definitions (invalid fmris); expect
failure."""
exit=1)
if char == "-":
else:
"""Send a series of valid packages; expect success."""
# driver actions are not valid except on OpenSolaris
return
def readfile():
"etc/devlink.tab"))
return dllines
"etc/devlink.tab"), "w")
# Install
# Verify that three entries got added
# Verify that the tab character got written correctly
# Upgrade
# Verify that there are four entries now
# Verify they are what they should be
# Remove
# Install again
# Diddle with it
dllines[i] = "type=ddi_pseudo;name=zippy\t\D\n"
# Upgrade
# Verify that we spewed a message on upgrade
# Verify the new set
["zerg2", "zorg", "borg", "zork", "zippy"])
# Null out the "zippy" entry
writefile([])
# Install again
# Diddle with it
dllines[i] = "type=ddi_pseudo;name=zippy\t\D\n"
# Remove
# Verify that we spewed a message on removal
# Verify that the one left behind was the one we overwrote.
# Null out the "zippy" entry, but add the "zerg" entry
writefile(["type=ddi_pseudo;name=zerg\t\D\n"])
# Install ... again
# Make sure we didn't get a second zerg line
# Now for the same test on upgrade
"""Make sure that aliases properly appear and disappear on
upgrade. This is the result of a bug in update_drv, but it's
not a bad idea to test some of this ourselves."""
# driver actions are not valid except on OpenSolaris
return
"etc/driver_aliases"))
"""Make sure that an alias can be moved from one driver action
to another."""
"""Verify uninstall fails as expected for unprivileged users."""
# driver actions are not valid except on OpenSolaris
if not install:
cmd = ["uninstall"]
elif name == "only_driver":
elif name == "only_group":
elif name == "only_hardlink":
elif name == "only_user":
if install:
else:
for p in pkg_list:
exit=1)
exit=1)
for p in pkg_list:
for p in pkg_list:
# Modifying operations require permissions needed to create and
# manage lock files.
# Should fail since user doesn't have permission to refresh
# publisher metadata.
exit=1)
""" Verify that a timestamp of '0' for a passwd file will not
cause further package operations to fail. This can happen
when there are time synchronization issues within a virtual
environment or in other cases. """
# This should work regardless of whether a user is installed
# at the same time as the file in a package, or if the user is
# installed first and then files owned by that user are
# installed.
["only_user", "only_user_file"],
["only_group", "only_group_file"]]
"""A couple of bogus hard link target tests."""
# A package which tries to install a hard link to a target that
# doesn't exist shouldn't stack trace, but exit sanely.
# A package which tries to install a hard link to a target
# specified as an absolute path should install that link
# relative to the image root.
# Make sure we installed one and only one pkginfo file, and with
# the correct information.
# Create the hardlinks as we'd have for the old refcounting
# system.
# Make sure that upgrading the actions modifies the pkginfo file
# correctly, and that the hardlinks go away.
# Start over, but this time "break" the hardlinks.
pkg10 = """
open pkg1@1.0,5.11-0
add depend type=optional fmri=pkg:/pkg2
close
"""
pkg20 = """
open pkg2@1.0,5.11-0
close
"""
pkg11 = """
open pkg1@1.1,5.11-0
add depend type=optional fmri=pkg:/pkg2@1.1
close
"""
pkg21 = """
open pkg2@1.1,5.11-0
close
"""
pkg30 = """
open pkg3@1.0,5.11-0
add depend type=require fmri=pkg:/pkg1@1.1
close
"""
pkg40 = """
open pkg4@1.0,5.11-0
add depend type=exclude fmri=pkg:/pkg1@1.1
close
"""
pkg50 = """
open pkg5@1.0,5.11-0
add depend type=exclude fmri=pkg:/pkg1@1.1
add depend type=require fmri=pkg:/pkg1@1.0
close
"""
pkg505 = """
open pkg5@1.0.5,5.11-0
add depend type=exclude fmri=pkg:/pkg1@1.1
add depend type=require fmri=pkg:/pkg1@1.0
close
"""
pkg51 = """
open pkg5@1.1,5.11-0
add depend type=exclude fmri=pkg:/pkg1@1.1
add depend type=exclude fmri=pkg:/pkg2
add depend type=require fmri=pkg:/pkg1@1.0
close
"""
pkg60 = """
open pkg6@1.0,5.11-0
add depend type=exclude fmri=pkg:/pkg1@1.1
close
"""
pkg61 = """
open pkg6@1.1,5.11-0
close
"""
bug_18653 = """
open entire@1.0,5.11-0
add depend type=incorporate fmri=osnet-incorporation@1.0
close
open entire@1.1,5.11-0
add depend type=incorporate fmri=osnet-incorporation@1.1
close
open osnet-incorporation@1.0,5.11-0
add depend type=incorporate fmri=sun-solaris@1.0
add depend type=incorporate fmri=sun-solaris-510@1.0
close
open osnet-incorporation@1.1,5.11-0
add depend type=incorporate fmri=sun-solaris@1.1
add depend type=incorporate fmri=sun-solaris-510@1.1
close
open sun-solaris@1.0,5.11-0
add depend type=require fmri=osnet-incorporation
add depend type=conditional predicate=perl-510 fmri=sun-solaris-510@1.0
close
open sun-solaris@1.1,5.11-0
add depend type=require fmri=osnet-incorporation
add depend type=conditional predicate=perl-510 fmri=sun-solaris-510@1.1
close
open sun-solaris-510@1.0,5.11-0
add depend type=require fmri=osnet-incorporation
add depend type=require fmri=perl-510@1.0
close
open perl-510@1.0,5.11-0
close
open perl-510@1.1,5.11-0
close
"""
pkg70 = """
open pkg7@1.0,5.11-0
add depend type=conditional predicate=pkg:/pkg2@1.1 fmri=pkg:/pkg6@1.1
close
"""
pkg80 = """
open pkg8@1.0,5.11-0
add depend type=require-any fmri=pkg:/pkg9@1.0 fmri=pkg:/pkg2@1.1 fmri=pkg:/nonsuch
close
"""
pkg81 = """
open pkg8@1.1,5.11-0
add depend type=require-any fmri=pkg:/pkg9@1.1 fmri=pkg:/pkg2@1.1 fmri=pkg:/nonsuch
close
"""
pkg90 = """
open pkg9@1.0,5.11-0
close
"""
pkg91 = """
open pkg9@1.1,5.11-0
close
"""
pkg100 = """
open pkg10@1.0,5.11-0
close
"""
pkg101 = """
open pkg10@1.1,5.11-0
close
"""
pkg102 = """
open pkg10@1.2,5.11-0
add depend type=origin fmri=pkg10@1.1,5.11-0
close
"""
pkg110 = """
open pkg11@1.0,5.11-0
add depend type=origin root-image=true fmri=SUNWcs@0.5.11-0.75
close
"""
pkg111 = """
open pkg11@1.1,5.11-0
add depend type=origin root-image=true fmri=SUNWcs@0.5.11-1.0
close
"""
pkg121 = """
open pkg12@1.1,5.11-0
"""
pkg121 += """
close
"""
pkg122 = """
open pkg12@1.2,5.11-0
"""
pkg122 += """
close
"""
pkg123 = """
open pkg12@1.3,5.11-0
"""
pkg123 += """
close
"""
pkg132 = """
open pkg13@1.2,5.11-0
add depend type=parent fmri=pkg12@1.2,5.11-0
close
"""
pkg142 = """
open pkg14@1.2,5.11-0
add depend type=parent fmri=pkg12@1.2,5.11-0
add depend type=parent fmri=pkg13@1.2,5.11-0
close
"""
pkg_nosol = """
open pkg-nosol-A@1.0,5.11-0
add depend type=require-any fmri=pkg:/pkg-nosol-B fmri=pkg:/pkg-nosol-C
add depend type=require fmri=pkg:/pkg-nosol-D
close
open pkg-nosol-B@1.0,5.11-0
add depend type=incorporate fmri=pkg:/pkg-nosol-E@2.0
close
open pkg-nosol-C@1.0,5.11-0
add depend type=incorporate fmri=pkg:/pkg-nosol-E@2.0
close
open pkg-nosol-D@1.0,5.11-0
add depend type=incorporate fmri=pkg:/pkg-nosol-E@1.0
close
open pkg-nosol-E@1.0,5.11-0
close
open pkg-nosol-E@2.0,5.11-0
close
"""
pkg_renames = """
open pkg_need_rename@1.0,5.11-0
add depend type=require fmri=pkg_rename
close
open pkg_rename@1.0,5.11-0
add set name=pkg.renamed value=true
add depend type=require fmri=pkg:/pkg_bar
close
open pkg_bar@1.0,5.11-0
close
open trusted@1.0,5.11-0
add set name=pkg.renamed value=true
close
close
"""
pkgSUNWcs075 = """
open SUNWcs@0.5.11-0.75
close
"""
leaf_template = """
open pkg{0}{1}@{2},5.11-0
add depend type=require fmri=pkg:/{3}_incorp{4}
close
"""
install_hold = "add set name=pkg.depend.install-hold value=test"
leaf_expansion = [
("A","_0", "1.0", "A", ""),
("A","_1", "1.0", "A", ""),
("A","_2", "1.0", "A", ""),
("A","_3", "1.0", "A", ""),
("B","_0", "1.0", "B", ""),
("B","_1", "1.0", "B", ""),
("B","_2", "1.0", "B", ""),
("B","_3", "1.0", "B", ""),
("A","_0", "1.1", "A", "@1.1"),
("A","_1", "1.1", "A", "@1.1"),
("A","_2", "1.1", "A", "@1.1"),
("A","_3", "1.1", "A", "@1.1"),
("B","_0", "1.1", "B", "@1.1"),
("B","_1", "1.1", "B", "@1.1"),
("B","_2", "1.1", "B", "@1.1"),
("B","_3", "1.1", "B", "@1.1"),
("A","_0", "1.2", "A", "@1.2"),
("A","_1", "1.2", "A", "@1.2"),
("A","_2", "1.2", "A", "@1.2"),
("A","_3", "1.2", "A", "@1.2"),
("B","_0", "1.2", "B", "@1.2"),
("B","_1", "1.2", "B", "@1.2"),
("B","_2", "1.2", "B", "@1.2"),
("B","_3", "1.2", "B", "@1.2"),
("A","_0", "1.3", "A", ""),
("A","_1", "1.3", "A", ""),
("A","_2", "1.3", "A", ""),
("A","_3", "1.3", "A", ""),
("B","_0", "1.3", "B", ""),
("B","_1", "1.3", "B", ""),
("B","_2", "1.3", "B", ""),
("B","_3", "1.3", "B", "")
]
incorps = [ """
open A_incorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/pkgA_0@1.0
add depend type=incorporate fmri=pkg:/pkgA_1@1.0
add depend type=incorporate fmri=pkg:/pkgA_2@1.0
add depend type=incorporate fmri=pkg:/pkgA_3@1.0
close
""",
"""
open B_incorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/pkgB_0@1.0
add depend type=incorporate fmri=pkg:/pkgB_1@1.0
add depend type=incorporate fmri=pkg:/pkgB_2@1.0
add depend type=incorporate fmri=pkg:/pkgB_3@1.0
close
""",
"""
open A_incorp@1.1,5.11-0
add depend type=incorporate fmri=pkg:/pkgA_0@1.1
add depend type=incorporate fmri=pkg:/pkgA_1@1.1
add depend type=incorporate fmri=pkg:/pkgA_2@1.1
add depend type=incorporate fmri=pkg:/pkgA_3@1.1
add set name=pkg.depend.install-hold value=test
close
""",
"""
open B_incorp@1.1,5.11-0
add depend type=incorporate fmri=pkg:/pkgB_0@1.1
add depend type=incorporate fmri=pkg:/pkgB_1@1.1
add depend type=incorporate fmri=pkg:/pkgB_2@1.1
add depend type=incorporate fmri=pkg:/pkgB_3@1.1
add set name=pkg.depend.install-hold value=test
close
""",
"""
open A_incorp@1.2,5.11-0
add depend type=incorporate fmri=pkg:/pkgA_0@1.2
add depend type=incorporate fmri=pkg:/pkgA_1@1.2
add depend type=incorporate fmri=pkg:/pkgA_2@1.2
add depend type=incorporate fmri=pkg:/pkgA_3@1.2
add set name=pkg.depend.install-hold value=test.A
close
""",
"""
open B_incorp@1.2,5.11-0
add depend type=incorporate fmri=pkg:/pkgB_0@1.2
add depend type=incorporate fmri=pkg:/pkgB_1@1.2
add depend type=incorporate fmri=pkg:/pkgB_2@1.2
add depend type=incorporate fmri=pkg:/pkgB_3@1.2
add set name=pkg.depend.install-hold value=test.B
close
""",
"""
open A_incorp@1.3,5.11-0
add depend type=incorporate fmri=pkg:/pkgA_0@1.3
add depend type=incorporate fmri=pkg:/pkgA_1@1.3
add depend type=incorporate fmri=pkg:/pkgA_2@1.3
add depend type=incorporate fmri=pkg:/pkgA_3@1.3
add set name=pkg.depend.install-hold value=test.A
close
""",
"""
open B_incorp@1.3,5.11-0
add depend type=incorporate fmri=pkg:/pkgB_0@1.3
add depend type=incorporate fmri=pkg:/pkgB_1@1.3
add depend type=incorporate fmri=pkg:/pkgB_2@1.3
add depend type=incorporate fmri=pkg:/pkgB_3@1.3
add set name=pkg.depend.install-hold value=test.B
close
""",
"""
open incorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/A_incorp@1.0
add depend type=incorporate fmri=pkg:/B_incorp@1.0
add set name=pkg.depend.install-hold value=test
close
""",
"""
open incorp@1.1,5.11-0
add depend type=incorporate fmri=pkg:/A_incorp@1.1
add depend type=incorporate fmri=pkg:/B_incorp@1.1
add set name=pkg.depend.install-hold value=test
close
""",
"""
open incorp@1.2,5.11-0
add depend type=incorporate fmri=pkg:/A_incorp@1.2
add depend type=incorporate fmri=pkg:/B_incorp@1.2
add set name=pkg.depend.install-hold value=test
close
""",
"""
open incorp@1.3,5.11-0
add depend type=incorporate fmri=pkg:/A_incorp@1.3
add depend type=exclude fmri=pkg:/pkgB_0
add set name=pkg.depend.install-hold value=test
close
"""
]
bug_7394_incorp = """
open bug_7394_incorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/pkg1@2.0
close
"""
exclude_group = """
close
open gold-server@1.0
close
close
"""
optional_group = """
open consolidation/desktop/desktop-incorporation@0.5.11-0.175.3.0.0.28.0
add depend type=incorporate fmri=communication/im/pidgin@2.10.11-0.175.3.0.0.26.0
close
open communication/im/pidgin@2.10.11-0.175.3.0.0.26.0
add depend type=require fmri=consolidation/desktop/desktop-incorporation
close
open communication/im/pidgin@2.10.11-5.12.0.0.0.90.0
add depend type=require fmri=consolidation/desktop/desktop-incorporation
close
open group/feature/multi-user-desktop@5.12-5.12.0.0.0.94.0
add depend type=group fmri=communication/im/pidgin
close
open communication/im/libotr@4.1.0-5.12.0.0.0.94.0
add depend type=optional fmri=communication/im/pidgin@2.10.11-5.12.0.0.0.88.0
close
"""
for t in self.leaf_expansion:
self.incorp_pkgs = []
"""Verify install or exact-install won't fail with a multiple
match error for a renamed package that shares a common
basename."""
""" exercise require dependencies """
"""Verify that a simultaneous exclude and group dependency on
the same package is handled gracefully."""
# These should fail (gracefully) because my-rsync packages
# gold-server package.
# installed.
# list.
# placed on avoid list as part of operation.
# Now remove gold-server and then verify install will fail.
# This should fail as there's no installed constraining package
# and user didn't provide sufficient input.
""" exercise exclude dependencies """
# install pkg w/ exclude dep.
# install pkg that is allowed by dep
# try to install disallowed pkg
# install pkg
# try to install pkg exclude dep on already
# installed pkg
# install a package w/ both exclude
# and require dependencies
# pick pkg to install that fits constraint
# of already installed pkg
# install a package that requires updating
# existing package to avoid exclude
# dependency
# try to install two incompatible pkgs
""" exercise exclude dependencies """
# Install pkg w/ exclude dep.
# Exact-install should ignore exclude dependencies,
# except user specifies both pkg name in command line.
# Exact-install a package w/ both exclude
# and require dependencies.
# pick pkg to exact-install that fits constraint.
# Exact- install two packages with proper version selected for
# one package based on the version of the other package.
# try to exact-install two incompatible pkgs
""" check to make sure that optional dependencies are enforced
"""
# pkg2 is optional, it should not have been installed
# this should install pkg1@1.1 and upgrade pkg2 to pkg2@1.1
# this should not install pkg2@1.0 because of the optional
# dependency in pkg1
""" check to make sure that optional dependencies are enforced
"""
# pkg2 is optional, it should not have been installed
# Verify with exact-install, the optional dependency package
# should be removed.
# Verify exact-install pkg2@1.0 should succeed and pkg1 should
# be removed.
""" shake out incorporation dependencies """
# simple pkg requiring controlling incorp
# should control pkgA_1 as well
# try nested incorporations
# try to break incorporation
# try update (using '*' which also checks that the update all
# path is used when '*' is specified)
# what happens when incorporation specified
# a package that isn't in the catalog
# test pkg.depend.install-hold feature
# next attempt will fail because incorporations prevent motion
# even though explicit dependency exists from pkg to
# incorporation.
# test to see if we could install both; presence of incorp
# causes relaxation of pkg.depend.install-hold and also test
# that parsable output works when -n is used
# this attempt also succeeds because pkg.depend.install-hold is
# relaxed since A_incorp is on command line
# now demonstrate w/ version 1.2 subincorps that master incorp
# prevents upgrade since pkg.depend.install-hold of master != other incorps
""" shake out incorporation dependencies """
# Simple pkg requiring controlling incorp
# should control pkgA_1 as well.
# Verify exact-install will upgrade pkgA_0 and A_incorp to 1.1
#, and uninstall pkgA_1.
# Try nested incorporations.
# Try to break incorporation.
# Only specify A_incorp@1.1 should succeed. install holds
# should be ignored.
# what happens when incorporation specified
# a package that isn't in the catalog.
# test pkg.depend.install-hold feature.
"""Get conditional dependencies working"""
# Test bug 18653
"perl-510 sun-solaris-510")
# Uninstall should fail because sun-solaris conditional
# dependency requires sun-solaris-510.
# Uninstalling both the predicate and the target of the
# conditional dependency should work.
# Check that reject also works.
# Verify that if the predicate of a conditional can be
# installed, but the consequent cannot, the package delivering
# the conditional dependency can still be installed.
"sun-solaris")
# Verify that the package incorporating a package that delivers
# a conditional for a consequent that cannot be installed can be
# removed.
"""Get conditional dependencies working."""
# Presenting pkg7@1.0 and pkg2@1.1 in the command line should
# trigger conditional dependency.
# If only pkg7@1.0 present in the command line, pkg2@1.1
# should be removed and pkg6@1.1 should not be installed.
"""Get require-any dependencies working"""
# test to see if solver will fail gracefully when no solution is
# possible and a require-any dependency is involved
# test to see if solver will pick one
# test to see if solver will be happy w/ renamed packages,
# already installed dependencies.
# test to see if solver will install new verion of existing
# package rather than add new package
# see if update works the same way
# test to see if uninstall is clever enough
"""Get require-any dependencies working"""
# Test to see if solver will fail gracefully when no solution is
# possible and a require-any dependency is involved.
# Test to see if solver will pick one.
# Test to see if solver will be happy w/ renamed packages,
# already installed dependencies.
"pkg8@1.0")
# test to see if solver will install new verion of existing
# package rather than add new package
"""Get origin dependencies working"""
# check install or exact-install behavior
# check update behavior
# check that dependencies are ignored if
# dependency not present
# make sure attempts to force install don't work
# check origin root-image=true dependencies
# relies on SUNWcs in root image; make image 1 the root image
# attach c2p 1 -> 0.
# try to install or exact-instal packages that have unmet
# parent dependencies.
# install or exact-install packages in parent.
# try to install or exact-install packages that have unmet
# parent dependencies.
# install or exact-install packages in parent.
# try to install or exact-install packages that have unmet
# parent dependencies.
# install packages in parent
# try to install or exact-install packages that have unmet parent dependencies.
# try to install or exact-install packages that have satisfied parent deps.
# install or exact-install packages in parent.
if install_cmd == "install":
else:
# try to install or exact-install packages that have satisfied.
# parent deps.
"""Ensure useful error messages are produced when an optional
dependency in a proposed package cannot be satisfied due to
another proposed package."""
# desktop-incorporation should not be listed as a rejected
# package; rejected packages are always listed with full FMRI
# and scheme
# all of these should show up as rejected packages
# reason for rejection should reference optional dependency type
foo10 = """
open foo@1.0,5.11-0
close"""
bar10 = """
open bar@1.0,5.11-0
close"""
moo10 = """
open moo@1.0,5.11-0
close"""
quux10 = """
open quux@1.0,5.11-0
add depend type=optional fmri=optional@1.0
close"""
baz10 = """
open baz@1.0,5.11-0
add depend type=require fmri=corge@1.0
close"""
corge10 = """
open corge@1.0,5.11-0
close"""
optional10 = """
open optional@1.0,5.11-0
close"""
upgrade_p10 = """
open upgrade-p@1.0,5.11-0
close"""
upgrade_p11 = """
open upgrade-p@1.1,5.11-0
close"""
upgrade_np10 = """
open upgrade-np@1.0,5.11-0
close"""
upgrade_np11 = """
open upgrade-np@1.1,5.11-0
close"""
incorp_p10 = """
open incorp-p@1.0,5.11-0
add depend type=incorporate fmri=upgrade-p@1.0
close"""
incorp_p11 = """
open incorp-p@1.1,5.11-0
add depend type=incorporate fmri=upgrade-p@1.1
close"""
incorp_np10 = """
open incorp-np@1.0,5.11-0
add depend type=incorporate fmri=upgrade-np@1.0
close"""
incorp_np11 = """
open incorp-np@1.1,5.11-0
add depend type=incorporate fmri=upgrade-np@1.1
close"""
""" depot 1 gets foo and moo, depot 2 gets foo and bar,
depot 3 is empty, depot 4 gets upgrade_np@1.1
depot 5 gets corge10, depot6 is empty
depot7 is a copy of test1's repository for test3
depot1 is mapped to publisher test1 (preferred)
depot2 is mapped to publisher test2
depot3 is not mapped during setUp
depot4 is not mapped during setUp
depot5 is not mapped during setUp
depot6 is not mapped during setUp"""
# Two depots are intentionally started for some publishers.
"test3", "test2", "test4", "test1", "test3"])
# Copy contents of test1's repo to a repo for test3.
# Create image and hence primary publisher
# Create second publisher using depot #2
# Install and uninstall moo (which is unique to depot 1)
# Install and uninstall bar (which is unique to depot 2)
# Install and uninstall foo (which is in both depots)
# In this case, we should select foo from depot 1, since
# it is preferred.
""" Test install from an explicit preferred publisher """
""" Test install from an explicit non-preferred publisher """
"""Install a package from the preferred publisher, and then
upgrade it, failing to implicitly switching to a non-preferred
publisher and then managing it explicitly"""
"""Install a package from a non-preferred publisher, and then
try to upgrade it, failing to implicitly switch to the preferred
publisher and then succeed doing it explicitly."""
"""Install a package from the preferred publisher, and then
upgrade it, failing to implicitly switch to a non-preferred
publisher, when the package is constrained by an
incorporation, and then succeed when doing so explicitly"""
"""Install a package from the preferred publisher, and then
upgrade it, implicitly switching to a non-preferred
publisher, when the package is constrained by an
incorporation."""
"""Verify that packages can still be installed from a repository
even when any of the other repositories are not reachable and
--no-refresh is used."""
# Change the second publisher to point to an unreachable URI.
"test2")
# Verify that no packages are installed.
# Verify moo can be installed (as only depot1 has it) even
# though test2 cannot be reached (and needs a refresh).
# Verify moo can be installed (as only depot1 has it) even
# though test2 cannot be reached (and needs a refresh) if
# --no-refresh is used.
# Reset the test2 publisher.
# Install v1.0 of upgrade-np from test2 to prepare for
# update.
# Set test1 to point to an unreachable URI.
"test1")
# Set test2 so that upgrade-np has a new version available
# even though test1's repository is not accessible.
# Verify update works even though test1 is unreachable
# since upgrade-np@1.1 is available from test2 if --no-refresh
# is used.
# Now reset everything for the next test.
"""Install a package from a publisher and try to remove it
using a different publisher name; this should fail."""
# Check to make sure that uninstalling using the explicit
# publisher works
"""Install a package from a publisher that has an optional
dependency; then change the preferred publisher and remove the
original publisher and then verify that installing the package
again succeeds since it is essentially a no-op."""
# Attempting to install an already installed package should
# be a no-op even if the corresponding publisher no longer
# exists.
# Update should work if we don't see the optional
# dependency.
# Add back the installed package's publisher, but using a
# a repository with an empty catalog. After that, attempt to
# install the package again, which should succeed even though
# the fmri is no longer in the publisher's catalog.
# Add a new publisher, with the same packages as the installed
# publisher. Then, add back the installed package's publisher,
# but using an empty repository. After that, attempt to install
# the package again, which should succeed since at least one
# publisher has the package in its catalog.
# Add a new publisher, using the installed package publisher's
# repository. After that, attempt to install the package again,
# which should simply result in a 'no updates necessary' exit
# code since the removed publisher's package is already the
# newest version available.
#
# Change the image metadata back to where it was, in preparation
# for subsequent tests.
# Remove the installed packages.
"""Install a package from the preferred publisher, change the
preferred publisher, and attempt to remove the package."""
# Change the image metadata back to where it was, in preparation
# for the next test.
"""Install a package from the preferred publisher, remove the
preferred publisher, and then evaluate whether an uninstall
would succeed regardless of whether its publisher still exists
or another publisher has the same fmri in its catalog."""
# Attempting to uninstall should work even if the corresponding
# publisher no longer exists.
# Add back the installed package's publisher, but using a
# a repository with an empty catalog. After that, attempt to
# uninstall the package again, which should succeed even though
# the fmri is no longer in the publisher's catalog.
# Add a new publisher, with a repository with the same packages
# as the installed publisher. Then, add back the installed
# package's publisher using an empty repository. After that,
# attempt to uninstall the package again, which should succeed
# even though the package's installed publisher is known, but
# doesn't have the package's fmri in its catalog, but the
# package's fmri is in a different publisher's catalog.
# Add a new publisher, with a repository with the same packages
# as the installed publisher. After that, attempt to uninstall
# the package again, which should succeed even though the fmri
# is only in a different publisher's catalog.
# Finally, actually remove the package.
# Change the image metadata back to where it was, in preparation
# for subsequent tests.
"""Verify that when multiple non-preferred publishers offer the
same package that the expected install behaviour occurs."""
# make sure we look here first; tests rely on that
# First, verify that installing a package from a non-preferred
# publisher will cause its dependencies to be installed from the
# same publisher if the preferred publisher does not offer them.
# Next, verify that naming the specific publishers for a package
# and all of its dependencies will install the package from the
# specified sources instead of the same publisher the package is a
# dependency of.
# Finally, cleanup for the next test.
"""Test various aspects of the stick/non-sticky
behavior of publishers"""
# For ease of debugging
# install from non-preferred repo explicitly
# Demonstrate that preferred publisher is not
# acceptable, since test2 is sticky by default
# Check that we can proceed once test2 is not sticky
# Restore to pristine
# Repeat the test w/ preferred
# Check that search order can be overridden w/ explicit
# version specification...
"""Test to make sure update follows the same
publisher selection mechanisms as pkg install"""
# try update
"""Test to make sure disabled publishers are
automatically made non-sticky, and after
being enabled keep their previous value
of stickiness"""
# For ease of debugging
# install from non-preferred repo explicitly
# Demonstrate that preferred publisher is not
# acceptable, since test2 is sticky by default
# Disable test2 and then we should be able to proceed
"""Verify that packages installed from a publisher that has
been removed can still satisfy dependencies."""
# this should work, since dependency is already installed
# even though it is from a disabled publisher
there is a newer package version available works as expected.
"""
# Ensure a new image is created.
# Add second publisher using repository #2.
# Install older version of package from test1.
# Verify setting test2 as higher-ranked would not result in
# update since test1 is sticky.
# Verify setting test1 as higher-ranked and non-sticky would not
# result in update since test2 is lower-ranked and not
# non-sticky.
# Verify setting test2 as non-sticky would result in update even
# though it is lower-ranked since it is non-sticky..
# Verify placing a publisher between test1 and test2 causes the
# update to fail since even though test1 and test2 are
# non-sticky, they are not adjacent.
# Verify setting test2 as higher-ranked and sticky would result
# in update since test1 is non-sticky and test2 is higher-ranked.
# Verify update of 'upgrade-p' package will result in upgrade
# from 1.0 -> 1.1.
# Revert to 1.0 and verify install behaves the same.
"""Test that pkg client returns with exit code 1 when only one
publisher is specified and it's not reachable (bug 7176158)."""
# Create private image for this test.
# Set origin to an invalid repo.
"test1")
# Check if install -n returns with exit code 1
"""
If a new essential directory is added to the format of an image it will
be necessary to update this test suite. To update this test suite,
decide in what ways it is necessary to corrupt the image (removing the
new directory or file, or removing the some or all of contents of the
new directory for example). Make the necessary changes in
pkg5unittest.SingleDepotTestCaseCorruptImage to allow the needed
corruptions, then add new tests to the suite below. Be sure to add
tests for both Full and User images, and perhaps Partial images if
situations are found where these behave differently than Full or User
images.
"""
foo11 = """
open foo@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
close """
# For each test:
# in subsequent notes) in verious ways
# is set to that dirctory.
# Tests simulating a corrupted Full Image
""" Creates an empty bad_dir. """
dir missing. """
""" Creates bad_dir with only the cfg_cache file missing. """
""" Creates bad_dir with only the index dir missing. """
""" Creates bad_dir with all dirs and files present, but
"""
# This is expected to fail because it will see an empty
# publisher directory and not rebuild the files as needed
self):
""" Creates bad_dir with all dirs and files present, but with an
that refresh will work, and that an install after the refresh
also works.
"""
""" Sanity check to ensure that the code for creating
a bad_dir creates a good copy other than what's specified
to be wrong. """
# Tests simulating a corrupted User Image
# These tests are duplicates of those above but instead of creating
# a corrupt full image, they create a corrupt User image.
""" Creates a corrupted image at bad_dir by creating empty
bad_dir. """
[".org.opensolaris,pkg"])
""" Creates a corrupted image at bad_dir by creating bad_dir
[".org.opensolaris,pkg"])
""" Creates a corrupted image at bad_dir by creating
bad_dir with only the cfg_cache file missing. """
""" Creates a corrupted image at bad_dir by creating
bad_dir with only the index dir missing. """
[".org.opensolaris,pkg"])
""" Creates a corrupted image at bad_dir by creating bad_dir
with all dirs and files present, but with an empty publisher
[".org.opensolaris,pkg"])
""" Creates bad_dir with all dirs and files present, but with
refresh will work, and that an install after the refresh also
works.
"""
[".org.opensolaris,pkg"])
""" Sanity check to ensure that the code for creating
a bad_dir creates a good copy other than what's specified
to be wrong. """
[".org.opensolaris,pkg"])
"""Test cases for obsolete packages."""
foo1 = """
open foo@1
add dir path=usr mode=0755 owner=root group=root
close
"""
# Obsolete packages can have metadata
foo2 = """
open foo@2
add set name=pkg.obsolete value=true
add set name=pkg.summary value="A test package"
close
"""
fbar = """
open fbar@1
add depend type=require fmri=foo@2
close
"""
qbar = """
open qbar@1
add depend type=require fmri=qux@2
close
"""
qux1 = """
open qux@1
add dir path=usr mode=0755 owner=root group=root
close
"""
qux2 = """
open qux@2
add set name=pkg.renamed value=true
add depend type=require fmri=foo@1
close
"""
fred1 = """
open fred@1
add depend type=require fmri=foo
close
"""
fred2 = """
open fred@2
close
"""
# First install the non-obsolete version of foo
# Now install the obsolete version, and ensure it disappears (5)
# Explicitly installing an obsolete package succeeds, but
# results in nothing on the system. (1)
# Installing a package with a dependency on an obsolete package
# fails. (2)
# Installing a package with a dependency on a renamed package
# succeeds, leaving the first package and the renamed package on
# the system, as well as the empty, pre-renamed package. (3)
# A simple rename test: First install the pre-renamed version of
# qux. Then install the renamed version, and see that the new
# package is installed, and the renamed package is installed,
# but marked renamed. (4)
# Install a package that's going to be obsoleted and a package
# that depends on it. Update the package to its obsolete
# version and see that it fails. (6, sorta)
# now add a version of fred that doesn't require foo, and
# show that update works
# test fix for bug 12898
foo1 = """
open foo@1
add dir path=usr mode=0755 owner=root group=root
close
"""
# Obsolete packages can have metadata
foo2 = """
open foo@2
add set name=pkg.obsolete value=true
add set name=pkg.summary value="A test package"
close
"""
fbar = """
open fbar@1
add depend type=require fmri=foo@2
close
"""
qbar = """
open qbar@1
add depend type=require fmri=qux@2
close
"""
qux1 = """
open qux@1
add dir path=usr mode=0755 owner=root group=root
close
"""
qux2 = """
open qux@2
add set name=pkg.renamed value=true
add depend type=require fmri=foo@1
close
"""
fred1 = """
open fred@1
add depend type=require fmri=foo
close
"""
fred2 = """
open fred@2
close
"""
# First exact-install the non-obsolete version of foo
# Now exact-install the obsolete version, and ensure it disappears
# (5).
# Explicitly exact-installing an obsolete package succeeds, but
# results in nothing on the system. (1)
# Exact-installing a package with a dependency on an obsolete
# package fails. (2)
# Exact-installing a package with a dependency on a renamed
# package succeeds, leaving the first package and the renamed
# package on the system, as well as the empty, pre-renamed
# package. (3)
# A simple rename test: First exact-install the pre-renamed
# version of qux. Then install the renamed version, and see
# that the new package is installed, and the renamed package
# is installed, but marked renamed. (4)
# Exact-install a package that's going to be obsoleted and a
# package that depends on it. Update the package to its
# obsolete version and see that it fails. (6, sorta)
# If fred is not in the command line, we should ignore its
# restriction and install foo@2.
# now add a version of fred that doesn't require foo, and
# show that update works
"""Upgrade a package to a version with a dependency on a renamed
package. A => A' (-> Br (-> C))"""
t7ap1_1 = """
open t7ap1@1
close
"""
t7ap1_2 = """
open t7ap1@2
add depend type=require fmri=t7ap2
close
"""
t7ap2_1 = """
open t7ap2@1
add set name=pkg.renamed value=true
add depend type=require fmri=t7ap3
close
"""
t7ap3_1 = """
open t7ap3@1
close
"""
"""Upgrade a package to a version with a dependency on a renamed
package. Like 7a except package A starts off depending on B.
A (-> B) => A' (-> Br (-> C))"""
t7bp1_1 = """
open t7bp1@1
add depend type=require fmri=t7bp2
close
"""
t7bp1_2 = """
open t7bp1@2
add depend type=require fmri=t7bp2
close
"""
t7bp2_1 = """
open t7bp2@1
close
"""
t7bp2_2 = """
open t7bp2@1
add set name=pkg.renamed value=true
add depend type=require fmri=t7bp3
close
"""
t7bp3_1 = """
open t7bp3@1
close
"""
"""Upgrade a package to a version with a dependency on a renamed
package. Like 7b, except package A doesn't change.
A (-> B) => A (-> Br (-> C))"""
t7cp1_1 = """
open t7cp1@1
add depend type=require fmri=t7cp2
close
"""
t7cp2_1 = """
open t7cp2@1
close
"""
t7cp2_2 = """
open t7cp2@2
add set name=pkg.renamed value=true
add depend type=require fmri=t7cp3
close
"""
t7cp3_1 = """
open t7cp3@1
close
"""
"""Upgrade a package to a version with a dependency on an
obsolete package. This version is unlikely to happen in real
life."""
t6ap1_1 = """
open t6ap1@1
close
"""
t6ap1_2 = """
open t6ap1@2
add depend type=require fmri=t6ap2
close
"""
t6ap2_1 = """
open t6ap2@1
add set name=pkg.obsolete value=true
close
"""
"""Install a package with a dependency, and update after
publishing updated packages for both, but where the dependency
has become obsolete."""
t6ap1_1 = """
open t6ap1@1
add depend type=require fmri=t6ap2
close
"""
t6ap1_2 = """
open t6ap1@2
add depend type=require fmri=t6ap2
close
"""
t6ap2_1 = """
open t6ap2@1
close
"""
t6ap2_2 = """
open t6ap2@2
add set name=pkg.obsolete value=true
close
"""
"""Upgrade a package to an obsolete leaf version when another
depends on it."""
t8ap1_1 = """
open t8ap1@1
close
"""
t8ap1_2 = """
open t8ap1@2
add set name=pkg.obsolete value=true
close
"""
t8ap2_1 = """
open t8ap2@1
add depend type=require fmri=t8ap1
close
"""
"""Publish an package with a dependency, then publish both as
obsolete, update, and see that both packages have gotten
removed."""
t13ap1_1 = """
open t13ap1@1
add depend type=require fmri=t13ap2
close
"""
t13ap1_2 = """
open t13ap1@2
add set name=pkg.obsolete value=true
close
"""
t13ap2_1 = """
open t13ap2@1
close
"""
t13ap2_2 = """
open t13ap2@2
add set name=pkg.obsolete value=true
close
"""
"""Install or exact-install a package with an ambiguous name,
where only one match is non-obsolete."""
t11p1 = """
open netbeans@1
add set name=pkg.obsolete value=true
close
"""
t11p2 = """
close
"""
"""Install or exact-install a package using an ambiguous name
where pkg is renamed to another package, but not the
conflicting one"""
t11p1 = """
open netbonze@1
add set name=pkg.renamed value=true
add depend type=require fmri=SUNWnetbonze
close
"""
t11p2 = """
close
"""
t11p3 = """
open SUNWnetbonze@1
close
"""
"""Install or exact-install a package using an ambiguous name
where only one match is non-renamed, and the renamed match
is renamed to the other."""
t11p1 = """
open netbooze@1
close
"""
t11p2 = """
open netbooze@2
add set name=pkg.renamed value=true
close
"""
t11p3 = """
close
"""
t11p4 = """
close
"""
"""Upgrade a package across a rename to an ambiguous name."""
t12p1_1 = """
open netbeenz@1
close
"""
t12p1_2 = """
open netbeenz@2
add set name=pkg.renamed value=true
close
"""
t12p2_1 = """
close
"""
"""If a renamed package has nothing depending on it, it should
be removed."""
p1_1 = """
open remrenA@1
close
"""
p1_2 = """
open remrenA@2
add set name=pkg.renamed value=true
add depend type=require fmri=pkg:/remrenB
close
"""
p2_1 = """
open remrenB@1
close
"""
p3_1 = """
open remrenC@1
add depend type=require fmri=pkg:/remrenA
close
"""
# But if there is something depending on the renamed package, it
# can't be removed.
"""If there are multiple renames, make sure we delete as much
as possible, but no more."""
A1 = """
open chained_A@1
close
"""
A2 = """
open chained_A@2
add set name=pkg.renamed value=true
add depend type=require fmri=pkg:/chained_B@2
close
"""
B2 = """
open chained_B@2
add set name=pkg.renamed value=true
add depend type=require fmri=pkg:/chained_C@2
close
"""
C2 = """
open chained_C@2
close
"""
X = """
open chained_X@1
add depend type=require fmri=pkg:/chained_A
close
"""
Y = """
open chained_Y@1
add depend type=require fmri=pkg:/chained_B
close
"""
Z = """
open chained_Z@1
close
"""
for p in ["chained_A@1", "chained_X@1"]:
for p in ["chained_A@2", "chained_X@1", "chained_B@2",
"chained_C@2", "chained_Z"]:
for p in ["chained_C@2", "chained_Z"]:
# make sure renamed pkgs no longer needed are uninstalled
for p in ["chained_A@2", "chained_B@2"]:
"""Ensure that the existence of an obsolete package version
does not prevent the system from upgrading to or installing
a resurrected version."""
pA_1 = """
open reintroA@1
close
"""
pA_2 = """
open reintroA@2
add set name=pkg.obsolete value=true
close
"""
pA_3 = """
open reintroA@3
close
"""
pB_1 = """
open reintroB@1
add depend type=require fmri=pkg:/reintroA@1
close
"""
pB_2 = """
open reintroB@2
close
"""
pB_3 = """
open reintroB@3
add depend type=require fmri=pkg:/reintroA@3
close
"""
pB_3))
# Check installation of an unobsoleted package with no
# dependencies.
# Testing reintroA@1 -> reintroA@3 with update
# Testing reintroA@1 -> reintroA@3 with install or
# exact-install.
# Testing empty image -> reintroA@3 with install or
# exact-install.
# Testing reintroA@1 -> reintroA@2 -> reintroA@3 with install
# or exact-install.
# Check installation of a package with an unobsoleted
# dependency.
# Testing reintroB@1 -> reintroB@3 with update
# Testing reintroB@1 -> reintroB@3 with install or
# exact-install
# Testing empty image -> reintroB@3 with install or
# exact-install
# Testing reintroB@1 -> reintroB@2 -> reintroB@3 with install
# or exact-install
"""We should be able to incorporate an obsolete package."""
p1_1 = """
open inc1p1@1
add depend type=incorporate fmri=inc1p2@1
close
"""
p2_1 = """
open inc1p2@1
add set name=pkg.obsolete value=true
close
"""
if install_cmd == "install":
else:
"""We should be able to continue incorporating a package when it
becomes obsolete on upgrade."""
p1_1 = """
open inc2p1@1
add depend type=incorporate fmri=inc2p2@1
close
"""
p1_2 = """
open inc2p1@2
add depend type=incorporate fmri=inc2p2@2
close
"""
p2_1 = """
open inc2p2@1
close
"""
p2_2 = """
open inc2p2@2
add set name=pkg.obsolete value=true
close
"""
bug_15713570 = """
open oldcompiler@1.0,5.11-0
add depend type=require fmri=oldperl@1.0
close
open oldperl@1.0,5.11-0
add depend type=require fmri=osnet-incorporation
close
open oldperl@2.0,5.11-0
add set name=pkg.obsolete value=true
close
open entire@1.0,5.11-0
add depend type=incorporate fmri=osnet-incorporation
add depend type=incorporate fmri=osnet-incorporation@1
add depend type=incorporate fmri=osnet-incorporation@1.0
close
open entire@2.1,5.11-0
add depend type=incorporate fmri=osnet-incorporation
add depend type=incorporate fmri=osnet-incorporation@1
add depend type=incorporate fmri=osnet-incorporation@1.1
close
open entire@2.2,5.11-0
add depend type=incorporate fmri=osnet-incorporation
add depend type=incorporate fmri=osnet-incorporation@1
add depend type=incorporate fmri=osnet-incorporation@1.2
close
open osnet-incorporation@1.0,5.11-0
add depend type=incorporate fmri=oldperl@1.0
close
open osnet-incorporation@1.1,5.11-0
add depend type=incorporate fmri=oldperl@2.0
close
open osnet-incorporation@1.2,5.11-0
add depend type=incorporate fmri=oldperl@2.0
close
"""
"""If an unincorporated package has its dependency obsoleted
by a doubly nested incorporation with multiple levels of
incorporation, there is no useful error message generated"""
"error message does not mention oldcompiler and oldperl packages")
"""Tests involving obsolete packages and multiple publishers."""
obs = """
open stem@1
add set name=pkg.obsolete value=true
close
"""
nonobs = """
open stem@1
close
"""
"""If an obsolete package is found in a preferred publisher and
a non-obsolete package of the same name is found in a
non-preferred publisher, pick the preferred pub as usual """
# We should choose the obsolete package, which means nothing
# gets installed.
"""Same as test_01, but now we have ambiguity in the package
names. While at first blush we might follow the same rule as in
test_01 (choose the preferred publisher), in this case, we can't
figure out which package from the preferred publisher we want,
so the choice already isn't as straightforward, so we choose the
non-obsolete package."""
lobs = """
add set name=pkg.obsolete value=true
close
"""
"""Tests involving incorporations and multiple publishers."""
incorporated_latest = """
open vim@7.4.233-5.12.0.0.0.44.1
close
open vim@7.4.232-5.12.0.0.0.44.1
close"""
incorporated = """
open vim@7.4.1-5.12.0.0.0.45.0
close
open vim@7.4.1-5.12.0.0.0.44.1
close """
incorporates = """
open userland-incorporation@0.5.12-5.12.0.0.0.44.1
add depend type=incorporate fmri=vim@7.4-5.12.0.0.0.44.1
close
open vim-incorporation@0.5.12-5.12.0.0.0.44.1
add depend type=incorporate fmri=vim@7.4.1-5.12.0.0.0.44.1
close"""
"""Ensure that if the newest release version of a package is
available for an older branch that incorporate dependencies work
as expected."""
# First, install two incorporations that intersect such that
# only the version before the latest branch can be installed.
# Then, attempt to install vim; this should succeed even though
# the newest version available is for an older branch.
"""Ensure that if another publisher offers newer packages that
satisfy an incorporate dependency, but are rejected because of
publisher selection, that the preferred publisher's package can
still satisfy the incorporate."""
# First, install the incorporation.
# Next, add the second publisher.
# Next, verify that first publisher's incorporated package can
# be installed since it satisfies incorporate dependencies even
# though second publisher's versions will be rejected.
"""Tests involving one or more packages that require license acceptance
or display."""
maxDiff = None
# Tests in this suite use the read only data directory.
baz10 = """
open baz@1.0,5.11-0
add license copyright.baz license=copyright.baz
close """
# First iteration has just a copyright.
licensed10 = """
open licensed@1.0,5.11-0
add depend type=require fmri=baz@1.0
add license copyright.licensed license=copyright.licensed
close """
# Second iteration has copyright that must-display and a new license
# that doesn't require acceptance.
licensed12 = """
open licensed@1.2,5.11-0
add depend type=require fmri=baz@1.0
add license copyright.licensed license=copyright.licensed must-display=True
add license license.licensed license=license.licensed
close """
# Third iteration now requires acceptance of license.
licensed13 = """
open licensed@1.3,5.11-0
add depend type=require fmri=baz@1.0
add license copyright.licensed license=copyright.licensed must-display=True
add license license.licensed license=license.licensed must-accept=True
close """
"license.licensed", "license.licensed.addendum"]
# Packages with copyright in non-ascii character
nonascii10 = """
open nonascii@1.0,5.11-0
add license 88591enc.copyright license=copyright
close """
# Packages with copyright in non-ascii character
utf8enc10 = """
open utf8enc@1.0,5.11-0
add license utf8enc.copyright license=copyright
close """
# Packages with copyright in unsupported character set
unsupported10 = """
open unsupported@1.0,5.11-0
add license unsupported.copyright license=copyright
close """
# Use license with latin1 i.e 88591 encoding
"88591enc.copyright")
# Use utf-8 encoding license
"utf8enc.copyright")
# Use unsupported license
"unsupported.copyright")
"""Verifies that install and update handle license
acceptance and display."""
# First, test the basic install case to see if a license that
# does not require viewing or acceptance will be installed.
]])
# Verify that --licenses include the license in output.
"grep 'license.licensed'")
# Verify that licenses that require display are included in
# -n output even if --licenses is not provided.
# Next, check that an upgrade succeeds when a license requires
# display and that the license will be displayed.
[],
# Next, check that an update fails if the user has not
# specified --accept and a license requires acceptance.
# Check that asking for parsable output doesn't change this
# requirement.
# Verify that licenses are not included in -n output if
# --licenses is not provided.
# Verify that --licenses include the license in output.
"grep 'license.licensed'")
# Next, check that an update succeeds if the user has
# specified --accept and a license requires acceptance.
"""Verifies that install with --parsable handles licenses
with non-ascii & non UTF locale"""
"""This set of tests is intended to verify that the client will handle
image state and action errors gracefully during install or uninstall
operations. Unlike the client API version of these tests, the CLI only
needs to be tested for failure cases since it uses the client API."""
# Teardown the test root every time.
dir10 = """
open dir@1.0,5.11-0
add dir path=dir mode=755 owner=root group=bin
close """
dir11 = """
open dir@1.1,5.11-0
add dir path=dir mode=750 owner=root group=bin
close """
# Purposefully omits depend on dir@1.0.
filesub10 = """
open filesub@1.0,5.11-0
close """
filesub11 = """
open filesub@1.1,5.11-0
close """
# Dependency providing file intentionally omitted.
hardlink10 = """
open hardlink@1.0,5.11-0
add hardlink path=hardlink target=file
close """
# Empty packages suitable for corruption testing.
foo10 = """
open foo@1.0,5.11-0
close """
unsupp10 = """
open unsupported@1.0
add depend type=require fmri=foo@1.0
close """
for p in plist:
f.write("\n")
f.close()
"""Verify that directory install fails as expected when it has
been replaced with a link prior to install."""
# The dest_dir's installed path.
dest_dir_name = "dir"
# Directory replaced with a link (fails for install).
"""Verify that file install works as expected when its parent
directory has been replaced with a link."""
# File's parent directory replaced with a link.
"""Verify that hardlink install fails as expected when
hardlink target is missing."""
# Hard link target is missing (failure expected).
# Publish a package and then add some unsupported action data
# to the repository's copy of the manifest and catalog.
if unsupp_content is None:
# No manipulation required.
return
mcontent = None
# Update the catalog signature.
# Update the catalog actions.
# Write out the new catalog.
"""Verify that packages with invalid or unsupported actions are
handled gracefully.
"""
# Base package needed for tests.
# Verify that a package with unsupported content doesn't cause
# a problem.
newact = "depend type=new-type fmri=foo@1.1"
# Now create a new image and verify that pkg install will fail
# for the unsupported package, but succeed for the supported
# one.
# Verify that a package with invalid content behaves the same.
newact = "depend notvalid"
# Now verify that if a newer version of the unsupported package
# is found that is supported, it can be installed.
"""Verify that if a directory or file is replaced with a link
that targets itself (resulting in ELOOP) pkg fails gracefully.
"""
# Create an image and install a package delivering a file.
# Now replace the file with a link that points to itself.
else:
# Verify that pkg verify gracefully fails if traversing a
# link targeting itself.
# Verify that pkg succeeds if attempting to update a
# package containing a file replaced with a link loop.
# Now remove the package delivering the file and replace the
# directory with a link loop.
# Verify that pkg verify gracefully fails if traversing a
# link targeting itself.
# Verify that pkg gracefully fails if attempting to update
# a package containing a directory replace with a link loop.
"""This set of tests verifies that packages which deliver conflicting
actions into the same name in a namespace cannot be installed
simultaneously."""
pkg_boring10 = """
open boring@1.0,5.11-0
close """
pkg_dupfiles = """
open dupfiles@0,5.11-0
close
"""
pkg_dupfilesp1 = """
open dupfilesp1@0,5.11-0
close
"""
pkg_dupfilesp2 = """
open dupfilesp2@0,5.11-0
close
"""
pkg_dupfilesp2v2 = """
open dupfilesp2@2,5.11-0
close
"""
pkg_dupfilesp3 = """
open dupfilesp3@0,5.11-0
close
"""
pkg_dupfilesp4 = """
open dupfilesp4@0,5.11-0
close
"""
pkg_dupotherfilesp1 = """
open dupotherfilesp1@0,5.11-0
close
"""
pkg_dupotherfilesp2 = """
open dupotherfilesp2@0,5.11-0
close
"""
pkg_dupotherfilesp2v2 = """
open dupotherfilesp2@2,5.11-0
close
"""
pkg_dupotherfilesp3 = """
open dupotherfilesp3@0,5.11-0
close
"""
pkg_identicalfiles = """
open identicalfiles@0,5.11-0
close
"""
pkg_overlaid = """
open overlaid@0,5.11-0
add dir path=etc mode=0755 owner=root group=root
close
open overlaid@1,5.11-0
add dir path=etc mode=0755 owner=root group=root
close
open overlaid@2,5.11-0
add dir path=etc mode=0755 owner=root group=root
close
open overlaid@3,5.11-0
add set name=pkg.renamed value=true
add depend type=require fmri=overlaid-renamed@3
add depend type=exclude fmri=overlaid-renamed@4
close
open overlaid-renamed@3,5.11-0
add depend type=optional fmri=overlaid@3
add dir path=etc mode=0755 owner=root group=root
add file tmp/file3 original_name=overlaid:etc/pam.conf path=etc/pam.conf mode=644 owner=root group=sys preserve=renamenew overlay=allow
close
open overlaid-renamed@4.0,5.11-0
add depend type=optional fmri=overlaid@3
add dir path=etc mode=0755 owner=root group=root
add file tmp/file4 original_name=overlaid:etc/pam.conf path=etc/pam/pam.conf mode=644 owner=root group=sys preserve=renamenew
close
open overlaid-renamed@4.1,5.11-0
add depend type=optional fmri=overlaid@3
add dir path=etc mode=0755 owner=root group=root
add file tmp/file4 original_name=overlaid:etc/pam.conf path=etc/pam/pam.conf mode=644 owner=root group=sys preserve=renamenew overlay=allow
close
"""
# 'overlay' is ignored unless 'preserve' is also set.
pkg_invalid_overlaid = """
open invalid-overlaid@0,5.11-0
close
"""
pkg_overlayer = """
open overlayer@0,5.11-0
close
"""
pkg_overlayer_move = """
open overlayer-move@0,5.11-0
close
open overlayer-move@1,5.11-0
add file tmp/file3 path=etc/pam/pam.conf mode=644 owner=root group=sys preserve=true overlay=true original_name=overlayer-move:etc/pam.conf
close
"""
pkg_overlayer_update = """
open overlayer-update@0,5.11-0
close
open overlayer-update@1,5.11-0
close
open overlayer-update@2,5.11-0
close
open overlayer-update@3,5.11-0
close
"""
pkg_multi_overlayer = """
open multi-overlayer@0,5.11-0
close
"""
# overlaying file is treated as conflicting file if its mode, owner, and
# group attributes don't match the action being overlaid
pkg_mismatch_overlayer = """
open mismatch-overlayer@0,5.11-0
close
"""
# overlaying file is treated as conflicting file if it doesn't set overlay=true
# even if file being overlaid allows overlay.
pkg_invalid_overlayer = """
open invalid-overlayer@0,5.11-0
close
"""
open unpreserved-overlayer@0,5.11-0
add file tmp/unpreserved path=etc/pam.conf mode=644 owner=root group=sys overlay=true
close
"""
pkgremote_pkg1 = """
open pkg1@0,5.11-0
close
"""
pkgremote_pkg2 = """
open pkg2@0,5.11-0
close
"""
pkg_dupfilesv1 = """
open dupfilesv1@0,5.11-0
add set name=variant.arch value=sparc value=i386
close
"""
pkg_dupfilesv2 = """
open dupfilesv2@0,5.11-0
close
"""
pkg_dupfilesv3 = """
open dupfilesv3@0,5.11-0
add set name=variant.arch value=sparc value=i386
close
"""
pkg_dupfilesv4 = """
open dupfilesv4@0,5.11-0
add set name=variant.arch value=sparc value=i386
close
"""
pkg_dupfilesv5 = """
open dupfilesv5@0,5.11-0
add set name=variant.opensolaris.zone value=global value=nonglobal
add file tmp/file1 path=dir/pathname mode=0777 owner=root group=bin variant.opensolaris.zone=nonglobal
close
"""
pkg_dupfilesv6 = """
open dupfilesv6@0,5.11-0
close
"""
pkg_dupfilesf1 = """
open dupfilesf1@0,5.11-0
close
"""
pkg_dupfilesf2 = """
open dupfilesf2@0,5.11-0
close
"""
pkg_dupfilesf3 = """
open dupfilesf3@0,5.11-0
close
"""
pkg_dupfilesf4 = """
open dupfilesf4@0,5.11-0
close
"""
pkg_duppathfilelink = """
open duppath-filelink@0,5.11-0
close
"""
pkg_duplink = """
open duplink@0,5.11-0
close
"""
pkg_dupmultitypes1 = """
open dupmultitypes@1,5.11-0
add dir path=multitypepath mode=0755 owner=root group=bin
close
"""
pkg_dupmultitypes2 = """
open dupmultitypes@2,5.11-0
add dir path=multitypepath mode=0755 owner=root group=bin
close
"""
pkg_dupmultitypes3_0 = """
open dupmultitypes3@0,5.11-0
add link path=multitypepath target=blah
add link path=multitypepath target=blah
close
"""
pkg_dupmultitypes3_1 = """
open dupmultitypes3@1,5.11-0
add dir path=multitypepath mode=0755 owner=root group=bin
add dir path=multitypepath mode=0755 owner=root group=bin
close
"""
open duppath-nonidenticallinks@0,5.11-0
close
"""
open duppath-nonidenticallinksp1@0,5.11-0
close
"""
open duppath-nonidenticallinksp2@0,5.11-0
close
"""
open duppath-nonidenticallinksp2@1,5.11-0
close
"""
open duppath-nonidenticaldirs@0,5.11-0
close
"""
open duppath-almostidenticaldirs@0,5.11-0
close
"""
pkg_implicitdirs = """
open implicitdirs@0,5.11-0
close
"""
pkg_implicitdirs2 = """
open implicitdirs2@0,5.11-0
close
"""
pkg_implicitdirs3 = """
open implicitdirs3@0,5.11-0
close
"""
pkg_implicitdirs4 = """
open implicitdirs4@0,5.11-0
"""
pkg_implicitdirs5 = """
open implicitdirs5@0,5.11-0
"""
pkg_implicitdirs6 = """
open implicitdirs6@0,5.11-0
"""
pkg_implicitdirs7 = """
open implicitdirs7@0,5.11-0
"""
pkg_dupdir = """
open dupdir@0,5.11-0
close
"""
pkg_dupdirv1 = """
open dupdir@1,5.11-0
close
"""
pkg_dupdirnowhere = """
open dupdirnowhere@0,5.11-0
close
"""
pkg_dupdirp1 = """
open dupdirp1@1,5.11-0
add dir path=dir owner=root group=bin mode=0755
close
"""
pkg_dupdirp2 = """
open dupdirp2@1,5.11-0
add dir path=dir owner=root group=sys mode=0755
close
"""
pkg_dupdirp2_2 = """
open dupdirp2@2,5.11-0
add dir path=dir owner=root group=bin mode=0755
close
"""
pkg_dupdirp3 = """
open dupdirp3@1,5.11-0
add dir path=dir owner=root group=bin mode=0750
close
"""
pkg_dupdirp4 = """
open dupdirp4@1,5.11-0
add dir path=dir owner=root group=sys mode=0750
close
"""
pkg_dupdirp5 = """
open dupdirp5@1,5.11-0
add dir path=dir owner=root group=other mode=0755
close
"""
pkg_dupdirp6 = """
open dupdirp6@1,5.11-0
add dir path=dir owner=root group=other mode=0755
close
"""
pkg_dupdirp7 = """
open dupdirp7@1,5.11-0
close
"""
pkg_dupdirp8 = """
open dupdirp8@1,5.11-0
add dir path=dir owner=root group=bin mode=0755
close
"""
pkg_dupdirp8_2 = """
open dupdirp8@2,5.11-0
add dir path=dir owner=root group=sys mode=0755
close
"""
pkg_dupdirp9 = """
open dupdirp9@1,5.11-0
add dir path=var owner=root group=other mode=0755
add dir path=usr owner=root group=other mode=0755
close
"""
pkg_dupdirp10 = """
open dupdirp10@1,5.11-0
add dir path=var owner=root group=bin mode=0755
add dir path=usr owner=root group=bin mode=0755
close
"""
pkg_dupdirp11 = """
open dupdirp11@1,5.11-0
close
"""
pkg_dupdirp12 = """
open dupdirp12@1,5.11-0
add legacy pkg=dupdirp9
close
"""
pkg_userdb = """
open userdb@0,5.11-0
close
"""
userdb_files = {
daemon:x:1:1::/:
sys:x:3:3::/:
""",
root::0:
other::1:root
bin::2:root,daemon
sys::3:root,bin,adm
adm::4:root,daemon
""",
root:9EIfTNBp9elws:13817::::::
daemon:NP:6445::::::
bin:NP:6445::::::
sys:NP:6445::::::
adm:NP:6445::::::
""",
root
bin
sys
adm
"""
}
pkg_dupuser = """
open dupuser@0,5.11-0
add user username=kermit group=adm gcos-field="kermit 1"
add user username=kermit group=adm gcos-field="kermit 2"
close
"""
pkg_dupuserp1 = """
open dupuserp1@0,5.11-0
add user username=kermit group=adm gcos-field="kermit 1"
close
"""
pkg_dupuserp2 = """
open dupuserp2@0,5.11-0
add user username=kermit group=adm gcos-field="kermit 2"
close
"""
pkg_dupuserp2v2 = """
open dupuserp2@1,5.11-0
close
"""
pkg_dupuserp3 = """
open dupuserp3@0,5.11-0
add user username=kermit group=adm gcos-field="kermit 2"
close
"""
pkg_dupuserp4 = """
open dupuserp4@0,5.11-0
add user username=kermit group=adm gcos-field="kermit 4"
close
"""
pkg_otheruser = """
open otheruser@0,5.11-0
close
"""
pkg_othergroup = """
open othergroup@0,5.11-0
add group groupname=fozzie gid=87
add group groupname=fozzie gid=88
add group groupname=fozzie gid=89
close
"""
pkg_othergroup1 = """
open othergroup@1,5.11-0
add group groupname=fozzie gid=87
close
"""
pkg_conflictgroup1 = """
open conflictgroup1@0,5.11
add user group=fozzie uid=20 username=fozzie
add group groupname=fozzie gid=200
close
"""
pkg_conflictgroup2 = """
open conflictgroup2@0,5.11
add user group=fozzie uid=21 username=fozzie
add group groupname=fozzie gid=201
close
"""
pkg_driverdb = """
open driverdb@0,5.11-0
add file tmp/devlink.tab path=etc/devlink.tab mode=0644 owner=root group=bin
add file tmp/driver_aliases path=etc/driver_aliases mode=0644 owner=root group=bin
add file tmp/driver_classes path=etc/driver_classes mode=0644 owner=root group=bin
add file tmp/minor_perm path=etc/minor_perm mode=0644 owner=root group=bin
add file tmp/name_to_major path=etc/name_to_major mode=0644 owner=root group=bin
add file tmp/device_policy path=etc/security/device_policy mode=0644 owner=root group=bin
add file tmp/extra_privs path=etc/security/extra_privs mode=0644 owner=root group=bin
close
"""
driverdb_files = {
"tmp/devlink.tab": "",
"tmp/driver_aliases": "",
"tmp/driver_classes": "",
"tmp/minor_perm": "",
"tmp/name_to_major": "",
"tmp/device_policy": "",
"tmp/extra_privs": ""
}
pkg_dupdrv = """
open dupdriver@0,5.11-0
add driver name=asy perms="* 0666 root sys" perms="*,cu 0600 uucp uucp"
add driver name=asy perms="* 0666 root sys" alias=pci11c1,480
close
"""
pkg_dupdepend1 = """
open dupdepend1@0,5.11-0
add depend type=require fmri=dupfilesp1
add depend type=require fmri=dupfilesp1
close
"""
pkg_dupdepend2 = """
open dupdepend2@0,5.11-0
add depend type=require fmri=dupfilesp1
add depend type=incorporate fmri=dupfilesp1
close
"""
pkg_dupdepend3 = """
open dupdepend3@0,5.11-0
add depend type=require fmri=dupfilesp1@0-0
add depend type=require fmri=dupfilesp1@0-0
close
"""
pkg_dupdepend4 = """
open dupdepend4@0,5.11-0
add depend type=require fmri=dupfilesp1@0-0
add depend type=incorporate fmri=dupfilesp1@0-0
close
"""
pkg_tripledupfilea = """
open tripledupfilea@0,5.11-0
add set name=variant.foo value=one
close
"""
pkg_tripledupfileb = """
open tripledupfileb@0,5.11-0
add set name=variant.foo value=one value=two
close
"""
pkg_tripledupfilec = """
open tripledupfilec@0,5.11-0
add set name=variant.foo value=one value=two
close
"""
pkg_variantedtypes = """
open vpath@0,5.11-0
add set name=variant.foo value=one value=two
variant.foo=two
close
"""
"tmp/unpreserved"]
# Keep the depots around for the duration of the entire class
pkgs = []
for i in range(20):
s = """
open massivedupdir{0:d}@0,5.11-0
add dir path=usr owner=root group={{0}} mode={{1}} zig={{2}}
close
""".format(i)
if i == 14:
elif i in (1, 9):
elif i in (3, 8, 12, 17):
else:
"""Test conflict group IDs will not cause user action failure.
"""
if "fozzie" in line:
break
if "fozzie" in line:
break
if "fozzie" in line:
break
if "fozzie" in line:
break
"""Test the behavior of pkg(1) when multiple file actions
deliver to the same pathname."""
# Duplicate files in the same package
# Duplicate files in different packages, but in the same
# transaction
# Duplicate files in different packages, in different
# transactions
# Test that being in a duplicate file situation doesn't break
# you completely and allows you to add and remove other packages
# If the packages involved get upgraded but leave the actions
# themselves alone, we should be okay.
# Test that removing one of two offending actions reverts the
# system to a clean state.
# You should be able to upgrade to a fixed set of packages in
# order to move past the problem, too.
# If we upgrade to a version of a conflicting package that no
# longer has the conflict, but at the same time introduce a new
# file action at the path with different contents, we should
# fail.
# Removing one of more than two offending actions can't do much
# of anything, but should leave the system alone.
"dupfilesp1 dupfilesp2@0 dupfilesp3")
# Verify should report a duplicate action error on dupfilesp1,
# dupfilesp2 and dupfilesp3 and shouldn't report it was failing
# due to hashes being wrong.
if l.startswith("pkg://test/dupfilesp1"):
index = i
# Removing dupfilesp3, verify should still report a duplicate
# action error on dupfilesp1 and dupfilesp2.
# Removing all but one of the offending actions should get us
# back to sanity.
"dupfilesp1 dupfilesp2@0 dupfilesp3")
# Make sure we handle cleaning up multiple files properly.
"dupfilesp1 dupfilesp2@0 dupotherfilesp1 dupotherfilesp2")
# Re-use the overlay packages for some preserve testing.
"invalid-overlayer")
# We may have been able to lay down the package, but because the
# file is marked preserve=true, we didn't actually overwrite
# Make sure we get rid of all implicit directories.
# Make sure identical actions don't cause problems
# Trigger a bug similar to 17943 via duplicate files.
"dupfilesp1@0 dupfilesp2@0 dupfilesp3@0 dupotherfilesp1@0 "
"dupotherfilesp2@0 dupotherfilesp3@0")
# If an uninstall causes a fixup to happen and we can't because
# we lost the cached files and the repo is down, make sure we
# fail before actually uninstalling anything.
"""Test the behaviour of pkg(1) when actions for editable files
overlay other actions."""
# Ensure that overlay is allowed for file actions when one
# action has specified preserve attribute and overlay=allow,
# and *one* (only) other action has specified overlay=true
# (preserve does not have to be set).
# Ensure boring package is installed as conflict checking is
# bypassed (and thus, overlay semantics) if all packages are
# removed from an image.
# Should fail because one action specified overlay=allow,
# but not preserve (it isn't editable).
# Should fail because one action is overlayable but overlaying
# action doesn't declare its intent to overlay.
# Should fail because one action is overlayable but overlaying
# action mode, owner, and group attributes don't match.
# Should succeed because one action is overlayable and
# overlaying action declares its intent to overlay.
)
# Should fail because multiple actions are not allowed to
# overlay a single action.
# Should succeed even though file is different than originally
# delivered since original package permits file modification.
# Should succeed because package delivering overlayable file
# permits modification and because package delivering overlay
# file permits modification.
# Verify that the file isn't touched on uninstall of the
# overlaying package if package being overlaid is still
# installed.
# Verify that removing the last package delivering an overlaid
# file removes the file.
)
# Verify that installing both packages at the same time results
# in only the overlaying file being delivered.
)
# Verify that the file isn't touched on uninstall of the
# overlaid package if overlaying package is still installed.
# Re-install overlaid package and verify that file content
# does not change.
)
# Should succeed because one action is overlayable and
# overlaying action declares its intent to overlay even
# though the overlaying action isn't marked with preserve.
)
# Should succeed because overlaid action permits modification
# and contents matches overlaying action.
# Should succeed even though file has been modified since
# overlaid action permits modification.
# Should fail because overlaying action does not permit
# modification.
# Should revert to content delivered by overlaying action.
# Should revert to content delivered by overlaying action.
# Should revert to content delivered by overlaid action.
# Install overlaying package, then update overlaid package and
# verify that file content does not change if only preserve
# attribute changes.
)
# Now update overlaid package again, and verify that file
# content does not change even though overlaid content has.
# Now update overlaid package again this time as part of a
# rename, and verify that file content does not change even
# though file has moved between packages.
# Verify that unpreserved overlay is not salvaged when both
# overlaid and overlaying package are removed at the same time.
# (Preserved files are salvaged if they have been modified on
# uninstall.)
# Ensure directory is empty before testing.
# Verify etc directory not found after uninstall.
"unpreserved-overlayer")
)
salvaged = [
if n.startswith("etc")
]
# Next, update overlaid package again this time as part of a
# file move. Verify that the configuration file exists at both
# the new location and the old location, that the content has
# not changed in either, and that the new configuration exists
# as expected as ".new".
"unpreserved-overlayer")
)
installed=['etc/pam/pam.conf.new'],
)
# file has not been changed.
"unpreserved-overlayer")
)
salvaged = [
if n.startswith("pam.conf")
]
# Next, repeat the same set of tests performed above for renames
# and moves with an overlaying, preserved file.
#
# Install overlaying package, then update overlaid package and
# verify that file content does not change if only preserve
# attribute changes.
)
# Now update overlaid package again, and verify that file
# content does not change even though overlaid content has.
# Now update overlaid package again this time as part of a
# rename, and verify that file content does not change even
# though file has moved between packages.
# Verify that preserved overlay is salvaged when both overlaid
# and overlaying package are removed at the same time.
# (Preserved files are salvaged if they have been modified on
# uninstall.)
# Ensure directory is empty before testing.
# Verify etc directory found after uninstall.
)
salvaged = [
if n.startswith("etc")
]
# Next, update overlaid package again, this time as part of a
# file move where the overlay attribute was dropped. Verify
# that the configuration file exists at both the new location
# and the old location, that the content has not changed in
# either, and that the new configuration exists as expected as
# ".new".
)
installed=['etc/pam/pam.conf.new'],
)
)
# Next, update overlaid package again, this time as part of a
# file move. Verify that the configuration file exists at both
# the new location and the old location, that the content has
# not changed in either, and that the new configuration exists
# as expected as ".new".
)
installed=['etc/pam/pam.conf.new'],
)
# Next, downgrade the package and verify that if an overlaid
# file moves back to its original location, the content of the
# overlay file will not change.
)
# Now upgrade again for remaining tests.
installed=['etc/pam/pam.conf.new'],
)
# uninstall as overlay file and overlaid file is different from
# packaged.
)
if n.startswith("pam")
)
# Should have three entries; one should be 'pam' directory
# (presumably containing pam.conf-X...), another a file starting
# with 'pam.conf', and finally a 'pam-XXX' directory containing
# the 'pam.conf.new-XXX'.
# Next, install overlaid package and overlaying package, then
# upgrade each to a version where the file has changed
# locations and verify that the content remains intact.
)
"overlayer-move@1")
)
# Next, downgrade overlaid-renamed and overlaying package to
# versions where the file is restored to its original location
# and verify that the content is reverted to the original
# overlay version since this is a downgrade.
"overlayer-move@0")
)
)
# Next, install overlaid package and overlaying package and
# verify preserve acts as expected for overlay package as it is
# updated.
)
# unpreserved -> preserved
)
# preserved -> renameold
)
# renameold -> renamenew
installed=['etc/pam.conf.new'],
)
"""Test the behavior of pkg(1) when multiple actions of
different types deliver to the same pathname."""
# In the same package
# In different packages, in the same transaction
# In different packages, in different transactions
# Does removal of one of the busted packages get us out of the
# situation?
# Implicit directory conflicts with a file
# Implicit directory coincides with a delivered directory
# Make sure that we don't die trying to fixup a directory using
# an implicit directory action.
"implicitdirs7")
# XXX We don't currently fix up anything beneath a directory
# that was restored, so we have to do it by hand.
# Removing one of more than two offending actions can't do much
# of anything, but should leave the system alone.
"dupfilesp1 duplink dupdir@0")
tmap = {
}
# XXX The checks here rely on verify failing due to action types
# not matching what's on the system; they should probably report
# duplicate actions instead. Checking the output text is a bit
# ugly, too, but we do need to make sure that the two problems
# become one.
verify_type_re = "File Type: '(.*?)' should be '(.*?)'"
# We make sure that what got reported is correct -- two actions
# of different types in conflict with whatever actually got laid
# down.
# Now we uninstall one of the packages delivering a type which
# isn't what's on the filesystem. The filesystem should remain
# unchanged, but one of the errors should go away.
if whatis == "directory":
else:
# Now we do the same thing, but we uninstall the package
# delivering the type which *is* what's on the filesystem. This
# should also leave the filesystem alone, even though what's
# there will match *neither* of the remaining installed
# packages.
"dupfilesp1 duplink dupdir@0")
if whatis == "directory":
elif whatis == "symbolic link":
elif whatis == "regular file":
# Go from multiple conflicting types down to just one type.
# This also tests the case where a package version being newly
# installed gets fixed at the same time.
"dupmultitypes@1")
# Upgrading from multiple instances of one refcounted type to
# multiple instances of another (here, link to directory) should
# succeed.
"""Test the behavior of pkg(1) when multiple non-file actions of
the same type deliver to the same pathname, but whose other
attributes differ."""
# One package, two links with different targets
# One package, two directories with different perms
# One package, two dirs with same modes expressed two ways
# One package delivers a directory explicitly, another
# implicitly.
# Make sure that we don't die trying to fixup a directory using
# an implicit directory action.
"implicitdirs4 implicitdirs5 implicitdirs6")
# Make sure that we don't die trying to fixup a directory using
# an implicit directory action when that's all that's left.
"implicitdirs4 implicitdirs5 implicitdirs6")
# If two packages deliver conflicting directories and another
# package delivers that directory implicitly, make sure the
# third package isn't blamed.
exit=1)
# Two packages, two links with different targets, installed at
# once
# Two packages, two links with different targets, installed
# separately
# If we get into a broken state, can we get out of it?
"duppath-nonidenticallinksp1 duppath-nonidenticallinksp2@0")
# If we get into a broken state, can we make it a little bit
# better by uninstalling one of the packages? Removing dupdir5
# here won't reduce the number of different groups under which
# dir is delivered, but does reduce the number of actions
# delivering it.
"dupdirp1 dupdirp2@1 dupdirp5 dupdirp6")
"dupdirp5")
# Make sure we can install a package delivering an implicit
# directory that's currently in conflict.
# And make sure we can uninstall it again.
# Removing the remaining conflicts in a couple of steps should
# result in a verifiable system.
# Add everything back in, remove everything but one variant of
# the directory and an implicit directory, and verify.
"dupdirp2@1 dupdirp5 dupdirp6 dupdirp7")
# Get us into a saner state by upgrading.
"dupdirp2@1 dupdirp5 dupdirp6")
# Get us into a sane state by upgrading.
"dupdirp2@1")
# We start in a sane state, but the update would result in
# conflict, though no more actions deliver the path in
# question.
# How about removing one of the conflicting packages? We'll
# remove the package which doesn't match the state on disk.
"duppath-nonidenticallinksp1 duppath-nonidenticallinksp2@0")
else:
# Now we'll try removing the package which *does* match the
# state on disk. The code should clean up after us.
"duppath-nonidenticallinksp1 duppath-nonidenticallinksp2@0")
else:
# Let's try a duplicate directory delivered with all sorts of
# crazy conflicts!
# Trigger bug 17943: we install packages with conflicts in two
# directories (p9, p10). We also install a package (p11) which
# delivers those directories implicitly. Then remove the last,
# triggering the stack trace associated with the bug.
"dupdirp9 dupdirp10 dupdirp11")
# Do the same, but with a package that delivers var implicitly
# via a legacy action.
"dupdirp12")
"""Test the behavior of pkg(1) when multiple non-file actions of
the same type deliver to the same pathname, but differ in their
variants or facets."""
install_cmd = "install"
# Two packages delivering the same directory, one under the
# current architecture, the other not tagged with an arch
# variant.
# Two packages delivering the same directory with different
# attributes -- one under the current architecture, the other
# tagged with another arch variant.
else:
# Two packages delivering a file at the same path where one is
# tagged only for non-global zones should install successfully
# together in a global zone.
try:
except OSError as e:
else:
raise
f.close()
# Two packages delivering the same directory, one with the
# devel facet false, the other true.
# Two packages delivering the same directory, one with the
# devel facet true, the other without.
# Two packages delivering the same directory, one with the
# devel facet false, the other without.
"""Test the behaviour of pkg(1) when attempting to remove
conflicting packages from a publisher which has also been
removed."""
# Dummy publisher so test publisher can be removed.
# If packages with conflicting actions are found during
# uninstall, and the publisher of the package has been
# removed, uninstall should still succeed.
"""Test the behavior of pkg(1) when changing a variant or a
facet would cause the new image to contain conflicting
actions."""
# Create the image as an x86 image, as the first test only works
# changing variant from x86 to sparc.
# The x86 variant is safe, but the sparc variant has two files
# with the same pathname.
# With the devel facet turned off, the package is safe, but
# turning it on would cause a duplicate file to be added.
"""Test that a change-variant that removes a package and
improves but doesn't fix a conflicting action situation is
allowed."""
"tripledupfilec")
"tripledupfilea")
"""Test the behavior of pkg(1) when multiple user actions
deliver the same user."""
# This is largely identical to test_multiple_files; we may want
# to commonize in the future.
# Duplicate users in the same package
# Duplicate users in different packages, but in the same
# transaction
# Duplicate users in different packages, in different
# transactions
# Test that being in a duplicate user situation doesn't break
# you completely and allows you to add and remove other packages
"dupuserp2@0")
# If the packages involved get upgraded but leave the actions
# themselves alone, we should be okay.
# Test that removing one of two offending actions reverts the
# system to a clean state.
# You should be able to upgrade to a fixed set of packages in
# order to move past the problem, too.
"dupuserp2@0")
# If we upgrade to a version of a conflicting package that no
# longer has the conflict, but at the same time introduce a new
# conflicting user action, we should fail.
"dupuserp2@0")
# Removing one of more than two offending actions can't do much
# of anything, but should leave the system alone.
"dupuserp1 dupuserp2@0 dupuserp3")
# Removing all but one of the offending actions should get us
# back to sanity.
"dupuserp1 dupuserp2@0 dupuserp3")
# Make sure we don't get confused when two actions in different
# namespace groups but with the same key attribute value are
# adjacent in the action cache.
"otheruser othergroup@0")
"""Test the behavior of pkg(1) when multiple driver actions
deliver the same driver."""
"""Test to make sure we can have multiple depend actions on
(more or less) the same fmri"""
# Two identical unversioned require dependencies
# Two dependencies of different types on an identical
# unversioned fmri
# Two identical versioned require dependencies
# Two dependencies of different types on an identical versioned
# fmri
"""Test that actions which would otherwise conflict but are
delivered under different variants don't conflict."""
additional_args="--variant foo=one")
"""Test pkg.depend.explicit-install action behaviors."""
pkgs = (
"""
open group@1.0,5.11-0
add depend type=group fmri=pkg:/A
close """,
"""
open incorp@1.0,5.11-0
add depend type=incorporate fmri=pkg:/A@1.0,5.11-0.1
close """,
"""
open A@1.0,5.11-0.1
close """,
"""
open A@1.0,5.11-0.1.1.0
add depend type=require fmri=pkg:/idr@1.0,5.11-0.1.1.0
close """,
"""
open idr@1.0,5.11-0.1.1.0
add set name=pkg.depend.explicit-install value=true
add depend type=incorporate fmri=pkg:/A@1.0,5.11-0.1.1.0
close """,
)
pkgs2 = (
"""
open A@1.0,5.11-0.1.1.1
add depend type=require fmri=pkg:/idr@1.0,5.11-0.1.1.1
close """,
"""
open idr@1.0,5.11-0.1.1.1
add set name=pkg.depend.explicit-install value=false
add depend type=incorporate fmri=pkg:/A@1.0,5.11-0.1.1.1
close """,
)
pkgs3 = (
"""
open A@1.0,5.11-0.1.1.2
add depend type=require fmri=pkg:/idr@1.0,5.11-0.1.1.2
close """,
"""
open idr@1.0,5.11-0.1.1.2
add depend type=incorporate fmri=pkg:/A@1.0,5.11-0.1.1.2
close """,
)
pkgs4 = (
"""
open C1@1.0
add depend type=require-any fmri=pkg:/C2@1.0 fmri=pkg:/C2@2.0
close """,
"""
open C2@1.0
add depend type=require fmri=pkg:/C3@1.0,5.11-0.1
close """,
"""
open C2@2.0
add set name=pkg.depend.explicit-install value=true
add depend type=require fmri=pkg:/C3@1.0,5.11-0.1
close """,
"""
open C3@1.0,5.11-0.1
close """,
)
pkgs5 = (
"""
open Hiera1@1.0
add depend type=require fmri=pkg:/Hiera2@1.0
close """,
"""
open Hiera2@1.0
add depend type=require fmri=pkg:/Hiera3@1.0
close """,
"""
open Hiera3@1.0
add set name=pkg.depend.explicit-install value=true
close """,
)
# Test install works as expected.
# This will fail because idr@1.0-0.1.1.0 has
# pkg.depend.explicit-install set to true.
expected = \
"A 1.0-0.1 i--\n" \
"group 1.0-0 i--\n" \
"incorp 1.0-0 i--\n"
# Test exact-install works as expected.
# This will fail because idr@1.0-0.1.1.0 has
# pkg.depend.explicit-install set to true.
# Test exact-install idr.
expected = \
"idr 1.0-0.1.1.0 i--\n"
expected = \
"A 1.0-0.1.1.0 i--\n" \
"group 1.0-0 i--\n" \
"idr 1.0-0.1.1.0 i--\n"
expected = \
"idr 1.0-0.1.1.0 i--\n"
expected = \
"A 1.0-0.1.1.0 i--\n" \
"group 1.0-0 i--\n" \
"idr 1.0-0.1.1.0 i--\n"
expected = \
"A 1.0-0.1.1.1 i--\n" \
"group 1.0-0 i--\n" \
"idr 1.0-0.1.1.1 i--\n" \
"incorp 1.0-0 i--\n"
# test updating all packages.
expected = \
"A 1.0-0.1.1.2 i--\n" \
"group 1.0-0 i--\n" \
"idr 1.0-0.1.1.2 i--\n" \
"incorp 1.0-0 i--\n"
# test require-any with pkg.depend.explicit-install tag.
expected = \
"C1 1.0 i--\n" \
"C2 1.0 i--\n" \
"C3 1.0-0.1 i--\n"
expected = \
"C1 1.0 i--\n" \
"C2 2.0 i--\n" \
"C3 1.0-0.1 i--\n"
# Test hierarchic dependencies.
expected = \
"A 1.0-0.1 i--\n" \
"group 1.0-0 i--\n" \
"incorp 1.0-0 i--\n"
expected = \
"A 1.0-0.1 i--\n" \
"group 1.0-0 i--\n"
# This will fail, because idr@1.0-0.1.1.0 is filtered.
# Explicitly install idr@1.0-0.1.1.0.
# Update again.
expected = \
"A 1.0-0.1.1.0 i--\n" \
"idr 1.0-0.1.1.0 i--\n"
# This will fail.
expected = \
"A 1.0-0.1.1.2 i--\n" \
"idr 1.0-0.1.1.2 i--\n"
pkgs = (
"""
open entire@5.12-5.12.0.0.0.96.0
add set name=pkg.depend.install-hold value=core-os
add depend fmri=consolidation/osnet/osnet-incorporation type=require
add depend fmri=consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.96.1 facet.version-lock.consolidation/osnet/osnet-incorporation=true type=incorporate
add depend fmri=consolidation/osnet/osnet-incorporation@5.12-5.12.0 type=incorporate
add depend fmri=consolidation/install/install-incorporation type=require
add depend fmri=consolidation/install/install-incorporation@5.12-5.12.0.0.0.4.0 facet.version-lock.consolidation/install/install-incorporation=true type=incorporate
close
"""
"""
open consolidation/install/install-incorporation@5.12-5.12.0.0.0.4.0
add depend fmri=consolidation/osnet/osnet-incorporation type=require
close
"""
"""
open consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.96.1
add set name=pkg.depend.install-hold value=core-os.osnet
add depend fmri=pkg:/system/data/terminfo/terminfo-core@5.12,5.12-5.12.0.0.0.96.1 type=incorporate
close
"""
"""
open system/data/terminfo/terminfo-core@5.12-5.12.0.0.0.96.1
add depend fmri=consolidation/osnet/osnet-incorporation type=require
close
"""
)
nightly_pkgs = (
"""
open consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.97.32830
add set name=pkg.depend.install-hold value=core-os.osnet
add depend fmri=pkg:/system/data/terminfo/terminfo-core@5.12-5.12.0.0.0.95.32487 type=incorporate
close
"""
"""
open consolidation/install/install-incorporation@5.12-5.12.0.0.0.4.0
add depend fmri=consolidation/osnet/osnet-incorporation type=require
close
"""
"""
open system/data/terminfo/terminfo-core@5.12-5.12.0.0.0.95.32487
add depend fmri=consolidation/osnet/osnet-incorporation type=require
close
"""
)
"""Verify that incorporated packages not affected by install-holds
will be downgraded if the incorporating package is requested by
the user or will be updated as part of a general update
operation."""
)
# In this case, we expect osnet-incorporation to be upgraded and
# terminfo-core to be downgraded; install-incorporation should
# not be modified since it was not named on the command-line.
]
)
# In this case, we expect osnet-incorporation and
# install-incorporation to be upgraded, and terminfo-core to be
# downgraded.
]
)
pkgs = (
"""
open A@1.0,5.11-0
close """,
"""
open A@2.0,5.11-0
close """,
"""
open B@1.0,5.11-0
add set pkg.depend.install-hold=B
close """,
"""
open B@2.0,5.11-0
add set pkg.depend.install-hold=B
close """,
"""
open C@1.0,5.11-0
add set pkg.depend.install-hold=parent.C
close """,
"""
open C@2.0,5.11-0
add set pkg.depend.install-hold=parent.C
close """,
"""
open incorp@1.0,5.11-0
add depend type=incorporate fmri=A@2.0
close """,
"""
open incorp@2.0,5.11-0
add depend type=incorporate fmri=A@1.0
close """,
"""
open parent_incorp@1.0,5.11-0
add depend type=incorporate fmri=child_incorp@2.0
close """,
"""
open parent_incorp@2.0,5.11-0
add depend type=incorporate fmri=child_incorp@1.0
close """,
"""
open child_incorp@1.0,5.11-0
add depend type=incorporate fmri=A@1.0
close """,
"""
open child_incorp@2.0,5.11-0
add depend type=incorporate fmri=A@2.0
close """,
"""
open ihold_incorp@1.0,5.11-0
add set pkg.depend.install-hold=parent
add depend type=incorporate fmri=B@1.0
add depend type=incorporate fmri=C@1.0
close """,
"""
open ihold_incorp@2.0,5.11-0
add set pkg.depend.install-hold=parent
add depend type=incorporate fmri=B@2.0
add depend type=incorporate fmri=C@2.0
close """,
"""
open p_incorp@1.0,5.11-0
add depend type=incorporate fmri=D@2.0
close """,
"""
open p_incorp@2.0,5.11-0
add depend type=incorporate fmri=D@1.0
close """,
"""
open D@2.0,5.11-0
close """,
)
pub2_pkgs = (
"""
open D@1.0,5.11-0
close """,
)
""" Test that downgrades are allowed if they are incorporated
by FMRIs which are requested by the user or are about to be
updated as part of an update-all operation."""
# When incorp moves forward, A should move backwards
# start over and test if that also works if we do an update all
# prepare test for nested incorporations
# test update of nested incorporation supports downgrade
# prepare test for explicit downgrade of incorp
# test explicit downgrade of incorp downgrades incorp'ed pkgs
"""Test correct handling of install-holds when determining
which pkgs are ok to downgrade."""
# prepare test for install-hold
# test that install hold prevents downgrade
# prep test for parent install-hold
# test that downgrade is allowed if install-hold is child of
# requested FMRI
"""Test that implicit publisher switches of incorporated pkgs
are not allowed."""
# prepare test for publisher switch
if __name__ == "__main__":