cros_unibuild_convert: fix cros-workon usages
According to crbug.com/1078242, we should omit the leading ../ from
CROS_WORKON_LOCALNAME.
This changes the unibuild converter, which generates ebuilds, to
follow that pattern.
For virtual packages, the package was converted away from using
cros-workon.eclass entirely, as we don't really need this
functionality with a virtual package.
BUG=chromium:1078242
TEST=emerge-nocturne chromeos-base/chromeos-config-bsp
Change-Id: I81db2fefb5583dfd86660815e8b95327beae3ee1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2239714
Tested-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Andrew Lamb <andrewlamb@chromium.org>
Commit-Queue: Andrew Lamb <andrewlamb@chromium.org>
Auto-Submit: Jack Rosenthal <jrosenth@chromium.org>
diff --git a/contrib/cros_unibuild_convert.py b/contrib/cros_unibuild_convert.py
index 4b4d9ea..696aa47 100755
--- a/contrib/cros_unibuild_convert.py
+++ b/contrib/cros_unibuild_convert.py
@@ -89,19 +89,12 @@
return gen_cros_copyright() + """
EAPI=7
-# cros_workon applies only to ebuild and files directory. Use the
-# canonical empty project.
-CROS_WORKON_PROJECT="chromiumos/infra/build/empty-project"
-CROS_WORKON_LOCALNAME="../platform/empty-project"
-
-inherit cros-workon
-
DESCRIPTION="ChromeOS Unibuild Config virtual package"
HOMEPAGE="https://chromium.googlesource.com/chromiumos/platform2/+/master/chromeos-config/README.md"
LICENSE="BSD-Google"
SLOT="0"
-KEYWORDS="~*"
+KEYWORDS="*"
DEPEND="%(depends)s"
RDEPEND="${DEPEND}"
@@ -119,7 +112,7 @@
# cros_workon applies only to ebuild and files directory. Use the
# canonical empty project.
CROS_WORKON_PROJECT="chromiumos/infra/build/empty-project"
-CROS_WORKON_LOCALNAME="../platform/empty-project"
+CROS_WORKON_LOCALNAME="platform/empty-project"
inherit cros-workon cros-unibuild
@@ -205,11 +198,19 @@
return res.stdout.strip() or None
-def write_file(fullpath, file_contents):
+def write_file(fullpath, file_contents, make_ebuild_symlink=False):
os.makedirs(fullpath.parent, exist_ok=True)
log('Writing {}...'.format(fullpath))
with open(fullpath, 'w') as f:
f.write(file_contents)
+ if make_ebuild_symlink:
+ if not fullpath.name.endswith('.ebuild'):
+ raise ValueError(
+ 'make_ebuild_symlink specified, but path does not look like an ebuild')
+ prefix, _, _ = fullpath.name.rpartition('.')
+ linkname = fullpath.parent / '{}-r1.ebuild'.format(prefix)
+ log('Creating symlink {} -> {}...'.format(linkname, fullpath))
+ os.symlink(fullpath.name, linkname)
def generate_make_defaults(contents):
@@ -324,14 +325,16 @@
self.ec_extras_build_target = sorted(list(self.ec_firmware_extras
| self.pd_firmwares)) or None
- def write_file(self, overlay_flags, path, file_contents):
+ def write_file(self, overlay_flags, path, file_contents,
+ make_ebuild_symlink=False):
dirs = []
if overlay_flags & M_PUBLIC:
dirs += [self.public_overlay]
if overlay_flags & M_PRIVATE:
dirs += [self.private_overlay]
for d in dirs:
- write_file(d / path, file_contents)
+ write_file(d / path, file_contents,
+ make_ebuild_symlink=make_ebuild_symlink)
class Dut:
@@ -696,11 +699,11 @@
M_PRIVATE, 'chromeos-base/chromeos-config-bsp-private/files/model.yaml',
private_config_yaml)
overlays.write_file(
- M_PUBLIC, 'virtual/chromeos-config-bsp/chromeos-config-bsp-9999.ebuild',
- public_vpackage)
+ M_PUBLIC, 'virtual/chromeos-config-bsp/chromeos-config-bsp-2.ebuild',
+ public_vpackage, make_ebuild_symlink=True)
overlays.write_file(
- M_PRIVATE, 'virtual/chromeos-config-bsp/chromeos-config-bsp-9999.ebuild',
- private_vpackage)
+ M_PRIVATE, 'virtual/chromeos-config-bsp/chromeos-config-bsp-3.ebuild',
+ private_vpackage, make_ebuild_symlink=True)
overlays.write_file(
M_PUBLIC,
'chromeos-base/chromeos-config-bsp/chromeos-config-bsp-9999.ebuild',