def main(argv): # Set umask to a sane value so that files created as root are readable. os.umask(0o22) options, target = ParseOptions(argv) # Calculate a list of Packages index files to compare against. Whenever we # upload a package, we check to make sure it's not already stored in one of # the packages files we uploaded. This list of packages files might contain # both board and host packages. pkg_indexes = _GrabAllRemotePackageIndexes(options.previous_binhost_url) if options.set_version: version = options.set_version else: version = GetVersion() if options.prepend_version: version = '%s-%s' % (options.prepend_version, version) acl = 'public-read' binhost_base_url = options.binhost_base_url if options.private: binhost_base_url = options.upload if target: acl = portage_util.FindOverlayFile(_GOOGLESTORAGE_GSUTIL_FILE, board=target.board_variant, buildroot=options.build_path) if acl is None: cros_build_lib.Die('No Google Storage ACL file %s found in %s overlay.', _GOOGLESTORAGE_GSUTIL_FILE, target.board_variant) binhost_conf_dir = None if options.binhost_conf_dir: binhost_conf_dir = os.path.join(options.build_path, options.binhost_conf_dir) uploader = PrebuiltUploader(options.upload, acl, binhost_base_url, pkg_indexes, options.build_path, options.packages, options.skip_upload, binhost_conf_dir, options.dryrun, target, options.slave_targets, version) if options.sync_host: uploader.SyncHostPrebuilts(options.key, options.git_sync, options.sync_binhost_conf) if options.board or options.slave_targets: uploader.SyncBoardPrebuilts(options.key, options.git_sync, options.sync_binhost_conf, options.upload_board_tarball, options.prepackaged_tarball, options.toolchains_overlay_tarballs, options.toolchains_overlay_upload_path, options.toolchain_tarballs, options.toolchain_upload_path)
def testFindOverlayFile(self): """Verify that the first file found is returned.""" file_to_find = 'something_special' full_path = os.path.join(self.tempdir, 'src', 'private-overlays', 'overlay-%s' % self.PUB_PRIV, file_to_find) osutils.Touch(full_path) self.assertEqual( full_path, portage_util.FindOverlayFile(file_to_find, self.BOTH, self.PUB_PRIV_VARIANT, self.tempdir))
def GetPrebuiltAclArgs(build_target): """Read and parse the GS ACL file from the private overlays. Args: build_target (build_target_util.BuildTarget): The build target. Returns: list[list[str]]: A list containing all of the [arg, value] pairs. E.g. [['-g', 'group_id:READ'], ['-u', 'user:FULL_CONTROL']] """ acl_file = portage_util.FindOverlayFile(_GOOGLESTORAGE_GSUTIL_FILE, board=build_target.name) if not acl_file: raise NoAclFileFound('No ACL file found for %s.' % build_target.name) lines = osutils.ReadFile(acl_file).splitlines() # Remove comments. lines = [line.split('#', 1)[0].strip() for line in lines] # Remove empty lines. lines = [line.strip() for line in lines if line.strip()] return [line.split() for line in lines]