Commit 6df42451 authored by jessicag's avatar jessicag Committed by Commit bot

Update ADD handling in Dockerfiles and test bundle creation.

Current Dockerfiles were written with a misunderstanding of how wildcards and directory sources interact with the ADD command. This was discovered in testing using the generated tarballs.

The change fixes an incorrect comment in the engine Dockerfile.

Additionally, create_bundle.py was updated to tar up the filesystem state from a context other than the build directory.

These changes mean that for the env_tests bundle, running the Dockerfile in the context of the tarball results in a system file structure such that /blimp/ contains the set of dpendencies for the testing binaries in the same directory structure as // (the chromium src directory).

This change does not remove the duplicate ./third_party/blimp_fonts (./fonts is used instead) for the engine environment.

BUG=616945, 608487, 630438

Review-Url: https://codereview.chromium.org/2154873002
Cr-Commit-Position: refs/heads/master@{#407237}
parent 5b7b3f37
...@@ -175,6 +175,8 @@ if (is_linux) { ...@@ -175,6 +175,8 @@ if (is_linux) {
_rebased_blimp_engine_env_tests_manifest, _rebased_blimp_engine_env_tests_manifest,
"--output", "--output",
rebase_path(_bundle), rebase_path(_bundle),
"--tar-contents-rooted-in",
rebase_path("//")
] ]
} }
} }
...@@ -4,8 +4,6 @@ RUN mkdir /engine ...@@ -4,8 +4,6 @@ RUN mkdir /engine
RUN useradd -ms /bin/bash blimp_user RUN useradd -ms /bin/bash blimp_user
# The glob below expands to all files, but does not add directories
# recursively.
ADD * /engine/ ADD * /engine/
ADD gen/third_party/blimp_fonts /engine/fonts ADD gen/third_party/blimp_fonts /engine/fonts
RUN mv /engine/chrome_sandbox /engine/chrome-sandbox RUN mv /engine/chrome_sandbox /engine/chrome-sandbox
......
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
# Engine itself. # Engine itself.
FROM base:latest FROM base:latest
RUN mkdir -p /out/test/ RUN mkdir -p /blimp/
# The glob below expands to all files, but does not add directories RUN useradd -ms /bin/bash blimp_user
# recursively.
# Test binaries assume src directory is 2 levels down. While this behavior can
# be changed with flags, the directory structure is set up to minimize
# potential problems with initial integration.
ADD * /out/test/
RUN chown -R blimp_user /out/test/ # Put all the Blimp related files in /blimp so they are kept separate from
# the OS files. Using '.' instead of '*' ensures directory structure is
# maintained since ADD only copies the contents of directories.
ADD . /blimp/
RUN chown -R blimp_user /blimp
USER blimp_user USER blimp_user
\ No newline at end of file
...@@ -15,19 +15,22 @@ import os ...@@ -15,19 +15,22 @@ import os
import subprocess import subprocess
import sys import sys
def ReadDependencies(manifest): def ReadDependencies(manifest, relative_path):
"""Read the manifest and return the list of dependencies. """Returns a list of dependencies based on the specified manifest file.
The returned dependencies will be made relative to |relative_path| and
normalized.
:raises IOError: if the manifest could not be read. :raises IOError: if the manifest could not be read.
""" """
deps = [] dependency_list = []
with open(manifest) as f: with open(manifest) as f:
for line in f.readlines(): for line in f.readlines():
# Strip comments. # Strip comments.
dep = line.partition('#')[0].strip() dependency = line.partition('#')[0].strip()
# Ignore empty strings. # Ignore empty strings.
if dep: if dependency:
deps.append(dep) dependency = os.path.normpath(os.path.join(relative_path, dependency))
return deps dependency_list.append(dependency)
return dependency_list
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
...@@ -50,9 +53,19 @@ def main(): ...@@ -50,9 +53,19 @@ def main():
help=('name and path of bundle to create'), help=('name and path of bundle to create'),
required=True, required=True,
metavar='FILE') metavar='FILE')
parser.add_argument('--tar-contents-rooted-in',
help=('optional path prefix to use inside the resulting '
'tar file'),
required=False,
metavar='DIR')
args = parser.parse_args() args = parser.parse_args()
deps = ReadDependencies(args.manifest) dependencies_path = args.build_dir
if args.tar_contents_rooted_in:
dependencies_path = args.tar_contents_rooted_in
relative_path = os.path.relpath(args.build_dir, dependencies_path)
dependency_list = ReadDependencies(args.manifest, relative_path)
try: try:
env = os.environ.copy() env = os.environ.copy()
...@@ -65,7 +78,7 @@ def main(): ...@@ -65,7 +78,7 @@ def main():
# use as part of a "docker build". That is group readable with # use as part of a "docker build". That is group readable with
# executable files also being group executable. # executable files also being group executable.
"--mode=g+rX", "--mode=g+rX",
"-C", args.build_dir] + deps "-C", dependencies_path] + dependency_list
for f in args.filelist: for f in args.filelist:
dirname, basename = os.path.split(f) dirname, basename = os.path.split(f)
subprocess_args.extend(["-C", dirname, basename]) subprocess_args.extend(["-C", dirname, basename])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment