Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Make zip generation (more) reproducible
  Make _bower_archive rule deterministic

Change-Id: Ic7f059bc53b1a5bb970b8e52708679f9c784c6bf
This commit is contained in:
David Pursehouse 2018-04-25 08:58:24 +09:00
commit dcb0d67c93
4 changed files with 21 additions and 5 deletions

View File

@ -73,6 +73,8 @@ genrule2(
("tar -hcf- $(locations :pg_code) |" +
" tar --strip-components=2 -C $$TMP/ -xf-"),
"cd $$TMP",
"TZ=UTC",
"export TZ",
"find . -exec touch -t 198001010000 '{}' ';'",
"zip -rq $$ROOT/$@ *",
]),

View File

@ -28,6 +28,8 @@ def _impl(ctx):
source = ctx.outputs.zip.path + ".source"
external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
cmd = [
"TZ=UTC",
"export TZ",
"rm -rf %s" % source,
"mkdir %s" % source,
" && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
@ -50,7 +52,7 @@ def _impl(ctx):
":".join(transitive_jar_paths),
"-d %s" % dir]),
"find %s -exec touch -t 198001010000 '{}' ';'" % dir,
"(cd %s && zip -qr ../%s *)" % (dir, ctx.outputs.zip.basename),
"(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename),
]
ctx.actions.run_shell(
inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk,

View File

@ -75,12 +75,18 @@ def _bower_archive(ctx):
_bash(ctx, " && " .join([
"TMP=$(mktemp -d || mktemp -d -t bazel-tmp)",
"TZ=UTC",
"export UTC",
"cd $TMP",
"mkdir bower_components",
"cd bower_components",
"unzip %s" % ctx.path(download_name),
"cd ..",
"zip -r %s bower_components" % renamed_name,]))
"find . -exec touch -t 198001010000 '{}' ';'",
"zip -Xr %s bower_components" % renamed_name,
"cd ..",
"rm -rf ${TMP}",
]))
dep_version = ctx.attr.semver if ctx.attr.semver else ctx.attr.version
ctx.file(version_name,
@ -149,11 +155,13 @@ def _js_component(ctx):
name = name[:-4]
dest = "%s/%s" % (dir, name)
cmd = " && ".join([
"TZ=UTC",
"export TZ",
"mkdir -p %s" % dest,
"cp %s %s/" % (' '.join([s.path for s in ctx.files.srcs]), dest),
"cd %s" % dir,
"find . -exec touch -t 198001010000 '{}' ';'",
"zip -qr ../%s *" % ctx.outputs.zip.basename
"zip -Xqr ../%s *" % ctx.outputs.zip.basename
])
ctx.actions.run_shell(
@ -228,13 +236,15 @@ def _bower_component_bundle_impl(ctx):
outputs=[out_zip],
command=" && ".join([
"p=$PWD",
"TZ=UTC",
"export TZ",
"rm -rf %s.dir" % out_zip.path,
"mkdir -p %s.dir/bower_components" % out_zip.path,
"cd %s.dir/bower_components" % out_zip.path,
"for z in %s; do unzip -q $p/$z ; done" % " ".join(sorted([z.path for z in zips])),
"cd ..",
"find . -exec touch -t 198001010000 '{}' ';'",
"zip -qr $p/%s bower_components/*" % out_zip.path,
"zip -Xqr $p/%s bower_components/*" % out_zip.path,
]),
mnemonic="BowerCombine")

View File

@ -54,9 +54,11 @@ def _add_file(in_file, output):
def _make_war(input_dir, output):
return '(%s)' % ' && '.join([
'root=$(pwd)',
'TZ=UTC',
'export TZ',
'cd %s' % input_dir,
"find . -exec touch -t 198001010000 '{}' ';' 2> /dev/null",
'zip -9qr ${root}/%s .' % (output.path),
'zip -X -9qr ${root}/%s .' % (output.path),
])
def _war_impl(ctx):