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:
Simon Willnauer 2014-06-03 16:23:06 +02:00
parent a4de19efdd
commit 93552fe8f4
1 changed files with 15 additions and 23 deletions

View File

@ -329,28 +329,21 @@ def find_release_version(src_branch):
return match.group(1)
raise RuntimeError('Could not find release version in branch %s' % src_branch)
class Artifact:
def __init__(self, path, name, ext):
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 artifact_names(release, path = ''):
return [os.path.join(path, 'elasticsearch-%s.%s' % (release, t)) for t in ['deb', 'tar.gz', 'zip']]
def get_artifacts(release):
common_artifacts = artifacts(release, 'target/releases/')
for a in common_artifacts:
if not os.path.isfile(a.fullpath):
raise RuntimeError('Could not find required artifact at %s' % a.fullpath)
common_artifacts = artifact_names(release, 'target/releases/')
for f in common_artifacts:
if not os.path.isfile(f):
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)
if os.path.isfile(rpm):
log('RPM [%s] contains: ' % rpm)
run('rpm -pqli %s' % rpm)
# 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')
shutil.move(rpm, renamed_rpm.fullpath)
renamed_rpm = os.path.join('target/rpm/elasticsearch/RPMS/noarch/', 'elasticsearch-%s.noarch.rpm' % release)
shutil.move(rpm, renamed_rpm)
common_artifacts.append(renamed_rpm)
else:
raise RuntimeError('Could not find required artifact at %s' % rpm)
@ -359,17 +352,16 @@ def get_artifacts(release):
# Generates sha1 checsums for all files
# and returns the checksum files as well
# as the given files in a list
def generate_checksums(artifacts):
def generate_checksums(files):
res = []
for a in artifacts:
directory = os.path.dirname(a.fullpath)
file = os.path.basename(a.fullpath)
ext = 'sha1.txt'
checksum_file = '%s.%s' % (file, ext)
for release_file in files:
directory = os.path.dirname(release_file)
file = os.path.basename(release_file)
checksum_file = '%s.sha1.txt' % file
if os.system('cd %s; shasum %s > %s' % (directory, file, checksum_file)):
raise RuntimeError('Failed to generate checksum for file %s' % a)
res = res + [Artifact(directory, file, ext), a]
raise RuntimeError('Failed to generate checksum for file %s' % release_file)
res = res + [os.path.join(directory, checksum_file), release_file]
return res
def download_and_verify(release, files, plugins=None, base_url='https://download.elasticsearch.org/elasticsearch/elasticsearch'):