diff options
author | Olav Vitters <olav@vitters.nl> | 2015-11-19 19:32:15 +0100 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2015-11-19 19:32:15 +0100 |
commit | d715e84c00aa6004b1b37c55cd8343fb43d2407a (patch) | |
tree | 7bcba01ae52b0324c466e3788232d85a6c85e271 | |
parent | a566bfe4398ff5baae38f4911aa07a9494a1e9cb (diff) | |
download | mgagnome-d715e84c00aa6004b1b37c55cd8343fb43d2407a.tar mgagnome-d715e84c00aa6004b1b37c55cd8343fb43d2407a.tar.gz mgagnome-d715e84c00aa6004b1b37c55cd8343fb43d2407a.tar.bz2 mgagnome-d715e84c00aa6004b1b37c55cd8343fb43d2407a.tar.xz mgagnome-d715e84c00aa6004b1b37c55cd8343fb43d2407a.zip |
read spec as utf8, spec only option to co, accept more mkrel options
-rwxr-xr-x | mgagnome | 37 |
1 files changed, 21 insertions, 16 deletions
@@ -299,7 +299,7 @@ def clean_pkgconfig_prov(prov): class SpecFile(object): re_update_version = re.compile(r'^(?P<pre>Version[ \t]*:\s*)(?P<version>.+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) - re_update_release = re.compile(r'^(?P<pre>Release[ \t]*:\s*)(?P<release>%mkrel \d+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) + re_update_release = re.compile(r'^(?P<pre>Release[ \t]*:\s*)(?P<release>%mkrel [0-9.]+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) re_update_patch = re.compile(r'^(?P<pre>Patch)(?P<nr>[0-9]*)(?P<pre2>[ \t]*:\s*)(?P<patch>.+)(?P<post>\s*)\n', re.MULTILINE + re.IGNORECASE) re_br_part = re.compile(r'(?P<br>[^\s%{},<>=][^\s%{},<>=]*)\b(?P<post>\s*(?:(?P<operator>=|>=|<=|=<|=>|>|<)\s*(?P<version>[^\s%{},]+|\%\{[^\s{%}]+\}|\%[^\s%{},]+)\b)?)') @@ -364,7 +364,7 @@ class SpecFile(object): ] made_changes = False - with open(self.path, "r") as f: + with open(self.path, "r", encoding="utf-8") as f: data = f.read() for reason, change_to, regexp in re_clean_spec: if change_to is None: @@ -547,7 +547,7 @@ class SpecFile(object): def remove_patch(self, nr): nrs = [str(nr)] if nr == 0: nrs.append('') - with open(self.path, "r") as f: + with open(self.path, "r", encoding="utf-8") as f: data = f.read() len_before=len(data) @@ -592,7 +592,7 @@ class SpecFile(object): # Determine the last command that failed if os.path.exists(logfile): print(logfile) - with open(logfile, "r") as f: + with open(logfile, "r", encoding="utf-8") as f: for line in line_input(f): if line.startswith('+ '): cmd_before = (cmd, cmd_before) @@ -663,7 +663,7 @@ class SpecFile(object): # XXX - doesn't handle buildrequires with version numbers :-( made_changes = False - with open(self.path, "r") as f: + with open(self.path, "r", encoding="utf-8") as f: data = f.read() data_before=data @@ -738,7 +738,7 @@ class SpecFile(object): if not self.ensure_no_local_changes(force): return False - with open(self.path, "r") as f: + with open(self.path, "r", encoding="utf-8") as f: data = f.read() if data.count("%subrel") != 0: @@ -756,6 +756,7 @@ class SpecFile(object): data, nr = self.re_update_release.subn(r'\g<pre>%mkrel 1\g<post>', data, 1) if nr != 1: + print(data, file=sys.stdout) print("ERROR: Could not reset release!", file=sys.stderr) return False @@ -822,7 +823,7 @@ class Patch(object): ) with tempfile.NamedTemporaryFile(dir=os.path.dirname(self.path), delete=False) as fdst: - with open(self.path, "r") as fsrc: + with open(self.path, "r", encoding="utf-8") as fsrc: # Start with any existing DEP3 headers for i in range(self.dep3['last_nr']): fdst.write(fsrc.read()) @@ -863,7 +864,7 @@ class Patch(object): last_nr = 0 nr = 0 try: - with open(self.path, "r") as f: + with open(self.path, "r", encoding="utf-8") as f: for line in line_input(f): nr += 1 # stop trying to parse when real patch begins @@ -1043,13 +1044,15 @@ class Downstream(object): @classmethod @retry(subprocess.CalledProcessError) - def co(cls, package, cwd=None): + def co(cls, package, cwd=None, spec_only=False): if cwd is None: cwd = os.path.expanduser(cls.PKGROOT) cmd = ['mgarepo', 'co'] if cls.DISTRO: cmd.extend(('-d', cls.DISTRO)) + if spec_only: + cmd.append('-s') cmd.append(package) return subprocess.check_call(cmd, cwd=cwd) @@ -1117,29 +1120,29 @@ class Downstream(object): raise ValueError("Multiple packages found and cannot determine package for version %s" % version) def write_file(path, data): - with tempfile.NamedTemporaryFile(mode='w+t',dir=os.path.dirname(path), delete=False) as fdst: + with tempfile.NamedTemporaryFile(mode='w+t',dir=os.path.dirname(path), delete=False, encoding="utf-8") as fdst: fdst.write(data) fdst.flush() os.rename(fdst.name, path) def cmd_co_multi(args): - package, what_to_print = args + package, what_to_print, options = args print(what_to_print) try: - Downstream.co(package) + Downstream.co(package, spec_only=options.spec_only) except subprocess.CalledProcessError: pass def cmd_co(options, parser): - with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor: + with concurrent.futures.ProcessPoolExecutor(max_workers=8) as executor: if options.all: - packages = ((package, package) for package in Downstream().packages) + packages = ((package, package, options) for package in Downstream().packages) elif len(options.package): - packages = ((package, package) for package in options.package) + packages = ((package, package, options) for package in options.package) else: - packages = ((l[0], "%s => %s" % (l[0], l[1])) for l in sorted(join_streams(auto_update=False))) + packages = ((l[0], "%s => %s" % (l[0], l[1]), options) for l in sorted(join_streams(auto_update=False))) executor.map(cmd_co_multi, packages) @@ -1660,6 +1663,8 @@ def main(): subparser = subparsers.add_parser('co', help='checkout all GNOME packages') subparser.add_argument("-a", "--all", action="store_true", dest="all", help="checkout all Downstream packages") + subparser.add_argument("-s", action="store_true", dest="spec_only", + help="only checkout SPECS/ directory") subparser.add_argument("package", help="Package name", nargs='*') subparser.set_defaults( func=cmd_co, all=False |