83 if len(new_cloneperms) == 1: |
83 if len(new_cloneperms) == 1: |
84 self.attrs["clone_perms"] = new_cloneperms[0] |
84 self.attrs["clone_perms"] = new_cloneperms[0] |
85 else: |
85 else: |
86 self.attrs["clone_perms"] = new_cloneperms |
86 self.attrs["clone_perms"] = new_cloneperms |
87 |
87 |
88 def __usr_sbin_init(self): |
88 @staticmethod |
|
89 def __usr_sbin_init(): |
89 """Initialize paths to device management commands that we will |
90 """Initialize paths to device management commands that we will |
90 execute when handling package driver actions""" |
91 execute when handling package driver actions""" |
91 |
92 |
92 usr_sbin = DebugValues.get("driver-cmd-dir", "/usr/sbin") + "/" |
93 usr_sbin = DebugValues.get("driver-cmd-dir", "/usr/sbin") + "/" |
93 self.__class__.usr_sbin = usr_sbin |
94 DriverAction.usr_sbin = usr_sbin |
94 self.__class__.add_drv = usr_sbin + "add_drv" |
95 DriverAction.add_drv = usr_sbin + "add_drv" |
95 self.__class__.rem_drv = usr_sbin + "rem_drv" |
96 DriverAction.rem_drv = usr_sbin + "rem_drv" |
96 self.__class__.update_drv = usr_sbin + "update_drv" |
97 DriverAction.update_drv = usr_sbin + "update_drv" |
97 |
98 |
98 def __getstate__(self): |
99 def __getstate__(self): |
99 """This object doesn't have a default __dict__, instead it |
100 """This object doesn't have a default __dict__, instead it |
100 stores its contents via __slots__. Hence, this routine must |
101 stores its contents via __slots__. Hence, this routine must |
101 be provide to translate this object's contents into a |
102 be provide to translate this object's contents into a |
133 print ("command run was:"), " ".join(args) |
134 print ("command run was:"), " ".join(args) |
134 print ("command output was:") |
135 print ("command output was:") |
135 print "-" * 60 |
136 print "-" * 60 |
136 print buf, |
137 print buf, |
137 print "-" * 60 |
138 print "-" * 60 |
|
139 |
|
140 @staticmethod |
|
141 def remove_aliases(driver_name, aliases, image): |
|
142 if not DriverAction.update_drv: |
|
143 DriverAction.__usr_sbin_init() |
|
144 rem_base = (DriverAction.update_drv, "-b", image.get_root(), "-d") |
|
145 for i in aliases: |
|
146 args = rem_base + ("-i", '%s' % i, driver_name) |
|
147 DriverAction.__call(args, "driver (%(name)s) upgrade (removal " |
|
148 "of alias '%(alias)s')", |
|
149 {"name": driver_name, "alias": i}) |
138 |
150 |
139 @classmethod |
151 @classmethod |
140 def __activate_drivers(cls): |
152 def __activate_drivers(cls): |
141 cls.__call([cls.usr_sbin + "devfsadm", "-u"], |
153 cls.__call([cls.usr_sbin + "devfsadm", "-u"], |
142 "Driver activation failed", {}) |
154 "Driver activation failed", {}) |
370 |
382 |
371 def __update_install(self, image, orig): |
383 def __update_install(self, image, orig): |
372 add_base = ( self.update_drv, "-b", image.get_root(), "-a" ) |
384 add_base = ( self.update_drv, "-b", image.get_root(), "-a" ) |
373 rem_base = ( self.update_drv, "-b", image.get_root(), "-d" ) |
385 rem_base = ( self.update_drv, "-b", image.get_root(), "-d" ) |
374 |
386 |
375 nalias = set(self.attrlist("alias")) |
387 add_alias = set(self.attrlist("alias")) - \ |
376 oalias = set(orig.attrlist("alias")) |
388 set(orig.attrlist("alias")) |
377 add_alias = nalias - oalias |
|
378 rem_alias = oalias - nalias |
|
379 |
389 |
380 nclass = set(self.attrlist("class")) |
390 nclass = set(self.attrlist("class")) |
381 oclass = set(orig.attrlist("class")) |
391 oclass = set(orig.attrlist("class")) |
382 add_class = nclass - oclass |
392 add_class = nclass - oclass |
383 rem_class = oclass - nclass |
393 rem_class = oclass - nclass |
406 args = add_base + ("-i", '%s' % i, self.attrs["name"]) |
416 args = add_base + ("-i", '%s' % i, self.attrs["name"]) |
407 self.__call(args, "driver (%(name)s) upgrade (addition " |
417 self.__call(args, "driver (%(name)s) upgrade (addition " |
408 "of alias '%(alias)s')", |
418 "of alias '%(alias)s')", |
409 {"name": self.attrs["name"], "alias": i}) |
419 {"name": self.attrs["name"], "alias": i}) |
410 |
420 |
411 for i in rem_alias: |
421 # Removing aliases has already been taken care of in |
412 args = rem_base + ("-i", '%s' % i, self.attrs["name"]) |
422 # imageplan.execute by calling remove_aliases. |
413 self.__call(args, "driver (%(name)s) upgrade (removal " |
|
414 "of alias '%(alias)s')", |
|
415 {"name": self.attrs["name"], "alias": i}) |
|
416 |
423 |
417 # update_drv doesn't do anything with classes, so we have to |
424 # update_drv doesn't do anything with classes, so we have to |
418 # futz with driver_classes by hand. |
425 # futz with driver_classes by hand. |
419 def update_classes(add_class, rem_class): |
426 def update_classes(add_class, rem_class): |
420 dcp = os.path.normpath(os.path.join( |
427 dcp = os.path.normpath(os.path.join( |