2349 import of 86 fails on kernel/drv/sd.conf
2839 driver actions should support devlinks
--- a/src/man/pkg.5.txt Mon Oct 13 15:46:42 2008 -0500
+++ b/src/man/pkg.5.txt Mon Oct 13 22:45:17 2008 -0700
@@ -181,6 +181,12 @@
privs This specifies privileges used by the driver. There may
be more than one privs attribute for any given driver.
+ devlink This specifies an entry in /etc/devlink.tab. The value
+ is the exact line to go into the file, with tabs denoted
+ by "\t". See devlinks(1M) for more information. There
+ may be more than one devlink attribute for any given
+ driver.
+
Depend actions
The 'depend' action represents an inter-package dependency. A package
may depend on another package because the first requires functionality
--- a/src/modules/actions/driver.py Mon Oct 13 15:46:42 2008 -0500
+++ b/src/modules/actions/driver.py Mon Oct 13 22:45:17 2008 -0700
@@ -33,6 +33,7 @@
import os
import subprocess
+from tempfile import mkstemp
import generic
@@ -154,6 +155,25 @@
self.__call(args, "driver (%(name)s) clone permission "
"update", {"name": self.attrs["name"]})
+ if "devlink" in self.attrs:
+ dlp = os.path.normpath(os.path.join(
+ image.get_root(), "etc/devlink.tab"))
+ dlf = file(dlp)
+ dllines = dlf.readlines()
+ dlf.close()
+
+ dlt, dltp = mkstemp(suffix=".devlink.tab",
+ dir=image.get_root() + "/etc")
+ dlt = os.fdopen(dlt, "w")
+ dlt.writelines(dllines)
+ dlt.writelines((
+ s.replace("\\t", "\t") + "\n"
+ for s in self.attrlist("devlink")
+ if s.replace("\\t", "\t") + "\n" not in dllines
+ ))
+ dlt.close()
+ os.rename(dltp, dlp)
+
def __update_install(self, image, orig):
add_base = ( self.update_drv, "-b", image.get_root(), "-a" )
rem_base = ( self.update_drv, "-b", image.get_root(), "-d" )
@@ -243,6 +263,74 @@
print "tried to add %s and remove %s" % \
(add_class, rem_class)
+ # We have to update devlink.tab by hand, too.
+ def update_devlinks():
+ dlp = os.path.normpath(os.path.join(
+ image.get_root(), "etc/devlink.tab"))
+
+ try:
+ dlf = file(dlp)
+ lines = dlf.readlines()
+ dlf.close()
+ except IOError, e:
+ e.args += ("reading",)
+ raise
+
+ olines = set(orig.attrlist("devlink"))
+ nlines = set(self.attrlist("devlink"))
+ add_lines = nlines - olines
+ rem_lines = olines - nlines
+
+ missing_entries = []
+ for line in rem_lines:
+ try:
+ lineno = lines.index(line.replace("\\t", "\t") + "\n")
+ except ValueError:
+ missing_entries.append(line.replace("\\t", "\t"))
+ continue
+ del lines[lineno]
+
+ # Don't put in duplicates. Because there's no way to
+ # tell what driver owns what line, this means that if
+ # two drivers try to own the same line, one of them will
+ # be unhappy if the other is uninstalled. So don't do
+ # that.
+ lines.extend((
+ s.replace("\\t", "\t") + "\n"
+ for s in add_lines
+ if s.replace("\\t", "\t") + "\n" not in lines
+ ))
+
+ try:
+ dlt, dltp = mkstemp(suffix=".devlink.tab",
+ dir=image.get_root() + "/etc")
+ dlt = os.fdopen(dlt, "w")
+ dlt.writelines(lines)
+ dlt.close()
+ os.rename(dltp, dlp)
+ except IOError, e:
+ e.args += ("writing",)
+ raise
+
+ if missing_entries:
+ raise RuntimeError, missing_entries
+
+ if "devlink" in orig.attrs or "devlink" in self.attrs:
+ try:
+ update_devlinks()
+ except IOError, e:
+ print "%s (%s) upgrade (devlinks modification) " \
+ "failed %s etc/devlink.tab with error: " \
+ "%s (%s)" % (self.name, self.attrs["name"],
+ e[1], e[0], e[2])
+ except RuntimeError, e:
+ print "%s (%s) upgrade (devlinks modification) " \
+ "failed modifying\netc/devlink.tab. The " \
+ "following entries were to be removed, " \
+ "but were\nnot found:\n " % \
+ (self.name, self.attrs["name"]) + \
+ "\n ".join(e.args[0])
+
# For perms, we do removes first because of a busted starting
# point in build 79, where smbsrv has perms of both "* 666" and
# "* 640". The actions move us from 666 to 640, but if we add
@@ -595,6 +683,52 @@
self.__call(args, "driver (%(name)s) clone permission "
"update", {"name": self.attrs["name"]})
+ if "devlink" in self.attrs:
+ dlp = os.path.normpath(os.path.join(
+ image.get_root(), "etc/devlink.tab"))
+
+ try:
+ dlf = file(dlp)
+ lines = dlf.readlines()
+ dlf.close()
+ except IOError, e:
+ print "%s (%s) removal (devlinks modification) " \
+ "failed reading etc/devlink.tab with error: " \
+ "%s (%s)" % (self.name, self.attrs["name"],
+ e[0], e[1])
+ return
+
+ devlinks = self.attrlist("devlink")
+
+ missing_entries = []
+ for line in devlinks:
+ try:
+ lineno = lines.index(line.replace("\\t", "\t") + "\n")
+ except ValueError:
+ missing_entries.append(line.replace("\\t", "\t"))
+ continue
+ del lines[lineno]
+
+ if missing_entries:
+ print "%s (%s) removal (devlinks modification) " \
+ "failed modifying\netc/devlink.tab. The " \
+ "following entries were to be removed, " \
+ "but were\nnot found:\n " % \
+ (self.name, self.attrs["name"]) + \
+ "\n ".join(missing_entries)
+
+ try:
+ dlt, dltp = mkstemp(suffix=".devlink.tab",
+ dir=image.get_root() + "/etc")
+ dlt = os.fdopen(dlt, "w")
+ dlt.writelines(lines)
+ dlt.close()
+ os.rename(dltp, dlp)
+ except IOError, e:
+ print "%s (%s) removal (devlinks modification) " \
+ "failed writing etc/devlink.tab with error: " \
+ "%s (%s)" % (self.name, self.attrs["name"],
+ e[0], e[1])
def generate_indices(self):
ret = {}
--- a/src/tests/baseline.txt Mon Oct 13 15:46:42 2008 -0500
+++ b/src/tests/baseline.txt Mon Oct 13 22:45:17 2008 -0700
@@ -282,6 +282,7 @@
cli.t_pkg_install.py TestImageCreateCorruptImage.test_var_pkg_missing_pkg|pass
cli.t_pkg_install.py TestImageCreateCorruptImage.test_var_pkg_ospkg_missing_cfg_cache_alongside|pass
cli.t_pkg_install.py TestPkgInstallActions.test_basics_0|pass
+cli.t_pkg_install.py TestPkgInstallActions.test_devlink|pass
cli.t_pkg_install.py TestPkgInstallActions.test_grouptest|pass
cli.t_pkg_install.py TestPkgInstallActions.test_invalid_open|pass
cli.t_pkg_install.py TestPkgInstallActions.test_minugid|pass
--- a/src/tests/cli/t_pkg_install.py Mon Oct 13 15:46:42 2008 -0500
+++ b/src/tests/cli/t_pkg_install.py Mon Oct 13 22:45:17 2008 -0700
@@ -28,6 +28,7 @@
testutils.setup_environment("../../../proto")
import os
+import re
import time
import unittest
import shutil
@@ -952,6 +953,37 @@
add depend fmri=pkg:/[email protected] type=require
close """
+ self.devicebase = """
+ open [email protected],5.11-0
+ add dir mode=0755 owner=root group=root path=/tmp
+ add dir mode=0755 owner=root group=root path=/etc
+ add dir mode=0755 owner=root group=root path=/etc/security
+ add file """ + self.testdata_dir + """/empty mode=0600 owner=root group=root path=/etc/devlink.tab 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 file """ + self.testdata_dir + """/empty mode=0644 owner=root group=sys path=/etc/driver_classes preserve=true
+ add file """ + self.testdata_dir + """/empty mode=0644 owner=root group=sys path=/etc/minor_perm preserve=true
+ add file """ + self.testdata_dir + """/empty mode=0644 owner=root group=root path=/etc/security/device_policy preserve=true
+ add file """ + self.testdata_dir + """/empty mode=0644 owner=root group=sys path=/etc/security/extra_privs preserve=true
+ close
+ """
+
+ self.devlink10 = """
+ open [email protected],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
+ """
+
+ self.devlink20 = """
+ open [email protected],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
+ """
+
for f in self.misc_files:
filename = os.path.join(self.testdata_dir, f)
file_handle = open(filename, 'wb')
@@ -1108,6 +1140,129 @@
self.pkgsend(durl, "open '%s'" % valid_name)
self.pkgsend(durl, "close -A")
+ def test_devlink(self):
+ durl = self.dc.get_depot_url()
+ self.pkgsend_bulk(durl, self.devicebase)
+ self.pkgsend_bulk(durl, self.devlink10)
+ self.pkgsend_bulk(durl, self.devlink20)
+ self.image_create(durl)
+
+ def readfile():
+ dlf = file(os.path.join(self.get_img_path(),
+ "etc/devlink.tab"))
+ dllines = dlf.readlines()
+ dlf.close()
+ return dllines
+
+ def writefile(dllines):
+ dlf = file(os.path.join(self.get_img_path(),
+ "etc/devlink.tab"), "w")
+ dlf.writelines(dllines)
+ dlf.close()
+
+ def assertContents(dllines, contents):
+ actual = re.findall("name=([^\t;]*)",
+ "\n".join(dllines), re.M)
+ self.assert_(set(actual) == set(contents))
+
+ # Install
+ self.pkg("install [email protected]")
+ self.pkg("verify -v")
+
+ dllines = readfile()
+
+ # Verify that three entries got added
+ self.assert_(len(dllines) == 3)
+
+ # Verify that the tab character got written correctly
+ self.assert_(dllines[0].find("\t") > 0)
+
+ # Upgrade
+ self.pkg("install [email protected]")
+ self.pkg("verify -v")
+
+ dllines = readfile()
+
+ # Verify that there are four entries now
+ self.assert_(len(dllines) == 4)
+
+ # Verify they are what they should be
+ assertContents(dllines, ["zerg2", "zorg", "borg", "zork"])
+
+ # Remove
+ self.pkg("uninstall devlinktest")
+ self.pkg("verify -v")
+
+ # Install again
+ self.pkg("install [email protected]")
+
+ # Diddle with it
+ dllines = readfile()
+ for i, line in enumerate(dllines):
+ if line.find("zerg") != -1:
+ dllines[i] = "type=ddi_pseudo;name=zippy\t\D\n"
+ writefile(dllines)
+
+ # Upgrade
+ self.pkg("install [email protected]")
+
+ # Verify that we spewed a message on upgrade
+ self.assert_(self.output.find("not found") != -1)
+ self.assert_(self.output.find("name=zerg") != -1)
+
+ # Verify the new set
+ dllines = readfile()
+ self.assert_(len(dllines) == 5)
+ assertContents(dllines,
+ ["zerg2", "zorg", "borg", "zork", "zippy"])
+
+ self.pkg("uninstall devlinktest")
+
+ # Null out the "zippy" entry
+ writefile([])
+
+ # Install again
+ self.pkg("install [email protected]")
+
+ # Diddle with it
+ dllines = readfile()
+ for i, line in enumerate(dllines):
+ if line.find("zerg") != -1:
+ dllines[i] = "type=ddi_pseudo;name=zippy\t\D\n"
+ writefile(dllines)
+
+ # Remove
+ self.pkg("uninstall devlinktest")
+
+ # Verify that we spewed a message on removal
+ self.assert_(self.output.find("not found") != -1)
+ self.assert_(self.output.find("name=zerg") != -1)
+
+ # Verify that the one left behind was the one we overwrote.
+ dllines = readfile()
+ self.assert_(len(dllines) == 1)
+ assertContents(dllines, ["zippy"])
+
+ # Null out the "zippy" entry, but add the "zerg" entry
+ writefile(["type=ddi_pseudo;name=zerg\t\D\n"])
+
+ # Install ... again
+ self.pkg("install [email protected]")
+
+ # Make sure we didn't get a second zerg line
+ dllines = readfile()
+ self.failUnless(len(dllines) == 3, msg=dllines)
+ assertContents(dllines, ["zerg", "borg", "warg"])
+
+ # Now for the same test on upgrade
+ dllines.append("type=ddi_pseudo;name=zorg\t\D\n")
+ writefile(dllines)
+
+ self.pkg("install [email protected]")
+ dllines = readfile()
+ self.failUnless(len(dllines) == 4, msg=dllines)
+ assertContents(dllines, ["zerg2", "zorg", "borg", "zork"])
+
class TestDependencies(testutils.SingleDepotTestCase):
# Only start/stop the depot once (instead of for every test)
persistent_depot = True
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/SUNWfixes.prototype Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,46 @@
+i pkginfo=SUNWfixes.pkginfo
+f none boot/grub/splash.xpm.gz 0644 root sys
+e none boot/solaris/devicedb/master 0644 root sys
+e none etc/driver_aliases 0644 root sys
+e none etc/hba.conf 0644 root bin
+e none etc/ima.conf 0644 root bin
+e none etc/inet/hosts 0444 root sys
+e none etc/inet/services 0444 root sys
+e none etc/mpapi.conf 0644 root bin
+e none etc/name_to_major 0644 root sys
+e none etc/nsswitch.conf 0644 root sys
+e none etc/pam.conf 0644 root sys
+e none etc/passwd 0644 root sys
+e none etc/power.conf 0644 root sys
+e none etc/security/auth_attr 0644 root sys
+e none etc/security/exec_attr 0644 root sys
+e none etc/security/policy.conf 0644 root sys
+e none etc/security/prof_attr 0644 root sys
+e none etc/shadow 0400 root sys
+e none etc/user_attr 0644 root sys
+f none etc/zones/SUNWblank.xml 0444 root bin
+f none etc/zones/SUNWdefault.xml 0444 root bin
+e none kernel/drv/sd.conf 0644 root sys
+f none lib/svc/method/sshd 0555 root bin
+f none lib/svc/method/svc-coreadm 0555 root bin
+d none root 0700 root root
+e none root/.bashrc 0644 root root
+e none root/.profile 0644 root root
+f none usr/bin/ksh 0755 root bin
+l none usr/has/bin/ex=vi
+f none usr/has/bin/sh 0755 root root
+f none usr/has/bin/vi 0755 root bin
+l none usr/has/bin/view=vi
+f none usr/jdk/instances/jdk1.6.0/LICENSE 0644 root bin
+f none usr/jdk/instances/jdk1.6.0/README.html 0644 root bin
+f none usr/jdk/instances/jdk1.6.0/jre/LICENSE 0644 root bin
+f none usr/jdk/instances/jdk1.6.0/jre/README 0644 root bin
+f none usr/jdk/instances/jdk1.6.0/jre/lib/fontconfig.properties 0644 root bin
+f none usr/lib/vp-services 0555 root bin
+f none usr/lib/vp-shares 0555 root bin
+f none usr/share/applications/services.desktop 0644 root bin
+f none usr/share/applications/shares.desktop 0644 root bin
+f none usr/share/man/man.cf 0644 root bin
+f none var/svc/manifest/system/coreadm.xml 444 root sys
+f none var/svc/profile/generic_limited_net.xml 0444 root sys
+f none var/svc/profile/generic_open.xml 0444 root sys
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/common/SUNWcsd Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,11 @@
+package SUNWcsd
+import SUNWcsd
+drop etc/driver_aliases
+drop etc/name_to_major
+from ./SUNWfixes import
+etc/driver_aliases
+etc/name_to_major
+chattr etc/driver_aliases opensolaris.zone=global
+chattr etc/name_to_major opensolaris.zone=global
+end import
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/common/SUNWii Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,6 @@
+package SUNWii
+import SUNWiiu
+import SUNWiir
+add driver name=ii perms="* 0666 root sys" privs=sys_devices privs=sys_config \
+ devlink="type=ddi_pseudo;name=ii\t\D"
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/common/SUNWmms Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,6 @@
+package SUNWmms
+import SUNWmmsr
+import SUNWmmsu
+add driver name=dmd
+add driver name=dda devlink="type=ddi_pseudo;name=dda\tdda/\N0\M0"
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/common/SUNWrdc Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,6 @@
+package SUNWrdc
+import SUNWrdcu
+import SUNWrdcr
+add driver name=rdc perms="* 0666 root sys" privs=sys_devices privs=sys_config \
+ devlink="type=ddi_pseudo;name=rdc\t\D"
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/common/SUNWscm Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,12 @@
+package SUNWscm
+import SUNWscmu
+import SUNWscmr
+add driver name=nskern perms="* 0666 root sys" privs=sys_devices \
+ privs=sys_config devlink="type=ddi_pseudo;name=nskern\t\D"
+add driver name=ncall perms="* 0666 root sys" privs=sys_devices \
+ privs=sys_config devlink="type=ddi_pseudo;name=ncall\t\D"
+add driver name=nsctl perms="* 0666 root sys" privs=sys_devices \
+ privs=sys_config devlink="type=ddi_pseudo;name=nsctl\t\D"
+add driver name=sdbc perms="* 0666 root sys" privs=sys_devices \
+ privs=sys_config devlink="type=ddi_pseudo;name=sdbc\t\D"
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/common/SUNWsmbfskr Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,5 @@
+package SUNWsmbfskr
+import SUNWsmbfskr
+add driver name=nsmb perms="* 0666 root sys" \
+ devlink="type=ddi_pseudo;name=nsmb\t\D"
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/common/SUNWspsv Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,6 @@
+package SUNWspsv
+import SUNWspsvu
+import SUNWspsvr
+add driver name=sv perms="* 0666 root sys" privs=sys_devices privs=sys_config \
+ devlink="type=ddi_pseudo;name=sv\t\D"
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/i386/SUNWpcmci Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,7 @@
+package SUNWpcmci
+import SUNWpcmci
+add driver name=pcs
+add driver name=pcic class=pcmcia alias=pciclass,060500 alias=pciclass,060700
+add driver name=pem perms="* 0666 bin bin" \
+ devlink="type=pcmcia:event;name=pem\tpem"
+end package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/distro-import/100a/sparc/SUNWpcmci Mon Oct 13 22:45:17 2008 -0700
@@ -0,0 +1,8 @@
+package SUNWpcmci
+import SUNWpcmci
+add driver name=pcs
+add driver name=pcic class=pcmcia alias=pciclass,060500 alias=pciclass,060700
+add driver name=pem perms="* 0666 bin bin" \
+ devlink="type=pcmcia:event;name=pem\tpem"
+add driver name=stp4020 class=pcmcia alias=SUNW,pcmcia
+end package
--- a/src/util/distro-import/Makefile Mon Oct 13 15:46:42 2008 -0500
+++ b/src/util/distro-import/Makefile Mon Oct 13 22:45:17 2008 -0700
@@ -50,9 +50,8 @@
# we're doing this until the necessary actions are available. For now,
# cache as-installed versions.
#
-ELIDED_FILES= \
+ELIDED_FILES_BASE= \
boot/solaris/devicedb/master \
- etc/devlink.tab \
etc/hba.conf \
etc/ima.conf \
etc/inet/services \
@@ -60,8 +59,22 @@
etc/security/auth_attr \
etc/security/exec_attr \
etc/security/prof_attr \
- etc/user_attr \
- kernel/drv/sd.conf
+ etc/user_attr
+
+ELIDED_FILES_86 = $(ELIDED_FILES_BASE) etc/devlink.tab
+ELIDED_FILES_89 = $(ELIDED_FILES_BASE) kernel/drv/sd.conf etc/devlink.tab
+ELIDED_FILES_90 = $(ELIDED_FILES_89)
+ELIDED_FILES_91 = $(ELIDED_FILES_89)
+ELIDED_FILES_92 = $(ELIDED_FILES_89)
+ELIDED_FILES_93 = $(ELIDED_FILES_89)
+ELIDED_FILES_94 = $(ELIDED_FILES_89)
+ELIDED_FILES_95 = $(ELIDED_FILES_89)
+ELIDED_FILES_96 = $(ELIDED_FILES_89)
+ELIDED_FILES_97 = $(ELIDED_FILES_89)
+ELIDED_FILES_98 = $(ELIDED_FILES_89)
+ELIDED_FILES_99 = $(ELIDED_FILES_89)
+ELIDED_FILES_100a = $(ELIDED_FILES_BASE) kernel/drv/sd.conf
+ELIDED_FILES = $(ELIDED_FILES_$(BUILDID))
#
# these files get placed into proto area from per-build cached versions