From 5a56fe29526447df66ca706df6fc7ac3894d5d89 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 13 Nov 2017 23:02:58 +0100 Subject: [PATCH] Add fwsreleasers --- .gitignore | 1 + fwsreleasers/__init__.py | 3 +++ fwsreleasers/main.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 .gitignore create mode 100644 fwsreleasers/__init__.py create mode 100644 fwsreleasers/main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4672b50 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +fwsreleasers/__pycache__/ diff --git a/fwsreleasers/__init__.py b/fwsreleasers/__init__.py new file mode 100644 index 0000000..b976653 --- /dev/null +++ b/fwsreleasers/__init__.py @@ -0,0 +1,3 @@ +from fwsreleasers.main import \ + RsyncSRPMSReleaser + diff --git a/fwsreleasers/main.py b/fwsreleasers/main.py new file mode 100644 index 0000000..b2cd729 --- /dev/null +++ b/fwsreleasers/main.py @@ -0,0 +1,53 @@ +import os +from tempfile import mkdtemp +import shutil +from tito.common import create_builder, debug, \ + run_command, get_project_name, warn_out, error_out +from tito.release import RsyncReleaser + +RSYNC_USERNAME = 'RSYNC_USERNAME' # environment variable name + +class RsyncSRPMSReleaser(RsyncReleaser): + """ + Just build the srpm and rsync it on a remote location + """ + REQUIRED_CONFIG = ['rsync', 'srpm_disttag'] + + # Default list of packages to copy + filetypes = ['srpm'] + + # By default run rsync with these paramaters + rsync_args = "-lvz" + + def __init__(self, name=None, tag=None, build_dir=None, + config=None, user_config=None, + target=None, releaser_config=None, no_cleanup=False, + test=False, auto_accept=False, + prefix="temp_dir=", **kwargs): + RsyncReleaser.__init__(self, name, tag, build_dir, config, + user_config, target, releaser_config, no_cleanup, test, + auto_accept, **kwargs) + + def release(self, dry_run=False, no_build=False, scratch=False): + self.dry_run = dry_run + + # Check if the releaser specifies a srpm disttag: + srpm_disttag = None + if self.releaser_config.has_option(self.target, "srpm_disttag"): + srpm_disttag = self.releaser_config.get(self.target, "srpm_disttag") + self.builder.srpm(dist=srpm_disttag) + + if self.releaser_config.has_option(self.target, 'rsync_args'): + self.rsync_args = self.releaser_config.get(self.target, 'rsync_args') + + rsync = self.releaser_config.get(self.target, 'rsync').split(" ") + for destination in rsync: + for artifact in self.builder.artifacts: + if artifact.endswith('.src.rpm'): + cmd = "rsync %s %s %s" % (self.rsync_args, artifact, destination) + if self.dry_run: + self.print_dry_run_warning(cmd) + else: + output = run_command(cmd) + debug(output) + os.remove(artifact)