X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=hippotat.git;a=blobdiff_plain;f=hippotatlib%2Fownsource.py;h=16ccdbd06510d41746f2d07cdd0bc065af9d1f35;hp=385c9ea3cd47b06f65377f5019856010de12cf7d;hb=b3e598b5ea54399982e0183a3e59835b0f82f077;hpb=a7d05900523bc273c20c2c8e700f6df5be2bb6de diff --git a/hippotatlib/ownsource.py b/hippotatlib/ownsource.py index 385c9ea..16ccdbd 100644 --- a/hippotatlib/ownsource.py +++ b/hippotatlib/ownsource.py @@ -5,22 +5,25 @@ # # Copyright 2017 Ian Jackson # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version, with the "CAF Login -# Exception" as published by Ian Jackson (version 2, or at your option -# any later version) as an Additional Permission. +# AGPLv3+ + CAFv2+ # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public +# License as published by the Free Software Foundation, either +# version 3 of the License, or (at your option) any later version, +# with the "CAF Login Exception" as published by Ian Jackson +# (version 2, or at your option any later version) as an Additional +# Permission. # -# You should have received a copy of the GNU Affero General Public -# License and the CAF Login Exception along with this program, in the -# file AGPLv3+CAFv2. If not, email Ian Jackson -# . +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License and the CAF Login Exception along with this program, in +# the file AGPLv3+CAFv2. If not, email Ian Jackson +# . import os @@ -37,7 +40,7 @@ except ImportError: pass class SourceShipmentPreparer(): def __init__(s, destdir): # caller may modify, and should read after calling generate() - s.output_names = ['srcbomb.tar.gz', 'fullsrcbomb.tar'] + s.output_names = ['srcbomb.tar.gz', 'srcpkgsbomb.tar'] s.output_paths = [None,None] # alternatively caller may read this # defaults, caller can modify after creation s.logger = lambda m: print('SourceShipmentPreparer',m) @@ -50,10 +53,12 @@ class SourceShipmentPreparer(): s.cwd = os.getcwd() s.find_rune_base = "find -type f -perm -004 \! -path '*/tmp/*'" s.ignores = ['*~', '*.bak', '*.tmp', '#*#', '__pycache__', - '[0-9][0-9][0-9][0-9]-src.cpio'] + '[0-9][0-9][0-9][0-9]-src.tar'] s.rune_shell = ['/bin/bash', '-ec'] s.show_pathnames = True s.download_packages = True + s.stream_stderr = sys.stderr + s.stream_debug = open('/dev/null','w') s.rune_cpio = r''' set -o pipefail ( @@ -98,10 +103,10 @@ class SourceShipmentPreparer(): return [] r = [] for l in excl: - l.strip + l = l.strip() if l.startswith('#'): next if not len(l): next - r += l + r.append(l) return r def src_likeparent_git(s, src): @@ -183,7 +188,7 @@ class SourceShipmentPreparer(): find_rune = s.srcdir_find_rune(d) total_rune = s.rune_cpio % find_rune - name = s.new_output_name('src.cpio', infol) + name = s.new_output_name('src.tar', infol) s._dirmap[d] = name fh = s.open_output_fh(name, 'wb') @@ -271,8 +276,8 @@ class SourceShipmentPreparer(): subprocess.run(cmdl, cwd=s._packages_path, stdin=subprocess.DEVNULL, - stdout=sys.stdout, - stderr=sys.stderr, + stdout=s.stream_debug, + stderr=s.stream_stderr, restore_signals=True, check=True) @@ -342,11 +347,16 @@ class SourceShipmentPreparer(): def mk_inner_portmanteau(s): outputs = [s.manifest_name] + outputs_done = { } mfh = s.open_output_fh(s.manifest_name,'w') for me in s._manifest: try: fname = me['file'] except KeyError: fname = me.get('file_print','') - else: outputs.append(fname) + else: + try: outputs_done[fname] + except KeyError: + outputs.append(fname) + outputs_done[fname] = 1 print('%s\t%s' % (fname, me['info']), file=mfh) mfh.close() @@ -354,6 +364,7 @@ class SourceShipmentPreparer(): s._destdir, outputs) def mk_packages_portmanteau(s): + if not s.download_packages: return s._mk_portmanteau(1, s.rune_portmanteau_uncompressed, s._packages_path, s._package_sources)