Revert "[BUILD] Calculate the full path ahead of time"
Revert "[BUILD] Promote artifacts from strings to their own type" This reverts commit dcd4ba0654eb6780235718092969c2f9e6b38775. This reverts commit 00d7eb3c0a6eefdb5947d07b18cf071ba538d696.
This commit is contained in:
parent
a4de19efdd
commit
93552fe8f4
|
@ -329,28 +329,21 @@ def find_release_version(src_branch):
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
raise RuntimeError('Could not find release version in branch %s' % src_branch)
|
raise RuntimeError('Could not find release version in branch %s' % src_branch)
|
||||||
|
|
||||||
class Artifact:
|
def artifact_names(release, path = ''):
|
||||||
def __init__(self, path, name, ext):
|
return [os.path.join(path, 'elasticsearch-%s.%s' % (release, t)) for t in ['deb', 'tar.gz', 'zip']]
|
||||||
self.path = path # path/to
|
|
||||||
self.name = name # elasticsearch-9.9.99
|
|
||||||
self.ext = ext # tar.gz
|
|
||||||
self.fullpath = os.path.join(self.path, "%s.%s" % (self.name, self.ext))
|
|
||||||
|
|
||||||
def artifacts(release, path = ''):
|
|
||||||
return [Artifact(path, "elasticsearch-%s" % release, t) for t in ['deb', 'tar.gz', 'zip']]
|
|
||||||
|
|
||||||
def get_artifacts(release):
|
def get_artifacts(release):
|
||||||
common_artifacts = artifacts(release, 'target/releases/')
|
common_artifacts = artifact_names(release, 'target/releases/')
|
||||||
for a in common_artifacts:
|
for f in common_artifacts:
|
||||||
if not os.path.isfile(a.fullpath):
|
if not os.path.isfile(f):
|
||||||
raise RuntimeError('Could not find required artifact at %s' % a.fullpath)
|
raise RuntimeError('Could not find required artifact at %s' % f)
|
||||||
rpm = os.path.join('target/rpm/elasticsearch/RPMS/noarch/', 'elasticsearch-%s-1.noarch.rpm' % release)
|
rpm = os.path.join('target/rpm/elasticsearch/RPMS/noarch/', 'elasticsearch-%s-1.noarch.rpm' % release)
|
||||||
if os.path.isfile(rpm):
|
if os.path.isfile(rpm):
|
||||||
log('RPM [%s] contains: ' % rpm)
|
log('RPM [%s] contains: ' % rpm)
|
||||||
run('rpm -pqli %s' % rpm)
|
run('rpm -pqli %s' % rpm)
|
||||||
# this is an oddness of RPM that is attches -1 so we have to rename it
|
# this is an oddness of RPM that is attches -1 so we have to rename it
|
||||||
renamed_rpm = Artifact('target/rpm/elasticsearch/RPMS/noarch/', 'elasticsearch-%s' % release, 'noarch.rpm')
|
renamed_rpm = os.path.join('target/rpm/elasticsearch/RPMS/noarch/', 'elasticsearch-%s.noarch.rpm' % release)
|
||||||
shutil.move(rpm, renamed_rpm.fullpath)
|
shutil.move(rpm, renamed_rpm)
|
||||||
common_artifacts.append(renamed_rpm)
|
common_artifacts.append(renamed_rpm)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Could not find required artifact at %s' % rpm)
|
raise RuntimeError('Could not find required artifact at %s' % rpm)
|
||||||
|
@ -359,17 +352,16 @@ def get_artifacts(release):
|
||||||
# Generates sha1 checsums for all files
|
# Generates sha1 checsums for all files
|
||||||
# and returns the checksum files as well
|
# and returns the checksum files as well
|
||||||
# as the given files in a list
|
# as the given files in a list
|
||||||
def generate_checksums(artifacts):
|
def generate_checksums(files):
|
||||||
res = []
|
res = []
|
||||||
for a in artifacts:
|
for release_file in files:
|
||||||
directory = os.path.dirname(a.fullpath)
|
directory = os.path.dirname(release_file)
|
||||||
file = os.path.basename(a.fullpath)
|
file = os.path.basename(release_file)
|
||||||
ext = 'sha1.txt'
|
checksum_file = '%s.sha1.txt' % file
|
||||||
checksum_file = '%s.%s' % (file, ext)
|
|
||||||
|
|
||||||
if os.system('cd %s; shasum %s > %s' % (directory, file, checksum_file)):
|
if os.system('cd %s; shasum %s > %s' % (directory, file, checksum_file)):
|
||||||
raise RuntimeError('Failed to generate checksum for file %s' % a)
|
raise RuntimeError('Failed to generate checksum for file %s' % release_file)
|
||||||
res = res + [Artifact(directory, file, ext), a]
|
res = res + [os.path.join(directory, checksum_file), release_file]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def download_and_verify(release, files, plugins=None, base_url='https://download.elasticsearch.org/elasticsearch/elasticsearch'):
|
def download_and_verify(release, files, plugins=None, base_url='https://download.elasticsearch.org/elasticsearch/elasticsearch'):
|
||||||
|
|
Loading…
Reference in New Issue