diff --git a/autospec/specfiles.py b/autospec/specfiles.py index 371b34e..78eaf4e 100644 --- a/autospec/specfiles.py +++ b/autospec/specfiles.py @@ -64,6 +64,7 @@ class Specfile(object): self.extra_make_install = "" self.extra_make32_install = "" self.tarball_prefix = "" + self.prefixes = dict() self.gcov_file = "" self.rawname = "" self.golibpath = "" @@ -410,13 +411,13 @@ class Specfile(object): elif self.default_pattern == "mvnbin": self._write_strip("%setup -q -n " + self.tarball_prefix) else: - if self.tarball_prefix: - prefix = self.tarball_prefix - self._write_strip("%setup -q -n " + self.tarball_prefix) + if self.prefixes[self.url]: + prefix = self.prefixes[self.url] + self._write_strip("%setup -q -n " + prefix) else: # Have to make up a path and create it prefix = os.path.splitext(os.path.basename(self.url))[0] - self._write_strip("%setup -q -c " + prefix) + self._write_strip("%setup -q -c -n " + prefix) for archive in self.sources["archive"]: # Skip POM files - they don't need to be extracted if archive.endswith('.pom'): @@ -425,6 +426,21 @@ class Specfile(object): self._write_strip("%setup -q -T -D -n {0} -b {1}" .format(prefix, self.source_index[archive])) + # Now handle extra versions, indexed by SOURCE + for url in self.sources["version"]: + if self.prefixes[url]: + prefix = self.prefixes[url] + self._write_strip("cd ..") + self._write_strip("%setup -q -T -n {0} -b {1}" + .format(prefix, + self.source_index[url])) + else: + # Have to make up a path and create it + prefix = os.path.splitext(os.path.basename(url))[0] + self._write_strip("cd ..") + self._write_strip("%setup -q -T -c -n {0} -b {1}" + .format(prefix, + self.source_index[url])) for archive, destination in zip(self.sources["archive"], self.sources["destination"]): if destination.startswith(':'): diff --git a/autospec/tarball.py b/autospec/tarball.py index 197d2fe..bbf9f03 100644 --- a/autospec/tarball.py +++ b/autospec/tarball.py @@ -45,6 +45,7 @@ gcov_file = "" archives = [] giturl = "" domain = "" +prefixes = dict() def get_go_artifacts(url, target, ver): @@ -146,6 +147,7 @@ def build_unzip(zip_path): and this function gets the 'prefix-dir' portion from the start of the unzip -l output. """ prefix = None + zipfile = os.path.basename(zip_path) contents = subprocess.check_output(["unzip", "-q", "-l", zip_path], universal_newlines=True) lines = contents.splitlines() if contents else [] # looking for directory prefix in unzip output as it may differ from default @@ -187,7 +189,6 @@ def build_unzip(zip_path): # If we didn't find a common prefix, make a dir, based on the zip filename if not prefix: - zipfile = os.path.basename(zip_path) subdir = os.path.splitext(zipfile)[0] extract_cmd = "unzip -qq -d {0} {1}".format( os.path.join(build.base_path, subdir), zip_path) @@ -691,6 +692,7 @@ def process(url_arg, name_arg, ver_arg, target, archives_arg, filemanager): global path global tarball_prefix global archives + global prefixes url = url_arg name = name_arg version = ver_arg @@ -710,6 +712,8 @@ def process(url_arg, name_arg, ver_arg, target, archives_arg, filemanager): tar_path = check_or_get_file(url, tarfile) # determine extract command and tarball prefix for the tarfile extract_cmd, tarball_prefix = find_extract(tar_path, tarfile) + # Store the detected prefix associated with this file + prefixes[url] = tarball_prefix # set global path with tarball_prefix path = os.path.join(build.base_path, tarball_prefix) # Now that the metadata has been collected print the header @@ -729,6 +733,9 @@ def process(url_arg, name_arg, ver_arg, target, archives_arg, filemanager): if not extraurl: # Nothing to do here continue + if extraurl == url: + # This is the same as the SOURCE0 package, which we already handled + continue buildpattern.sources["version"].append(extraurl) name, rawname, extraver = name_and_version(name_arg, extraver, filemanager) # Make sure we don't stick to a single version @@ -736,11 +743,13 @@ def process(url_arg, name_arg, ver_arg, target, archives_arg, filemanager): tarfile = os.path.basename(extraurl) tar_path = check_or_get_file(extraurl, tarfile, mode="a") extract_cmd, tarball_prefix = find_extract(tar_path, tarfile) + prefixes[extraurl] = tarball_prefix prepare_and_extract(extract_cmd) def load_specfile(specfile): """Load the specfile object with the tarball_prefix, gcov_file, and rawname.""" specfile.tarball_prefix = tarball_prefix + specfile.prefixes = prefixes specfile.gcov_file = gcov_file specfile.rawname = rawname