new_variant: handle empty lists for cros_workon

Make sure that the list of packages to cros_workon start or stop
is not empty. If it is empty, then don't try to cros_workon start
or stop it, because the library will raise an exception.

BUG=b:159092931
TEST=cros_workon all of the packages that are listed for Hatch,
so that when the build gets to the workon-and-emerge point, there
won't be any packages to stop working on:

(cr) $ cros_workon --board=hatch start coreboot libpayload \
vboot_reference depthcharge intel-cmlfsp coreboot-private-files-hatch \
chromeos-ec chromeos-config-bsp-hatch-private
(cr) $ ./new_variant.py --board=hatch --variant=tiamat

Generate the fitimage as directed, outside the chroot.

(cr) $ ./new_variant.py --continue

Observe that the emerge is successful, and you get a prompt to push
to coreboot. At that point, abort and clean up.

(cr) $ cros_workon --board=hatch stop coreboot libpayload \
vboot_reference depthcharge intel-cmlfsp coreboot-private-files-hatch \
chromeos-ec chromeos-config-bsp-hatch-private
(cr) $ ./new_variant.py --abort

Now make sure that the program doesn't try to cros_workon start an
empty list:

Change config_workon_pkgs in hatch.py to [].

(cr) $ ./new_variant.py --board=hatch --variant=tiamat

Generate the fitimage as directed, outside the chroot.

(cr) $ ./new_variant.py --continue

Observe that the build_config step succeeds. Once the build pauses
for coreboot upload, `./new_variant.py --abort` and then restore
hatch.py.

Change-Id: I481ab7c386e1fbc6f8dfca4006677bf01c09aacc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2247049
Tested-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
1 file changed