Attempt to copy local Sources during releases.

For releasers copying into a build system SCM, we now extract the
SourceX filenames from the spec file, and anything we see in the
relative directory matching those exactly will be copied. (i.e. if you
store additional sources for your package at the same level as your spec
file, these will now be copied)
This commit is contained in:
Devan Goodwin 2012-04-20 16:26:44 -03:00
parent c0844f7018
commit 2486ed3327
2 changed files with 29 additions and 0 deletions

View file

@ -33,6 +33,23 @@ BUILDER_SHORTCUTS = {
}
def extract_sources(spec_file_lines):
"""
Returns a list of sources from the given spec file.
Some of these will be URL's, which is fine they will be ignored.
We're really just after relative filenames that might live in the same
location as the spec file, mostly used with NoTgzBuilder packages.
"""
filenames = []
source_pattern = re.compile('^Source\d+?:\s*(.*)')
for line in spec_file_lines:
match = source_pattern.match(line)
if match:
filenames.append(match.group(1))
return filenames
def extract_bzs(output):
"""
Parses the output of CVS diff or a series of git commit log entries,

View file

@ -152,6 +152,12 @@ class Releaser(object):
# we modify and then use a spec file copy from a different location.
files_to_copy = [self.builder.spec_file] # full paths
f = open(self.builder.spec_file, 'r')
lines = f.readlines()
f.close()
source_filenames = extract_sources(lines)
debug("Watching for source filenames: %s" % source_filenames)
for filename in os.listdir(self.builder.rpmbuild_gitcopy):
full_filepath = os.path.join(self.builder.rpmbuild_gitcopy, filename)
if os.path.isdir(full_filepath):
@ -166,6 +172,12 @@ class Releaser(object):
# builder is in use.
continue
# Check if file looks like it matches a Source line in the spec file:
if filename in source_filenames:
debug(" copying: %s" % filename)
files_to_copy.append(full_filepath)
continue
# Check if file ends with something this builder subclass wants
# to copy:
copy_it = False