From 8fa666e9d9809ca691c4edd1dcc01a954c9426ee Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Aug 25 2017 12:19:57 +0000 Subject: Avoid branch detection for 'rpkg sources' After CentOS change 7a006813224aebdf3ce1d0d1667f97949af4c7a2, it was impossible (without explicit --release option) to download sources in unclean git branch. It would be pity to have such limitation everywhere, even for non-CentOS dist-git instances where branch info is not used for source location. So let's make this feature optional: [cpkg] lookaside_kwargs = branch Also, the original motivation was that it a bit complicates 'rpkg' re-usability (rhbz#1410403). Signed-off-by: Pavel Raiskup --- diff --git a/etc/rpkg/rpkg.conf b/etc/rpkg/rpkg.conf index eedc2c7..9b6b944 100644 --- a/etc/rpkg/rpkg.conf +++ b/etc/rpkg/rpkg.conf @@ -1,5 +1,7 @@ [rpkg] lookaside = http://localhost/repo/pkgs +# Additional arguments needed to construct lookaside download URL. +#lookaside_request_params = branch lookasidehash = md5 lookaside_cgi = https://localhost/repo/pkgs/upload.cgi gitbaseurl = ssh://%(user)s@localhost/%(module)s diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 1c80d2e..9385d0f 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -80,6 +80,8 @@ class Commands(object): self.lookasidehash = lookasidehash # The CGI server for the lookaside self.lookaside_cgi = lookaside_cgi + # Additional arguments needed for lookaside url expansion + self.lookaside_request_params = None # The base URL of the git server self.gitbaseurl = gitbaseurl # The anonymous version of the git url @@ -1758,12 +1760,22 @@ class Commands(object): sourcesf = SourcesFile(self.sources_filename, self.source_entry_type) + args = dict() + if self.lookaside_request_params: + if 'branch' in self.lookaside_request_params.split(): + # The value of branch_merge is dynamic property; to get it's + # value you need to be in proper branch or you need to first + # specify --release (which is pretty annoying). Since not every + # dist-git instance out there really needs 'branch' argument to + # expand lookaside cache urls - make it optional. + args['branch'] = self.branch_merge + for entry in sourcesf.entries: outfile = os.path.join(outdir, entry.file) self.lookasidecache.download( self.ns_module_name if self.lookaside_namespaced else self.module_name, entry.file, entry.hash, outfile, - hashtype=entry.hashtype, branch=self.branch_merge) + hashtype=entry.hashtype, **args) def switch_branch(self, branch, fetch=True): """Switch the working branch diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 8ae2707..4b0fa98 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -175,6 +175,7 @@ class cliClient(object): self._cmd.debug = self.args.debug self._cmd.verbose = self.args.v self._cmd.clone_config = items.get('clone_config') + self._cmd.lookaside_request_params = items.get('lookaside_request_params') # This function loads the extra stuff once we figure out what site # we are