dlc: Add licensing file to DLC images

Licensing information is needed inside the DLC images. The dlc build
script is modified to use the licenses_lib script to generate the
licensing for the DLC and add that information to the DLC image.
licenses_lib is modified to generate licenses for specific packages.

BUG=chromium:911228
TEST=Create OS image before and after the change and verify
about_os_credits.html hasn't changed. Deploy dummy-dlc and verify a new
LICENSE file containning the license info is in
/run/imageloader/dummy-dlc/dummy-package/LICENSE.

Cq-Depend: chromium:2023857, chromium:2129955
Change-Id: I305cf11121a8ea1301ca172ffa0d7b335138f436
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2023772
Tested-by: Andrew Lassalle <andrewlassalle@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Andrew Lassalle <andrewlassalle@chromium.org>
diff --git a/cli/deploy.py b/cli/deploy.py
index feaf616..613fbf2 100644
--- a/cli/deploy.py
+++ b/cli/deploy.py
@@ -954,7 +954,7 @@
   return True
 
 
-def _EmergePackages(pkgs, device, strip, sysroot, root, emerge_args):
+def _EmergePackages(pkgs, device, strip, sysroot, root, board, emerge_args):
   """Call _Emerge for each package in pkgs."""
   dlc_deployed = False
   for pkg_path in _GetPackagesPaths(pkgs, strip, sysroot):
@@ -964,7 +964,7 @@
 
     dlc_id, dlc_package = _GetDLCInfo(device, pkg_path, from_dut=False)
     if dlc_id and dlc_package:
-      _DeployDLCImage(device, sysroot, dlc_id, dlc_package)
+      _DeployDLCImage(device, sysroot, board, dlc_id, dlc_package)
       dlc_deployed = True
       # Clean up empty directories created by emerging DLCs.
       device.run(['test', '-d', '/build/rootfs', '&&', 'rmdir',
@@ -1005,10 +1005,10 @@
     return False
 
 
-def _DeployDLCImage(device, sysroot, dlc_id, dlc_package):
+def _DeployDLCImage(device, sysroot, board, dlc_id, dlc_package):
   """Deploy (install and mount) a DLC image."""
   # Build the DLC image if the image is outdated or doesn't exist.
-  build_dlc.InstallDlcImages(sysroot=sysroot, dlc_id=dlc_id)
+  build_dlc.InstallDlcImages(sysroot=sysroot, dlc_id=dlc_id, board=board)
 
   logging.debug('Uninstall DLC %s if it is installed.', dlc_id)
   try:
@@ -1193,7 +1193,7 @@
       # Select function (emerge or unmerge) and bind args.
       if emerge:
         func = functools.partial(_EmergePackages, pkgs, device, strip,
-                                 sysroot, root, emerge_args)
+                                 sysroot, root, board, emerge_args)
       else:
         func = functools.partial(_UnmergePackages, pkgs, device, root,
                                  pkgs_attrs)