From 5d335a84cac9fe148f5a086839fd14b9874527d5 Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Sep 23 2022 21:38:34 +0000 Subject: [PATCH 1/2] Fixes for explodedSRPM layouts. Signed-off-by: Troy Dawson --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 1b6a0c4..bc3bb13 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -1153,7 +1153,7 @@ class Commands(object): def sources_filename(self): if self.layout is None: return os.path.join(self.path, 'sources') - return os.path.join(self.path, self.layout.sources_file_template) + return os.path.join(self.path, self.layout.sources_file_template.replace("{0.repo_name}",self.repo_name)) @property def osbs_config_filename(self): @@ -2163,9 +2163,9 @@ class Commands(object): self.log.info("sources file doesn't exist. Source files download skipped.") return - # Default to putting the files where the repository is + # Default to putting the files in the layout sourcedir if not outdir: - outdir = self.path + outdir = self.layout.sourcedir sourcesf = SourcesFile(self.sources_filename, self.source_entry_type) @@ -2798,7 +2798,7 @@ class Commands(object): if not hashtype == 'sha256': cmd.extend(["--define", "_source_filedigest_algorithm %s" % hashtype, "--define", "_binary_filedigest_algorithm %s" % hashtype]) - specpath = os.path.join(self.path, self.spec) + specpath = os.path.join(self.layout.specdir, self.spec) tmpdir = None try: if not self.uses_rpmautospec or not rpmautospec_process_distgit: @@ -3238,7 +3238,7 @@ class Commands(object): if not hashtype == 'sha256': cmd.extend(["--define", "_source_filedigest_algorithm %s" % hashtype, "--define", "_binary_filedigest_algorithm %s" % hashtype]) - specpath = os.path.join(self.path, self.spec) + specpath = os.path.join(self.layout.specdir, self.spec) tmpdir = None try: if not self.uses_rpmautospec or not rpmautospec_process_distgit: diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 9694f14..b0a16fb 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -1484,7 +1484,7 @@ class cliClient(object): 'sources', help='Download source files', description='Download source files') sources_parser.add_argument( - '--outdir', default=os.curdir, + '--outdir', help='Directory to download files into (defaults to pwd)') sources_parser.set_defaults(command=self.sources) diff --git a/pyrpkg/sources.py b/pyrpkg/sources.py index 858461d..06f3ab7 100644 --- a/pyrpkg/sources.py +++ b/pyrpkg/sources.py @@ -67,15 +67,32 @@ class SourcesFile(object): return self.entry_type(m.group('hashtype'), m.group('file'), m.group('hash')) - # Try falling back on the old format + # Try falling back on the old Fedora format try: hash, file = stripped.split(' ', 1) except ValueError: - raise MalformedLineError( - 'sources has invalid content: {0}\n' - 'Please note that sources file must not be modified manually.' - .format(stripped)) + # Try old Centos Format + try: + hash, file_path = stripped.split(' ', 1) + if len(hash) == 128: + hashtype='sha512' + elif len(hash) == 64: + hashtype='sha256' + elif len(hash) == 40: + hashtype='sha1' + elif len(hash) == 32: + hashtype='md5' + else: + hashtype='unknown' + file = file_path.split('/')[1] + return self.entry_type(hashtype, file, hash) + + except ValueError: + raise MalformedLineError( + 'sources has invalid content: {0}\n' + 'Please note that sources file must not be modified manually.' + .format(stripped)) return self.entry_type('md5', file, hash) From 39b1ee6406c127cabb665c5d4aa391fdd818505f Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Oct 04 2022 21:14:04 +0000 Subject: [PATCH 2/2] Use os.path.split Signed-off-by: Troy Dawson --- diff --git a/pyrpkg/sources.py b/pyrpkg/sources.py index 06f3ab7..e02eda2 100644 --- a/pyrpkg/sources.py +++ b/pyrpkg/sources.py @@ -85,7 +85,7 @@ class SourcesFile(object): hashtype='md5' else: hashtype='unknown' - file = file_path.split('/')[1] + file = os.path.split(file_path)[1] return self.entry_type(hashtype, file, hash) except ValueError: