From: Tomasz Buchert Date: Sat, 29 Aug 2015 21:07:52 +0000 (+0200) Subject: still runs X-Git-Tag: v0.3~2 X-Git-Url: http://git.thekondor.net/?a=commitdiff_plain;h=d3bee42aa76a4dfc786ddb2c236cae9418cc9cc2;p=debocker.git still runs --- diff --git a/debocker b/debocker index dc601c8..548a6a4 100755 --- a/debocker +++ b/debocker @@ -17,7 +17,8 @@ HERE = realpath(dirname(__file__)) sys.path.append(join(HERE, 'src')) from debocker.utils import cached_constant, cached_property, tmppath, \ - calculate_md5_and_size, log_check_call, log_check_output + calculate_md5_and_size, log_check_call, log_check_output, \ + get_filelist from debocker.log import log, LOW, fail from debocker.debian import extract_pristine_tar @@ -151,7 +152,7 @@ class Package: if comp: tar += [ compressions[comp] ] debian = join(self.path, 'debian') - filelist = get_reproducible_filelist(debian, self.path) + filelist = get_filelist(debian, self.path) tar += [ '--no-recursion', '-C', self.path ] tar += filelist log_check_call(tar, stdout = output) @@ -207,19 +208,6 @@ def make_quilt_bundle(name, version, control, bundler.add_source_file(debian_name, debian, 'debian_tarball') bundler.write_bundle(output = output) -def get_reproducible_filelist(path, base = None): - if base is None: - base = path - elements = [] - for p, ds, fs in os.walk(path): - p = relpath(p, base) - if p != '.': - p = join('.', p) - elements += [ join(p, x) for x in ds ] - elements += [ join(p, x) for x in fs ] - return sorted(elements) - - # STEPS STEPS = OrderedDict([ @@ -341,7 +329,7 @@ class Bundler: with open(dockerfile, 'w') as f: f.write(rendered) - file_list = get_reproducible_filelist(self.wdir) + file_list = get_filelist(self.wdir) # tar everything tar = [ 'tar', 'c', '-h', '--numeric-owner' ] tar += [ '--no-recursion' ] diff --git a/src/debocker/utils.py b/src/debocker/utils.py index 76c1215..5006e3e 100644 --- a/src/debocker/utils.py +++ b/src/debocker/utils.py @@ -4,7 +4,7 @@ import os import hashlib from tempfile import TemporaryDirectory from datetime import datetime -from os.path import join +from os.path import join, relpath from subprocess import check_call, check_output from .log import log, LOW @@ -66,3 +66,16 @@ def log_check_call(cmd, **kwds): def log_check_output(cmd, **kwds): log('Run (output): {}'.format(cmd), LOW) return check_output(cmd, **kwds) + +def get_filelist(path, base = None): + # reproducible list of files + if base is None: + base = path + elements = [] + for p, ds, fs in os.walk(path): + p = relpath(p, base) + if p != '.': + p = join('.', p) + elements += [ join(p, x) for x in ds ] + elements += [ join(p, x) for x in fs ] + return sorted(elements)