hooks: licensing: force python3.6 for now

When building a package that supports multiple versions of python and
one is selected that doesn't support portage (which this code needs),
the call fails.  Force it to use Python 3.6 until we know portage is
updated to support Python 3.8 too.

Also fix some shellcheck warnings while here.

BUG=b:187794810
TEST=`emerge-$BOARD toolchain-tests` works which uses python3.8

Change-Id: I379bf50a5b0782918508fede5e2019a0cec06fa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/3687616
Commit-Queue: Ram Chandrasekar <rchandrasekar@google.com>
Reviewed-by: Ram Chandrasekar <rchandrasekar@google.com>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/hooks/install/gen-package-licenses.sh b/hooks/install/gen-package-licenses.sh
index 0e70f96..fc09899 100755
--- a/hooks/install/gen-package-licenses.sh
+++ b/hooks/install/gen-package-licenses.sh
@@ -5,13 +5,15 @@
 
 generate_licensing()
 {
-  local PKG="${CATEGORY}/${PF}"
+  local PKG="${CATEGORY:-}/${PF:-}"
 
   # This expands to something like
   # /build/x86-alex/tmp/portage/dev-util/libc-bench-0.0.1-r6
   # Run FEATURES='noclean' emerge-x86-alex libc-bench to prevent having the
   # directory cleaned up if you are debugging.
-  einfo "Generating license for ${PKG} in ${PORTAGE_BUILDDIR}"
+  einfo "Generating license for ${PKG} in ${PORTAGE_BUILDDIR:-}"
+  # TODO(b/187794810): Move this to python3.8 once portage supports it.
+  python3.6 \
   /mnt/host/source/chromite/licensing/ebuild_license_hook \
       --builddir "${PORTAGE_BUILDDIR}" || die "
 Failed Generating Licensing for ${PKG}