def _getRootdir(self):
if not os.path.exists(self._rootdir):
- raise errors.BootstrapError("Root dir: %s not exist" % self._rootdir)
+ raise errors.BootstrapError("dir: %s not exist" % self._rootdir)
return self._rootdir
rootdir = property(fget = lambda self: self._getRootdir(),
if key == name:
self._pkgmgr = cls
if not self._pkgmgr:
- raise errors.BootstrapError("Backend: %s can't be loaded correctly" % name)
+ raise errors.BootstrapError("Backend: %s can't be loaded correctly"\
+ % name)
pkgmgr = property(fget = lambda self: self._pkgmgr,
fset = lambda self, name: self._setPkgmgr(name),
pkg_manager.setup()
for repo in repolist:
- if 'proxy' in repo.keys():
- pkg_manager.addRepository(repo['name'], repo['baseurl'], proxy = repo['proxy'])
+ if 'proxy' in repo:
+ pkg_manager.addRepository(repo['name'], repo['baseurl'],
+ proxy=repo['proxy'])
else:
pkg_manager.addRepository(repo['name'], repo['baseurl'])
shutil.rmtree(destdir, ignore_errors = True)
shutil.copytree(srcdir, destdir)
# create '/tmp' in chroot
- if not os.path.exists(os.path.join(os.path.abspath(self.rootdir), "tmp")):
- os.makedirs(os.path.join(os.path.abspath(self.rootdir), "tmp"))
+ _tmpdir = os.path.join(os.path.abspath(self.rootdir), "tmp")
+ if not os.path.exists(_tmpdir):
+ os.makedirs(_tmpdir)
msger.info("Bootstrap created.")
shutil.copyfile("/etc/resolv.conf", chrootdir + "/etc/resolv.conf")
try:
- subprocess.call("zypper -n --no-gpg-checks update", preexec_fn=mychroot, shell=True)
+ subprocess.call("zypper -n --no-gpg-checks update",
+ preexec_fn=mychroot, shell=True)
except OSError, err:
- raise errors.BootstrapError("Bootstrap: %s Update fail" % chrootdir)
+ raise errors.BootstrapError("Bootstrap: %s update failed" %\
+ chrootdir)
def cleanup(self, name):
self.rootdir = name
chroot.cleanup_mounts(self.rootdir)
shutil.rmtree(self.rootdir, ignore_errors=True)
except:
- raise errors.BootstrapError("Bootstrap: %s clean up fail " % self.rootdir)
+ raise errors.BootstrapError("Bootstrap: %s clean up failed" %\
+ self.rootdir)
"""Default bind mounts"""
for pt in BIND_MOUNTS:
- chrootmounts.append(fs_related.BindChrootMount(pt, chrootdir, None))
+ chrootmounts.append(fs_related.BindChrootMount(pt,
+ chrootdir,
+ None))
chrootmounts.append(fs_related.BindChrootMount("/",
chrootdir,
"ro"))
for kernel in os.listdir("/lib/modules"):
- chrootmounts.append(fs_related.BindChrootMount("/lib/modules/"+kernel,
- chrootdir,
- None,
- "ro"))
+ chrootmounts.append(fs_related.BindChrootMount(
+ "/lib/modules/"+kernel,
+ chrootdir,
+ None,
+ "ro"))
return chrootmounts
if val.split(':')[0] in ('file', 'http', 'https', 'ftp'):
if repostr.has_key(option):
- repostr[option] += "name:%s,baseurl:%s," % (option, val)
+ repostr[option] += "name:%s,baseurl:%s," % \
+ (option, val)
else:
- repostr[option] = "name:%s,baseurl:%s," % (option, val)
+ repostr[option] = "name:%s,baseurl:%s," % \
+ (option, val)
continue
self.bootstraps[name] = repostr
def get_optparser(self):
optparser = cmdln.CmdlnOptionParser(self)
- optparser.add_option('-d', '--debug', action='store_true', dest='debug',
+ optparser.add_option('-d', '--debug', action='store_true',
+ dest='debug',
help=SUPPRESS_HELP)
optparser.add_option('-v', '--verbose', action='store_true',
dest='verbose',
try:
largs.append(argv.pop(0))
except IndexError:
- raise errors.Usage("%s option requires an argument" % arg)
+ raise errors.Usage("option %s requires arguments" % arg)
else:
if arg.startswith("--"):
if self.options.cachedir is not None:
configmgr.create['cachedir'] = abspath(self.options.cachedir)
os.environ['ZYPP_LOCKFILE_ROOT'] = configmgr.create['cachedir']
+
if self.options.local_pkgs_path is not None:
if not os.path.exists(self.options.local_pkgs_path):
msger.error('Local pkgs directory: \'%s\' not exist' \
# No ks provided when called by convertor, so skip the dependency check
if self.ks:
- # If we have btrfs partition we need to check that we have toosl for those
+ # If we have btrfs partition we need to check necessary tools
for part in self.ks.handler.partition.partitions:
if part.fstype and part.fstype == "btrfs":
self._dep_checks.append("mkfs.btrfs")
def copy_attachment(self):
""" Subclass implement it to handle attachment files
-
NOTE: This needs to be called before unmounting the instroot.
"""
pass
#The default kernel type from kickstart.
if self.ks:
- self._default_kernel = kickstart.get_default_kernel(self.ks, "kernel")
+ self._default_kernel = kickstart.get_default_kernel(self.ks,
+ "kernel")
else:
self._default_kernel = None
LiveCDImageCreator = x86LiveImageCreator
elif arch.startswith("arm"):
LiveCDImageCreator = LiveImageCreatorBase
-
else:
raise CreatorError("Architecture not supported!")
misc.packing(dstfile, self.__imgdir)
if self.pack_to:
- mountfp_xml = os.path.splitext(self.pack_to)[0].rstrip('.tar') + ".xml"
+ mountfp_xml = os.path.splitext(self.pack_to)[0]
+ mountfp_xml = misc.strip_end(mountfp_xml, '.tar') + ".xml"
else:
mountfp_xml = self.name + ".xml"
# save mount points mapping file to xml
return s
def _create_mkinitrd_config(self):
- #write to tell which modules to be included in initrd
+ """write to tell which modules to be included in initrd"""
mkinitrd = ""
mkinitrd += "PROBE=\"no\"\n"
% (self.name,
name,
self.__disk_format))
- xml += " <disk file='%s-%s.%s' use='system' format='%s'>\n" \
+ xml += " <disk file='%s-%s.%s' use='system' format='%s'>\n"\
% (self.name,
name,
self.__disk_format,
mic_plugin_type = "imager"
@classmethod
- def check_image_exists(self, destdir, apacking=None, images=[], release=None):
+ def check_image_exists(self, destdir, apacking=None,
+ images=[],
+ release=None):
+
# if it's a packing file, reset images
if apacking:
images = [apacking]
#repostrs = misc.get_repostrs_from_ks(opts['ks'])
#for item in repostrs:
# repolist.append(convert_repostr(item))
- msger.info("Failed to find propery bootstrap, please check config file")
+ msger.info("cannot find valid bootstrap, please check the config")
msger.info("Back to native running")
return
else:
bootstrap_lst = bootstrap_env.bootstraps
setattr(bootstrap_env, 'rootdir', name)
if not bootstrap_lst or not name in bootstrap_lst:
- msger.info("Creating bootstrap %s under %s" % (name, bootstrap_env.homedir))
+ msger.info("Creating bootstrap %s under %s" % \
+ (name, bootstrap_env.homedir))
bootstrap_env.create(name, repolist)
msger.info("Use bootstrap: %s" % bootstrap_env.rootdir)
# make unique and remain the original order
lst = sorted(set(lst), key=lst.index)
- bindmounts = ';'.join(map(lambda p: os.path.abspath(os.path.expanduser(p)), lst))
+ bindmounts = ';'.join(map(lambda p: os.path.abspath(os.path.expanduser(p)),
+ lst))
msger.info("Start mic command in bootstrap")
bootstrap_env.run(name, argv, cwd, bindmounts)