4883 import failure for non-sunos platforms due to missing pspawn
4265 test_actuators test case fails on Solaris 10
4266 client.py assumes ZFS snapshot is created in fix_image
4267 driver actions run by test_suite on Linux
4272 t_unix_usergrp test fails on Mac OS
5077 MacOS/Linux: Image.update_install_pkgs fails with errno.ENOTEMPTY
5459 history purge unit test fails on Windows
5058 set-authority for new authority fails on Windows
5563 su_wrap feature of CLI tests doesn't pass LD_LIBRARY_PATH
5566 build fails on Windows if PRIVATE_BUILD not set
5567 t_pkg_info missing closing quote
5568 test cases fail because noaccess account doesn't exist on Linux
5570 tests fail because build makes scripts executable by user only
5576 no perms unit test fails on Linux due to uncaught exception
5607 several test cases have ordering problem with group file
--- a/src/client.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/client.py Fri Jan 23 16:04:18 2009 -0600
@@ -362,7 +362,9 @@
# Create a snapshot in case they want to roll back
try:
be = bootenv.BootEnv(img.get_root())
- msg(_("Created ZFS snapshot: %s" % be.snapshot_name))
+ if be.exists():
+ msg(_("Created ZFS snapshot: %s" %
+ be.snapshot_name))
except RuntimeError:
pass # Error is printed by the BootEnv call.
success = img.repair(repairs, progresstracker)
--- a/src/modules/client/bootenv.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/modules/client/bootenv.py Fri Jan 23 16:04:18 2009 -0600
@@ -61,6 +61,7 @@
self.be_name_clone = None
self.clone_dir = None
self.is_live_BE = False
+ self.is_valid = False
self.snapshot_name = None
self.root = root
rc = 0
@@ -130,6 +131,7 @@
emsg(_("pkg: unable to create an auto "
"snapshot. pkg recovery is disabled."))
raise RuntimeError, "recoveryDisabled"
+ self.is_valid = True
break
else:
@@ -137,6 +139,12 @@
# if were are on UFS.
raise RuntimeError, "recoveryDisabled"
+ def exists(self):
+
+ """Return true if this object represents a valid BE."""
+
+ return self.is_valid
+
def init_image_recovery(self, img, be_name=None):
"""Initialize for an image-update.
@@ -347,6 +355,9 @@
def __init__(self, root):
pass
+ def exists(self):
+ return False
+
def init_image_recovery(self, img, be_name=None):
pass
--- a/src/modules/client/history.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/modules/client/history.py Fri Jan 23 16:04:18 2009 -0600
@@ -552,7 +552,7 @@
except KeyboardInterrupt:
raise
except EnvironmentError, e:
- if e.errno == errno.ENOENT:
+ if e.errno in (errno.ENOENT, errno.ESRCH):
# History already purged; record as successful.
self.operation_result = RESULT_SUCCEEDED
return
--- a/src/modules/client/image.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/modules/client/image.py Fri Jan 23 16:04:18 2009 -0600
@@ -1146,17 +1146,29 @@
# populate it. The easy test is to try to remove the directory,
# which will fail if it's already got entries in it, or doesn't
# exist. Other errors are beyond our capability to handle.
+ statedir = os.path.join(self.imgdir, "state", "installed")
try:
- os.rmdir("%s/state/installed" % self.imgdir)
+ os.rmdir(statedir)
except EnvironmentError, e:
- if e.errno == errno.EEXIST:
+ if e.errno in (errno.EEXIST, errno.ENOTEMPTY):
return
elif e.errno == errno.EACCES:
+ # The directory may exist and be non-empty
+ # even though we got EACCES. Try
+ # to determine its emptiness another way.
+ try:
+ if os.path.isdir(statedir) and \
+ len(os.listdir(statedir)) > 0:
+ return
+ except EnvironmentError:
+ # ignore this error, pass on the original
+ # access error
+ pass
raise api_errors.PermissionsException(e.filename)
elif e.errno != errno.ENOENT:
raise
- tmpdir = "%s/state/installed.build" % self.imgdir
+ tmpdir = os.path.join(self.imgdir, "state", "installed.build")
# Create the link forest in a temporary directory. We should
# only execute this method once (if ever) in the lifetime of an
@@ -1166,32 +1178,34 @@
try:
os.makedirs(tmpdir)
except OSError, e:
+ if e.errno == errno.EACCES:
+ raise api_errors.PermissionsException(e.filename)
if e.errno != errno.EEXIST or \
not os.path.isdir(tmpdir):
raise
return
- proot = "%s/pkg" % self.imgdir
+ proot = os.path.join(self.imgdir, "pkg")
for pd, vd in (
(p, v)
for p in sorted(os.listdir(proot))
- for v in sorted(os.listdir("%s/%s" % (proot, p)))
+ for v in sorted(os.listdir(os.path.join(proot, p)))
):
- path = "%s/%s/%s/installed" % (proot, pd, vd)
+ path = os.path.join(proot, pd, vd, "installed")
if not os.path.exists(path):
continue
fmristr = urllib.unquote("%s@%s" % (pd, vd))
auth = self.installed_file_authority(path)
f = pkg.fmri.PkgFmri(fmristr, authority = auth)
- fi = file("%s/%s" % (tmpdir, f.get_link_path()), "w")
+ fi = file(os.path.join(tmpdir, f.get_link_path()), "w")
fi.close()
# Someone may have already created this directory. Junk the
# directory we just populated if that's the case.
try:
- portable.rename(tmpdir, "%s/state/installed" % self.imgdir)
+ portable.rename(tmpdir, statedir)
except EnvironmentError, e:
if e.errno != errno.EEXIST:
raise
@@ -1562,7 +1576,7 @@
shutil.rmtree("%s/catalog/%s" %
(self.imgdir, auth_name))
except OSError, e:
- if e.errno != errno.ENOENT:
+ if e.errno not in (errno.ENOENT, errno.ESRCH):
raise
def fmri_is_same_pkg(self, cfmri, pfmri):
--- a/src/modules/pkgsubprocess.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/modules/pkgsubprocess.py Fri Jan 23 16:04:18 2009 -0600
@@ -28,10 +28,13 @@
import os
import types
import subprocess
-import pkg.pspawn
import pkg.portable
-from pkg.pspawn import posix_spawnp
-from pkg.pspawn import SpawnFileAction
+try:
+ import pkg.pspawn
+ from pkg.pspawn import posix_spawnp
+ from pkg.pspawn import SpawnFileAction
+except ImportError:
+ pass
__all__ = ["Popen", "PIPE", "STDOUT", "call"]
@@ -52,7 +55,7 @@
env, universal_newlines, startupinfo, creationflags)
- if pkg.portable.osname == "sunos":
+ if "pkg.pspawn" in globals():
def _execute_child(self, args, executable, preexec_fn,
close_fds, cwd, env, universal_newlines, startupinfo,
--- a/src/setup.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/setup.py Fri Jan 23 16:04:18 2009 -0600
@@ -339,10 +339,9 @@
# installation directory.
private_build = os.getenv("PRIVATE_BUILD", None)
- # It's OK to have /'s here, python figures it out when writing files
if private_build is None:
self.install_lib = py_install_dir
- self.install_data = "/"
+ self.install_data = os.path.sep
self.root = root_dir
else:
self.install_lib = os.path.join(root_dir, py_install_dir)
@@ -373,7 +372,8 @@
file_util.copy_file(srcname, dst_path, update = True)
# make scripts executable
os.chmod(dst_path,
- os.stat(dst_path).st_mode | stat.S_IEXEC)
+ os.stat(dst_path).st_mode
+ | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
install_sw(CP, CPVER, CPARC, CPDIR, CPURL, CPIDIR)
install_sw(PO, POVER, POARC, PODIR, POURL, POIDIR)
--- a/src/tests/api/t_unix_usergrp.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/api/t_unix_usergrp.py Fri Jan 23 16:04:18 2009 -0600
@@ -79,11 +79,10 @@
# This should work on unix systems, since we'll "bootstrap"
# out to the OS's version. And AFAIK all unix systems have
- # a "root" group.
+ # a group with gid 0.
+ grpname = portable.get_name_by_gid(0, self.tempdir, True)
self.assert_(0 == \
- portable.get_group_by_name("root", self.tempdir, True))
- self.assert_("root" == \
- portable.get_name_by_gid(0, self.tempdir, True))
+ portable.get_group_by_name(grpname, self.tempdir, True))
def testGroup3(self):
""" Test with corrupt/oddball group file """
--- a/src/tests/cli/t_actuators.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_actuators.py Fri Jan 23 16:04:18 2009 -0600
@@ -164,14 +164,14 @@
empty_data = ""
svcprop_data = \
-"""#!/usr/bin/sh
+"""#!/bin/sh
cat $PKG_TEST_DIR/$PKG_SVCPROP_OUTPUT
exit $PKG_SVCPROP_EXIT_CODE
"""
svcadm_data = \
-"""#!/usr/bin/sh
+"""#!/bin/sh
echo $0 "$@" >> $PKG_TEST_DIR/svcadm_arguments
-exit $(PKG_SVCADM_EXIT_CODE)
+exit $PKG_SVCADM_EXIT_CODE
"""
--- a/src/tests/cli/t_api_info.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_api_info.py Fri Jan 23 16:04:18 2009 -0600
@@ -57,7 +57,7 @@
pkg1 = """
open [email protected],5.11-0
add dir mode=0755 owner=root group=bin path=/bin
- add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video
+ add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video"
close
"""
--- a/src/tests/cli/t_pkg_authority.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_pkg_authority.py Fri Jan 23 16:04:18 2009 -0600
@@ -167,22 +167,22 @@
self.image_create(durl, prefix=pfx)
self.pkg("set-authority --no-refresh -O http://%s1 test1" %
- self.bogus_url, su_wrap="noaccess", exit=1)
+ self.bogus_url, su_wrap=True, exit=1)
self.pkg("set-authority --no-refresh -O http://%s1 foo" %
self.bogus_url)
self.pkg("authority | grep foo")
self.pkg("set-authority -P --no-refresh -O http://%s2 test2" %
- self.bogus_url, su_wrap="noaccess", exit=1)
- self.pkg("unset-authority foo", su_wrap="noaccess", exit=1)
+ self.bogus_url, su_wrap=True, exit=1)
+ self.pkg("unset-authority foo", su_wrap=True, exit=1)
self.pkg("unset-authority foo")
self.pkg("set-authority -m http://%s1 mtest" % self.bogus_url, \
- su_wrap="noaccess", exit=1)
+ su_wrap=True, exit=1)
self.pkg("set-authority -m http://%s2 mtest" %
self.bogus_url)
self.pkg("set-authority -M http://%s2 mtest" %
- self.bogus_url, su_wrap="noaccess", exit=1)
+ self.bogus_url, su_wrap=True, exit=1)
self.pkg("set-authority -M http://%s2 mtest" %
self.bogus_url)
--- a/src/tests/cli/t_pkg_depotd.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_pkg_depotd.py Fri Jan 23 16:04:18 2009 -0600
@@ -250,6 +250,7 @@
self.__dc.start()
def testBadArgs(self):
+ self.__dc.set_port(12000)
self.__dc.set_readonly()
self.__dc.set_rebuild()
self.__dc.set_norefresh_index()
--- a/src/tests/cli/t_pkg_info.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_pkg_info.py Fri Jan 23 16:04:18 2009 -0600
@@ -131,7 +131,7 @@
pkg1 = """
open [email protected],5.11-0
add dir mode=0755 owner=root group=bin path=/bin
- add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video
+ add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video"
close
"""
--- a/src/tests/cli/t_pkg_install.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_pkg_install.py Fri Jan 23 16:04:18 2009 -0600
@@ -32,6 +32,7 @@
import time
import unittest
import shutil
+import pkg.portable as portable
from stat import *
class TestPkgInstallBasics(testutils.SingleDepotTestCase):
@@ -1069,14 +1070,18 @@
add file """ + self.testdata_dir + """/ftpusers mode=0644 owner=root group=sys path=etc/ftpd/ftpusers preserve=true
add file """ + self.testdata_dir + """/empty mode=0644 owner=root group=sys path=etc/name_to_major preserve=true
add file """ + self.testdata_dir + """/empty mode=0644 owner=root group=sys path=etc/driver_aliases preserve=true
- add dir mode=0755 owner=root group=bin path=/lib
- add dir mode=0755 owner=root group=sys path=/etc
- add dir mode=0755 owner=root group=sys path=/etc/ftpd
- add dir mode=0755 owner=root group=sys path=/var
- add dir mode=0755 owner=root group=sys path=/var/svc
- add dir mode=0755 owner=root group=sys path=/var/svc/manifest
- add dir mode=0755 owner=root group=bin path=/usr
- add dir mode=0755 owner=root group=bin path=/usr/local
+ add dir mode=0755 owner=root group=sys path=etc
+ add dir mode=0755 owner=root group=sys path=etc/ftpd
+ close """
+
+ self.basics1 = """
+ open [email protected],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=sys path=var/svc
+ add dir mode=0755 owner=root group=sys path=var/svc/manifest
+ add dir mode=0755 owner=root group=bin path=usr
+ add dir mode=0755 owner=root group=bin path=usr/local
close """
self.grouptest = """
@@ -1119,12 +1124,14 @@
open [email protected],5.11-0
add file """ + self.testdata_dir + """/empty mode=0755 owner=root group=root path=/usr/local/bin/silver
add depend fmri=pkg:/[email protected] type=require
+ add depend fmri=pkg:/[email protected] type=require
close """
self.silver20 = """
open [email protected],5.11-0
add file """ + self.testdata_dir + """/empty mode=0755 owner=Kermit group=Kermit path=/usr/local/bin/silver
add user username=Kermit group=Kermit home-dir=/export/home/Kermit group-list=lp group-list=staff
add depend fmri=pkg:/[email protected] type=require
+ add depend fmri=pkg:/[email protected] type=require
add depend fmri=pkg:/[email protected] type=require
close """
@@ -1177,25 +1184,29 @@
durl = self.dc.get_depot_url()
self.pkgsend_bulk(durl, self.basics0)
+ self.pkgsend_bulk(durl, self.basics1)
self.image_create(durl)
self.pkg("list -a")
self.pkg("list", exit=1)
self.pkg("install basics")
+ self.pkg("install basics1")
self.pkg("list")
self.pkg("verify")
- self.pkg("uninstall basics")
+ self.pkg("uninstall basics basics1")
self.pkg("verify")
def test_grouptest(self):
durl = self.dc.get_depot_url()
self.pkgsend_bulk(durl, self.basics0)
+ self.pkgsend_bulk(durl, self.basics1)
self.pkgsend_bulk(durl, self.grouptest)
self.image_create(durl)
self.pkg("install basics")
+ self.pkg("install basics1")
self.pkg("install grouptest")
self.pkg("verify")
@@ -1205,10 +1216,12 @@
def test_usertest(self):
durl = self.dc.get_depot_url()
self.pkgsend_bulk(durl, self.basics0)
+ self.pkgsend_bulk(durl, self.basics1)
self.pkgsend_bulk(durl, self.grouptest)
self.pkgsend_bulk(durl, self.usertest10)
self.image_create(durl)
self.pkg("install basics")
+ self.pkg("install basics1")
self.pkg("install usertest")
self.pkg("verify")
@@ -1262,10 +1275,13 @@
in IPS development)."""
durl = self.dc.get_depot_url()
self.pkgsend_bulk(durl, self.basics0)
+ self.pkgsend_bulk(durl, self.basics1)
self.pkgsend_bulk(durl, self.silver10)
self.pkgsend_bulk(durl, self.silver20)
self.pkgsend_bulk(durl, self.grouptest)
self.image_create(durl)
+ self.pkg("install [email protected]")
+ self.pkg("install [email protected]")
self.pkg("install [email protected]")
self.pkg("list [email protected]")
self.pkg("verify -v")
@@ -1316,6 +1332,10 @@
self.pkgsend(durl, "close -A")
def test_devlink(self):
+ # driver actions are not valid except on OpenSolaris
+ if portable.util.get_canonical_os_name() != "sunos":
+ return
+
durl = self.dc.get_depot_url()
self.pkgsend_bulk(durl, self.devicebase)
self.pkgsend_bulk(durl, self.devlink10)
@@ -1443,14 +1463,19 @@
durl = self.dc.get_depot_url()
pkg_list = [self.foo10, self.only_attr10, self.only_depend10,
- self.only_directory10, self.only_driver10, self.only_file10,
+ self.only_directory10, self.only_file10,
self.only_group10, self.only_hardlink10, self.only_legacy10,
self.only_license10, self.only_link10, self.only_user10]
+
+ # driver actions are not valid except on OpenSolaris
+ if portable.util.get_canonical_os_name() == 'sunos':
+ pkg_list += [self.only_driver10]
for p in pkg_list:
self.pkgsend_bulk(durl, p)
self.pkgsend_bulk(durl, self.devicebase)
self.pkgsend_bulk(durl, self.basics0)
+ self.pkgsend_bulk(durl, self.basics1)
self.image_create(durl)
@@ -1480,11 +1505,11 @@
pname = name_mat.group(1)
__manually_check_deps(pname)
self.pkg("install --no-refresh %s" % pname,
- su_wrap="noaccess", exit=1)
- self.pkg("install %s" % pname, su_wrap="noaccess",
+ su_wrap=True, exit=1)
+ self.pkg("install %s" % pname, su_wrap=True,
exit=1)
self.pkg("install --no-refresh %s" % pname)
- self.pkg("uninstall %s" % pname, su_wrap="noaccess",
+ self.pkg("uninstall %s" % pname, su_wrap=True,
exit=1)
self.pkg("uninstall %s" % pname)
__manually_check_deps(pname, install=False)
@@ -1499,12 +1524,13 @@
self.pkgsend_bulk(durl, p)
self.pkgsend_bulk(durl, self.devicebase)
self.pkgsend_bulk(durl, self.basics0)
+ self.pkgsend_bulk(durl, self.basics1)
- self.pkg("image-update --no-refresh", su_wrap="noaccess")
- self.pkg("image-update", su_wrap="noaccess", exit=1)
- self.pkg("refresh", su_wrap="noaccess", exit=1)
+ self.pkg("image-update --no-refresh", su_wrap=True)
+ self.pkg("image-update", su_wrap=True, exit=1)
+ self.pkg("refresh", su_wrap=True, exit=1)
self.pkg("refresh")
- self.pkg("image-update --no-refresh", su_wrap="noaccess",
+ self.pkg("image-update --no-refresh", su_wrap=True,
exit=1)
self.pkg("image-update")
--- a/src/tests/cli/t_pkg_property.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_pkg_property.py Fri Jan 23 16:04:18 2009 -0600
@@ -68,9 +68,9 @@
self.image_create(durl)
self.pkg("property")
- self.pkg("set-property require-optional True", su_wrap="noaccess", exit=1)
+ self.pkg("set-property require-optional True", su_wrap=True, exit=1)
self.pkg("set-property require-optional True")
- self.pkg("unset-property require-optional", su_wrap="noaccess", exit=1)
+ self.pkg("unset-property require-optional", su_wrap=True, exit=1)
self.pkg("unset-property require-optional")
def test_bug_4372(self):
--- a/src/tests/cli/t_pkg_rebuild_index.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/t_pkg_rebuild_index.py Fri Jan 23 16:04:18 2009 -0600
@@ -50,7 +50,7 @@
durl = self.dc.get_depot_url()
self.image_create(durl)
self.pkg("rebuild-index")
- self.pkg("rebuild-index", exit=1, su_wrap="noaccess")
+ self.pkg("rebuild-index", exit=1, su_wrap=True)
if __name__ == "__main__":
--- a/src/tests/cli/testutils.py Fri Jan 23 14:02:08 2009 +0000
+++ b/src/tests/cli/testutils.py Fri Jan 23 16:04:18 2009 -0600
@@ -31,6 +31,10 @@
import errno
import platform
import tempfile
+try:
+ import pwd
+except ImportError:
+ pass
# Set the path so that modules above can be found
path_to_parent = os.path.join(os.path.dirname(__file__), "..")
@@ -159,6 +163,15 @@
str += botdivider
return str
+def get_su_wrap_user():
+ for u in ["noaccess", "nobody"]:
+ try:
+ pwd.getpwnam(u)
+ return u
+ except (KeyError, NameError):
+ pass
+ raise RuntimeError("Unable to determine user for su.")
+
class DepotTracebackException(pkg5unittest.Pkg5TestCase.failureException):
def __init__(self, logfile, output):
Exception.__init__(self)
@@ -327,18 +340,19 @@
if su_wrap:
if su_wrap == True:
- su_wrap = "noaccess"
- su_wrap = "su %s -c '" % su_wrap
+ su_wrap = get_su_wrap_user()
+ su_wrap = "su %s -c 'LD_LIBRARY_PATH=%s " % \
+ (su_wrap, os.getenv("LD_LIBRARY_PATH", ""))
su_end = "'"
else:
su_wrap = ""
su_end = ""
if prefix:
- cmdline = "%s;%s%s %s/usr/bin/pkg %s" % (prefix,
- su_wrap, wrapper, g_proto_area, command)
+ cmdline = "%s;%s%s %s/usr/bin/pkg %s%s" % (prefix,
+ su_wrap, wrapper, g_proto_area, command, su_end)
else:
- cmdline = "%s%s %s/usr/bin/pkg %s" % (su_wrap, wrapper,
- g_proto_area, command)
+ cmdline = "%s%s %s/usr/bin/pkg %s%s" % (su_wrap, wrapper,
+ g_proto_area, command, su_end)
self.debugcmd(cmdline)
p = subprocess.Popen(cmdline, shell = True,