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
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)
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([
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' ]
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
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)