pack_firmware: Enable using sfx2 as ZIP based updater package

The new futility supports all commands that updater5 provides and can be
now be switched to the simpler SFX program.

As the first step, we want to enable sfx2, and when it goes stable we
can start removing other dependency (--script, sfx.sh, ... etc).

BUG=chromium:875551
TEST=BOARD=chell; emerge-$BOARD chromeos-firmware-$BOARD
     /build/$BOARD/usr/sbin/chromeos-firmwareupdate
CQ-DEPEND=CL:1282084

Change-Id: I97c52899dff539044dd7f867f1c1c9d42c25ec4e
Reviewed-on: https://chromium-review.googlesource.com/1282544
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/pack_firmware.py b/pack_firmware.py
index 09a6e6c..dbe3ac0 100755
--- a/pack_firmware.py
+++ b/pack_firmware.py
@@ -8,7 +8,7 @@
 
 It requires:
  - at least one firmware image (*.bin, should be AP or EC or ...)
- - pack/sfx.sh as the self extraction (and installation) script
+ - pack/sfx?.sh as the self extraction (and installation) script
 """
 
 from __future__ import print_function
@@ -60,7 +60,7 @@
 # For testing
 packer = None
 
-# Variables that we replace in pack/sfx.sh and pack/setvars_template.
+# Variables that we replace in pack/setvars_template.
 REPLACE_VARS = [
     'TARGET_RO_FWID',
     'TARGET_FWID',
@@ -83,7 +83,7 @@
   Private members:
     _args: Parsed arguments.
     _script_base: Base directory with useful files (src/platform/firmware).
-    _sfx_file: Path to `sfx.sh`.
+    _sfx_file: Path to the SFX program (pack/sfx?.sh).
     _basedir: Base temporary directory.
     _tmpdir: Temporary directory for use for running tools.
     _tmp_dirs: List of temporary directories created.
@@ -97,7 +97,7 @@
     # we can access the script files using the same path as the script.
     self._script_base = os.path.dirname(progname)
     self._args = None
-    self._sfx_file = os.path.join(self._script_base, 'pack', 'sfx.sh')
+    self._sfx_file = os.path.join(self._script_base, 'pack', 'sfx2.sh')
     self._setvars_template_file = os.path.join(
         self._script_base, 'pack', 'setvars_template')
     self._basedir = None
@@ -963,7 +963,7 @@
     """
     args = self._args = self.ParseArgs(argv)
 
-    self._EnsureCommand('shar', 'sharutils')
+    self._EnsureCommand('zip', 'zip')
     if not os.path.exists(self._sfx_file):
       raise PackError("Cannot find required file '%s'" % self._sfx_file)
     try:
diff --git a/pack_firmware_unittest.py b/pack_firmware_unittest.py
index 6fa7095..cc67b14 100755
--- a/pack_firmware_unittest.py
+++ b/pack_firmware_unittest.py
@@ -191,13 +191,13 @@
     # Starting up in another directory (without required files) should fail.
     with self.assertRaises(pack_firmware.PackError) as e:
       pack_firmware.main(['/'])
-    self.assertIn("'/pack/sfx.sh'", str(e.exception))
+    self.assertIn("'/pack/sfx2.sh'", str(e.exception))
 
-    # Should check for 'shar' tool.
+    # Should check for 'zip' tool.
     with mock.patch.object(osutils, 'Which', return_value=None):
       with self.assertRaises(pack_firmware.PackError) as e:
         pack_firmware.main(['.'])
-      self.assertIn("'shar'", str(e.exception))
+      self.assertIn("'zip'", str(e.exception))
 
     # Should complain if we don't provide at least one image.
     with self.assertRaises(pack_firmware.PackError) as e:
@@ -447,7 +447,6 @@
       for fname in ['RO_FRID', 'RW_FWID']:
         shutil.copy2(os.path.join('test', fname), destdir)
 
-    rc.AddCmdResult(partial_mock.Regex('type shar'), returncode=0)
     rc.AddCmdResult(partial_mock.ListRegex('file'), returncode=0,
                     output='ELF 64-bit LSB executable, etc.\n')
     rc.AddCmdResult(