Commit fe92995d authored by Dan Jacques's avatar Dan Jacques Committed by Commit Bot

[cipd] Allow packaging whole root.

Currently, the "cipd" recipe module allows a package to be created by
adding directories to a PackageDefinition via "add_dir". However, there
is no current way to add the entirety of a root directory to a package.
The PackageDefinition will generate a relative path of "''", which CIPD
will reject as empty.

Make it so that if the user supplies the root directory as the directory
to add to the package, it properly includes it as ".".

BUG=None
TEST=local
  - Ran recipe with this modification, seems to work

R=iannucci@chromium.org, nodir@chromium.org, vadimsh@chromium.org

Change-Id: Ib5c72038cf153776808f084db835c60f61fd9044
Reviewed-on: https://chromium-review.googlesource.com/510309Reviewed-by: 's avatarVadim Shtayura <vadimsh@chromium.org>
Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Daniel Jacques <dnj@chromium.org>
parent 62ca960a
......@@ -61,7 +61,9 @@ class PackageDefinition(object):
def _rel_path(self, path):
"""Returns a forward-slash-delimited version of `path` which is relative to
the package root. Will raise ValueError if path is not inside the root."""
if path != self.package_root and not self.package_root.is_parent_of(path):
if path == self.package_root:
return '.'
if not self.package_root.is_parent_of(path):
raise ValueError(
'path %r is not the package root %r and not a child thereof' %
(path, self.package_root))
......
......@@ -286,7 +286,7 @@
"cipd",
"create",
"-pkg-def",
"{\"data\": [{\"file\": \"a/path/to/file.py\"}, {\"file\": \"some_config.cfg\"}, {\"dir\": \"directory\", \"exclude\": []}, {\"dir\": \"other_dir\", \"exclude\": [\".*\\\\.pyc\"]}], \"install_mode\": \"\", \"package\": \"infra/fake-package\", \"root\": \"[START_DIR]/some_subdir\"}",
"{\"data\": [{\"file\": \"a/path/to/file.py\"}, {\"file\": \"some_config.cfg\"}, {\"dir\": \".\", \"exclude\": []}, {\"dir\": \"directory\", \"exclude\": []}, {\"dir\": \"other_dir\", \"exclude\": [\".*\\\\.pyc\"]}], \"install_mode\": \"\", \"package\": \"infra/fake-package\", \"root\": \"[START_DIR]/some_subdir\"}",
"-json-output",
"/path/to/tmp/json",
"-service-account-json",
......
......@@ -68,6 +68,7 @@ def RunSteps(api, use_pkg, pkg_files, pkg_dirs, ver_files, install_mode):
pkg = api.cipd.PackageDefinition('infra/fake-package', root, install_mode)
for fullpath in pkg_files:
pkg.add_file(api.path.abs_to_path(fullpath))
pkg.add_dir(root)
for obj in pkg_dirs:
pkg.add_dir(api.path.abs_to_path(obj.get('path', '')),
obj.get('exclusions'))
......
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