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

Commit c1a32958 authored by Mitchell Wills's avatar Mitchell Wills Committed by android-build-merger
Browse files

Merge "[generate-self-extracting-archive] Cleanup and improve error handling"

am: 78ed7113

Change-Id: I322acdca35089c7380b1ccf43731f0cfffe94417
parents 80508409 78ed7113
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ def _pipe_bytes(src, dst):
      break
    dst.write(b)

_MAX_OFFSET_WIDTH = 8
_MAX_OFFSET_WIDTH = 20
def _generate_extract_command(start, end, extract_name):
  """Generate the extract command.

@@ -119,6 +119,10 @@ def _generate_extract_command(start, end, extract_name):


def main(argv):
  if len(argv) != 5:
    print 'generate-self-extracting-archive.py expects exactly 4 arguments'
    sys.exit(1)

  output_filename = argv[1]
  input_archive_filename = argv[2]
  comment = argv[3]
@@ -129,6 +133,14 @@ def main(argv):
  with open(license_filename, 'r') as license_file:
    license = license_file.read()

  if not license:
    print 'License file was empty'
    sys.exit(1)

  if 'SOFTWARE LICENSE AGREEMENT' not in license:
    print 'License does not look like a license'
    sys.exit(1)

  comment_line = '# %s\n' % comment
  extract_name = os.path.basename(input_archive_filename)

@@ -161,5 +173,9 @@ def main(argv):
      trailing_zip.seek(0)
      _pipe_bytes(trailing_zip, output)

  umask = os.umask(0)
  os.umask(umask)
  os.chmod(output_filename, 0o777 & ~umask)

if __name__ == "__main__":
  main(sys.argv)