diff options
author | biao716.wang <biao716.wang@samsung.com> | 2022-08-18 17:44:23 +0900 |
---|---|---|
committer | biao716.wang <biao716.wang@samsung.com> | 2022-08-18 17:46:00 +0900 |
commit | 518ad41e97d71404b6e45b21c687455f37351a12 (patch) | |
tree | 299461cb490fca281cf8bcbfc66925c9693b5136 | |
parent | ff5819fa88cf0522c567925aa5919eb300c628f8 (diff) | |
download | mic-518ad41e97d71404b6e45b21c687455f37351a12.tar.gz mic-518ad41e97d71404b6e45b21c687455f37351a12.tar.bz2 mic-518ad41e97d71404b6e45b21c687455f37351a12.zip |
Merge release-0.28.17 from 'tools/mic'upstream/0.28.17submit/tizen/20220818.092614
Change-Id: I929aa3c676c041e6ab361c3b6dd5a2613ed6cd0d
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
76 files changed, 895 insertions, 539 deletions
diff --git a/ChangeLog b/ChangeLog index 7e587d7..d837a46 100755..100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,58 @@ +Release 0.28.17 - Wed Aug. 10 2022 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Add --block-recommends option to allow not install recommended packages + +Release 0.28.16 - Thu Feb. 10 2022 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Add postscripts-maxruntime option to set the max run time for post scripts + +Release 0.28.15 - Mon Jul. 05 2021 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Don't install recommended packages in mic + +Release 0.28.14 - Fri May. 14 2021 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Encrypt user password with SHA512 instead of MD5. + * Fix pylint error, reimport glob. + +Release 0.28.13 - Tue Mar. 23 2021 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Add new option for squashfs file system to support M1 feature. + +Release 0.28.12 - Feb Jan. 05 2021 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Support to create image with f2fs file system. + * Fix the bug that no print last installed package. + * Remove urlgrabber directory from mic. + +Release 0.28.11 - Thu Nov. 05 2020 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * add dependece for yum directly. + * fix run error issue for parser repomd.xml when here is group type. + * Refine code, remove duplicated code + * Separate qcow plugin scripts + +Release 0.28.10 - Tue Jul. 21 2020 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Create btrfs images with the metadata single option. + * Refine code with SAM tools check. + +Release 0.28.9 - Wed Jun. 17 2020 - Yan Meng <yan11.meng@samsung.com> +===================================================================== + * increase max loop device number in mic. + * fix build error with Typeerror. + * Fix the bug that truncates existing inittab file. + +Release 0.28.8 - Thu May. 7 2020 - Yan Meng <yan11.meng@samsung.com> +===================================================================== + * remove unnecessary /etc/fstab file. + +Release 0.28.7 - Mon Feb. 17 2020 - Yan Meng <yan11.meng@samsung.com> +===================================================================== + * fix pylint errors for mic + * add option for mic to skip set hosts when create + * skip set hosts by mic when /etc/hosts exists + Release 0.28.6 - Fri Feb. 15 2019 - Jin Xiao <jin.xiao@samsung.com> ===================================================================== * new distribution support: Ubuntu 18.04. diff --git a/debian/changelog b/debian/changelog index a10a43a..e803282 100755..100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,70 @@ +mic (0.28.17) unstable; urgency=low + * Add --block-recommends option to allow not install recommended packages + + -- Biao Wang <biao716.wang@samsung.com> Wed, 10 Aug 2022 15:00:00 +0800 + +mic (0.28.16) unstable; urgency=low + * Add postscripts-maxruntime option to set the max run time for post scripts. + + -- Biao Wang <biao716.wang@samsung.com> Thu, 10 Feb 2022 15:00:00 +0800 + +mic (0.28.15) unstable; urgency=low + * Don't install recommended packages in mic. + + -- Biao Wang <biao716.wang@samsung.com> Mon, 05 Jul 2021 15:00:00 +0800 + +mic (0.28.14) unstable; urgency=low + * Encrypt user password with SHA512 instead of MD5. + * Fix pylint error, reimport glob. + + -- Biao Wang <biao716.wang@samsung.com> Fri, 14 May 2021 15:00:00 +0800 + + +mic (0.28.13) unstable; urgency=low + * Add new option for squashfs file system to support M1 feature. + + -- Biao Wang <biao716.wang@samsung.com> Tue, 23 Mar 2021 15:00:00 +0800 + +mic (0.28.12) unstable; urgency=low + * Support to create image with f2fs file system. + * Fix the bug that no print last installed package. + * Remove urlgrabber directory from mic. + + -- Biao Wang <biao716.wang@samsung.com> Fri, 05 Feb 2021 15:00:00 +0800 + +mic (0.28.11) unstable; urgency=low + * add dependece for yum directly. + * fix run error issue for parser repomd.xml when here is group type. + * Refine code, remove duplicated code + * Separate qcow plugin scripts + + -- Biao Wang <biao716.wang@samsung.com> Thu, 05 Nov 2020 15:00:00 +0800 + +mic (0.28.10) unstable; urgency=low + * Create btrfs images with the metadata single option. + * Refine code with SAM tools check. + + -- Biao Wang <biao716.wang@samsung.com> Tue, 21 Jul 2020 15:00:00 +0800 + +mic (0.28.9) unstable; urgency=low + * increase max loop device number in mic. + * fix build error with Typeerror. + * Fix the bug that truncates existing inittab file. + + -- Yan Meng <yan11.meng@samsung.com> Wed, 17 Jun 2020 15:00:00 +0800 + +mic (0.28.8) unstable; urgency=low + * remove unnecessary /etc/fstab file. + + -- Yan Meng <yan11.meng@samsung.com> Thu, 7 May 2020 15:00:00 +0800 + +mic (0.28.7) unstable; urgency=low + * fix pylint errors for mic + * add option for mic to skip set hosts when create + * skip set hosts by mic when /etc/hosts exists + + -- Yan Meng <yan11.meng@samsung.com> Mon, 17 Feb 2020 15:00:00 +0800 + mic (0.28.6) unstable; urgency=low * new distribution support: Ubuntu 18.04. diff --git a/debian/control b/debian/control index 72cc18e..9647472 100644 --- a/debian/control +++ b/debian/control @@ -14,7 +14,8 @@ Depends: ${misc:Depends}, ${python:Depends}, python-urlgrabber, cpio, bzip2, - gzip + gzip, + yum Conflicts: mic2 Description: image creator for Linux distributions diff --git a/doc/RELEASE_NOTES b/doc/RELEASE_NOTES index 290ba61..c207ac3 100755..100644 --- a/doc/RELEASE_NOTES +++ b/doc/RELEASE_NOTES @@ -1,3 +1,138 @@ +MIC Image Creator 0.28.17 Release Notes +====================================== +Released Aug 10 2022 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Add --block-recommends option to block install recommends packages. + +MIC Image Creator 0.28.16 Release Notes +====================================== +Released Feb 10 2022 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Add postscripts-maxruntime option to set the max run time for post scripts. + +MIC Image Creator 0.28.15 Release Notes +====================================== +Released Jul 05 2021 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Don't install recommended packages in mic. + +MIC Image Creator 0.28.14 Release Notes +====================================== +Released May 14 2021 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Encrypt user password with SHA512 instead of MD5. + * Fix pylint error, reimport glob. + +MIC Image Creator 0.28.13 Release Notes +====================================== +Released Mar 23 2021 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Add new option for squashfs to support M1 feature. + +MIC Image Creator 0.28.12 Release Notes +====================================== +Released Feb 05 2021 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Support to create image with f2fs file system. + * Fix the bug that no print last installed package. + * Remove urlgrabber directory from mic. + +MIC Image Creator 0.28.11 Release Notes +====================================== +Released Nov 05 2020 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * add dependece for yum directly. + * fix run error issue for parser repomd.xml when here is group type. + * Refine code, remove duplicated code + * Separate qcow plugin scripts + +MIC Image Creator 0.28.10 Release Notes +====================================== +Released Jul 21 2020 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Create btrfs images with the metadata single option. + * Refine code with SAM tools check. + +MIC Image Creator 0.28.9 Release Notes +====================================== +Released Jun 17 2020 + +This release note documents the changes included in the new release. And +the release contains new features. + +Bug Fixes +-------------------------- + * increase max loop device number in mic. + * fix build error with Typeerror. + * Fix the bug that truncates existing inittab file. + +MIC Image Creator 0.28.8 Release Notes +====================================== +Released May 7 2020 + +This release note documents the changes included in the new release. And +the release contains new features. + +Bug Fixes +-------------------------- + * remove unnecessary /etc/fstab file. + +MIC Image Creator 0.28.7 Release Notes +====================================== +Released Feb 17 2020 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * add option for mic to skip set hosts when create. + +Bug Fixes +-------------------------- + * fix pylint errors for mic. + * skip set hosts by mic when /etc/hosts exists. + MIC Image Creator 0.28.6 Release Notes ====================================== Released Feb 15 2019 @@ -25,7 +160,7 @@ MIC Image Creator 0.28.4 Release Notes Released Sep 28 2018 This release note documents the changes included in the new release. And -the release contains new features, enhancements and bug fixes. +the release contains new features. new features -------------------------- diff --git a/mic/3rdparty/pykickstart/base.py b/mic/3rdparty/pykickstart/base.py index e3597df..75ce249 100644 --- a/mic/3rdparty/pykickstart/base.py +++ b/mic/3rdparty/pykickstart/base.py @@ -79,7 +79,7 @@ class KickstartCommand(KickstartObject): # We don't want people using this class by itself. if self.__class__ is KickstartCommand: - raise TypeError, "KickstartCommand is an abstract class." + raise TypeError ("KickstartCommand is an abstract class.") KickstartObject.__init__(self, *args, **kwargs) @@ -122,7 +122,7 @@ class KickstartCommand(KickstartObject): """Parse the list of args and set data on the KickstartCommand object. This method must be provided by all subclasses. """ - raise TypeError, "parse() not implemented for KickstartCommand" + raise TypeError ("parse() not implemented for KickstartCommand") def apply(self, instroot="/"): """Write out the configuration related to the KickstartCommand object. @@ -171,7 +171,7 @@ class DeprecatedCommand(KickstartCommand): def __init__(self, writePriority=None, *args, **kwargs): # We don't want people using this class by itself. if self.__class__ is KickstartCommand: - raise TypeError, "DeprecatedCommand is an abstract class." + raise TypeError ("DeprecatedCommand is an abstract class.") # Create a new DeprecatedCommand instance. KickstartCommand.__init__(self, writePriority, *args, **kwargs) @@ -245,7 +245,7 @@ class BaseHandler(KickstartObject): # We don't want people using this class by itself. if self.__class__ is BaseHandler: - raise TypeError, "BaseHandler is an abstract class." + raise TypeError ("BaseHandler is an abstract class.") KickstartObject.__init__(self, *args, **kwargs) @@ -388,7 +388,7 @@ class BaseHandler(KickstartObject): cmd = args[0] if not self.commands.has_key(cmd): - raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown command: %s" % cmd)) + raise KickstartParseError (formatErrorMsg(lineno, msg=_("Unknown command: %s" % cmd))) elif self.commands[cmd] != None: self.commands[cmd].currentCmd = cmd self.commands[cmd].currentLine = self.currentLine @@ -429,13 +429,13 @@ class BaseData(KickstartObject): def __init__(self, *args, **kwargs): """Create a new BaseData instance. - - lineno -- Line number in the ks-file where this object was defined + + lineno -- Line number in the ks-file where this object was defined """ # We don't want people using this class by itself. if self.__class__ is BaseData: - raise TypeError, "BaseData is an abstract class." + raise TypeError ("BaseData is an abstract class.") KickstartObject.__init__(self, *args, **kwargs) self.lineno = 0 diff --git a/mic/3rdparty/pykickstart/commands/autopart.py b/mic/3rdparty/pykickstart/commands/autopart.py index cf28b5c..22c3b66 100644 --- a/mic/3rdparty/pykickstart/commands/autopart.py +++ b/mic/3rdparty/pykickstart/commands/autopart.py @@ -42,7 +42,7 @@ class FC3_AutoPart(KickstartCommand): def parse(self, args): if len(args) > 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "autopart") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "autopart")) self.autopart = True return self diff --git a/mic/3rdparty/pykickstart/commands/device.py b/mic/3rdparty/pykickstart/commands/device.py index 321410e..afed26c 100644 --- a/mic/3rdparty/pykickstart/commands/device.py +++ b/mic/3rdparty/pykickstart/commands/device.py @@ -82,7 +82,7 @@ class FC3_Device(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) != 2: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name"))) self.moduleOpts = opts.moduleOpts self.type = extra[0] @@ -108,7 +108,7 @@ class F8_Device(FC3_Device): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name"))) dd = F8_DeviceData() self._setToObj(self.op, opts, dd) diff --git a/mic/3rdparty/pykickstart/commands/displaymode.py b/mic/3rdparty/pykickstart/commands/displaymode.py index 6a12d58..afd58ea 100644 --- a/mic/3rdparty/pykickstart/commands/displaymode.py +++ b/mic/3rdparty/pykickstart/commands/displaymode.py @@ -56,7 +56,7 @@ class FC3_DisplayMode(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % self.currentCmd) + raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % self.currentCmd)) if self.currentCmd == "cmdline": self.displayMode = DISPLAY_MODE_CMDLINE diff --git a/mic/3rdparty/pykickstart/commands/driverdisk.py b/mic/3rdparty/pykickstart/commands/driverdisk.py index 82a58c0..43d6259 100644 --- a/mic/3rdparty/pykickstart/commands/driverdisk.py +++ b/mic/3rdparty/pykickstart/commands/driverdisk.py @@ -113,13 +113,13 @@ class FC3_DriverDisk(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))) if len(extra) == 1 and opts.source: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))) if not extra and not opts.source: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command."))) ddd = self.handler.DriverDiskData() self._setToObj(self.op, opts, ddd) @@ -145,17 +145,17 @@ class FC4_DriverDisk(FC3_DriverDisk): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))) if len(extra) == 1 and opts.source: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))) elif len(extra) == 1 and opts.biospart: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command."))) elif opts.source and opts.biospart: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command."))) if not extra and not opts.source and not opts.biospart: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command."))) ddd = self.handler.DriverDiskData() self._setToObj(self.op, opts, ddd) diff --git a/mic/3rdparty/pykickstart/commands/fcoe.py b/mic/3rdparty/pykickstart/commands/fcoe.py index 3320849..2f4b492 100644 --- a/mic/3rdparty/pykickstart/commands/fcoe.py +++ b/mic/3rdparty/pykickstart/commands/fcoe.py @@ -90,7 +90,7 @@ class F12_Fcoe(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: mapping = {"command": "fcoe", "options": extra} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) self._setToObj(self.op, opts, zd) zd.lineno = self.lineno diff --git a/mic/3rdparty/pykickstart/commands/firewall.py b/mic/3rdparty/pykickstart/commands/firewall.py index 24a01bd..1d21759 100644 --- a/mic/3rdparty/pykickstart/commands/firewall.py +++ b/mic/3rdparty/pykickstart/commands/firewall.py @@ -112,11 +112,11 @@ class FC3_Firewall(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - + if len(extra) != 0: mapping = {"command": "firewall", "options": extra} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping) - + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) + self._setToSelf(self.op, opts) return self diff --git a/mic/3rdparty/pykickstart/commands/ignoredisk.py b/mic/3rdparty/pykickstart/commands/ignoredisk.py index 676d080..48f281d 100644 --- a/mic/3rdparty/pykickstart/commands/ignoredisk.py +++ b/mic/3rdparty/pykickstart/commands/ignoredisk.py @@ -80,7 +80,7 @@ class F8_IgnoreDisk(FC3_IgnoreDisk): if errorCheck: if (len(self.ignoredisk) == 0 and len(self.onlyuse) == 0) or (len(self.ignoredisk) > 0 and (len(self.onlyuse) > 0)): - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command."))) return retval @@ -126,7 +126,7 @@ class RHEL6_IgnoreDisk(F8_IgnoreDisk): if self.interactive: howmany += 1 if howmany != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command."))) return retval diff --git a/mic/3rdparty/pykickstart/commands/interactive.py b/mic/3rdparty/pykickstart/commands/interactive.py index fa3dc02..b4e286b 100644 --- a/mic/3rdparty/pykickstart/commands/interactive.py +++ b/mic/3rdparty/pykickstart/commands/interactive.py @@ -48,7 +48,7 @@ class FC3_Interactive(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "interactive") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "interactive")) self.interactive = True return self diff --git a/mic/3rdparty/pykickstart/commands/iscsi.py b/mic/3rdparty/pykickstart/commands/iscsi.py index da5a544..9c25111 100644 --- a/mic/3rdparty/pykickstart/commands/iscsi.py +++ b/mic/3rdparty/pykickstart/commands/iscsi.py @@ -110,7 +110,7 @@ class FC6_Iscsi(KickstartCommand): if len(extra) != 0: mapping = {"command": "iscsi", "options": extra} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) dd = self.handler.IscsiData() self._setToObj(self.op, opts, dd) diff --git a/mic/3rdparty/pykickstart/commands/iscsiname.py b/mic/3rdparty/pykickstart/commands/iscsiname.py index a87d063..ccfbe5f 100644 --- a/mic/3rdparty/pykickstart/commands/iscsiname.py +++ b/mic/3rdparty/pykickstart/commands/iscsiname.py @@ -49,6 +49,6 @@ class FC6_IscsiName(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "iscsiname") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "iscsiname")) self.iscsiname = extra[0] return self diff --git a/mic/3rdparty/pykickstart/commands/key.py b/mic/3rdparty/pykickstart/commands/key.py index c20c423..cfeb62e 100644 --- a/mic/3rdparty/pykickstart/commands/key.py +++ b/mic/3rdparty/pykickstart/commands/key.py @@ -57,7 +57,7 @@ class RHEL5_Key(KickstartCommand): if self.skip: self.key = KS_INSTKEY_SKIP elif len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "key") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "key")) else: self.key = extra[0] diff --git a/mic/3rdparty/pykickstart/commands/keyboard.py b/mic/3rdparty/pykickstart/commands/keyboard.py index babc2ac..90379c4 100644 --- a/mic/3rdparty/pykickstart/commands/keyboard.py +++ b/mic/3rdparty/pykickstart/commands/keyboard.py @@ -46,10 +46,10 @@ class FC3_Keyboard(KickstartCommand): return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "keyboard") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "keyboard")) self.keyboard = extra[0] return self diff --git a/mic/3rdparty/pykickstart/commands/lang.py b/mic/3rdparty/pykickstart/commands/lang.py index cf5e46c..846a356 100644 --- a/mic/3rdparty/pykickstart/commands/lang.py +++ b/mic/3rdparty/pykickstart/commands/lang.py @@ -48,7 +48,7 @@ class FC3_Lang(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "lang") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "lang")) self.lang = extra[0] return self diff --git a/mic/3rdparty/pykickstart/commands/lilocheck.py b/mic/3rdparty/pykickstart/commands/lilocheck.py index 92b3f93..754a32c 100644 --- a/mic/3rdparty/pykickstart/commands/lilocheck.py +++ b/mic/3rdparty/pykickstart/commands/lilocheck.py @@ -48,7 +48,7 @@ class FC3_LiloCheck(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "lilocheck") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "lilocheck")) self.check = True return self diff --git a/mic/3rdparty/pykickstart/commands/logging.py b/mic/3rdparty/pykickstart/commands/logging.py index 6985619..0708f77 100644 --- a/mic/3rdparty/pykickstart/commands/logging.py +++ b/mic/3rdparty/pykickstart/commands/logging.py @@ -60,7 +60,7 @@ class FC6_Logging(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if opts.port and not opts.host: - raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Can't specify --port without --host.")) + raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Can't specify --port without --host."))) self._setToSelf(self.op, opts) return self diff --git a/mic/3rdparty/pykickstart/commands/logvol.py b/mic/3rdparty/pykickstart/commands/logvol.py index c1b9cc3..08bbf14 100644 --- a/mic/3rdparty/pykickstart/commands/logvol.py +++ b/mic/3rdparty/pykickstart/commands/logvol.py @@ -225,7 +225,7 @@ class FC3_LogVol(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) == 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol")) lvd = self.handler.LogVolData() self._setToObj(self.op, opts, lvd) diff --git a/mic/3rdparty/pykickstart/commands/mediacheck.py b/mic/3rdparty/pykickstart/commands/mediacheck.py index 388823a..9a785d8 100644 --- a/mic/3rdparty/pykickstart/commands/mediacheck.py +++ b/mic/3rdparty/pykickstart/commands/mediacheck.py @@ -47,7 +47,7 @@ class FC4_MediaCheck(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "mediacheck") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "mediacheck")) self.mediacheck = True return self diff --git a/mic/3rdparty/pykickstart/commands/method.py b/mic/3rdparty/pykickstart/commands/method.py index e21064a..3b384c1 100644 --- a/mic/3rdparty/pykickstart/commands/method.py +++ b/mic/3rdparty/pykickstart/commands/method.py @@ -86,7 +86,7 @@ class FC3_Method(KickstartCommand): if self.currentCmd == "harddrive": if self.biospart is None and self.partition is None or \ self.biospart is not None and self.partition is not None: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of biospart or partition options must be specified.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of biospart or partition options must be specified."))) return self diff --git a/mic/3rdparty/pykickstart/commands/monitor.py b/mic/3rdparty/pykickstart/commands/monitor.py index 8c8c2c4..57f1e51 100644 --- a/mic/3rdparty/pykickstart/commands/monitor.py +++ b/mic/3rdparty/pykickstart/commands/monitor.py @@ -64,7 +64,7 @@ class FC3_Monitor(KickstartCommand): if extra: mapping = {"cmd": "monitor", "options": extra} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(cmd)s command: %(options)s") % mapping) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(cmd)s command: %(options)s") % mapping)) self._setToSelf(self.op, opts) return self diff --git a/mic/3rdparty/pykickstart/commands/mouse.py b/mic/3rdparty/pykickstart/commands/mouse.py index c643bce..d7ad1ae 100644 --- a/mic/3rdparty/pykickstart/commands/mouse.py +++ b/mic/3rdparty/pykickstart/commands/mouse.py @@ -60,7 +60,7 @@ class RHEL3_Mouse(KickstartCommand): self._setToSelf(self.op, opts) if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "mouse") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "mouse")) self.mouse = extra[0] return self diff --git a/mic/3rdparty/pykickstart/commands/multipath.py b/mic/3rdparty/pykickstart/commands/multipath.py index 84ba755..4d5b26b 100644 --- a/mic/3rdparty/pykickstart/commands/multipath.py +++ b/mic/3rdparty/pykickstart/commands/multipath.py @@ -95,7 +95,7 @@ class FC6_MultiPath(KickstartCommand): for path in mpath.paths: if path.device == dd.device: mapping = {"device": path.device, "multipathdev": path.mpdev} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Device '%(device)s' is already used in multipath '%(multipathdev)s'") % mapping) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Device '%(device)s' is already used in multipath '%(multipathdev)s'") % mapping)) if mpath.name == dd.mpdev: parent = x diff --git a/mic/3rdparty/pykickstart/commands/raid.py b/mic/3rdparty/pykickstart/commands/raid.py index 0f4c92a..adf3524 100644 --- a/mic/3rdparty/pykickstart/commands/raid.py +++ b/mic/3rdparty/pykickstart/commands/raid.py @@ -248,9 +248,9 @@ class FC3_Raid(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) == 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "raid") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "raid")) if len(extra) == 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid")) rd = self.handler.RaidData() self._setToObj(self.op, opts, rd) diff --git a/mic/3rdparty/pykickstart/commands/repo.py b/mic/3rdparty/pykickstart/commands/repo.py index 543ef94..b673982 100644 --- a/mic/3rdparty/pykickstart/commands/repo.py +++ b/mic/3rdparty/pykickstart/commands/repo.py @@ -155,18 +155,18 @@ class FC6_Repo(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - + if len(extra) != 0: mapping = {"command": "repo", "options": extra} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) # This is lame, but I can't think of a better way to make sure only # one of these two is specified. if opts.baseurl and opts.mirrorlist: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command."))) if self.urlRequired and not opts.baseurl and not opts.mirrorlist: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command."))) rd = self.handler.RepoData() self._setToObj(self.op, opts, rd) @@ -207,7 +207,7 @@ class F8_Repo(FC6_Repo): def methodToRepo(self): if not self.handler.method.url: - raise KickstartError, formatErrorMsg(self.handler.method.lineno, msg=_("Method must be a url to be added to the repo list.")) + raise KickstartError (formatErrorMsg(self.handler.method.lineno, msg=_("Method must be a url to be added to the repo list."))) reponame = "ks-method-url" repourl = self.handler.method.url rd = self.handler.RepoData(name=reponame, baseurl=repourl) diff --git a/mic/3rdparty/pykickstart/commands/rescue.py b/mic/3rdparty/pykickstart/commands/rescue.py index 1893d4e..682fefa 100644 --- a/mic/3rdparty/pykickstart/commands/rescue.py +++ b/mic/3rdparty/pykickstart/commands/rescue.py @@ -61,7 +61,7 @@ class F10_Rescue(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if opts.nomount and opts.romount: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --nomount and --romount may be specified for rescue command.")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --nomount and --romount may be specified for rescue command."))) self._setToSelf(self.op, opts) self.rescue = True diff --git a/mic/3rdparty/pykickstart/commands/rootpw.py b/mic/3rdparty/pykickstart/commands/rootpw.py index e038b45..4237db8 100644 --- a/mic/3rdparty/pykickstart/commands/rootpw.py +++ b/mic/3rdparty/pykickstart/commands/rootpw.py @@ -62,7 +62,7 @@ class FC3_RootPw(KickstartCommand): self._setToSelf(self.op, opts) if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "rootpw") + raise KickstartValueError ( formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "rootpw")) self.password = extra[0] return self diff --git a/mic/3rdparty/pykickstart/commands/services.py b/mic/3rdparty/pykickstart/commands/services.py index 2e0eab8..f640822 100644 --- a/mic/3rdparty/pykickstart/commands/services.py +++ b/mic/3rdparty/pykickstart/commands/services.py @@ -66,6 +66,6 @@ class FC6_Services(KickstartCommand): self._setToSelf(self.op, opts) if len(self.disabled) == 0 and len(self.enabled) == 0: - raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("One of --disabled or --enabled must be provided.")) + raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("One of --disabled or --enabled must be provided."))) return self diff --git a/mic/3rdparty/pykickstart/commands/skipx.py b/mic/3rdparty/pykickstart/commands/skipx.py index 36d1a8d..2067df8 100644 --- a/mic/3rdparty/pykickstart/commands/skipx.py +++ b/mic/3rdparty/pykickstart/commands/skipx.py @@ -48,7 +48,7 @@ class FC3_SkipX(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "skipx") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "skipx")) self.skipx = True return self diff --git a/mic/3rdparty/pykickstart/commands/sshpw.py b/mic/3rdparty/pykickstart/commands/sshpw.py index e7867eb..759dbeb 100644 --- a/mic/3rdparty/pykickstart/commands/sshpw.py +++ b/mic/3rdparty/pykickstart/commands/sshpw.py @@ -93,7 +93,7 @@ class F13_SshPw(KickstartCommand): ud.lineno = self.lineno if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "sshpw") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "sshpw")) ud.password = extra[0] if ud in self.dataList(): diff --git a/mic/3rdparty/pykickstart/commands/timezone.py b/mic/3rdparty/pykickstart/commands/timezone.py index f5441de..06d09d6 100644 --- a/mic/3rdparty/pykickstart/commands/timezone.py +++ b/mic/3rdparty/pykickstart/commands/timezone.py @@ -58,7 +58,7 @@ class FC3_Timezone(KickstartCommand): self._setToSelf(self.op, opts) if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "timezone") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "timezone")) self.timezone = extra[0] return self diff --git a/mic/3rdparty/pykickstart/commands/updates.py b/mic/3rdparty/pykickstart/commands/updates.py index 53ec49f..6e18af9 100644 --- a/mic/3rdparty/pykickstart/commands/updates.py +++ b/mic/3rdparty/pykickstart/commands/updates.py @@ -51,7 +51,7 @@ class F7_Updates(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s only takes one argument") % "updates") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s only takes one argument") % "updates")) elif len(extra) == 0: self.url = "floppy" else: diff --git a/mic/3rdparty/pykickstart/commands/upgrade.py b/mic/3rdparty/pykickstart/commands/upgrade.py index a68a82d..5f44ea1 100644 --- a/mic/3rdparty/pykickstart/commands/upgrade.py +++ b/mic/3rdparty/pykickstart/commands/upgrade.py @@ -54,7 +54,7 @@ class FC3_Upgrade(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")) if self.currentCmd == "upgrade": self.upgrade = True @@ -91,10 +91,10 @@ class F11_Upgrade(FC3_Upgrade): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade") + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")) if (opts.root_device is not None) and (opts.root_device == ""): - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device")) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device"))) else: self.root_device = opts.root_device diff --git a/mic/3rdparty/pykickstart/commands/xconfig.py b/mic/3rdparty/pykickstart/commands/xconfig.py index 644ee86..bbde49f 100644 --- a/mic/3rdparty/pykickstart/commands/xconfig.py +++ b/mic/3rdparty/pykickstart/commands/xconfig.py @@ -96,7 +96,7 @@ class FC3_XConfig(KickstartCommand): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if extra: mapping = {"command": "xconfig", "options": extra} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) self._setToSelf(self.op, opts) return self diff --git a/mic/3rdparty/pykickstart/commands/zerombr.py b/mic/3rdparty/pykickstart/commands/zerombr.py index 79555a9..e99ea8d 100644 --- a/mic/3rdparty/pykickstart/commands/zerombr.py +++ b/mic/3rdparty/pykickstart/commands/zerombr.py @@ -63,7 +63,7 @@ class F9_ZeroMbr(FC3_ZeroMbr): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) if len(extra) > 0: - raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "zerombr") + raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "zerombr")) self.zerombr = True return self diff --git a/mic/3rdparty/pykickstart/options.py b/mic/3rdparty/pykickstart/options.py index d971d92..d07fcf6 100755 --- a/mic/3rdparty/pykickstart/options.py +++ b/mic/3rdparty/pykickstart/options.py @@ -48,9 +48,9 @@ class KSOptionParser(OptionParser): def error(self, msg): if self.lineno != None: - raise KickstartParseError, formatErrorMsg(self.lineno, msg=msg) + raise KickstartParseError ( formatErrorMsg(self.lineno, msg=msg)) else: - raise KickstartParseError, msg + raise KickstartParseError ( msg) def keys(self): retval = [] @@ -80,7 +80,7 @@ class KSOptionParser(OptionParser): for option in filter(lambda o: isinstance(o, Option), self.option_list): if option.required and not seen(self, option): - raise KickstartValueError, formatErrorMsg(self.lineno, _("Option %s is required") % option) + raise KickstartValueError (formatErrorMsg(self.lineno, _("Option %s is required") % option)) elif seen(self, option) and usedTooNew(self, option): mapping = {"option": option, "intro": versionToString(option.introduced), "version": versionToString(self.version)} diff --git a/mic/3rdparty/pykickstart/parser.py b/mic/3rdparty/pykickstart/parser.py index 46495f6..a485dfe 100644 --- a/mic/3rdparty/pykickstart/parser.py +++ b/mic/3rdparty/pykickstart/parser.py @@ -84,20 +84,20 @@ def _preprocessStateMachine (lineIter): try: ksurl = ll.split(' ')[1] except: - raise KickstartParseError, formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll) + raise KickstartParseError (formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll)) try: url = grabber.urlopen(ksurl) - except grabber.URLGrabError, e: - raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror) + except grabber.URLGrabError as e: + raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror)) else: # Sanity check result. Sometimes FTP doesn't catch a file # is missing. try: if url.size < 1: - raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file")) + raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))) except: - raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file")) + raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))) # If that worked, write the remote file to the output kickstart # file in one burst. Then close everything up to get ready to @@ -129,8 +129,8 @@ def preprocessKickstart (f): """ try: fh = urlopen(f) - except grabber.URLGrabError, e: - raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror) + except grabber.URLGrabError as e: + raise KickstartError (formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)) rc = _preprocessStateMachine (iter(fh.readlines())) fh.close() @@ -351,7 +351,7 @@ class Packages(KickstartObject): (opts, extra) = op.parse_args(args=line.split()) if opts.nodefaults and opts.optional: - raise KickstartValueError, _("Group cannot specify both --nodefaults and --optional") + raise KickstartValueError (_("Group cannot specify both --nodefaults and --optional")) # If the group name has spaces in it, we have to put it back together # now. @@ -505,10 +505,10 @@ class KickstartParser: handle it. """ if not obj.sectionOpen: - raise TypeError, "no sectionOpen given for section %s" % obj + raise TypeError ("no sectionOpen given for section %s" % obj) if not obj.sectionOpen.startswith("%"): - raise TypeError, "section %s tag does not start with a %%" % obj.sectionOpen + raise TypeError ("section %s tag does not start with a %%" % obj.sectionOpen) self._sections[obj.sectionOpen] = obj @@ -538,7 +538,7 @@ class KickstartParser: if line == "": # This section ends at the end of the file. if self.version >= version.F8: - raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end.")) + raise KickstartParseError (formatErrorMsg(lineno, msg=_("Section does not end with %%end."))) self._finalize(obj) except StopIteration: @@ -563,7 +563,7 @@ class KickstartParser: elif args and (self._validState(args[0]) or args[0] in ["%include", "%ksappend"]): # This is an unterminated section. if self.version >= version.F8: - raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end.")) + raise KickstartParseError (formatErrorMsg(lineno, msg=_("Section does not end with %%end."))) # Finish up. We do not process the header here because # kicking back out to STATE_COMMANDS will ensure that happens. @@ -589,11 +589,11 @@ class KickstartParser: """ try: fn() - except Exception, msg: + except Exception as msg: if self.errorsAreFatal: raise else: - print msg + print (msg) def _isBlankOrComment(self, line): return line.isspace() or line == "" or line.lstrip()[0] == '#' @@ -630,7 +630,7 @@ class KickstartParser: continue if len(args) == 1 or not args[1]: - raise KickstartParseError, formatErrorMsg(lineno) + raise KickstartParseError (formatErrorMsg(lineno)) self._includeDepth += 1 @@ -656,7 +656,7 @@ class KickstartParser: # here. newSection = args[0] if not self._validState(newSection): - raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown kickstart section: %s" % newSection)) + raise KickstartParseError (formatErrorMsg(lineno, msg=_("Unknown kickstart section: %s" % newSection))) self._state = newSection obj = self._sections[self._state] @@ -705,8 +705,8 @@ class KickstartParser: try: s = urlread(f) - except grabber.URLGrabError, e: - raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror) + except grabber.URLGrabError as e: + raise KickstartError (formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)) self.readKickstartFromString(s, reset=False) diff --git a/mic/__init__.py b/mic/__init__.py index ab5cb7a..723746b 100755 --- a/mic/__init__.py +++ b/mic/__init__.py @@ -16,7 +16,7 @@ import os, sys -__version__ = "0.28.6" +__version__ = "0.28.17" cur_path = os.path.dirname(__file__) or '.' sys.path.insert(0, cur_path + '/3rdparty') diff --git a/mic/archive.py b/mic/archive.py index 72f506f..c6fde02 100644 --- a/mic/archive.py +++ b/mic/archive.py @@ -20,7 +20,7 @@ # * Used builtin function (W0141) # * Invalid name for type (C0103) # * Popen has no '%s' member (E1101) -# pylint: disable=W0142, W0612, W0141, C0103, E1101 +# pylint: disable= W0612, C0103, E1101 """ Compression and Archiving @@ -203,12 +203,12 @@ def compress(file_path, compress_format): @retval: the path of the compressed file """ if not os.path.isfile(file_path): - raise OSError, "can't compress a file not existed: '%s'" % file_path + raise OSError ("can't compress a file not existed: '%s'" % file_path) try: func = _COMPRESS_FORMATS[compress_format] except KeyError: - raise ValueError, "unknown compress format '%s'" % compress_format + raise ValueError ("unknown compress format '%s'" % compress_format) return func(file_path, True) def decompress(file_path, decompress_format=None): @@ -219,7 +219,7 @@ def decompress(file_path, decompress_format=None): @retval: the path of the decompressed file """ if not os.path.isfile(file_path): - raise OSError, "can't decompress a file not existed: '%s'" % file_path + raise OSError ("can't decompress a file not existed: '%s'" % file_path) (file_name, file_ext) = os.path.splitext(file_path) for key, suffixes in _COMPRESS_SUFFIXES.iteritems(): @@ -237,7 +237,7 @@ def decompress(file_path, decompress_format=None): try: func = _COMPRESS_FORMATS[decompress_format] except KeyError: - raise ValueError, "unknown decompress format '%s'" % decompress_format + raise ValueError ("unknown decompress format '%s'" % decompress_format) return func(file_path, False) @@ -276,7 +276,7 @@ def _do_untar(archive_name, target_dir=None): cmdln = ["tar", "-C", target_dir, "-xf", archive_name] (returncode, stdout, stderr) = _call_external(cmdln) if returncode != 0: - raise OSError, os.linesep.join([stdout, stderr]) + raise OSError (os.linesep.join([stdout, stderr])) def _imp_tarfile(archive_name, target_name): """ Archive the directory or the file with tarfile module @@ -400,19 +400,19 @@ def make_archive(archive_name, target_name): @retval: the archiving result """ if not os.path.exists(target_name): - raise OSError, "archive object does not exist: '%s'" % target_name + raise OSError ("archive object does not exist: '%s'" % target_name) for aformat, suffixes in _ARCHIVE_SUFFIXES.iteritems(): if filter(archive_name.endswith, suffixes): archive_format = aformat break else: - raise ValueError, "unknown archive suffix '%s'" % archive_name + raise ValueError ("unknown archive suffix '%s'" % archive_name) try: func, kwargs = _ARCHIVE_FORMATS[archive_format] except KeyError: - raise ValueError, "unknown archive format '%s'" % archive_format + raise ValueError ("unknown archive format '%s'" % archive_format) archive_name = os.path.abspath(archive_name) target_name = os.path.abspath(target_name) @@ -431,14 +431,14 @@ def extract_archive(archive_name, target_name): raise exception if fail to extract archive """ if not os.path.exists(archive_name): - raise OSError, "archived object does not exist: '%s'" % archive_name + raise OSError ("archived object does not exist: '%s'" % archive_name) archive_name = os.path.abspath(archive_name) target_name = os.path.abspath(target_name) if os.path.exists(target_name) and not os.path.isdir(target_name): - raise OSError, "%s should be directory where extracted files locate"\ - % target_name + raise OSError ("%s should be directory where extracted files locate"\ + % target_name) if not os.path.exists(target_name): os.makedirs(target_name) diff --git a/mic/bootstrap.py b/mic/bootstrap.py index c3e8471..e2ea8f1 100644 --- a/mic/bootstrap.py +++ b/mic/bootstrap.py @@ -23,6 +23,7 @@ import shutil import subprocess import rpm import glob +import errno from mic import msger from mic.utils import errors, proxy, misc @@ -161,7 +162,7 @@ class MiniBackend(object): # list means some errors happened in the transaction and non-empty # list that there were errors preventing the ts from starting... if errs is not None: - raise errors.BootstrapError("Transaction couldn't start: %s" % '\n'.join(errs)) + raise errors.BootstrapError("Transaction couldn't start: %s" % errs) def run_pkg_script(self, pkg, prog, script, arg): mychroot = lambda: os.chroot(self.rootdir) @@ -179,12 +180,12 @@ class MiniBackend(object): script = script.replace('\r', '') os.write(tmpfd, script) os.close(tmpfd) - os.chmod(tmpfp, 0700) + os.chmod(tmpfp, 0o700) try: script_fp = os.path.join('/tmp', os.path.basename(tmpfp)) subprocess.call([prog, script_fp, arg], preexec_fn=mychroot) - except (OSError, IOError), err: + except (OSError, IOError) as err: msger.warning(str(err)) finally: os.unlink(tmpfp) @@ -238,7 +239,7 @@ class Bootstrap(object): pkgmgr.optionals = list(optlist) map(pkgmgr.selectPackage, pkglist + list(optlist)) pkgmgr.runInstall() - except (OSError, IOError, errors.CreatorError), err: + except (OSError, IOError, errors.CreatorError) as err: raise errors.BootstrapError("%s" % err) def run(self, cmd, chdir, rootdir=None, bindmounts=None): @@ -312,7 +313,8 @@ class Bootstrap(object): gloablmounts = None try: proxy.set_proxy_environ() - gloablmounts = setup_chrootenv(rootdir, bindmounts) + #globalmounts is no useless, remove it, currently function always return none. + setup_chrootenv(rootdir, bindmounts) sync_timesetting(rootdir) sync_passwdfile(rootdir) sync_hostfile(rootdir) @@ -326,7 +328,7 @@ class Bootstrap(object): # add additional information to original exception value, tb = sys.exc_info()[1:] value = '%s: %s' % (value, ' '.join(cmd)) - raise RuntimeError, value, tb + raise RuntimeError (value, tb) finally: #if self.logfile and os.path.isfile(self.logfile): # msger.log(file(self.logfile).read()) diff --git a/mic/chroot.py b/mic/chroot.py index a8a41db..71e35b7 100644 --- a/mic/chroot.py +++ b/mic/chroot.py @@ -318,10 +318,11 @@ def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"): msger.info("Launching shell. Exit to continue.\n" "----------------------------------") - globalmounts = setup_chrootenv(chrootdir, bindmounts) + #globalmounts is no useless, remove it, currently function always return none. + setup_chrootenv(chrootdir, bindmounts) subprocess.call(execute, preexec_fn = mychroot, shell=True) - except OSError, err: + except OSError as err: raise errors.CreatorError("chroot err: %s" % str(err)) finally: diff --git a/mic/cmd_chroot.py b/mic/cmd_chroot.py index d7d76ef..35b089b 100755 --- a/mic/cmd_chroot.py +++ b/mic/cmd_chroot.py @@ -53,7 +53,7 @@ def main(parser, args, argv): configmgr.chroot['saveto'] = args.saveto
imagetype = misc.get_image_type(targetimage)
- if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg"):
+ if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg", "f2fsimg"):
imagetype = "loop"
chrootclass = None
diff --git a/mic/cmd_create.py b/mic/cmd_create.py index 203d08d..a62abc7 100755..100644 --- a/mic/cmd_create.py +++ b/mic/cmd_create.py @@ -82,7 +82,6 @@ def main(parser, args, argv): rpm.setVerbosity(rpm.RPMLOG_DEBUG)
except ImportError:
pass
-
#check the imager type
createrClass = None
for subcmd, klass in pluginmgr.get_plugins('imager').iteritems():
@@ -148,6 +147,12 @@ def main(parser, args, argv): if args.pkgmgr is not None:
configmgr.create['pkgmgr'] = args.pkgmgr
+ if args.skip_set_hosts:
+ configmgr.create['skip_set_hosts']=args.skip_set_hosts
+ if args.postscripts_maxruntime:
+ configmgr.create['postscripts_maxruntime']=int(args.postscripts_maxruntime)
+ if args.block_recommends:
+ configmgr.create['block_recommends']=args.block_recommends
if args.runtime:
configmgr.set_runtime(args.runtime)
diff --git a/mic/conf.py b/mic/conf.py index 9299cfe..279d14f 100755 --- a/mic/conf.py +++ b/mic/conf.py @@ -79,6 +79,9 @@ class ConfigMgr(object): "run_script": None, "tpk_install": None, "use_mic_in_bootstrap": False, + "skip_set_hosts": False, + "postscripts_maxruntime": 120, + "block_recommends": False, }, 'chroot': { "saveto": None, @@ -126,7 +129,7 @@ class ConfigMgr(object): try: self.__siteconf = siteconf self._parse_siteconf(siteconf) - except ConfigParser.Error, error: + except ConfigParser.Error as error: raise errors.ConfigError("%s" % error) def __get_siteconf(self): return self.__siteconf diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 7df75cf..f0243f7 100755..100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -26,6 +26,7 @@ import re import tarfile import glob import json +import errno from datetime import datetime import rpm import time @@ -37,8 +38,6 @@ from mic.chroot import kill_proc_inchroot from mic.archive import get_archive_suffixes from mic.conf import configmgr from mic.utils.grabber import myurlgrab -#post script max run time -MAX_RUN_TIME = 120 class BaseImageCreator(object): """Installs a system to a chroot directory. @@ -329,7 +328,7 @@ class BaseImageCreator(object): f = open(namefile, "w") f.write(content) f.close() - self.outimage.append(namefile); + self.outimage.append(namefile) # if 'content', save more details if 'content' in self._recording_pkgs: @@ -698,7 +697,7 @@ class BaseImageCreator(object): os.makedirs(self.workdir) self.__builddir = tempfile.mkdtemp(dir = self.workdir, prefix = "imgcreate-") - except OSError, (err, msg): + except OSError as msg: raise CreatorError("Failed create build directory in %s: %s" % (self.tmpdir, msg)) @@ -739,13 +738,13 @@ class BaseImageCreator(object): def __create_minimal_dev(self): """Create a minimal /dev so that we don't corrupt the host /dev""" origumask = os.umask(0000) - devices = (('null', 1, 3, 0666), - ('urandom',1, 9, 0666), - ('random', 1, 8, 0666), - ('full', 1, 7, 0666), - ('ptmx', 5, 2, 0666), - ('tty', 5, 0, 0666), - ('zero', 1, 5, 0666)) + devices = (('null', 1, 3, 0o666), + ('urandom',1, 9, 0o666), + ('random', 1, 8, 0o666), + ('full', 1, 7, 0o666), + ('ptmx', 5, 2, 0o666), + ('tty', 5, 0, 0o666), + ('zero', 1, 5, 0o666)) links = (("/proc/self/fd", "/dev/fd"), ("/proc/self/fd/0", "/dev/stdin"), @@ -855,7 +854,7 @@ class BaseImageCreator(object): os.unlink(self._instroot + "/etc/mtab") os.symlink("../proc/mounts", self._instroot + "/etc/mtab") - self.__write_fstab() + #self.__write_fstab() # get size of available space in 'instroot' fs self._root_fs_avail = misc.get_filesystem_avail(self._instroot) @@ -1120,7 +1119,7 @@ class BaseImageCreator(object): #self.__localinst_packages(pkg_manager) self.__check_packages(pkg_manager) - BOOT_SAFEGUARD = 256L * 1024 * 1024 # 256M + BOOT_SAFEGUARD = 256 * 1024 * 1024 # 256M checksize = self._root_fs_avail if checksize: checksize -= BOOT_SAFEGUARD @@ -1132,7 +1131,7 @@ class BaseImageCreator(object): if self.multiple_partitions: pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_DISKSPACE) pkg_manager.runInstall(checksize) - except CreatorError, e: + except CreatorError as e: raise except KeyboardInterrupt: raise @@ -1239,7 +1238,7 @@ class BaseImageCreator(object): msger.info("Running sign scripts ...") if os.path.exists(self._instroot + "/tmp"): shutil.rmtree(self._instroot + "/tmp") - os.mkdir (self._instroot + "/tmp", 0755) + os.mkdir (self._instroot + "/tmp", 0o755) for s in kickstart.get_sign_scripts(self.ks): (fd, path) = tempfile.mkstemp(prefix = "ks-runscript-", dir = self._instroot + "/tmp") @@ -1249,7 +1248,7 @@ class BaseImageCreator(object): os.write(fd, '\n') os.write(fd, 'exit 0\n') os.close(fd) - os.chmod(path, 0700) + os.chmod(path, 0o700) env = self._get_sign_scripts_env() oldoutdir = os.getcwd() @@ -1265,7 +1264,7 @@ class BaseImageCreator(object): if p.returncode != 0: raise CreatorError("Failed to execute %%sign script " "with '%s'" % (s.interp)) - except OSError, (err, msg): + except OSError as msg: raise CreatorError("Failed to execute %%sign script " "with '%s' : %s" % (s.interp, msg)) finally: @@ -1276,7 +1275,7 @@ class BaseImageCreator(object): msger.info("Running post scripts ...") if os.path.exists(self._instroot + "/tmp"): shutil.rmtree(self._instroot + "/tmp") - os.mkdir (self._instroot + "/tmp", 0755) + os.mkdir (self._instroot + "/tmp", 0o755) for s in kickstart.get_post_scripts(self.ks): (fd, path) = tempfile.mkstemp(prefix = "ks-postscript-", dir = self._instroot + "/tmp") @@ -1287,7 +1286,7 @@ class BaseImageCreator(object): os.write(fd, '\n') os.write(fd, 'exit 0\n') os.close(fd) - os.chmod(path, 0700) + os.chmod(path, 0o700) env = self._get_post_scripts_env(s.inChroot) if 'PATH' not in env: @@ -1299,7 +1298,6 @@ class BaseImageCreator(object): else: preexec = self._chroot script = "/tmp/" + os.path.basename(path) - start_time = time.time() try: try: @@ -1311,12 +1309,12 @@ class BaseImageCreator(object): while p.poll() == None: msger.info(p.stdout.readline().strip()) end_time = time.time() - if (end_time - start_time)/60 > MAX_RUN_TIME: - raise CreatorError("Your post script is executed more than "+MAX_RUN_TIME+"mins, please check it!") + if (end_time - start_time)/60 > configmgr.create['postscripts_maxruntime']: + raise CreatorError("Your post script is executed more than %d mins, please check it!" % configmgr.create['postscripts_maxruntime']) if p.returncode != 0: raise CreatorError("Failed to execute %%post script " "with '%s'" % (s.interp)) - except OSError, (err, msg): + except OSError as msg: raise CreatorError("Failed to execute %%post script " "with '%s' : %s" % (s.interp, msg)) finally: @@ -1416,7 +1414,7 @@ class BaseImageCreator(object): # find . | cpio --create --'format=newc' | gzip > ../ramdisk.img runner.show('find . | cpio --create %s | gzip > %s' % (item['cpioopts'], tmp_cpio_imgfile)) os.chdir(oldoutdir) - except OSError, (errno, msg): + except OSError as msg: raise CreatorError("Create image by cpio error: %s" % msg) def copy_cpio_image(self): diff --git a/mic/imager/loop.py b/mic/imager/loop.py index eb9f381..18f226c 100755..100644 --- a/mic/imager/loop.py +++ b/mic/imager/loop.py @@ -16,6 +16,7 @@ # Temple Place - Suite 330, Boston, MA 02111-1307, USA. import os +import sys import glob import shutil @@ -162,13 +163,15 @@ class LoopImageCreator(BaseImageCreator): 'label': label, 'fslabel':fslabel, 'name': imgname, - 'size': part.size or 4096L * 1024 * 1024, + 'size': part.size or 4096 * 1024 * 1024, 'fstype': part.fstype or 'ext3', 'fsopts': part.fsopts or None, 'aft_fstype': aft_fstype or None, 'extopts': part.extopts or None, + 'f2fsopts': part.f2fsopts or None, 'vdfsopts': part.vdfsopts or None, 'squashfsopts': part.squashfsopts or None, + 'squashfsoptions_maxsize': part.squashfsoptions_maxsize or None, 'cpioopts': part.cpioopts or None, 'loop': None, # to be created in _mount_instroot 'uuid': part.uuid or None, @@ -189,7 +192,7 @@ class LoopImageCreator(BaseImageCreator): if self.ks: self.__image_size = kickstart.get_image_size(self.ks, - 4096L * 1024 * 1024) + 4096 * 1024 * 1024) else: self.__image_size = 0 @@ -352,8 +355,9 @@ class LoopImageCreator(BaseImageCreator): "mountpoint": "/", "label": self.name, "name": imgname, - "size": self.__image_size or 4096L, + "size": self.__image_size or 4096, "fstype": self.__fstype or "ext3", + "f2fsopts": None, "extopts": None, "loop": None, "uuid": None, @@ -367,7 +371,7 @@ class LoopImageCreator(BaseImageCreator): fstype = loop['fstype'] fsopt = loop['fsopts'] mp = os.path.join(self._instroot, loop['mountpoint'].lstrip('/')) - size = loop['size'] * 1024L * 1024L + size = loop['size'] * 1024 * 1024 imgname = loop['name'] if fstype in ("ext2", "ext3", "ext4"): @@ -376,6 +380,8 @@ class LoopImageCreator(BaseImageCreator): MyDiskMount = fs.BtrfsDiskMount elif fstype in ("vfat", "msdos"): MyDiskMount = fs.VfatDiskMount + elif fstype == "f2fs": + MyDiskMount = fs.F2fsDiskMount else: raise MountError('Cannot support fstype: %s' % fstype) @@ -391,6 +397,8 @@ class LoopImageCreator(BaseImageCreator): if fstype in ("ext2", "ext3", "ext4"): loop['loop'].extopts = loop['extopts'] + elif fstype == "f2fs": + loop['loop'].f2fsopts = loop['f2fsopts'] try: msger.verbose('Mounting image "%s" on "%s"' % (imgname, mp)) @@ -401,7 +409,7 @@ class LoopImageCreator(BaseImageCreator): loop['loop'].uuid: loop['kspart'].uuid = loop['loop'].uuid - except MountError, e: + except MountError as e: raise def _unmount_instroot(self): @@ -449,6 +457,13 @@ class LoopImageCreator(BaseImageCreator): else: runner.show("%s " % args) + if item['squashfsoptions_maxsize']: + squashfsoptions_maxsize=int(item['squashfsoptions_maxsize']) * 1024 * 1024 + imgsize = os.stat(self._imgdir+"/"+item['label']+fs_suffix).st_size + if imgsize > squashfsoptions_maxsize: + msger.error("squashfs img size is too large (%d > %d)" % (imgsize, squashfsoptions_maxsize)) + sys.exit() + if item['aft_fstype'] == "vdfs": ##FIXME temporary code - replace this with fs.mkvdfs() if item['vdfsopts']: diff --git a/mic/imager/qcow.py b/mic/imager/qcow.py new file mode 100644 index 0000000..f4b66fc --- /dev/null +++ b/mic/imager/qcow.py @@ -0,0 +1,57 @@ +# +# Copyright (c) 2014 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +import os +import shutil + +from mic.imager.loop import LoopImageCreator +from mic.utils import errors, fs_related, runner + +class QcowImageCreator(LoopImageCreator): + img_format = 'qcow' + + def __init__(self, creatoropts=None, pkgmgr=None): + LoopImageCreator.__init__(self, creatoropts, pkgmgr) + self.cmd_qemuimg = 'qemu-img' + + def _stage_final_image(self): + try: + self.cmd_qemuimg = fs_related.find_binary_path('qemu-img') + except errors.CreatorError: + return LoopImageCreator._stage_final_image(self) + + self._resparse() + + imgfile = None + for item in self._instloops: + if item['mountpoint'] == '/': + if item['fstype'] == "ext4": + runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s' + % imgfile) + self.image_files.setdefault('partitions', {}).update( + {item['mountpoint']: item['label']}) + imgfile = os.path.join(self._imgdir, item['name']) + + if imgfile: + qemuimage = imgfile + ".x86" + runner.show("%s convert -O qcow2 %s %s" + % (self.cmd_qemuimg, imgfile, qemuimage)) + os.unlink(imgfile) + os.rename(qemuimage, imgfile) + + for item in os.listdir(self._imgdir): + shutil.move(os.path.join(self._imgdir, item), + os.path.join(self._outdir, item)) diff --git a/mic/imager/raw.py b/mic/imager/raw.py index 82e9a16..452ba8c 100755..100644 --- a/mic/imager/raw.py +++ b/mic/imager/raw.py @@ -372,7 +372,7 @@ class RawImageCreator(BaseImageCreator): % (rootdev, options) if footlabel == 0: syslinux_conf += "\tmenu default\n" - footlabel += 1; + footlabel += 1 msger.debug("Writing syslinux config %s/boot/extlinux/extlinux.conf" \ % self._instroot) @@ -422,7 +422,7 @@ class RawImageCreator(BaseImageCreator): if not self.__instloop is None: try: self.__instloop.cleanup() - except MountError, err: + except MountError as err: msger.warning("%s" % err) def _resparse(self, size = None): diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index 4cf9bd7..46bcca2 100755 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -36,7 +36,6 @@ from mic.utils import errors, misc, runner, fs_related as fs from custom_commands import desktop, micrepo, micboot, partition, installerfw from mic.utils.safeurl import SafeURL - AUTH_URL_PTN = r"(?P<scheme>.*)://(?P<username>.*)(:?P<password>.*)?@(?P<url>.*)" @@ -90,7 +89,7 @@ def apply_wrapper(func): def wrapper(*kargs, **kwargs): try: func(*kargs, **kwargs) - except (OSError, IOError, errors.KsError), err: + except (OSError, IOError, errors.KsError) as err: cfgcls = kargs[0].__class__.__name__ if msger.ask("Failed to apply %s, skip and continue?" % cfgcls): msger.warning("%s" % err) @@ -139,7 +138,7 @@ def read_kickstart(path): try: ks.readKickstart(path) - except (kserrors.KickstartParseError, kserrors.KickstartError), err: + except (kserrors.KickstartParseError, kserrors.KickstartError) as err: if msger.ask("Errors occured on kickstart file, skip and continue?"): msger.warning("%s" % err) pass @@ -237,7 +236,7 @@ class TimezoneConfig(KickstartConfig): subprocess.call([lncmd, "-s", self.path(tz_midst), self.path(tz_dest)]) - except (IOError, OSError), (errno, msg): + except (IOError, OSError) as msg: raise errors.KsError("Timezone setting error: %s" % msg) class AuthConfig(KickstartConfig): @@ -313,7 +312,7 @@ class UserConfig(KickstartConfig): p1 = subprocess.Popen(["/bin/echo", "%s:%s" %(user, password)], stdout = subprocess.PIPE, preexec_fn = self.chroot) - p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-m"], + p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-c","SHA512"], stdin = p1.stdout, stdout = subprocess.PIPE, preexec_fn = self.chroot) @@ -354,6 +353,12 @@ class UserConfig(KickstartConfig): @apply_wrapper def apply(self, user): for userconfig in user.userList: + #There exist root user already. + if userconfig.name == "root": + msger.debug("root user, just set root user groups attribution") + if userconfig.groups: + self.call(["/usr/sbin/usermod", "-a", "-G", "%s" % string.join(userconfig.groups, ","), "root"]) + continue self.addUser(userconfig) class ServicesConfig(KickstartConfig): @@ -372,7 +377,7 @@ class XConfig(KickstartConfig): @apply_wrapper def apply(self, ksxconfig): if ksxconfig.startX and os.path.exists(self.path("/etc/inittab")): - f = open(self.path("/etc/inittab"), "rw+") + f = open(self.path("/etc/inittab"), "r+") buf = f.read() buf = buf.replace("id:3:initdefault", "id:5:initdefault") f.seek(0) @@ -536,7 +541,7 @@ class NetworkConfig(KickstartConfig): p = self.path("/etc/sysconfig/network-scripts/ifcfg-" + network.device) f = file(p, "w+") - os.chmod(p, 0644) + os.chmod(p, 0o644) f.write("DEVICE=%s\n" % network.device) f.write("BOOTPROTO=%s\n" % network.bootProto) @@ -577,14 +582,14 @@ class NetworkConfig(KickstartConfig): p = self.path("/etc/sysconfig/network-scripts/keys-" + network.device) f = file(p, "w+") - os.chmod(p, 0600) + os.chmod(p, 0o600) f.write("KEY=%s\n" % network.wepkey) f.close() def write_sysconfig(self, useipv6, hostname, gateway): path = self.path("/etc/sysconfig/network") f = file(path, "w+") - os.chmod(path, 0644) + os.chmod(path, 0o644) f.write("NETWORKING=yes\n") @@ -614,7 +619,7 @@ class NetworkConfig(KickstartConfig): path = self.path("/etc/hosts") f = file(path, "w+") - os.chmod(path, 0644) + os.chmod(path, 0o644) f.write("127.0.0.1\t\t%s\n" % localline) f.write("::1\t\tlocalhost6.localdomain6 localhost6\n") f.close() @@ -625,7 +630,7 @@ class NetworkConfig(KickstartConfig): path = self.path("/etc/resolv.conf") f = file(path, "w+") - os.chmod(path, 0644) + os.chmod(path, 0o644) for ns in (nameservers): if ns: @@ -672,7 +677,12 @@ class NetworkConfig(KickstartConfig): nameservers = network.nameserver.split(",") self.write_sysconfig(useipv6, hostname, gateway) - self.write_hosts(hostname) + + #to avoid import error because of import each other + from mic.conf import configmgr + path=self.path("/etc/hosts") + if configmgr.create['skip_set_hosts'] == False and os.path.exists(path) == False: + self.write_hosts(hostname) self.write_resolv(nodns, nameservers) def use_installerfw(ks, feature): @@ -691,7 +701,7 @@ def get_image_size(ks, default = None): if p.mountpoint == "/" and p.size: __size = p.size if __size > 0: - return int(__size) * 1024L * 1024L + return int(__size) * 1024 * 1024 else: return default diff --git a/mic/kickstart/custom_commands/desktop.py b/mic/kickstart/custom_commands/desktop.py index c8bd647..a2359b3 100644 --- a/mic/kickstart/custom_commands/desktop.py +++ b/mic/kickstart/custom_commands/desktop.py @@ -57,7 +57,8 @@ class Mic_Desktop(KickstartCommand): def _getParser(self): try: - op = KSOptionParser(lineno=self.lineno) + #ingnore this pylit error, the lineno argument exist in olg version. using this way can compate old version. + op = KSOptionParser(lineno=self.lineno) #pylint: disable=unexpected-keyword-arg except TypeError: # the latest version has not lineno argument op = KSOptionParser() @@ -88,8 +89,8 @@ class Mic_Desktop(KickstartCommand): (opts, extra) = self.op.parse_args(args=args) if extra: - m = _("Unexpected arguments to %(command)s command: %(options)s") \ + m = ("Unexpected arguments to %(command)s command: %(options)s") \ % {"command": "desktop", "options": extra} - raise KickstartValueError, formatErrorMsg(self.lineno, msg=m) + raise KickstartValueError (formatErrorMsg(self.lineno, msg=m)) self._setToSelf(self.op, opts) diff --git a/mic/kickstart/custom_commands/installerfw.py b/mic/kickstart/custom_commands/installerfw.py index 4fa39ed..01deb76 100644 --- a/mic/kickstart/custom_commands/installerfw.py +++ b/mic/kickstart/custom_commands/installerfw.py @@ -58,7 +58,7 @@ class Mic_installerfw(KickstartCommand): if len(extra) != 1: msg = "Kickstart command \"%s\" requires one " \ "argumet - a list of legacy features to disable" % self.currentCmd - raise KickstartValueError, formatErrorMsg(self.lineno, msg = msg) + raise KickstartValueError (formatErrorMsg(self.lineno, msg = msg)) self.features = extra[0].split(",") diff --git a/mic/kickstart/custom_commands/partition.py b/mic/kickstart/custom_commands/partition.py index 341e8dc..b0e9246 100755 --- a/mic/kickstart/custom_commands/partition.py +++ b/mic/kickstart/custom_commands/partition.py @@ -26,11 +26,13 @@ class Mic_PartData(FC4_PartData): self.deleteRemovedAttrs() self.align = kwargs.get("align", None) self.extopts = kwargs.get("extopts", None) + self.f2fsopts = kwargs.get("f2fsopts", None) self.part_type = kwargs.get("part_type", None) self.uuid = kwargs.get("uuid", None) self.exclude_image = kwargs.get("exclude_from_image", False) self.vdfsopts = kwargs.get("vdfsopts", None) self.squashfsopts = kwargs.get("squashfsopts", None) + self.squashfsoptions_maxsize = kwargs.get("squashfsoptions_maxsize", None) self.cpioopts = kwargs.get("cpioopts", None) self.no_shrink = kwargs.get("no_shrink", False) self.init_expand = kwargs.get("init_expand", False) @@ -42,6 +44,8 @@ class Mic_PartData(FC4_PartData): retval += " --align" if self.extopts: retval += " --extoptions=%s" % self.extopts + if self.f2fsopts: + retval += " --f2fsoptions=%s" % self.f2fsopts if self.part_type: retval += " --part-type=%s" % self.part_type if self.uuid: @@ -52,6 +56,8 @@ class Mic_PartData(FC4_PartData): retval += " --vdfsoptions=%s" % self.vdfsopts if self.squashfsopts: retval += " --squashfsoptions=%s" % self.squashfsopts + if self.squashfsoptions_maxsize: + retval += " --squashfsoptions_maxsize=%s" % self.squashfsoptions_maxsize if self.cpioopts: retval += " --cpiooptions=%s" % self.cpioopts if self.no_shrink: @@ -72,6 +78,8 @@ class Mic_Partition(FC4_Partition): default=None) op.add_option("--extoptions", type="string", action="store", dest="extopts", default=None) + op.add_option("--f2fsoptions", type="string", action="store", dest="f2fsopts", + default=None) op.add_option("--part-type", type="string", action="store", dest="part_type", default=None) op.add_option("--uuid", dest="uuid", action="store", type="string") @@ -81,6 +89,8 @@ class Mic_Partition(FC4_Partition): default=None) op.add_option("--squashfsoptions", type="string", action="store", dest="squashfsopts", default=None) + op.add_option("--squashfsoptions_maxsize", type="string", action="store", dest="squashfsoptions_maxsize", + default=None) op.add_option("--cpiooptions", type="string", action="store", dest="cpioopts", default=None) op.add_option("--no-shrink", action="store_true", dest="no_shrink", default=False) diff --git a/mic/plugin.py b/mic/plugin.py index d7150d1..e433e25 100644 --- a/mic/plugin.py +++ b/mic/plugin.py @@ -77,7 +77,7 @@ class PluginMgr(object): self.plugin_dirs[pdir] = True msger.debug("Plugin module %s:%s imported"\ % (mod, pymod.__file__)) - except ImportError, err: + except ImportError as err: msg = 'Failed to load plugin %s/%s: %s' \ % (os.path.basename(pdir), mod, err) msger.verbose(msg) diff --git a/mic/pluginbase.py b/mic/pluginbase.py index ffdd993..db438b6 100644 --- a/mic/pluginbase.py +++ b/mic/pluginbase.py @@ -35,7 +35,7 @@ class _Plugin(object): def show_plugins(cls): for cls in cls.plugins[cls.mic_plugin_type]: - print cls + print (cls) def get_plugins(cls): return cls.plugins diff --git a/mic/rt_util.py b/mic/rt_util.py index 61b0bb2..b79e800 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -15,7 +15,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from __future__ import with_statement import os import sys import glob @@ -30,6 +29,8 @@ from mic.utils import errors, proxy from mic.utils.fs_related import find_binary_path, makedirs from mic.chroot import setup_chrootenv, cleanup_chrootenv, ELF_arch +from mic.plugin import pluginmgr + _libc = ctypes.cdll.LoadLibrary(None) _errno = ctypes.c_int.in_dll(_libc, "errno") _libc.personality.argtypes = [ctypes.c_ulong] @@ -64,8 +65,6 @@ def inbootstrap(): return (os.stat("/").st_ino != 2) def bootstrap_mic(argv=None): - - def mychroot(): os.chroot(rootdir) os.chdir(cwd) @@ -121,13 +120,13 @@ def bootstrap_mic(argv=None): bindmounts = get_bindmounts(cropts) ret = bsenv.run(argv, cwd, rootdir, bindmounts) - except errors.BootstrapError, err: + except errors.BootstrapError as err: raise errors.CreatorError("Failed to download/install bootstrap package " \ "or the package is in bad format: %s" % err) - except RuntimeError, err: + except RuntimeError as err: #change exception type but keep the trace back - value, tb = sys.exc_info()[1:] - raise errors.CreatorError, value, tb + value,tb = sys.exc_info()[1:] + raise errors.CreatorError((value,tb)) else: sys.exit(ret) finally: @@ -221,7 +220,7 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', for key, value in micpaths.items(): try: safecopy(value, _path(eval(key)), False, ["*.pyc", "*.pyo"]) - except (OSError, IOError), err: + except (OSError, IOError) as err: raise errors.BootstrapError(err) # auto select backend @@ -231,7 +230,7 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', wf.write(conf_str) # chmod +x /usr/bin/mic - os.chmod(_path(binpth), 0777) + os.chmod(_path(binpth), 0o777) # correct python interpreter mic_cont = file(_path(binpth)).read() @@ -263,3 +262,55 @@ def safecopy(src, dst, symlinks=False, ignore_ptns=()): makedirs(os.path.dirname(dst)) shutil.copy2(src, dst) + +def prepare_create(args): + """ + Usage: + ${name} ${cmd_name} <ksfile> [OPTS] + + ${cmd_option_list} + """ + + if args is None: + raise errors.Usage("Invalid arguments.") + + creatoropts = configmgr.create + ksconf = args.ksfile + + if creatoropts['runtime'] == 'bootstrap': + configmgr._ksconf = ksconf + bootstrap_mic() + + recording_pkgs = [] + if len(creatoropts['record_pkgs']) > 0: + recording_pkgs = creatoropts['record_pkgs'] + + if creatoropts['release'] is not None: + if 'name' not in recording_pkgs: + recording_pkgs.append('name') + if 'vcs' not in recording_pkgs: + recording_pkgs.append('vcs') + + configmgr._ksconf = ksconf + + # try to find the pkgmgr + pkgmgr = None + backends = pluginmgr.get_plugins('backend') + if 'auto' == creatoropts['pkgmgr']: + for key in configmgr.prefer_backends: + if key in backends: + pkgmgr = backends[key] + break + else: + for key in backends.keys(): + if key == creatoropts['pkgmgr']: + pkgmgr = backends[key] + break + + if not pkgmgr: + raise errors.CreatorError("Can't find backend: %s, " + "available choices: %s" % + (creatoropts['pkgmgr'], + ','.join(backends.keys()))) + return creatoropts, pkgmgr, recording_pkgs + diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py index 11f6801..9e2e2c3 100755 --- a/mic/utils/fs_related.py +++ b/mic/utils/fs_related.py @@ -66,18 +66,18 @@ def makedirs(dirname): """ try: os.makedirs(dirname) - except OSError, err: + except OSError as err: if err.errno != errno.EEXIST: raise def mkvdfs(in_img, out_img, fsoptions): """ This function is incomplete. """ fullpathmkvdfs = find_binary_path("mkfs.vdfs") -# args = fullpathmkvdfs + " -i -r "+ in_img + " -z 1024M -s " + out_img +# args = fullpathmkvdfs + " -i -r "+ in_img + " -z 1024M -s " + out_img args = fullpathmkvdfs + " " + fsoptions + " -r " + in_img + " " + out_img msger.verbose("vdfs args: %s" % args) runner.show("%s --help" % fullpathmkvdfs) -# if not sys.stdout.isatty(): +# if not sys.stdout.isatty(): # args.append("-no-progress") # runner.show("%s --help" % fullpathmkvdfs) ret = runner.show(args) @@ -139,7 +139,7 @@ class BindChrootMount: try: makedirs(self.dest) - except OSError, err: + except OSError as err: if err.errno == errno.ENOSPC: msger.warning("No space left on device '%s'" % err.filename) return @@ -333,7 +333,7 @@ class SparseLoopbackDisk(LoopbackDisk): msger.debug("Extending sparse file %s to %d" % (self.lofile, size)) if create: - fd = os.open(self.lofile, flags, 0644) + fd = os.open(self.lofile, flags, 0o644) else: fd = os.open(self.lofile, flags) @@ -343,7 +343,7 @@ class SparseLoopbackDisk(LoopbackDisk): os.ftruncate(fd, size) except: # may be limited by 2G in 32bit env - os.ftruncate(fd, 2**31L) + os.ftruncate(fd, 2**31) os.close(fd) @@ -411,7 +411,7 @@ class DiskMount(Mount): if self.rmdir and not self.mounted: try: os.rmdir(self.mountdir) - except OSError, e: + except OSError as e: pass self.rmdir = False @@ -446,6 +446,130 @@ class DiskMount(Mount): self.mounted = True +class F2fsDiskMount(DiskMount): + """A DiskMount object that is able to format/resize f2fs filesystems.""" + def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None, fsuuid=None): + self.__check_f2fs() + DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir) + self.blocksize = blocksize + self.fslabel = fslabel.replace("/", "") + self.uuid = fsuuid or None + self.skipformat = skipformat + self.fsopts = fsopts + self.__f2fsopts = None + self.blkidcmd = find_binary_path("blkid") + self.dumpe2fs = find_binary_path("dump." + self.fstype) + self.fsckcmd = find_binary_path("fsck." + self.fstype) + self.resizecmd = find_binary_path("resize." + self.fstype) + + def __get_f2fsopts(self): + return self.__f2f2opts + + def __set_f2fsopts(self, val): + if val is None: + self.__f2fsopts = None + else: + self.__f2fsopts = val + f2fsopts = property(__get_f2fsopts, __set_f2fsopts) + + def __check_f2fs(self): + found = False + """ Need to load f2fs module to mount it """ + load_module("f2fs") + for line in open("/proc/filesystems").xreadlines(): + if line.find("f2fs") > -1: + found = True + break + if not found: + raise MountError("Your system can't mount f2fs filesystem, please make sure your kernel has f2fs support and the module f2fs.ko has been loaded.") + + def __parse_field(self, output, field): + for line in output.split(" "): + if line.startswith(field + "="): + return line[len(field) + 1:].strip().replace("\"", "") + + raise KeyError("Failed to find field '%s' in output" % field) + + def __format_filesystem(self): + if self.skipformat: + msger.debug("Skip filesystem format.") + return + + msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device)) + + cmdlist = [self.mkfscmd, "-l", self.fslabel] + if self.__f2fsopts: + cmdlist.extend(self.__f2fsopts.split()) + cmdlist.extend([self.disk.device]) + + rc, errout = runner.runtool(cmdlist, catch=2) + if rc != 0: + raise MountError("Error creating %s filesystem on disk %s:\n%s" % + (self.fstype, self.disk.device, errout)) + + self.uuid = self.__parse_field(runner.outs([self.blkidcmd, self.disk.device]), "UUID") + + def __resize_filesystem(self, size = None): + msger.info("Resizing filesystem ...") + current_size = os.stat(self.disk.lofile)[stat.ST_SIZE] + + if size is None: + size = self.disk.size + + if size == current_size: + return + + if size > current_size: + self.disk.expand(size=size) + + self.__fsck() + + return size + + def __create(self): + resize = False + if not self.disk.fixed() and self.disk.exists(): + resize = True + + self.disk.create() + + if resize: + self.__resize_filesystem() + else: + self.__format_filesystem() + + def mount(self, options = None, init_expand = False): + self.__create() + if init_expand: + expand_size = long(self.disk.size * 1.5) + msger.info("Initial partition size expanded : %ld -> %ld" % (self.disk.size, expand_size)) + self.__resize_filesystem(expand_size) + self.disk.reread_size() + DiskMount.mount(self, options) + + def __fsck(self): + msger.info("Checking filesystem %s" % self.disk.lofile) + runner.quiet([self.fsckcmd, self.disk.lofile]) + + def __get_size_from_filesystem(self): + return self.disk.size + + def __resize_to_minimal(self): + msger.info("Resizing filesystem to minimal ...") + self.__fsck() + + return self.__get_size_from_filesystem() + + def resparse(self, size = None): + self.cleanup() + if size == 0: + minsize = 0 + else: + minsize = self.__resize_to_minimal() + self.disk.truncate(minsize) + self.__resize_filesystem(size) + return minsize + class ExtDiskMount(DiskMount): """A DiskMount object that is able to format/resize ext[23] filesystems.""" def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None, fsuuid=None): @@ -519,7 +643,7 @@ class ExtDiskMount(DiskMount): resize2fs(self.disk.lofile, size) if size and size != os.stat(self.disk.lofile)[stat.ST_SIZE]: - raise MountError("Failed to resize filesystem %s to " % (self.disk.lofile, size)) + raise MountError("Failed to resize filesystem %s to %d " % (self.disk.lofile, size)) return size @@ -699,7 +823,7 @@ class BtrfsDiskMount(DiskMount): return msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device)) - rc = runner.show([self.mkfscmd, "-L", self.fslabel, self.disk.device]) + rc = runner.show([self.mkfscmd, "-L", self.fslabel, "-m", "single", self.disk.device]) if rc != 0: raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device)) @@ -854,7 +978,7 @@ def create_image_minimizer(path, image, minimal_size): imgloop = LoopbackDisk(image, None) # Passing bogus size - doesn't matter cowloop = SparseLoopbackDisk(os.path.join(os.path.dirname(path), "osmin"), - 64L * 1024L * 1024L) + 64 * 1024 * 1024) snapshot = DeviceMapperSnapshot(imgloop, cowloop) @@ -906,10 +1030,11 @@ class LoopDevice(object): return 10 fint = lambda x: x[9:].isdigit() and int(x[9:]) or 0 - maxid = 1 + max(filter(lambda x: x<100, + maxid = 1 + max(filter(lambda x: x<256, map(fint, glob.glob("/dev/loop[0-9]*")))) if maxid < 10: maxid = 10 - if maxid >= 100: raise + if maxid >= 256: + raise Exception("maxid >= 256") return maxid def _kpseek(self, device): @@ -956,7 +1081,7 @@ class LoopDevice(object): try: self.cleanup() self.device = None - except MountError, e: + except MountError as e: raise CreatorError("%s" % e) def cleanup(self): @@ -979,9 +1104,6 @@ DEVICE_PIDFILE_DIR = "/var/tmp/mic/device" DEVICE_LOCKFILE = "/var/lock/__mic_loopdev.lock" def get_loop_device(losetupcmd, lofile): - global DEVICE_PIDFILE_DIR - global DEVICE_LOCKFILE - import fcntl makedirs(os.path.dirname(DEVICE_LOCKFILE)) fp = open(DEVICE_LOCKFILE, 'w') @@ -1017,7 +1139,7 @@ def get_loop_device(losetupcmd, lofile): with open(pidfile, 'w') as wf: wf.write(str(os.getpid())) - except MountError, err: + except MountError as err: raise CreatorError("%s" % str(err)) except: raise diff --git a/mic/utils/gpt_parser.py b/mic/utils/gpt_parser.py index 895600d..c499e81 100644 --- a/mic/utils/gpt_parser.py +++ b/mic/utils/gpt_parser.py @@ -282,7 +282,7 @@ class GptParser: if entry['index'] >= header['entries_cnt']: raise MountError("Partition table at LBA %d has only %d " \ - "records cannot change record number %d" % \ + "records cannot change record number " % \ (header['entries_cnt'], entry['index'])) # Read raw GPT header raw_hdr = self._read_disk(header['hdr_offs'], _GPT_HEADER_SIZE) diff --git a/mic/utils/grabber.py b/mic/utils/grabber.py index c42dc02..a87d5a4 100644 --- a/mic/utils/grabber.py +++ b/mic/utils/grabber.py @@ -56,7 +56,7 @@ def myurlgrab(url, filename, proxies, progress_obj = None): http_headers=(('Pragma', 'no-cache'),), quote=0, progress_obj=progress_obj) - except grabber.URLGrabError, err: + except grabber.URLGrabError as err: tmp = SafeURL(url) msg = str(err) diff --git a/mic/utils/misc.py b/mic/utils/misc.py index be14d01..a49e20f 100755 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -160,7 +160,7 @@ def hide_loopdev_presentation(): pass def unhide_loopdev_presentation(): - global _LOOP_RULE_PTH + #global _LOOP_RULE_PTH if not _LOOP_RULE_PTH: return @@ -302,7 +302,7 @@ def normalize_ksfile(ksconf, release, arch): def remove_temp_ks(): try: os.unlink(ksconf) - except OSError, err: + except OSError as err: msger.warning('Failed to remove temp ks file:%s:%s' % (ksconf, err)) import atexit @@ -375,6 +375,11 @@ def get_image_type(path): if file_header[0:len(vdi_flag)] == vdi_flag: return maptab["vdi"] + #Checking f2fs fs type. + blkidcmd = find_binary_path("blkid") + out = runner.outs([blkidcmd, '-o', 'value', '-s', 'TYPE', path]) + if out == "f2fs": + return "f2fsimg" output = runner.outs(['file', path]) isoptn = re.compile(r".*ISO 9660 CD-ROM filesystem.*(bootable).*") usbimgptn = re.compile(r".*x86 boot sector.*active.*") @@ -569,7 +574,8 @@ def get_metadata_from_repos(repos, cachedir): break for elm in root.getiterator("%sdata" % ns): - if elm.attrib["type"] in ("group_gz", "group"): + #"group" type has no "open-checksum" filed, remove it. + if elm.attrib["type"] == "group_gz": filepaths['comps'] = elm.find("%slocation" % ns).attrib['href'] checksums['comps'] = elm.find("%sopen-checksum" % ns).text sumtypes['comps'] = elm.find("%sopen-checksum" % ns).attrib['type'] @@ -715,26 +721,25 @@ def get_package(pkg, repometadata, arch = None): ns = root.getroot().tag ns = ns[0:ns.rindex("}")+1] for elm in root.getiterator("%spackage" % ns): - if elm.find("%sname" % ns).text == pkg: - if elm.find("%sarch" % ns).text in arches: - if repo["priority"] != None: - tmpprior = int(repo["priority"]) - if tmpprior < priority: - priority = tmpprior - location = elm.find("%slocation" % ns) - pkgpath = "%s" % location.attrib['href'] - target_repo = repo - break - elif tmpprior > priority: - break - version = elm.find("%sversion" % ns) - tmpver = "%s-%s" % (version.attrib['ver'], version.attrib['rel']) - if tmpver > ver: - ver = tmpver + if elm.find("%sname" % ns).text == pkg and elm.find("%sarch" % ns).text in arches: + if repo["priority"] != None: + tmpprior = int(repo["priority"]) + if tmpprior < priority: + priority = tmpprior location = elm.find("%slocation" % ns) pkgpath = "%s" % location.attrib['href'] target_repo = repo - break + break + elif tmpprior > priority: + break + version = elm.find("%sversion" % ns) + tmpver = "%s-%s" % (version.attrib['ver'], version.attrib['rel']) + if tmpver > ver: + ver = tmpver + location = elm.find("%slocation" % ns) + pkgpath = "%s" % location.attrib['href'] + target_repo = repo + break if repo["primary"].endswith(".sqlite"): con = sqlite.connect(repo["primary"]) if arch: @@ -898,18 +903,7 @@ def get_pkglist_in_comps(group, comps): def is_statically_linked(binary): return ", statically linked, " in runner.outs(['file', binary]) -def setup_qemu_emulator(rootdir, arch): - qemu_emulators = [] - # mount binfmt_misc if it doesn't exist - if not os.path.exists("/proc/sys/fs/binfmt_misc"): - modprobecmd = find_binary_path("modprobe") - runner.show([modprobecmd, "binfmt_misc"]) - if not os.path.exists("/proc/sys/fs/binfmt_misc/register"): - mountcmd = find_binary_path("mount") - runner.show([mountcmd, "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"]) - - # qemu_emulator is a special case, we can't use find_binary_path - # qemu emulator should be a statically-linked executable file +def get_qemu_arm_binary(arch): if arch == "aarch64": node = "/proc/sys/fs/binfmt_misc/aarch64" if os.path.exists("/usr/bin/qemu-arm64") and is_statically_linked("/usr/bin/qemu-arm64"): @@ -937,6 +931,21 @@ def setup_qemu_emulator(rootdir, arch): if not os.path.exists("/usr/bin/%s" % arm_binary): raise CreatorError("Please install a statically-linked %s" % arm_binary) + return (arm_binary, node) + +def setup_qemu_emulator(rootdir, arch): + qemu_emulators = [] + # mount binfmt_misc if it doesn't exist + if not os.path.exists("/proc/sys/fs/binfmt_misc"): + modprobecmd = find_binary_path("modprobe") + runner.show([modprobecmd, "binfmt_misc"]) + if not os.path.exists("/proc/sys/fs/binfmt_misc/register"): + mountcmd = find_binary_path("mount") + runner.show([mountcmd, "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"]) + + # qemu_emulator is a special case, we can't use find_binary_path + # qemu emulator should be a statically-linked executable file + arm_binary, node = get_qemu_arm_binary(arch) qemu_emulator = "/usr/bin/%s" % arm_binary if not os.path.exists(rootdir + "/usr/bin"): diff --git a/mic/utils/proxy.py b/mic/utils/proxy.py index 438f529..ca884a2 100644 --- a/mic/utils/proxy.py +++ b/mic/utils/proxy.py @@ -25,7 +25,6 @@ _my_noproxy = None _my_noproxy_list = [] def set_proxy_environ(): - global _my_noproxy, _my_proxies if not _my_proxies: return for key in _my_proxies.keys(): @@ -78,6 +77,8 @@ def _ip_to_int(ip): ipint = 0 shift = 24 for dec in ip.split("."): + if not dec.isdigit(): + continue ipint |= int(dec) << shift shift -= 8 return ipint @@ -118,7 +119,7 @@ def _set_noproxy_list(): c_result = os.popen(cmd).readlines() if len(c_result) == 0: continue - except Exception,e: + except Exception as e: msger.warning(str(e)) continue to_list = c_result[0].strip("\n").split(",") @@ -152,6 +153,8 @@ def _set_noproxy_list(): shift = 24 netmask = 0 for dec in mask.split("."): + if not dec.isdigit(): + continue netmask |= int(dec) << shift shift -= 8 ip &= netmask diff --git a/mic/utils/rpmmisc.py b/mic/utils/rpmmisc.py index eb481f8..a656e40 100644 --- a/mic/utils/rpmmisc.py +++ b/mic/utils/rpmmisc.py @@ -154,7 +154,7 @@ class RPMInstallCallback: elif what == rpm.RPMCALLBACK_INST_PROGRESS: if h is not None: - percent = (self.total_installed*100L)/self.total_actions + percent = (self.total_installed*100)/self.total_actions if total > 0: try: hdr, rpmloc = h @@ -414,7 +414,7 @@ def checkSig(ts, package): try: hdr = ts.hdrFromFdno(fdno) - except rpm.error, e: + except rpm.error as e: if str(e) == "public key not availaiable": value = 1 if str(e) == "public key not available": diff --git a/mic/utils/runner.py b/mic/utils/runner.py index 6d68e26..cd361a1 100644 --- a/mic/utils/runner.py +++ b/mic/utils/runner.py @@ -68,7 +68,7 @@ def runtool(cmdln_or_args, catch=1): (sout, serr) = p.communicate() # combine stdout and stderr, filter None out out = ''.join(filter(None, [sout, serr])) - except OSError, e: + except OSError as e: if e.errno == 2: # [Errno 2] No such file or directory raise errors.CreatorError('Cannot run command: %s, lost dependency?' % cmd) diff --git a/packaging/mic.changes b/packaging/mic.changes index a2de735..10ecdd2 100755..100644 --- a/packaging/mic.changes +++ b/packaging/mic.changes @@ -1,3 +1,47 @@ +* Thu Aug 10 2022 Biao Wang <biao716.wang@samsung.com> - 0.28.17 + * Add block-recommends option to block install recommends packages. + +* Thu Feb 10 2022 Biao Wang <biao716.wang@samsung.com> - 0.28.16 + * Add postscripts-maxruntime option to set the max run time for post scripts. + +* Mon Jul 05 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.15 + * Don't install recommended packages in mic. + +* Fri May 14 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.14 + * Encrypt user password with SHA512 instead of MD5. + * Fix pylint error, reimport glob. + +* Tue Mar 23 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.13 + * Add new squashfs option for squashfs file system. + +* Fri Feb 05 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.12 + * Support to create image with f2fs file system. + * Fix the bug that no print last installed package. + * Remove urlgrabber directory from mic. + +* Thu Nov 05 2020 Biao Wang <biao716.wang@samsung.com> - 0.28.11 + * add dependece for yum directly. + * fix run error issue for parser repomd.xml when here is group type. + * Refine code, remove duplicated code + * Separate qcow plugin scripts + +* Tue Jul 21 2020 Biao Wang <biao716.wang@samsung.com> - 0.28.10 + * Create btrfs images with the metadata single option. + * Refine code with SAM tools check. + +* Wed Jun 17 2020 Yan Meng <yan11.meng@samsung.com> - 0.28.9 + * increase max loop device number in mic. + * fix build error with Typeerror. + * Fix the bug that truncates existing inittab file. + +* Thu May 7 2020 Yan Meng <yan11.meng@samsung.com> - 0.28.8 + * remove unnecessary /etc/fstab file. + +* Mon Feb 17 2020 Yan Meng <yan11.meng@samsung.com> - 0.28.7 + * fix pylint errors for mic. + * add option for mic to skip set hosts when create. + * skip set hosts by mic when /etc/hosts exists. + * Fri Feb 15 2019 Jin Xiao <jin.xiao@samsung.com> - 0.28.6 * new distribution support: Ubuntu 18.04. diff --git a/packaging/mic.spec b/packaging/mic.spec index fdbe655..28bc1a2 100755 --- a/packaging/mic.spec +++ b/packaging/mic.spec @@ -9,19 +9,17 @@ Name: mic Summary: Image Creator for Linux Distributions -Version: 0.28.6 -Release: 0 +Version: 0.28.17 +Release: %{?release_prefix}%{?opensuse_bs:<CI_CNT>.<B_CNT>}%{!?opensuse_bs:0} Group: Development/Tools License: GPLv2 BuildArch: noarch URL: http://www.tizen.org Source0: %{name}_%{version}.tar.gz -%if 0%{?tizen_version:1} -Source1001: mic.manifest -%endif Requires: python >= 2.6 Requires: python-urlgrabber >= 3.9.0 +Requires: yum %if 0%{?suse_version} || 0%{?tizen_version:1} Requires: python-xml %endif @@ -41,20 +39,14 @@ Requires: cpio Requires: gzip Requires: bzip2 -%if 0%{?tizen_version:1} -Requires: qemu-linux-user -%else -Requires: qemu-arm-static -%endif - BuildRequires: python-devel %if ! 0%{?tizen_version:1} BuildRequires: python-docutils %endif -%if ! 0%{?centos_version} -BuildRequires:fdupes -%endif +Obsoletes: mic2 + +BuildRoot: %{_tmppath}/%{name}_%{version}-build %description The tool mic is used to create and manipulate images for Linux distributions. @@ -65,29 +57,22 @@ an image. %prep %setup -q -n %{name}-%{version} -%if 0%{?tizen_version:1} -cp %{SOURCE1001} . -%endif %build CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build -%if ! 0%{?tizen_version:1} make man -%endif %install -rm -rf %{buildroot} +rm -rf $RPM_BUILD_ROOT %if 0%{?suse_version} -%{__python} setup.py install --root=%{buildroot} --prefix=%{_prefix} +%{__python} setup.py install --root=$RPM_BUILD_ROOT --prefix=%{_prefix} %else -%{__python} setup.py install --root=%{buildroot} -O1 +%{__python} setup.py install --root=$RPM_BUILD_ROOT -O1 %endif # install man page mkdir -p %{buildroot}/%{_prefix}/share/man/man1 -%if ! 0%{?tizen_version:1} install -m644 doc/mic.1 %{buildroot}/%{_prefix}/share/man/man1 -%endif # install bash completion install -d -m0755 %{buildroot}/%{_sysconfdir}/bash_completion.d/ @@ -97,21 +82,10 @@ install -Dp -m0755 etc/bash_completion.d/%{name}.sh %{buildroot}/%{_sysconfdir}/ install -d -m0755 %{buildroot}/%{_sysconfdir}/zsh_completion.d/ install -Dp -m0755 etc/zsh_completion.d/_%{name} %{buildroot}/%{_sysconfdir}/zsh_completion.d/ -%if ! 0%{?centos_version} -%fdupes %{buildroot} -%endif - - %files -%if 0%{?tizen_version:1} -%manifest %{name}.manifest -%endif %defattr(-,root,root,-) -%if ! (0%{?suse_version} || 0%{?centos_version}) -%license COPYING -%endif %doc doc/* -%doc README.rst AUTHORS ChangeLog +%doc README.rst AUTHORS COPYING ChangeLog %if ! 0%{?tizen_version:1} %{_mandir}/man1/* %endif diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 8f3112d..d63c592 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -77,7 +77,7 @@ class MyYumRepository(yum.yumRepo.YumRepository): import M2Crypto m2c_connection = M2Crypto.SSL.Connection.clientPostConnectionCheck M2Crypto.SSL.Connection.clientPostConnectionCheck = None - except ImportError, err: + except ImportError as err: raise CreatorError("%s, please try to install python-m2crypto" % str(err)) proxy = None @@ -165,7 +165,7 @@ class Yum(BackendPlugin, yum.YumBase): f.write(conf) f.close() - os.chmod(confpath, 0644) + os.chmod(confpath, 0o644) def _cleanupRpmdbLocks(self, installroot): # cleans up temporary files left by bdb so that differing @@ -205,9 +205,9 @@ class Yum(BackendPlugin, yum.YumBase): return None except yum.Errors.InstallError: return "No package(s) available to install" - except yum.Errors.RepoError, e: + except yum.Errors.RepoError as e: raise CreatorError("Unable to download from repo : %s" % (e,)) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: raise CreatorError("Unable to install: %s" % (e,)) def deselectPackage(self, pkg): @@ -252,11 +252,11 @@ class Yum(BackendPlugin, yum.YumBase): self.selectPackage(p) return None - except (yum.Errors.InstallError, yum.Errors.GroupsError), e: + except (yum.Errors.InstallError, yum.Errors.GroupsError) as e: return e - except yum.Errors.RepoError, e: + except yum.Errors.RepoError as e: raise CreatorError("Unable to download from repo : %s" % (e,)) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: raise CreatorError("Unable to install: %s" % (e,)) def addRepository(self, name, url = None, mirrorlist = None, proxy = None, @@ -308,9 +308,9 @@ class Yum(BackendPlugin, yum.YumBase): ts = rpmUtils.transaction.initReadOnlyTransaction() try: hdr = rpmUtils.miscutils.hdrFromPackage(ts, pkg) - except rpmUtils.RpmUtilsError, e: - raise yum.Errors.MiscError, \ - 'Could not open local rpm file: %s: %s' % (pkg, e) + except rpmUtils.RpmUtilsError as e: + raise yum.Errors.MiscError \ + ('Could not open local rpm file: %s: %s' % (pkg, e)) self.deselectPackage(hdr['name']) yum.YumBase.installLocal(self, pkg, po, updateonly) @@ -335,7 +335,7 @@ class Yum(BackendPlugin, yum.YumBase): os.environ["LD_PRELOAD"] = "" try: (res, resmsg) = self.buildTransaction() - except yum.Errors.RepoError, e: + except yum.Errors.RepoError as e: raise CreatorError("Unable to download from repo : %s" %(e,)) if res != 2: @@ -393,7 +393,7 @@ class Yum(BackendPlugin, yum.YumBase): raise CreatorError("No enough space used for downloading.") # record the total size of installed pkgs - pkgs_total_size = 0L + pkgs_total_size = 0 for x in dlpkgs: if hasattr(x, 'installedsize'): pkgs_total_size += int(x.installedsize) @@ -444,11 +444,11 @@ class Yum(BackendPlugin, yum.YumBase): raise CreatorError("mic failes to install some packages") self._cleanupRpmdbLocks(self.conf.installroot) - except rpmUtils.RpmUtilsError, e: + except rpmUtils.RpmUtilsError as e: raise CreatorError("mic does NOT support delta rpm: %s" % e) - except yum.Errors.RepoError, e: + except yum.Errors.RepoError as e: raise CreatorError("Unable to download from repo : %s" % e) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: raise CreatorError("Unable to install: %s" % e) finally: msger.disable_logstderr() @@ -468,7 +468,7 @@ class Yum(BackendPlugin, yum.YumBase): } try: self.__pkgs_vcsinfo[lname] = hdr['VCS'] - except ValueError, KeyError: + except ValueError as KeyError: self.__pkgs_vcsinfo[lname] = None return self.__pkgs_vcsinfo diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index 77b942e..afddfd7 100644 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -21,7 +21,7 @@ import urlparse import rpm import glob -import zypp +import zypp #pylint: disable=import-error if not hasattr(zypp, 'PoolQuery') or \ not hasattr(zypp.RepoManager, 'loadSolvFile'): raise ImportError("python-zypp in host system cannot support PoolQuery or " @@ -109,7 +109,6 @@ class Zypp(BackendPlugin): def _cleanupRpmdbLocks(self, installroot): # cleans up temporary files left by bdb so that differing # versions of rpm don't cause problems - import glob for f in glob.glob(installroot + "/var/lib/rpm/__db*"): os.unlink(f) @@ -449,7 +448,7 @@ class Zypp(BackendPlugin): self.__build_repo_cache(name) - except RuntimeError, e: + except RuntimeError as e: raise CreatorError(str(e)) msger.verbose('repo: %s was added' % name) @@ -592,14 +591,14 @@ class Zypp(BackendPlugin): if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) - except CreatorError, e: + except CreatorError as e: raise CreatorError("Package download failed: %s" %(e,)) try: self.installPkgs(dlpkgs) except (RepoError, RpmError): raise - except Exception, e: + except Exception as e: raise CreatorError("Package installation failed: %s" % (e,)) def getVcsInfo(self): @@ -722,6 +721,9 @@ class Zypp(BackendPlugin): self.repo_manager.loadFromCache(repo) self.Z = zypp.ZYppFactory_instance().getZYpp() + if configmgr.create['block_recommends']: + msger.info("zypp not install recommend packages") + self.Z.resolver().setOnlyRequires(True) self.Z.initializeTarget(zypp.Pathname(self.instroot)) self.Z.target().load() @@ -835,6 +837,26 @@ class Zypp(BackendPlugin): for e in errors: msger.warning(e[0]) raise RepoError('Could not run transaction.') + def show_unresolved_dependencies_msg(self, unresolved_dependencies): + for pkg, need, needflags, sense, key in unresolved_dependencies: + + package = '-'.join(pkg) + + if needflags == rpm.RPMSENSE_LESS: + deppkg = ' < '.join(need) + elif needflags == rpm.RPMSENSE_EQUAL: + deppkg = ' = '.join(need) + elif needflags == rpm.RPMSENSE_GREATER: + deppkg = ' > '.join(need) + else: + deppkg = '-'.join(need) + + if sense == rpm.RPMDEP_SENSE_REQUIRES: + msger.warning("[%s] Requires [%s], which is not provided" \ + % (package, deppkg)) + + elif sense == rpm.RPMDEP_SENSE_CONFLICTS: + msger.warning("[%s] Conflicts with [%s]" % (package, deppkg)) def installPkgs(self, package_objects): if not self.ts: @@ -906,25 +928,7 @@ class Zypp(BackendPlugin): raise RepoError('Could not run transaction.') else: - for pkg, need, needflags, sense, key in unresolved_dependencies: - package = '-'.join(pkg) - - if needflags == rpm.RPMSENSE_LESS: - deppkg = ' < '.join(need) - elif needflags == rpm.RPMSENSE_EQUAL: - deppkg = ' = '.join(need) - elif needflags == rpm.RPMSENSE_GREATER: - deppkg = ' > '.join(need) - else: - deppkg = '-'.join(need) - - if sense == rpm.RPMDEP_SENSE_REQUIRES: - msger.warning("[%s] Requires [%s], which is not provided" \ - % (package, deppkg)) - - elif sense == rpm.RPMDEP_SENSE_CONFLICTS: - msger.warning("[%s] Conflicts with [%s]" % (package, deppkg)) - + self.show_unresolved_dependencies_msg(unresolved_dependencies) raise RepoError("Unresolved dependencies, transaction failed.") def __initialize_transaction(self): diff --git a/plugins/imager/fs_plugin.py b/plugins/imager/fs_plugin.py index c639211..21bb544 100755 --- a/plugins/imager/fs_plugin.py +++ b/plugins/imager/fs_plugin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#! /usr/bin/python2 # # Copyright (c) 2011 Intel, Inc. # @@ -19,7 +19,6 @@ import subprocess from mic import chroot, msger, rt_util from mic.utils import misc, errors, fs_related, runner from mic.imager import fs -from mic.conf import configmgr from mic.plugin import pluginmgr from mic.pluginbase import ImagerPlugin @@ -30,53 +29,8 @@ class FsPlugin(ImagerPlugin): def do_create(self, args): """${cmd_name}: create fs image - Usage: - ${name} ${cmd_name} <ksfile> [OPTS] - - ${cmd_option_list} """ - - if args is None: - raise errors.Usage("Invalid arguments.") - - creatoropts = configmgr.create - ksconf = args.ksfile - - if creatoropts['runtime'] == 'bootstrap': - configmgr._ksconf = ksconf - rt_util.bootstrap_mic() - - recording_pkgs = [] - if len(creatoropts['record_pkgs']) > 0: - recording_pkgs = creatoropts['record_pkgs'] - - if creatoropts['release'] is not None: - if 'name' not in recording_pkgs: - recording_pkgs.append('name') - if 'vcs' not in recording_pkgs: - recording_pkgs.append('vcs') - - configmgr._ksconf = ksconf - - # try to find the pkgmgr - pkgmgr = None - backends = pluginmgr.get_plugins('backend') - if 'auto' == creatoropts['pkgmgr']: - for key in configmgr.prefer_backends: - if key in backends: - pkgmgr = backends[key] - break - else: - for key in backends.keys(): - if key == creatoropts['pkgmgr']: - pkgmgr = backends[key] - break - - if not pkgmgr: - raise errors.CreatorError("Can't find backend: %s, " - "available choices: %s" % - (creatoropts['pkgmgr'], - ','.join(backends.keys()))) + creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args) creator = fs.FsImageCreator(creatoropts, pkgmgr) creator._include_src = args.include_src @@ -108,7 +62,7 @@ class FsPlugin(ImagerPlugin): creator.package(creatoropts["destdir"]) creator.create_manifest() if creatoropts['release'] is not None: - creator.release_output(ksconf, creatoropts['destdir'], + creator.release_output(args.ksfile, creatoropts['destdir'], creatoropts['release']) creator.print_outimage_info() except errors.CreatorError: @@ -121,7 +75,7 @@ class FsPlugin(ImagerPlugin): cmd = creatoropts['run_script'] try: runner.show(cmd) - except OSError,err: + except OSError as err: msger.warning(str(err)) diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py index 0b94f0e..f35ffd8 100755 --- a/plugins/imager/loop_plugin.py +++ b/plugins/imager/loop_plugin.py @@ -22,7 +22,6 @@ import tempfile from mic import chroot, msger, rt_util from mic.utils import misc, fs_related, errors, runner -from mic.conf import configmgr from mic.plugin import pluginmgr from mic.imager.loop import LoopImageCreator, load_mountpoints @@ -33,54 +32,9 @@ class LoopPlugin(ImagerPlugin): @classmethod def do_create(self, args): """${cmd_name}: create loop image - - Usage: - ${name} ${cmd_name} <ksfile> [OPTS] - - ${cmd_option_list} """ - if args is None: - raise errors.Usage("Invalid arguments") - - creatoropts = configmgr.create - ksconf = args.ksfile - - if creatoropts['runtime'] == "bootstrap": - configmgr._ksconf = ksconf - rt_util.bootstrap_mic() - - recording_pkgs = [] - if len(creatoropts['record_pkgs']) > 0: - recording_pkgs = creatoropts['record_pkgs'] - - if creatoropts['release'] is not None: - if 'name' not in recording_pkgs: - recording_pkgs.append('name') - if 'vcs' not in recording_pkgs: - recording_pkgs.append('vcs') - - configmgr._ksconf = ksconf - - # try to find the pkgmgr - pkgmgr = None - backends = pluginmgr.get_plugins('backend') - if 'auto' == creatoropts['pkgmgr']: - for key in configmgr.prefer_backends: - if key in backends: - pkgmgr = backends[key] - break - else: - for key in backends.keys(): - if key == creatoropts['pkgmgr']: - pkgmgr = backends[key] - break - - if not pkgmgr: - raise errors.CreatorError("Can't find backend: %s, " - "available choices: %s" % - (creatoropts['pkgmgr'], - ','.join(backends.keys()))) + creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args) creator = LoopImageCreator(creatoropts, pkgmgr, @@ -111,7 +65,7 @@ class LoopPlugin(ImagerPlugin): creator.create_manifest() if creatoropts['release'] is not None: - creator.release_output(ksconf, + creator.release_output(args.ksfile, creatoropts['destdir'], creatoropts['release']) creator.print_outimage_info() @@ -126,7 +80,7 @@ class LoopPlugin(ImagerPlugin): cmd = creatoropts['run_script'] try: runner.show(cmd) - except OSError,err: + except OSError as err: msger.warning(str(err)) msger.info("Finished.") @@ -159,7 +113,7 @@ class LoopPlugin(ImagerPlugin): raise errors.CreatorError("Cannot support fstype: %s" % fstype) name = os.path.join(tmpdir, name) - size = size * 1024L * 1024L + size = size * 1024 * 1024 loop = myDiskMount(fs_related.SparseLoopbackDisk(name, size), os.path.join(mntdir, mp.lstrip('/')), fstype, size, label) @@ -204,7 +158,7 @@ class LoopPlugin(ImagerPlugin): raise errors.CreatorError("damaged tarball for loop images") img = target - imgsize = misc.get_file_size(img) * 1024L * 1024L + imgsize = misc.get_file_size(img) * 1024 * 1024 imgtype = misc.get_image_type(img) if imgtype == "btrfsimg": fstype = "btrfs" @@ -212,6 +166,9 @@ class LoopPlugin(ImagerPlugin): elif imgtype in ("ext3fsimg", "ext4fsimg"): fstype = imgtype[:4] myDiskMount = fs_related.ExtDiskMount + elif imgtype == "f2fsimg": + fstype = "f2fs" + myDiskMount = fs_related.F2fsDiskMount else: raise errors.CreatorError("Unsupported filesystem type: %s" \ % imgtype) diff --git a/plugins/imager/qcow_plugin.py b/plugins/imager/qcow_plugin.py index d6758c5..2329958 100755 --- a/plugins/imager/qcow_plugin.py +++ b/plugins/imager/qcow_plugin.py @@ -19,47 +19,10 @@ import subprocess import shutil from mic import msger, rt_util -from mic.conf import configmgr from mic.plugin import pluginmgr from mic.pluginbase import ImagerPlugin -from mic.imager.loop import LoopImageCreator -from mic.utils import errors, fs_related, runner - -class QcowImageCreator(LoopImageCreator): - img_format = 'qcow' - - def __init__(self, creatoropts=None, pkgmgr=None): - LoopImageCreator.__init__(self, creatoropts, pkgmgr) - self.cmd_qemuimg = 'qemu-img' - - def _stage_final_image(self): - try: - self.cmd_qemuimg = fs_related.find_binary_path('qemu-img') - except errors.CreatorError: - return LoopImageCreator._stage_final_image(self) - - self._resparse() - - imgfile = None - for item in self._instloops: - if item['mountpoint'] == '/': - if item['fstype'] == "ext4": - runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s' - % imgfile) - self.image_files.setdefault('partitions', {}).update( - {item['mountpoint']: item['label']}) - imgfile = os.path.join(self._imgdir, item['name']) - - if imgfile: - qemuimage = imgfile + ".x86" - runner.show("%s convert -O qcow2 %s %s" - % (self.cmd_qemuimg, imgfile, qemuimage)) - os.unlink(imgfile) - os.rename(qemuimage, imgfile) - - for item in os.listdir(self._imgdir): - shutil.move(os.path.join(self._imgdir, item), - os.path.join(self._outdir, item)) +from mic.imager.qcow import QcowImageCreator +from mic.utils import errors, runner class QcowPlugin(ImagerPlugin): name = 'qcow' @@ -67,53 +30,9 @@ class QcowPlugin(ImagerPlugin): @classmethod def do_create(cls, args): """${cmd_name}: create qcow image - - Usage: - ${name} ${cmd_name} <ksfile> [OPTS] - - ${cmd_option_list} """ - if args is None: - raise errors.Usage("Invalid arguments") - - creatoropts = configmgr.create - ksconf = args.ksfile - - if creatoropts['runtime'] == "bootstrap": - configmgr._ksconf = ksconf - rt_util.bootstrap_mic() - - recording_pkgs = [] - if len(creatoropts['record_pkgs']) > 0: - recording_pkgs = creatoropts['record_pkgs'] - - if creatoropts['release'] is not None: - if 'name' not in recording_pkgs: - recording_pkgs.append('name') - if 'vcs' not in recording_pkgs: - recording_pkgs.append('vcs') - - configmgr._ksconf = ksconf - - # try to find the pkgmgr - pkgmgr = None - backends = pluginmgr.get_plugins('backend') - if 'auto' == creatoropts['pkgmgr']: - for key in configmgr.prefer_backends: - if key in backends: - pkgmgr = backends[key] - break - else: - for key in backends.keys(): - if key == creatoropts['pkgmgr']: - pkgmgr = backends[key] - break - - if not pkgmgr: - raise errors.CreatorError("Can't find backend: %s, " - "available choices: %s" % - (creatoropts['pkgmgr'], - ','.join(backends.keys()))) + + creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args) creator = QcowImageCreator(creatoropts, pkgmgr) @@ -142,7 +61,7 @@ class QcowPlugin(ImagerPlugin): creator.create_manifest() if creatoropts['release'] is not None: - creator.release_output(ksconf, + creator.release_output(args.ksfile, creatoropts['destdir'], creatoropts['release']) creator.print_outimage_info() @@ -156,8 +75,8 @@ class QcowPlugin(ImagerPlugin): if creatoropts['run_script']: cmd = creatoropts['run_script'] try: - runner.show(cmd) - except OSError,err: + runner.show(cmd) + except OSError as err: msger.warning(str(err)) diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py index e954b7b..697a35e 100755 --- a/plugins/imager/raw_plugin.py +++ b/plugins/imager/raw_plugin.py @@ -23,7 +23,6 @@ import tempfile from mic import chroot, msger, rt_util from mic.utils import misc, fs_related, errors, runner -from mic.conf import configmgr from mic.plugin import pluginmgr from mic.utils.partitionedfs import PartitionedMount @@ -36,51 +35,9 @@ class RawPlugin(ImagerPlugin): @classmethod def do_create(self, args): """${cmd_name}: create raw image - - Usage: - ${name} ${cmd_name} <ksfile> [OPTS] - - ${cmd_option_list} """ - creatoropts = configmgr.create - ksconf = args.ksfile - - if creatoropts['runtime'] == "bootstrap": - configmgr._ksconf = ksconf - rt_util.bootstrap_mic() - - recording_pkgs = [] - if len(creatoropts['record_pkgs']) > 0: - recording_pkgs = creatoropts['record_pkgs'] - - if creatoropts['release'] is not None: - if 'name' not in recording_pkgs: - recording_pkgs.append('name') - if 'vcs' not in recording_pkgs: - recording_pkgs.append('vcs') - - configmgr._ksconf = ksconf - - # try to find the pkgmgr - pkgmgr = None - backends = pluginmgr.get_plugins('backend') - if 'auto' == creatoropts['pkgmgr']: - for key in configmgr.prefer_backends: - if key in backends: - pkgmgr = backends[key] - break - else: - for key in backends.keys(): - if key == creatoropts['pkgmgr']: - pkgmgr = backends[key] - break - - if not pkgmgr: - raise errors.CreatorError("Can't find backend: %s, " - "available choices: %s" % - (creatoropts['pkgmgr'], - ','.join(backends.keys()))) + creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args) creator = raw.RawImageCreator(creatoropts, pkgmgr, args.compress_image, args.generate_bmap, args.fstab_entry) @@ -107,7 +64,7 @@ class RawPlugin(ImagerPlugin): creator.package(creatoropts["destdir"]) creator.create_manifest() if creatoropts['release'] is not None: - creator.release_output(ksconf, creatoropts['destdir'], creatoropts['release']) + creator.release_output(args.ksfile, creatoropts['destdir'], creatoropts['release']) creator.print_outimage_info() except errors.CreatorError: @@ -120,7 +77,7 @@ class RawPlugin(ImagerPlugin): cmd = creatoropts['run_script'] try: runner.show(cmd) - except OSError,err: + except OSError as err: msger.warning(str(err)) @@ -130,7 +87,7 @@ class RawPlugin(ImagerPlugin): @classmethod def do_chroot(cls, target, cmd=[]): img = target - imgsize = misc.get_file_size(img) * 1024L * 1024L + imgsize = misc.get_file_size(img) * 1024 * 1024 partedcmd = fs_related.find_binary_path("parted") disk = fs_related.SparseLoopbackDisk(img, imgsize) imgmnt = misc.mkdtemp() @@ -186,7 +143,7 @@ class RawPlugin(ImagerPlugin): # not recognize properly. # TODO: Can we make better assumption? fstype = "btrfs" - elif partition_info[5] in [ "ext2", "ext3", "ext4", "btrfs" ]: + elif partition_info[5] in [ "ext2", "ext3", "ext4", "btrfs", "f2fs" ]: fstype = partition_info[5] elif partition_info[5] in [ "fat16", "fat32" ]: fstype = "vfat" @@ -198,7 +155,7 @@ class RawPlugin(ImagerPlugin): if rootpart and rootpart == line[0]: mountpoint = '/' - elif not root_mounted and fstype in [ "ext2", "ext3", "ext4", "btrfs" ]: + elif not root_mounted and fstype in [ "ext2", "ext3", "ext4", "btrfs", "f2fs" ]: # TODO: Check that this is actually the valid root partition from /etc/fstab mountpoint = "/" root_mounted = True @@ -243,7 +200,7 @@ class RawPlugin(ImagerPlugin): @classmethod def do_unpack(cls, srcimg): - srcimgsize = (misc.get_file_size(srcimg)) * 1024L * 1024L + srcimgsize = (misc.get_file_size(srcimg)) * 1024 * 1024 srcmnt = misc.mkdtemp("srcmnt") disk = fs_related.SparseLoopbackDisk(srcimg, srcimgsize) srcloop = PartitionedMount(srcmnt, skipformat = True) @@ -68,7 +68,6 @@ PACKAGES = [MOD_NAME, MOD_NAME + '/3rdparty/pykickstart', MOD_NAME + '/3rdparty/pykickstart/commands', MOD_NAME + '/3rdparty/pykickstart/handlers', - MOD_NAME + '/3rdparty/pykickstart/urlgrabber', ] IMAGER_PLUGINS = glob.glob(os.path.join("plugins", "imager", "*.py")) diff --git a/tests/test_chroot.py b/tests/test_chroot.py index 3563f14..c98a889 100644 --- a/tests/test_chroot.py +++ b/tests/test_chroot.py @@ -36,7 +36,7 @@ if os.getuid() == 0: def testChroot(self): try: chroot.chroot(TEST_CHROOT_DIR, None, 'exit') - except Exception, e: + except Exception as e: raise self.failureException(e) if __name__ == "__main__": @@ -142,6 +142,9 @@ def create_parser(parser): parent_parser.add_argument('--tpk_install', action='store', dest='tpk_install', default=None, help='Copy tpk file to /usr/apps/.preload-tpk') parent_parser.add_argument('--rpm-debug', action='store_true', dest='rpm_debug', help='Set debug mode for rpm install') + parent_parser.add_argument('--skip-set-hosts', action='store_true', dest='skip_set_hosts', default=False, help='choose to skip set hosts by mic') + parent_parser.add_argument('--postscripts-maxruntime', dest='postscripts_maxruntime', default=120, help='max run time for post scripts') + parent_parser.add_argument('--block-recommends', action='store_true', dest='block_recommends', default=False, help='Do not install recommended packages') parser.set_defaults(alias="cr") |