Example #1
0
 def setUp(self):
     self._tempdir = tempfile.mkdtemp()
     # Create a dummy dict that contains the fstab info for boot&recovery.
     self._info = {"fstab": {}}
     dummy_fstab = \
         ["/dev/soc.0/by-name/boot /boot emmc defaults defaults",
          "/dev/soc.0/by-name/recovery /recovery emmc defaults defaults"]
     self._info["fstab"] = common.LoadRecoveryFSTab(lambda x: "\n".join(x),
                                                    2, dummy_fstab)
Example #2
0
 def setUp(self):
   self._tempdir = common.MakeTempDir()
   # Create a dummy dict that contains the fstab info for boot&recovery.
   self._info = {"fstab" : {}}
   dummy_fstab = [
       "/dev/soc.0/by-name/boot /boot emmc defaults defaults",
       "/dev/soc.0/by-name/recovery /recovery emmc defaults defaults"]
   self._info["fstab"] = common.LoadRecoveryFSTab("\n".join, 2, dummy_fstab)
   # Construct the gzipped recovery.img and boot.img
   self.recovery_data = bytearray([
       0x1f, 0x8b, 0x08, 0x00, 0x81, 0x11, 0x02, 0x5a, 0x00, 0x03, 0x2b, 0x4a,
       0x4d, 0xce, 0x2f, 0x4b, 0x2d, 0xaa, 0x04, 0x00, 0xc9, 0x93, 0x43, 0xf3,
       0x08, 0x00, 0x00, 0x00
   ])
   # echo -n "boot" | gzip -f | hd
   self.boot_data = bytearray([
       0x1f, 0x8b, 0x08, 0x00, 0x8c, 0x12, 0x02, 0x5a, 0x00, 0x03, 0x4b, 0xca,
       0xcf, 0x2f, 0x01, 0x00, 0xc4, 0xae, 0xed, 0x46, 0x04, 0x00, 0x00, 0x00
   ])
    print os.path.join(input_dir, "recovery/root/etc/recovery.fstab")
    print "*********************************************************************"
    print "*********************************************************************"
    print "*********************************************************************"

    def read_helper(input_path):
        try:
            with open(
                    os.path.join(input_dir,
                                 "recovery/root/etc/recovery.fstab")) as f:
                return f.read()
        except IOError, e:
            print "no such file!"

    OPTIONS.info_dict = LoadInfoDict(input_dir)
    OPTIONS.info_dict["fstab"] = common.LoadRecoveryFSTab(read_helper, 2)
    OPTIONS.secure_boot = OPTIONS.info_dict.get("secure_boot", False)
    OPTIONS.secure_boot_tool = OPTIONS.info_dict.get("secure_boot_tool", None)
    OPTIONS.single_key = OPTIONS.info_dict.get("single_key", True)

    recovery_img = GetBootableImage("IMAGES/recovery.img", "recovery.img",
                                    input_dir)
    boot_img = GetBootableImage("IMAGES/boot.img", "boot.img", input_dir)

    if not recovery_img or not boot_img:
        sys.exit(0)

    def output_sink(fn, data):
        if fn == "etc/install-recovery.sh":
            fn = "bin/install-recovery.sh"
        if data: