def installPackages(self, chroot_dir, package_list, callback = None): """Install the list of packages in the chroot environement""" self.__aptgetPreRun(chroot_dir) if not package_list: # No packages, so nothing to do return retry_count = 0 # Convert our list of packages to a space separated string packages = ' '.join(package_list) while (retry_count < 10): self.updateChroot(chroot_dir, callback = callback) # apt-get install command = "%s install %s" % (self.apt_cmd, packages) print _("Running 'apt-get install' command: %s") % (command) print _("\t in the chroot: %s") % (chroot_dir) result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) if result == 0: print _("Completed 'apt-get install' successfully") break if result < 0: print _("Process Aborted") return False print print _("Error running 'apt-get install' command: %s") % command print _("Will try 'apt-get update' in 15 seconds") time.sleep(15) retry_count += 1 # apt-get update command = "apt-get update" print _("Running 'apt-get update' command: %s") % command result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) if result != 0: print print _("Error running 'apt-get update' command: %s") % command print _("Will try 'apt-get install -f' in 15 seconds") time.sleep(15) else: print _("Completed 'apt-get update' successfully") print _("Will try 'apt-get install -f' in 15 seconds") time.sleep(15) # apt-get install -f command = "apt-get install -f" result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) if result != 0: print print _("Error running 'apt-get install -f' command: %s") % command print _("Will try 'apt-get install' in 15 seconds") time.sleep(15) else: print _("Completed 'apt-get install -f' successfully") print _("Will try 'apt-get install' in 15 seconds") time.sleep(15) else: raise OSError(_("Internal error while attempting to run: %s") % command) self.__aptgetPostRun() return True
def updateChroot(self, chroot_dir, output = None, callback = None): self.__aptgetPreRun(chroot_dir) print _("Updating the chroot dir: %s") % chroot_dir cmd_line = "apt-get update" result = pdk_utils.execChrootCommand(chroot_dir, cmd_line, output = output, callback = callback) if result: self.__aptgetPostRun() return result cmd_line = "apt-get upgrade -y --force-yes" result = pdk_utils.execChrootCommand(chroot_dir, cmd_line, output = output, callback = callback) self.__aptgetPostRun() return result
def updateChroot(self, chroot_dir, callback = None): """Update the chroot environment to have the latest packages""" command = "yum clean metadata" print _("Running 'yum update' command: %s") % (command) print _("\t in the chroot: %s") % (chroot_dir) pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) command = "yum -y update" print _("Running 'yum update' command: %s") % (command) print _("\t in the chroot: %s") % (chroot_dir) result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) return result
def cleanPackageCache(self, chroot_dir): """Clean out any cached package files""" command = "yum clean all" print _("Running 'yum clean' command: %s") % (command) print _("\t in the chroot: %s") % (chroot_dir) result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) return result
def installGroups(self, chroot_dir, groups_list, callback = None): """Install the list of groups in the chroot environement""" self.__yumPreRun(chroot_dir) if not groups_list: # No groups, so nothing to do return retry_count = 0 # Convert our list of packages to a space separated string groups = ' '.join(groups_list) while (retry_count < 10): self.updateChroot(chroot_dir, callback = callback) # yum groupinstall command = "yum -y groupinstall " for group in groups_list: command += "\"%s\" " % group #command = "yum -y groupinstall %s" % (groups) print _("Running 'yum groupinstall' command: %s") % (command) print _("\t in the chroot: %s") % (chroot_dir) result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) if result == 0: print _("Completed 'yum groupinstall' successfully") break print print _("Error running 'yum groupinstall' command: %s") % command print _("Will try 'yum update' in 15 seconds") time.sleep(15) retry_count += 1 # yum update command = "yum -y update" print _("Running 'yum update' command: %s") % command result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) if result != 0: print print _("Error running 'yum update' command: %s") % command time.sleep(15) else: print _("Completed 'yum update' successfully") print _("Will try 'yum install -f' in 15 seconds") time.sleep(15) else: raise OSError(_("Internal error while attempting to run: %s") % command) self.__yumPostRun(chroot_dir)
def chroot(self, cmd, output = None): if not os.path.isfile(os.path.join(self.chroot_path, 'bin/bash')): print >> sys.stderr, _("Incomplete jailroot at %s") % (self.chroot_path) raise ValueError(_("Internal Error: Invalid buildroot at %s") % (self.chroot_path)) self.mount() if output == None: output = [] result = pdk_utils.execChrootCommand(self.chroot_path, cmd, output = output, callback = self.progress_callback) if result != 0: print _("Error in chroot command exec. Result: %s") % result print _("Command was: %s") % cmd print _("chroot was: %s") % self.chroot_path sys.stdout.flush() return result
def resetPackageDB(self, chroot_dir, callback): """reset rpm database to deal with case of running in IA64""" """ due to unknown reason execChrootCommand doesn't work on wide-match symbol""" #FIXME command = "/usr/sbin/chroot %s rm -fr /var/lib/rpm/*db*" % (chroot_dir) print _("Running command: %s") % (command) os.system(command) command = "rpm --rebuilddb" print _("Running rpm db reset command: %s") % (command) print _("\t in the chroot: %s") % (chroot_dir) result = pdk_utils.execChrootCommand(chroot_dir, command, callback = callback) if result != 0 : print _("Error running command %s") %(command) return result
def cleanPackageCache(self, chroot_dir, output = None, callback = None): """Clean out any cached package files""" cmd_line = "apt-get clean" return pdk_utils.execChrootCommand(chroot_dir, cmd_line, output = output, callback = callback)