def check_updates(args=None): """Return list of (name, ver) tuples for packages with updates available""" installed = pacman.list_unofficial() updates = [] with progressbar.ProgressBar(max_value=len(installed)) as bar: for i, pkg in enumerate(installed): pkgname, curver = pkg try: data = ccr.info(pkgname) except ccr.PackageNotFound: continue newver = data.get('Version', '0-0') if parse_version(newver) > parse_version(curver): updates.append((pkgname, newver)) bar.update(i) return updates
def info(args): """Print package info""" try: package = args.package except AttributeError: package = args try: results = ccr.info(package) except ccr.PackageNotFound: print("Package not found") return 1 print(''.join([ termcolor.colored(_("Name : "), attrs=['bold']), results.Name, '\n', termcolor.colored(_("Version : "), attrs=['bold']), results.Version, '\n', termcolor.colored(_("URL : "), attrs=['bold']), results.URL, '\n', termcolor.colored(_("Licenses : "), attrs=['bold']), results.License, '\n', termcolor.colored(_("Category : "), attrs=['bold']), results.Category, '\n', termcolor.colored(_("Votes : "), attrs=['bold']), str(results.NumVotes), '\n', termcolor.colored(_("Maintainer : "), attrs=['bold']), results.Maintainer, '\n', termcolor.colored(_("OutOfDate : "), attrs=['bold']), "{val}".format(val=True if results.OutOfDate == '1' else False), '\n', termcolor.colored(_("Description : "), attrs=['bold']), results.Description, ]))
def install(args): """Install a given package""" try: pkgnames = args.package workingdir = args.build_dir or BUILD_DIR except AttributeError: pkgnames = args workingdir = BUILD_DIR if os.getuid() == 0: print('Installations as root are not allowed. Exiting.') return print(_("resolving dependencies...")) editor = os.getenv('EDITOR') or 'vim' # Check packages, to fail early packages = [] for pkgname in pkgnames: try: # Make sure the package exists ccr.info(pkgname) except ccr.PackageNotFound: print(_("Package not found: {pkg}").format(pkg=pkgname)) return 1 packages += dependency_chain(pkgname, workingdir) # Check dependencies for pkgname in packages: try: # Make sure the package exists ccr.info(pkgname) except ccr.PackageNotFound: print(_("Package not found: {pkg}").format(pkg=pkgname)) return 1 print_targets(packages) response = prompt.prompt(_("Proceed with installation?"), major=True) if response == prompt.NO: return 0 for package in packages: try: get_source_files([package], workingdir) except (requests.exceptions.HTTPError, tarfile.ReadError): print(_("Package not found: {pkg}").format(pkg=package)) return 1 # Ask to edit the PKGBUILD response = prompt.prompt(_("Edit {pkg} PKGBUILD with $EDITOR?").format(pkg=package), color='yellow') if response == prompt.YES: subprocess.call([editor, "{d}/{pkg}/PKGBUILD".format(d=workingdir, pkg=package)]) # Ask to edit the .install, if it exists if os.path.isfile("{d}/{pkg}/{pkg}.install".format(d=workingdir, pkg=package)): response = prompt.prompt(_("Edit {pkg}.install with $EDITOR?").format(pkg=package), color='yellow') if response == prompt.YES: subprocess.call([editor, "{d}/{pkg}/{pkg}.install".format(d=workingdir, pkg=package)]) # makepkg curdir = os.getcwd() os.chdir(os.path.join(workingdir, package)) try: subprocess.check_call(["makepkg", "-rsi"]) except subprocess.CalledProcessError: return 1 os.chdir(curdir)
def install(args): """Install a given package""" try: pkgnames = args.package workingdir = args.build_dir or BUILD_DIR except AttributeError: pkgnames = args workingdir = BUILD_DIR if os.getuid() == 0: print('Installations as root are not allowed. Exiting.') return print(_("resolving dependencies...")) editor = os.getenv('EDITOR') or 'vim' # Check packages, to fail early packages = [] for pkgname in pkgnames: try: # Make sure the package exists ccr.info(pkgname) except ccr.PackageNotFound: print(_("Package not found: {pkg}").format(pkg=pkgname)) return 1 packages += dependency_chain(pkgname, workingdir) # Check dependencies for pkgname in packages: try: # Make sure the package exists ccr.info(pkgname) except ccr.PackageNotFound: print(_("Package not found: {pkg}").format(pkg=pkgname)) return 1 print_targets(packages) response = prompt.prompt(_("Proceed with installation?"), major=True) if response == prompt.NO: return 0 for package in packages: try: get_source_files([package], workingdir) except (requests.exceptions.HTTPError, tarfile.ReadError): print(_("Package not found: {pkg}").format(pkg=package)) return 1 # Ask to edit the PKGBUILD response = prompt.prompt( _("Edit {pkg} PKGBUILD with $EDITOR?").format(pkg=package), color='yellow') if response == prompt.YES: subprocess.call([ editor, "{d}/{pkg}/PKGBUILD".format(d=workingdir, pkg=package) ]) # Ask to edit the .install, if it exists if os.path.isfile("{d}/{pkg}/{pkg}.install".format(d=workingdir, pkg=package)): response = prompt.prompt( _("Edit {pkg}.install with $EDITOR?").format(pkg=package), color='yellow') if response == prompt.YES: subprocess.call([ editor, "{d}/{pkg}/{pkg}.install".format(d=workingdir, pkg=package) ]) # makepkg curdir = os.getcwd() os.chdir(os.path.join(workingdir, package)) try: subprocess.check_call(["makepkg", "-rsi"]) except subprocess.CalledProcessError: return 1 os.chdir(curdir)