Loading README.rst +3 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ INTRODUCTION - a local abs sync; - an ad-hoc local cache; - nothing. You can also use it to update a PKGBUILD to the upstream version. It targets Devs and TUs to help them to stay informed of new release of their packages. It can also be used by AUR maintainers to track update for their packages. Loading @@ -38,6 +39,8 @@ Basically, you can run: You can add the last one in a cron job to get a daily report of which packages need updates. To update a PKGBUILD to the last upstream version, run: $ archversion update HOW IT WORKS ============ Loading src/bin/archversion +50 −3 Original line number Diff line number Diff line Loading @@ -20,15 +20,17 @@ '''Archlinux Version Controller''' from archversion import VERSION, DEFAULT_CONFIG_FILENAME, DEFAULT_CACHE_FILENAME from archversion.config import BaseConfigFile from archversion.version import VersionController from archversion.database import JsonDatabase from archversion.error import BaseError, MissingConfigFile from archversion.error import BaseError, MissingConfigFile, NoSuchFile from archversion.error import ERR_FATAL, ERR_ABORT, ERR_UNKNOWN from archversion import VERSION, DEFAULT_CONFIG_FILENAME, DEFAULT_CACHE_FILENAME from archversion.pacman import parse_pkgbuild, pkgbuild_set_version, pkgbuild_update_checksums from archversion.version import VersionController from collections import OrderedDict import argparse import logging import os def parse_argv(): '''Parse command line arguments''' Loading Loading @@ -64,6 +66,16 @@ def parse_argv(): "cache: list packages in cache. " "modes: list comparaison modes. ") p_list.set_defaults(func=command_list) # update parser p_update = sp_main.add_parser("update", help="update a PKGBUILD with latest version") p_update.add_argument("-p", "--path", default="PKGBUILD", help="name of the file to update. Default PKGBUILD") p_update.add_argument("-c", "--checksum", action="store_true", help="run updpkgsums after update") p_update.add_argument("-C", "--cache", action="store_true", help="use cache") p_update.set_defaults(func=command_update) # do parse namespace = p_main.parse_args() # Ensure subparser was choosen if "func" not in namespace: Loading Loading @@ -107,6 +119,41 @@ def command_list(args, vctrl): elif args.what == "modes": vctrl.print_modes() def command_update(args, vctrl): '''Handle update command call''' if not os.path.exists(args.path): raise NoSuchFile(args.path) if os.getresuid()[1] == 0: logging.warn("Warning: You should not run this as root") pkgdict = parse_pkgbuild(args.path) pkgname = pkgdict.get("pkgbase", pkgdict.get("pkgname", None)) pkgver = pkgdict.get("pkgver", None) # some sanity checks if "pkgname" is None: raise BaseError("Unable to detect pkgname in %s" % args.path) if "pkgver" is None: raise BaseError("Unable to detect pkgver in %s" % args.path) # get upstream version vctrl.packages = [ pkgname ] if not args.cache: vctrl.check_versions() upver = vctrl.cache.get(pkgname, None) if upver is None: raise BaseError("Unable to detect upstream version of %s" % pkgname) # print what we detect print("Package name: %s" % pkgname) print("PKGBUILD version: %s" % pkgver) print("Upstream version: %s" % vctrl.cache[pkgname]) # compare version if pkgver == upver: print("Version are the same.") return # update version with upstream pkgbuild_set_version(args.path, upver) # update checksum if args.checksum: pkgbuild_update_checksums(args.path) def main(): '''Program entry point''' try: Loading src/lib/archversion/pacman.py +19 −1 Original line number Diff line number Diff line Loading @@ -22,9 +22,9 @@ import logging import os import re import subprocess def parse_pkgbuild(path, shell="bash"): ''' Source variable from a PKGBUILD Loading @@ -44,4 +44,22 @@ def parse_pkgbuild(path, shell="bash"): bashenv.pop(env, None) return bashenv def pkgbuild_set_version(path, version, reset=True): ''' Change PKGBUILD pkgver to version If reset is True, pkgrel will be set to 1 ''' data = open(path, "r").read() data = re.sub("pkgver=.*", "pkgver=%s" % version, data) if reset: data = re.sub("pkgrel=.*", "pkgrel=1", data) open(path, "w").write(data) def pkgbuild_update_checksums(path): ''' Update checksums of PKGBUILD Use pacman provided scripts updpkgsums ''' subprocess.check_call(["updpkgsums"], shell=False, close_fds=True) # vim:set ts=4 sw=4 et ai: Loading
README.rst +3 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ INTRODUCTION - a local abs sync; - an ad-hoc local cache; - nothing. You can also use it to update a PKGBUILD to the upstream version. It targets Devs and TUs to help them to stay informed of new release of their packages. It can also be used by AUR maintainers to track update for their packages. Loading @@ -38,6 +39,8 @@ Basically, you can run: You can add the last one in a cron job to get a daily report of which packages need updates. To update a PKGBUILD to the last upstream version, run: $ archversion update HOW IT WORKS ============ Loading
src/bin/archversion +50 −3 Original line number Diff line number Diff line Loading @@ -20,15 +20,17 @@ '''Archlinux Version Controller''' from archversion import VERSION, DEFAULT_CONFIG_FILENAME, DEFAULT_CACHE_FILENAME from archversion.config import BaseConfigFile from archversion.version import VersionController from archversion.database import JsonDatabase from archversion.error import BaseError, MissingConfigFile from archversion.error import BaseError, MissingConfigFile, NoSuchFile from archversion.error import ERR_FATAL, ERR_ABORT, ERR_UNKNOWN from archversion import VERSION, DEFAULT_CONFIG_FILENAME, DEFAULT_CACHE_FILENAME from archversion.pacman import parse_pkgbuild, pkgbuild_set_version, pkgbuild_update_checksums from archversion.version import VersionController from collections import OrderedDict import argparse import logging import os def parse_argv(): '''Parse command line arguments''' Loading Loading @@ -64,6 +66,16 @@ def parse_argv(): "cache: list packages in cache. " "modes: list comparaison modes. ") p_list.set_defaults(func=command_list) # update parser p_update = sp_main.add_parser("update", help="update a PKGBUILD with latest version") p_update.add_argument("-p", "--path", default="PKGBUILD", help="name of the file to update. Default PKGBUILD") p_update.add_argument("-c", "--checksum", action="store_true", help="run updpkgsums after update") p_update.add_argument("-C", "--cache", action="store_true", help="use cache") p_update.set_defaults(func=command_update) # do parse namespace = p_main.parse_args() # Ensure subparser was choosen if "func" not in namespace: Loading Loading @@ -107,6 +119,41 @@ def command_list(args, vctrl): elif args.what == "modes": vctrl.print_modes() def command_update(args, vctrl): '''Handle update command call''' if not os.path.exists(args.path): raise NoSuchFile(args.path) if os.getresuid()[1] == 0: logging.warn("Warning: You should not run this as root") pkgdict = parse_pkgbuild(args.path) pkgname = pkgdict.get("pkgbase", pkgdict.get("pkgname", None)) pkgver = pkgdict.get("pkgver", None) # some sanity checks if "pkgname" is None: raise BaseError("Unable to detect pkgname in %s" % args.path) if "pkgver" is None: raise BaseError("Unable to detect pkgver in %s" % args.path) # get upstream version vctrl.packages = [ pkgname ] if not args.cache: vctrl.check_versions() upver = vctrl.cache.get(pkgname, None) if upver is None: raise BaseError("Unable to detect upstream version of %s" % pkgname) # print what we detect print("Package name: %s" % pkgname) print("PKGBUILD version: %s" % pkgver) print("Upstream version: %s" % vctrl.cache[pkgname]) # compare version if pkgver == upver: print("Version are the same.") return # update version with upstream pkgbuild_set_version(args.path, upver) # update checksum if args.checksum: pkgbuild_update_checksums(args.path) def main(): '''Program entry point''' try: Loading
src/lib/archversion/pacman.py +19 −1 Original line number Diff line number Diff line Loading @@ -22,9 +22,9 @@ import logging import os import re import subprocess def parse_pkgbuild(path, shell="bash"): ''' Source variable from a PKGBUILD Loading @@ -44,4 +44,22 @@ def parse_pkgbuild(path, shell="bash"): bashenv.pop(env, None) return bashenv def pkgbuild_set_version(path, version, reset=True): ''' Change PKGBUILD pkgver to version If reset is True, pkgrel will be set to 1 ''' data = open(path, "r").read() data = re.sub("pkgver=.*", "pkgver=%s" % version, data) if reset: data = re.sub("pkgrel=.*", "pkgrel=1", data) open(path, "w").write(data) def pkgbuild_update_checksums(path): ''' Update checksums of PKGBUILD Use pacman provided scripts updpkgsums ''' subprocess.check_call(["updpkgsums"], shell=False, close_fds=True) # vim:set ts=4 sw=4 et ai: