Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2de34596 authored by Tianjie Xu's avatar Tianjie Xu Committed by Gerrit Code Review
Browse files

Merge "Fix errors from validate_target_files"

parents eebe61d3 2e0b835d
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -357,9 +357,6 @@ class ValidateTargetFilesTest(test_utils.ReleaseToolsTestCase):
        'google/coral/coral:10/RP1A.200325.001/6337676:user/dev-keys',
        'ro.product.odm.device=coral',
    ]
    input_tmp = ValidateTargetFilesTest.make_build_prop({
        'ODM/etc/build.prop': '\n'.join(build_prop),
    })
    input_tmp = ValidateTargetFilesTest.make_build_prop(build_prop)

    self.assertRaises(ValueError, CheckBuildPropDuplicity,
                        input_tmp)
    self.assertRaises(ValueError, CheckBuildPropDuplicity, input_tmp)
+18 −5
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict):

  logging.info('Done checking %s', script_path)


# Symlink files in `src` to `dst`, if the files do not
# already exists in `dst` directory.
def symlinkIfNotExists(src, dst):
@@ -246,6 +247,7 @@ def symlinkIfNotExists(src, dst):
      continue
    os.symlink(os.path.join(src, filename), os.path.join(dst, filename))


def ValidateVerifiedBootImages(input_tmp, info_dict, options):
  """Validates the Verified Boot related images.

@@ -423,16 +425,25 @@ def ValidateVerifiedBootImages(input_tmp, info_dict, options):
          'Verified %s with avbtool (key: %s):\n%s', image, key,
          stdoutdata.rstrip())

def CheckDataDuplicity(lines):

def CheckDataInconsistency(lines):
    build_prop = {}
    for line in lines:
      if line.startswith("import") or line.startswith("#"):
        continue
      key, value = line.split("=", 1)
      if "=" not in line:
        continue

      key, value = line.rstrip().split("=", 1)
      if key in build_prop:
        logging.info("Duplicated key found for {}".format(key))
        if value != build_prop[key]:
          logging.error("Key {} is defined twice with different values {} vs {}"
                        .format(key, value, build_prop[key]))
          return key
      build_prop[key] = value


def CheckBuildPropDuplicity(input_tmp):
  """Check all buld.prop files inside directory input_tmp, raise error
  if they contain duplicates"""
@@ -448,9 +459,11 @@ def CheckBuildPropDuplicity(input_tmp):
        continue
      logging.info("Checking {}".format(path))
      with open(path, 'r') as fp:
        dupKey = CheckDataDuplicity(fp.readlines())
        dupKey = CheckDataInconsistency(fp.readlines())
        if dupKey:
          raise ValueError("{} contains duplicate keys for {}", path, dupKey)
          raise ValueError("{} contains duplicate keys for {}".format(
              path, dupKey))


def main():
  parser = argparse.ArgumentParser(