def package_source_hash(apiurl, project, package, revision=None): query = {} if revision: query['rev'] = revision # Will not catch packages that previous had a link, but no longer do. if package_source_link_copy(apiurl, project, package): query['expand'] = 1 try: url = makeurl(apiurl, ['source', project, package], query) root = ETL.parse(http_GET(url)).getroot() except HTTPError as e: if e.code == 400 or e.code == 404: # 400: revision not found, 404: package not found. return None raise e if revision and root.find('error') is not None: # OBS returns XML error instead of HTTP 404 if revision not found. return None from osclib.util import sha1_short return sha1_short(root.xpath('entry[@name!="_link"]/@md5'))
def package_source_hash(apiurl, project, package, revision=None): query = {} if revision: query['rev'] = revision # Will not catch packages that previous had a link, but no longer do. if package_source_link_copy(apiurl, project, package): query['expand'] = 1 try: url = makeurl(apiurl, ['source', project, package], query) root = ETL.parse(http_GET(url)).getroot() except HTTPError as e: if e.code == 400 or e.code == 404: # 400: revision not found, 404: package not found. return None raise e if revision and root.find('error') is not None: # OBS returns XML error instead of HTTP 404 if revision not found. return None from osclib.util import sha1_short return sha1_short(root.xpath('entry[@name!="_link"]/@md5'))
def repository_state(self, repository_pairs, simulate_merge): archs = self.target_archs(repository_pairs[0][0], repository_pairs[0][1]) states = repositories_states(self.apiurl, repository_pairs, archs) if simulate_merge: states.append(str(project_meta_revision(self.apiurl, repository_pairs[0][0]))) return sha1_short(states)
def repository_state(self, repository_pairs, simulate_merge): archs = self.target_archs(repository_pairs[0][0], repository_pairs[0][1]) states = repositories_states(self.apiurl, repository_pairs, archs) if simulate_merge: states.append(str(project_meta_revision(self.apiurl, repository_pairs[0][0]))) return sha1_short(states)
def repository_state(apiurl, project, repository): # Unfortunately, the state hash reflects the published state and not the # binaries published in repository. As such request binary list and hash. combined_state = [] for arch in target_archs(apiurl, project, repository): combined_state.append( repository_arch_state(apiurl, project, repository, arch)) from osclib.util import sha1_short return sha1_short(combined_state)
def repository_arch_state(apiurl, project, repository, arch): # just checking the mtimes of the repository's binaries url = makeurl(apiurl, ['build', project, repository, arch, '_repository']) from osclib.util import sha1_short try: return sha1_short(http_GET(url).read()) except HTTPError as e: # e.g. staging projects inherit the project config from 'ports' repository. # but that repository does not contain the archs we want, as such it has no state if e.code != 404: raise e
def repository_arch_state(apiurl, project, repository, arch): # just checking the mtimes of the repository's binaries url = makeurl(apiurl, ['build', project, repository, arch, '_repository']) from osclib.util import sha1_short try: return sha1_short(http_GET(url).read()) except HTTPError as e: # e.g. staging projects inherit the project config from 'ports' repository. # but that repository does not contain the archs we want, as such it has no state if e.code != 404: raise e
def repository_state(apiurl, project, repository, archs=[]): if not len(archs): archs = target_archs(apiurl, project, repository) # Unfortunately, the state hash reflects the published state and not the # binaries published in repository. As such request binary list and hash. combined_state = [] for arch in archs: combined_state.append(repository_arch_state(apiurl, project, repository, arch)) from osclib.util import sha1_short return sha1_short(combined_state)
def repository_state(self, repository_pairs): states = repositories_states(self.apiurl, repository_pairs) states.append( str(project_meta_revision(self.apiurl, repository_pairs[0][0]))) return sha1_short(states)
def __init__(self, **kwargs): self.kwargs = kwargs self.name = self.__class__.__name__[8:].lower() self.key = self.name if kwargs: self.key += '_' + sha1_short(str(kwargs))
def repository_arch_state(apiurl, project, repository, arch): # just checking the mtimes of the repository's binaries url = makeurl(apiurl, ['build', project, repository, arch, '_repository']) from osclib.util import sha1_short return sha1_short(http_GET(url).read())
def repository_arch_state(apiurl, project, repository, arch): # just checking the mtimes of the repository's binaries url = makeurl(apiurl, ['build', project, repository, arch, '_repository']) from osclib.util import sha1_short return sha1_short(http_GET(url).read())