def executeCode(ch): """ Menu choices """ if ch == 1: os.system("sudo pisi ur") print "\n" elif ch == 2: os.system("sudo pisi up") print "\n" elif ch == 3: extract_list() print "\n" elif ch == 4: try: f = open("userpacks.lst", "r") msg = "" for line in f: tmp = line.split("\n") msg = msg + tmp[0] + " " os.system("sudo pisi it " + msg) f.close() except IOError: print colorize( "No such file named userpacks.lst in the same directory!", "cyan") print "\n" elif ch == 0: exit()
def executeCode(ch): """ Menu choices """ if ch == 1: os.system("sudo pisi ur") print "\n" elif ch == 2: os.system("sudo pisi up") print "\n" elif ch == 3: extract_list() print "\n" elif ch == 4: try: f = open("userpacks.lst","r") msg = "" for line in f: tmp = line.split("\n") msg = msg + tmp[0] + " " os.system("sudo pisi it " + msg) f.close() except IOError: print colorize("No such file named userpacks.lst in the same directory!","cyan") print "\n" elif ch == 0: exit()
def run(self): self.init(database = True, write = False) for repo in self.repodb.list_repos(only_active=False): active = _("active") if self.repodb.repo_active(repo) else _("inactive") if active == _("active"): ctx.ui.info(util.colorize(_("%s [%s]") % (repo, active), 'green')) else: ctx.ui.info(util.colorize(_("%s [%s]") % (repo, active), 'red')) print(' ', self.repodb.get_repo_url(repo))
def get_default_packs(default_package_list): flag = 0 print colorize("pisi history extraction...", "cyan") os.system("pisi hs > history.lst") print colorize("done!", "green") print colorize("default package extraction...", "cyan") f = open("history.lst", "r") for line in f: if "Operation #2:" in line: #find Operation #2 label for core package list flag = 1 #raise first flag continue if flag >= 1 and flag != 3: #move pointer two line below flag = flag + 1 continue if flag == 3: #get package list one by one temp = line.split(' ') if "\n" in temp[0]: #if pack list is finished break # terminate loop default_package_list.append(temp[5]) f.close() print colorize("done!", "green") default_package_list.sort() #sort package list
def get_default_packs(default_package_list): flag = 0 print colorize("pisi history extraction...","cyan") os.system("pisi hs > history.lst") print colorize("done!","green") print colorize("default package extraction...","cyan") f = open("history.lst","r") for line in f: if "Operation #2:" in line:#find Operation #2 label for core package list flag = 1#raise first flag continue if flag >= 1 and flag != 3:#move pointer two line below flag = flag + 1 continue if flag == 3:#get package list one by one temp = line.split(' ') if "\n" in temp[0]:#if pack list is finished break# terminate loop default_package_list.append(temp[5]) f.close() print colorize("done!","green") default_package_list.sort()#sort package list
def main_program(): choice = 1 while choice != 0: """ Menu loop """ menuPrinting() choice = raw_input("Select one of them!\t") upperchoice=4 lowerchoice=0 if choice.isdigit() != True: print colorize("WRONG! Enter a NUMBER!\n","cyan") continue elif int(choice) > upperchoice or int(choice) < lowerchoice: print colorize("WRONG! Enter a VALID number!\n","cyan") continue else: executeCode(int(choice))
def main_program(): choice = 1 while choice != 0: """ Menu loop """ menuPrinting() choice = raw_input("Select one of them!\t") upperchoice = 4 lowerchoice = 0 if choice.isdigit() != True: print colorize("WRONG! Enter a NUMBER!\n", "cyan") continue elif int(choice) > upperchoice or int(choice) < lowerchoice: print colorize("WRONG! Enter a VALID number!\n", "cyan") continue else: executeCode(int(choice))
def run_automatic_only(self): """ Only list the automatically installed packages """ orphans = list_orphans() keys = orphans.keys() keys.sort() if keys and len(keys) > 0: maxlen = max([len(x) for x in keys]) for orphan in keys: owner = orphans[orphan] orphan_print = orphan if owner: orphan_print = util.colorize(orphan_print, 'green') else: orphan_print = util.colorize(orphan_print, 'brightwhite') if not owner: owner = _("Orphaned package") orphan_print += ' ' * max(0, maxlen - len(orphan)) ctx.ui.info('%s - %s ' % (orphan_print, unicode(owner)))
def print_packages(self, repo): component = ctx.get_option('component') if component: try: l = self.componentdb.get_packages(component, repo=repo, walk=True) except Exception as e: return else: l = pisi.api.list_available(repo) installed_list = pisi.api.list_installed() # maxlen is defined dynamically from the longest package name (#9021) if l: maxlen = max([len(_p) for _p in l]) l.sort() for p in l: if ctx.config.get_option('uninstalled') and p in installed_list: continue package = self.packagedb.get_package(p, repo) if p in installed_list: package.name = util.colorize(package.name, 'green') else: package.name = util.colorize(package.name, 'brightwhite') if self.options.long: ctx.ui.info(str(package) + '\n') else: package.name += ' ' * max(0, maxlen - len(p)) ctx.ui.info('%s - %s ' % (package.name, str(package.summary)))
def run(self): self.init(database = True, write = False) if not (ctx.get_option('no_color') or ctx.config.get_option('uninstalled')): ctx.ui.info(util.colorize(_('Installed packages are shown in this color'), 'green')) if self.args: for arg in self.args: self.print_packages(arg) else: # print for all repos for repo in pisi.api.list_repos(): ctx.ui.info(_("Repository : %s\n") % repo) self.print_packages(repo)
def run(self): self.init(database=True, write=False) if not (ctx.get_option('no_color') or ctx.config.get_option('uninstalled')): ctx.ui.info( util.colorize(_('Installed packages are shown in this color'), 'green')) if self.args: for arg in self.args: self.print_packages(arg) else: # print for all repos for repo in pisi.api.list_repos(): ctx.ui.info(_("Repository : %s\n") % repo) self.print_packages(repo)
def print_packages(self, repo): component = ctx.get_option('component') if component: l = self.componentdb.get_packages(component, repo=repo, walk=True) else: l = pisi.api.list_available(repo) installed_list = pisi.api.list_installed() l.sort() for p in l: package = self.packagedb.get_package(p, repo) if self.options.long: ctx.ui.info(unicode(package)) else: lenp = len(p) if p in installed_list: if ctx.config.get_option('uninstalled'): continue p = util.colorize(p, 'green') p = p + ' ' * max(0, 15 - lenp) ctx.ui.info('%s - %s ' % (p, unicode(package.summary)))
def upgrade(A=[], repo=None): """Re-installs packages from the repository, trying to perform a minimum or maximum number of upgrades according to options.""" packagedb = pisi.db.packagedb.PackageDB() installdb = pisi.db.installdb.InstallDB() replaces = packagedb.get_replaces() if not A: # if A is empty, then upgrade all packages A = installdb.list_installed() if repo: repo_packages = set(packagedb.list_packages(repo)) A = set(A).intersection(repo_packages) A_0 = A = set(A) Ap = find_upgrades(A, replaces) A = set(Ap) # Force upgrading of installed but replaced packages or else they will be removed (they are obsoleted also). # This is not wanted for a replaced driver package (eg. nvidia-X). # # sum(array, []) is a nice trick to flatten an array of arrays A |= set(sum(replaces.values(), [])) A |= upgrade_base(A) A = pisi.blacklist.exclude_from(A, ctx.const.blacklist) if ctx.get_option("exclude_from"): A = pisi.blacklist.exclude_from(A, ctx.get_option("exclude_from")) if ctx.get_option("exclude"): A = pisi.blacklist.exclude(A, ctx.get_option("exclude")) ctx.ui.debug("A = %s" % str(A)) if len(A) == 0: ctx.ui.info(_("No packages to upgrade.")) return True ctx.ui.debug("A = %s" % str(A)) if not ctx.config.get_option("ignore_dependency"): G_f, order = plan_upgrade(A, replaces=replaces) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component("system.base"): order = operations.helper.reorder_base_packages(order) ctx.ui.status(_("The following packages will be upgraded:")) ctx.ui.info(util.format_by_columns(sorted(order))) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(util.colorize(_("Total size of package(s): %.2f %s") % (total_size, symbol), "yellow")) needs_confirm = check_update_actions(order) if set(order) - A_0 - set(sum(replaces.values(), [])): ctx.ui.warning(_("There are extra packages due to dependencies.")) needs_confirm = True if ctx.get_option("dry_run"): return if needs_confirm and not ctx.ui.confirm(_("Do you want to continue?")): return False ctx.ui.notify(ui.packagestogo, order=order) conflicts = [] if not ctx.get_option("ignore_package_conflicts"): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x) + 1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be upgraded packages but do not install them. if ctx.get_option("fetch_only"): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) operations.remove.remove_obsoleted_packages() for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path) + 1, len(paths)), "yellow")) install_op = atomicoperations.Install(path, ignore_file_conflicts=True) install_op.install(True)
for repo in pisi.api.list_repos(): ctx.ui.info(_("Repository : %s\n") % repo) self.print_packages(repo) def print_packages(self, repo): component = ctx.get_option('component') if component: try: l = self.componentdb.get_packages(component, repo=repo, walk=True) except Exception, e: return else: l = pisi.api.list_available(repo) installed_list = pisi.api.list_installed() l.sort() for p in l: package = self.packagedb.get_package(p, repo) if self.options.long: ctx.ui.info(unicode(package)) else: lenp = len(p) if p in installed_list: if ctx.config.get_option('uninstalled'): continue p = util.colorize(p, 'green') p = p + ' ' * max(0, 15 - lenp) ctx.ui.info('%s - %s ' % (p, unicode(package.summary)))
walk=True) except Exception, e: return else: l = pisi.api.list_available(repo) installed_list = pisi.api.list_installed() # maxlen is defined dynamically from the longest package name (#9021) if l: maxlen = max([len(_p) for _p in l]) l.sort() for p in l: if ctx.config.get_option('uninstalled') and p in installed_list: continue package = self.packagedb.get_package(p, repo) if p in installed_list: package.name = util.colorize(package.name, 'green') else: package.name = util.colorize(package.name, 'brightwhite') if self.options.long: ctx.ui.info(unicode(package) + '\n') else: package.name += ' ' * max(0, maxlen - len(p)) ctx.ui.info('%s - %s ' % (package.name, unicode(package.summary)))
def run(self): self.init(database=True, write=False) component = ctx.get_option('component') if component: installed = pisi.api.list_installed() component_pkgs = self.componentdb.get_union_packages(component, walk=True) pkgs = list(set(installed) & set(component_pkgs)) elif self.args: pkgs = self.args else: ctx.ui.info(_('Checking all installed packages') + '\n') pkgs = pisi.api.list_installed() necessary_permissions = True # True if we should also check the configuration files check_config = ctx.get_option('config') # Line prefix prefix = _('Checking integrity of %s') # Determine maximum length of messages for proper formatting maxpkglen = max([len(_p) for _p in pkgs]) for pkg in pkgs: if self.installdb.has_package(pkg): check_results = pisi.api.check(pkg, check_config) ctx.ui.info("%s %s" % ((prefix % pkg), ' ' * (maxpkglen - len(pkg))), noln=True) if check_results['missing'] or check_results['corrupted'] \ or check_results['config']: ctx.ui.info(util.colorize(_("Broken"), 'brightred')) elif check_results['denied']: # We can't deduce a result when some files # can't be accessed necessary_permissions = False ctx.ui.info(util.colorize(_("Unknown"), 'yellow')) else: ctx.ui.info(util.colorize(_("OK"), 'green')) continue # Dump per file stuff for fpath in check_results['missing']: ctx.ui.info(util.colorize( _("Missing file: /%s") % fpath, 'brightred')) for fpath in check_results['denied']: ctx.ui.info(util.colorize( _("Access denied: /%s") % fpath, 'yellow')) for fpath in check_results['corrupted']: ctx.ui.info(util.colorize( _("Corrupted file: /%s") % fpath, 'brightyellow')) for fpath in check_results['config']: ctx.ui.info(util.colorize( _("Modified configuration file: /%s") % fpath, 'brightyellow')) else: # Package is not installed ctx.ui.info(_('Package %s not installed') % pkg) if not necessary_permissions: ctx.ui.info("") ctx.ui.warning(_("Pisi was unable to check the integrity of " "packages which contain files that you don't " "have read access.\n" "Running the check under a privileged user " "may help fixing this problem."))
def extract_list(): """ Gets installed Pisi packages by user """ print colorize("getting list of all installed packages...","cyan") installed_packages = list_installed()#get all installed packages installed_packages.sort() print colorize("done!","green") print colorize("getting list of default package list...","cyan") default_package_list = [] get_default_packs(default_package_list)#get default package list print colorize("done!","green") print colorize("comparison of lists...","cyan") fup = open("userpacks.lst","w") #compare lists for line in installed_packages: if line not in default_package_list: fup.write(line + "\n") fup.close() print colorize("done!","green")
def upgrade(A=[], repo=None): """Re-installs packages from the repository, trying to perform a minimum or maximum number of upgrades according to options.""" packagedb = pisi.db.packagedb.PackageDB() installdb = pisi.db.installdb.InstallDB() replaces = packagedb.get_replaces() if not A: # if A is empty, then upgrade all packages A = installdb.list_installed() if repo: repo_packages = set(packagedb.list_packages(repo)) A = set(A).intersection(repo_packages) A_0 = A = set(A) Ap = find_upgrades(A, replaces) A = set(Ap) # Force upgrading of installed but replaced packages or else they will be removed (they are obsoleted also). # This is not wanted for a replaced driver package (eg. nvidia-X). A |= set(pisi.util.flatten_list(replaces.values())) A |= upgrade_base(A) A = pisi.blacklist.exclude_from(A, ctx.const.blacklist) if ctx.get_option('exclude_from'): A = pisi.blacklist.exclude_from(A, ctx.get_option('exclude_from')) if ctx.get_option('exclude'): A = pisi.blacklist.exclude(A, ctx.get_option('exclude')) ctx.ui.debug('A = %s' % str(A)) if len(A) == 0: ctx.ui.info(_('No packages to upgrade.')) return True ctx.ui.debug('A = %s' % str(A)) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_upgrade(A, replaces=replaces) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) ctx.ui.status(_('The following packages will be upgraded:')) ctx.ui.info(util.format_by_columns(sorted(order))) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info( util.colorize( _('Total size of package(s): %.2f %s') % (total_size, symbol), "yellow")) needs_confirm = check_update_actions(order) # NOTE: replaces.values() was already flattened above, it can be reused if set(order) - A_0 - set(pisi.util.flatten_list(replaces.values())): ctx.ui.warning(_("There are extra packages due to dependencies.")) needs_confirm = True if ctx.get_option('dry_run'): return if needs_confirm and \ not ctx.ui.confirm(_("Do you want to continue?")): return False ctx.ui.notify(ui.packagestogo, order=order) conflicts = [] if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] for x in order: ctx.ui.info( util.colorize( _("Downloading %d / %d") % (order.index(x) + 1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be upgraded packages but do not install them. if ctx.get_option('fetch_only'): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) operations.remove.remove_obsoleted_packages() for path in paths: ctx.ui.info( util.colorize( _("Installing %d / %d") % (paths.index(path) + 1, len(paths)), "yellow")) install_op = atomicoperations.Install(path, ignore_file_conflicts=True) install_op.install(not ctx.get_option('compare_sha1sum'))
print "\n" elif ch == 4: try: f = open("userpacks.lst","r") msg = "" for line in f: tmp = line.split("\n") msg = msg + tmp[0] + " " os.system("sudo pisi it " + msg) f.close() except IOError: print colorize("No such file named userpacks.lst in the same directory!","cyan") print "\n" elif ch == 0: exit() def main_program(): choice = 1 while choice != 0: """ Menu loop """ menuPrinting() choice = raw_input("Select one of them!\t") upperchoice=4 lowerchoice=0
def upgrade_pkg_names(A = [], repo=None): """Re-installs packages from the repository, trying to perform a minimum or maximum number of upgrades according to options.""" packagedb = pisi.db.packagedb.PackageDB() installdb = pisi.db.installdb.InstallDB() replaces = packagedb.get_replaces() if not A: # if A is empty, then upgrade all packages A = installdb.list_installed() if repo: repo_packages = set(packagedb.list_packages(repo)) A = set(A).intersection(repo_packages) A_0 = A = set(A) Ap = find_upgrades(A, replaces) A = set(Ap) if len(A)==0: ctx.ui.info(_('No packages to upgrade.')) return True # Force upgrading of installed but replaced packages or else they wil be removed (they are obsoleted also). # This is not wanted for a replaced driver package (eg. nvidia-X). A |= set(replaces.values()) A |= upgrade_base(A) ctx.ui.debug('A = %s' % str(A)) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_upgrade(A) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) ctx.ui.info(_('The following packages will be upgraded: ') + util.strlist(order)) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of package(s): %.2f %s') % (total_size, symbol)) if ctx.get_option('dry_run'): return if set(order) - A_0 - set(replaces.values()): if not ctx.ui.confirm(_('There are extra packages due to dependencies. Do you want to continue?')): return False ctx.ui.notify(ui.packagestogo, order = order) conflicts = [] if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x)+1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be upgraded packages but do not install them. if ctx.get_option('fetch_only'): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) operations.remove.remove_replaced_packages(replaces.keys()) operations.remove.remove_obsoleted_packages() for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), "yellow")) install_op = atomicoperations.Install(path, ignore_file_conflicts = True) install_op.install(True)
def upgrade(A=[], repo=None): """Re-installs packages from the repository, trying to perform a minimum or maximum number of upgrades according to options.""" packagedb = pisi.db.packagedb.PackageDB() installdb = pisi.db.installdb.InstallDB() replaces = packagedb.get_replaces() if not A: # if A is empty, then upgrade all packages A = installdb.list_installed() if repo: repo_packages = set(packagedb.list_packages(repo)) A = set(A).intersection(repo_packages) A_0 = A = set(A) Ap = find_upgrades(A, replaces) A = set(Ap) # Force upgrading of installed but replaced packages or else they will be removed (they are obsoleted also). # This is not wanted for a replaced driver package (eg. nvidia-X). A |= set(pisi.util.flatten_list(replaces.values())) A |= upgrade_base(A) A = pisi.blacklist.exclude_from(A, ctx.const.blacklist) if ctx.get_option('exclude_from'): A = pisi.blacklist.exclude_from(A, ctx.get_option('exclude_from')) if ctx.get_option('exclude'): A = pisi.blacklist.exclude(A, ctx.get_option('exclude')) ctx.ui.debug('A = %s' % str(A)) if len(A)==0: ctx.ui.info(_('No packages to upgrade.')) return True ctx.ui.debug('A = %s' % str(A)) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_upgrade(A, replaces=replaces) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) ctx.ui.status(_('The following packages will be upgraded:')) ctx.ui.info(util.format_by_columns(sorted(order))) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(util.colorize(_('Total size of package(s): %.2f %s') % (total_size, symbol), "yellow")) needs_confirm = check_update_actions(order) # NOTE: replaces.values() was already flattened above, it can be reused if set(order) - A_0 - set(pisi.util.flatten_list(replaces.values())): ctx.ui.warning(_("There are extra packages due to dependencies.")) needs_confirm = True if ctx.get_option('dry_run'): return if needs_confirm and \ not ctx.ui.confirm(_("Do you want to continue?")): return False ctx.ui.notify(ui.packagestogo, order = order) conflicts = [] if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) automatic = operations.helper.extract_automatic(A, order) paths = [] for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x)+1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be upgraded packages but do not install them. if ctx.get_option('fetch_only'): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) operations.remove.remove_obsoleted_packages() try: for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), "yellow")) install_op = atomicoperations.Install(path, ignore_file_conflicts = True) if install_op.pkginfo.name in automatic: install_op.automatic = True install_op.install(True) except Exception as e: raise e finally: ctx.exec_usysconf()
try: l = self.componentdb.get_packages(component, repo=repo, walk=True) except Exception, e: return else: l = pisi.api.list_available(repo) installed_list = pisi.api.list_installed() # maxlen is defined dynamically from the longest package name (#9021) if l: maxlen = max([len(_p) for _p in l]) l.sort() for p in l: package = self.packagedb.get_package(p, repo) if self.options.long: if p in installed_list: package.name = util.colorize(package.name, 'green') else: package.name = util.colorize(package.name, 'brightwhite') ctx.ui.info(unicode(package)+'\n') else: lenp = len(p) if p in installed_list: if ctx.config.get_option('uninstalled'): continue p = util.colorize(p, 'green') p = util.colorize(p, 'brightwhite') p = p + ' ' * max(0, maxlen - lenp) ctx.ui.info('%s - %s ' % (p, unicode(package.summary)))
else: # print for all repos for repo in pisi.api.list_repos(): ctx.ui.info(_("Repository : %s\n") % repo) self.print_packages(repo) def print_packages(self, repo): component = ctx.get_option('component') if component: try: l = self.componentdb.get_packages(component, repo=repo, walk=True) except Exception, e: return else: l = pisi.api.list_available(repo) installed_list = pisi.api.list_installed() l.sort() for p in l: package = self.packagedb.get_package(p, repo) if self.options.long: ctx.ui.info(unicode(package)) else: lenp = len(p) if p in installed_list: if ctx.config.get_option('uninstalled'): continue p = util.colorize(p, 'green') p = p + ' ' * max(0, 15 - lenp) ctx.ui.info('%s - %s ' % (p, unicode(package.summary)))
def extract_list(): """ Gets installed Pisi packages by user """ print colorize("getting list of all installed packages...", "cyan") installed_packages = list_installed() #get all installed packages installed_packages.sort() print colorize("done!", "green") print colorize("getting list of default package list...", "cyan") default_package_list = [] get_default_packs(default_package_list) #get default package list print colorize("done!", "green") print colorize("comparison of lists...", "cyan") fup = open("userpacks.lst", "w") #compare lists for line in installed_packages: if line not in default_package_list: fup.write(line + "\n") fup.close() print colorize("done!", "green")
def install_pkg_names(A, reinstall=False): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of installs""" installdb = pisi.db.installdb.InstallDB() packagedb = pisi.db.packagedb.PackageDB() A = [str(x) for x in A] #FIXME: why do we still get unicode input here? :/ -- exa # A was a list, remove duplicates A_0 = A = set(A) # filter packages that are already installed if not reinstall: Ap = set(filter(lambda x: not installdb.has_package(x), A)) d = A - Ap if len(d) > 0: ctx.ui.warning( _("The following package(s) are already installed and are not going to be installed again:\n" ) + util.strlist(d)) A = Ap if len(A) == 0: ctx.ui.info(_('No packages to install.')) return True A |= operations.upgrade.upgrade_base(A) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_install_pkg_names(A) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) if len(order) > 1: ctx.ui.info( _("Following packages will be installed in the respective " "order to satisfy dependencies:\n") + util.strlist(order)) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of package(s): %.2f %s') % (total_size, symbol)) if ctx.get_option('dry_run'): return True if set(order) - A_0: if not ctx.ui.confirm( _('There are extra packages due to dependencies. Do you want to continue?' )): return False ctx.ui.notify(ui.packagestogo, order=order) ignore_dep = ctx.config.get_option('ignore_dependency') conflicts = [] if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] for x in order: ctx.ui.info( util.colorize( _("Downloading %d / %d") % (order.index(x) + 1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be installed packages but do not install them. if ctx.get_option('fetch_only'): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) for path in paths: ctx.ui.info( util.colorize( _("Installing %d / %d") % (paths.index(path) + 1, len(paths)), "yellow")) install_op = atomicoperations.Install(path) install_op.install(False) return True
def upgrade_pkg_names(A=[]): """Re-installs packages from the repository, trying to perform a minimum or maximum number of upgrades according to options.""" ignore_build = ctx.get_option('ignore_build_no') security_only = ctx.get_option('security_only') packagedb = pisi.db.packagedb.PackageDB() replaces = packagedb.get_replaces() installdb = pisi.db.installdb.InstallDB() if not A: # if A is empty, then upgrade all packages A = installdb.list_installed() A_0 = A = set(A) Ap = [] for x in A: if x.endswith(ctx.const.package_suffix): ctx.ui.debug(_("Warning: package *name* ends with '.pisi'")) # Handling of replacement packages if x in replaces.values(): Ap.append(x) continue if x in replaces.keys(): Ap.append(replaces[x]) continue if not installdb.has_package(x): ctx.ui.info(_('Package %s is not installed.') % x, True) continue (version, release, build) = installdb.get_version(x) if packagedb.has_package(x): pkg = packagedb.get_package(x) else: ctx.ui.info( _('Package %s is not available in repositories.') % x, True) continue if security_only: updates = [ i for i in pkg.history if pisi.version.Version(i.release) > pisi.version.Version(release) ] if not pisi.util.any(lambda i: i.type == 'security', updates): continue if ignore_build or (not build) or (not pkg.build): if pisi.version.Version(release) < pisi.version.Version( pkg.release): Ap.append(x) else: ctx.ui.info( _('Package %s is already at the latest release %s.') % (pkg.name, pkg.release), True) else: if build < pkg.build: Ap.append(x) else: ctx.ui.info( _('Package %s is already at the latest build %s.') % (pkg.name, pkg.build), True) A = set(Ap) if len(A) == 0: ctx.ui.info(_('No packages to upgrade.')) return True A |= upgrade_base(A) ctx.ui.debug('A = %s' % str(A)) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_upgrade(A) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) ctx.ui.info( _('The following packages will be upgraded: ') + util.strlist(order)) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of package(s): %.2f %s') % (total_size, symbol)) if ctx.get_option('dry_run'): return if set(order) - A_0 - set(replaces.values()): if not ctx.ui.confirm( _('There are extra packages due to dependencies. Do you want to continue?' )): return False ctx.ui.notify(ui.packagestogo, order=order) paths = [] for x in order: ctx.ui.info( util.colorize( _("Downloading %d / %d") % (order.index(x) + 1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be upgraded packages but do not install them. if ctx.get_option('fetch_only'): return if not ctx.get_option('ignore_package_conflicts'): if conflicts: operations.remove.remove_conflicting_packages(conflicts) if replaces: operations.remove.remove_replaced_packages(order, replaces) operations.remove.remove_obsoleted_packages() for path in paths: ctx.ui.info( util.colorize( _("Installing %d / %d") % (paths.index(path) + 1, len(paths)), "yellow")) install_op = atomicoperations.Install(path, ignore_file_conflicts=True) install_op.install(True)
def install_pkg_names(A, reinstall = False, extra = False): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of installs""" installdb = pisi.db.installdb.InstallDB() packagedb = pisi.db.packagedb.PackageDB() A = [str(x) for x in A] #FIXME: why do we still get unicode input here? :/ -- exa # A was a list, remove duplicates A_0 = A = set(A) # filter packages that are already installed if not reinstall: Ap = set(filter(lambda x: not installdb.has_package(x), A)) d = A - Ap if len(d) > 0: ctx.ui.warning(_("The following package(s) are already installed " "and are not going to be installed again:")) ctx.ui.info(util.format_by_columns(sorted(d))) A = Ap if len(A)==0: ctx.ui.info(_('No packages to install.')) return True A |= operations.upgrade.upgrade_base(A) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_install_pkg_names(A) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) if len(order) > 1: ctx.ui.info(util.colorize(_("Following packages will be installed:"), "brightblue")) ctx.ui.info(util.format_by_columns(sorted(order))) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(util.colorize(_('Total size of package(s): %.2f %s') % (total_size, symbol), "yellow")) if ctx.get_option('dry_run'): return True extra_packages = set(order) - A_0 if extra_packages: if not ctx.ui.confirm(_('There are extra packages due to dependencies. Do you want to continue?')): return False ctx.ui.notify(ui.packagestogo, order = order) ignore_dep = ctx.config.get_option('ignore_dependency') conflicts = [] if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] extra_paths = {} for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x)+1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) if x in extra_packages or (extra and x in A): extra_paths[install_op.package_fname] = x elif reinstall and x in installdb.installed_extra: installdb.installed_extra.remove(x) with open(os.path.join(ctx.config.info_dir(), ctx.const.installed_extra), "w") as ie_file: ie_file.write("\n".join(installdb.installed_extra) + ("\n" if installdb.installed_extra else "")) # fetch to be installed packages but do not install them. if ctx.get_option('fetch_only'): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), "yellow")) install_op = atomicoperations.Install(path) install_op.install(False) try: with open(os.path.join(ctx.config.info_dir(), ctx.const.installed_extra), "a") as ie_file: ie_file.write("%s\n" % extra_paths[path]) installdb.installed_extra.append(extra_paths[path]) except KeyError: pass return True
def menuPrinting(): """ User menu of Pisi Clone application """ print colorize('=' * 9 + 'Pisi Clone Menu' + '=' * 9,"yellow") print colorize('1-Update repository',"white") print colorize('2-Update Pisi',"white") print colorize('3-Extract package list from Pisi',"white") print colorize('4-Setup packages',"white") print colorize('0-Exit',"white") print colorize('=' * 24,"yellow")
continue if flag >= 1 and flag != 3:#move pointer two line below flag = flag + 1 continue if flag == 3:#get package list one by one temp = line.split(' ') if "\n" in temp[0]:#if pack list is finished break# terminate loop default_package_list.append(temp[5]) f.close() print colorize("done!","green") default_package_list.sort()#sort package list def extract_list(): """ Gets installed Pisi packages by user """ print colorize("getting list of all installed packages...","cyan") installed_packages = list_installed()#get all installed packages installed_packages.sort() print colorize("done!","green") print colorize("getting list of default package list...","cyan") default_package_list = [] get_default_packs(default_package_list)#get default package list print colorize("done!","green") print colorize("comparison of lists...","cyan")
def upgrade_pkg_names(A = []): """Re-installs packages from the repository, trying to perform a minimum or maximum number of upgrades according to options.""" ignore_build = ctx.get_option('ignore_build_no') security_only = ctx.get_option('security_only') packagedb = pisi.db.packagedb.PackageDB() replaces = packagedb.get_replaces() installdb = pisi.db.installdb.InstallDB() if not A: # if A is empty, then upgrade all packages A = installdb.list_installed() A_0 = A = set(A) Ap = [] for x in A: if x.endswith(ctx.const.package_suffix): ctx.ui.debug(_("Warning: package *name* ends with '.pisi'")) # Handling of replacement packages if x in replaces.values(): Ap.append(x) continue if x in replaces.keys(): Ap.append(replaces[x]) continue if not installdb.has_package(x): ctx.ui.info(_('Package %s is not installed.') % x, True) continue (version, release, build) = installdb.get_version(x) if packagedb.has_package(x): pkg = packagedb.get_package(x) else: ctx.ui.info(_('Package %s is not available in repositories.') % x, True) continue if security_only: updates = [i for i in pkg.history if pisi.version.Version(i.release) > pisi.version.Version(release)] if not pisi.util.any(lambda i:i.type == 'security', updates): continue if ignore_build or (not build) or (not pkg.build): if pisi.version.Version(release) < pisi.version.Version(pkg.release): Ap.append(x) else: ctx.ui.info(_('Package %s is already at the latest release %s.') % (pkg.name, pkg.release), True) else: if build < pkg.build: Ap.append(x) else: ctx.ui.info(_('Package %s is already at the latest build %s.') % (pkg.name, pkg.build), True) A = set(Ap) if len(A)==0: ctx.ui.info(_('No packages to upgrade.')) return True A |= upgrade_base(A) ctx.ui.debug('A = %s' % str(A)) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_upgrade(A) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) ctx.ui.info(_('The following packages will be upgraded: ') + util.strlist(order)) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of package(s): %.2f %s') % (total_size, symbol)) if ctx.get_option('dry_run'): return if set(order) - A_0 - set(replaces.values()): if not ctx.ui.confirm(_('There are extra packages due to dependencies. Do you want to continue?')): return False ctx.ui.notify(ui.packagestogo, order = order) paths = [] for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x)+1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be upgraded packages but do not install them. if ctx.get_option('fetch_only'): return if not ctx.get_option('ignore_package_conflicts'): if conflicts: operations.remove.remove_conflicting_packages(conflicts) if replaces: operations.remove.remove_replaced_packages(order, replaces) operations.remove.remove_obsoleted_packages() for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), "yellow")) install_op = atomicoperations.Install(path, ignore_file_conflicts = True) install_op.install(True)
def install_pkg_names(A, reinstall=False): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of installs""" installdb = pisi.db.installdb.InstallDB() packagedb = pisi.db.packagedb.PackageDB() A = [str(x) for x in A] # FIXME: why do we still get unicode input here? :/ -- exa # A was a list, remove duplicates A_0 = A = set(A) # filter packages that are already installed if not reinstall: Ap = set(filter(lambda x: not installdb.has_package(x), A)) d = A - Ap if len(d) > 0: ctx.ui.warning( _("The following package(s) are already installed and are not going to be installed again:\n") + util.strlist(d) ) A = Ap if len(A) == 0: ctx.ui.info(_("No packages to install.")) return True A |= operations.upgrade.upgrade_base(A) if not ctx.config.get_option("ignore_dependency"): G_f, order = plan_install_pkg_names(A) else: G_f = None order = list(A) componentdb = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component("system.base"): order = operations.helper.reorder_base_packages(order) if len(order) > 1: ctx.ui.info( _("Following packages will be installed in the respective " "order to satisfy dependencies:\n") + util.strlist(order) ) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_("Total size of package(s): %.2f %s") % (total_size, symbol)) if ctx.get_option("dry_run"): return True if set(order) - A_0: if not ctx.ui.confirm(_("There are extra packages due to dependencies. Do you want to continue?")): return False ctx.ui.notify(ui.packagestogo, order=order) ignore_dep = ctx.config.get_option("ignore_dependency") conflicts = [] if not ctx.get_option("ignore_package_conflicts"): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x) + 1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be installed packages but do not install them. if ctx.get_option("fetch_only"): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path) + 1, len(paths)), "yellow")) install_op = atomicoperations.Install(path) install_op.install(False) return True
def menuPrinting(): """ User menu of Binn application """ print colorize('=' * 9 + ' MENU ' + '=' * 9, "yellow") print colorize('1-Update repository', "white") print colorize('2-Update Pisi', "white") print colorize('3-Extract package list from Pisi', "white") print colorize('4-Setup packages', "white") print colorize('0-Exit', "white") print colorize('=' * 24, "yellow")