Merge pull request #72 from spkane/master

Configure rsync to preserve timestamps and file permissions
This commit is contained in:
Devan Goodwin 2013-04-24 09:08:13 -07:00
commit fa705ff825
2 changed files with 16 additions and 9 deletions

View file

@ -100,10 +100,11 @@ EXAMPLE
cvsroot = :gserver:cvs.example.com:/cvs/dist cvsroot = :gserver:cvs.example.com:/cvs/dist
branches = FEDORA-15 branches = FEDORA-15
; rsync tgz file to remote site ; rsync tgz file to remote site with custom rsync arguments
[rsync] [rsync]
releaser = tito.release.RsyncReleaser releaser = tito.release.RsyncReleaser
builder = tito.builder.MockBuilder builder = tito.builder.MockBuilder
builder.mock = fedora-15-x86_64 builder.mock = fedora-15-x86_64
filetypes = tgz filetypes = tgz
rsync = remoteserver.org:/srv/tarballs/ rsync = remoteserver.org:/srv/tarballs/
rsync_args = -rlvzpt

View file

@ -270,6 +270,9 @@ class RsyncReleaser(Releaser):
# Default list of packages to copy # Default list of packages to copy
filetypes = ['rpm', 'srpm', 'tgz'] filetypes = ['rpm', 'srpm', 'tgz']
# By default run rsync with these paramaters
rsync_args = "-rlvz"
def __init__(self, name=None, version=None, tag=None, build_dir=None, def __init__(self, name=None, version=None, tag=None, build_dir=None,
pkg_config=None, global_config=None, user_config=None, pkg_config=None, global_config=None, user_config=None,
target=None, releaser_config=None, no_cleanup=False, test=False, auto_accept=False, target=None, releaser_config=None, no_cleanup=False, test=False, auto_accept=False,
@ -299,6 +302,9 @@ class RsyncReleaser(Releaser):
self.builder._rpm() self.builder._rpm()
self.builder.cleanup() self.builder.cleanup()
if self.releaser_config.has_option(self.target, 'rsync_args'):
self.rsync_args = self.releaser_config.get(self.target, 'rsync_args')
rsync_locations = self.releaser_config.get(self.target, 'rsync').split(" ") rsync_locations = self.releaser_config.get(self.target, 'rsync').split(" ")
for rsync_location in rsync_locations: for rsync_location in rsync_locations:
if RSYNC_USERNAME in os.environ: if RSYNC_USERNAME in os.environ:
@ -309,22 +315,22 @@ class RsyncReleaser(Releaser):
# Make a temp directory to sync the existing repo contents into: # Make a temp directory to sync the existing repo contents into:
temp_dir = mkdtemp(dir=self.build_dir, prefix=self.prefix) temp_dir = mkdtemp(dir=self.build_dir, prefix=self.prefix)
self._rsync_from_remote(rsync_location, temp_dir) self._rsync_from_remote(self.rsync_args, rsync_location, temp_dir)
self._copy_files_to_temp_dir(temp_dir) self._copy_files_to_temp_dir(temp_dir)
self.process_packages(temp_dir) self.process_packages(temp_dir)
self.rsync_to_remote(temp_dir, rsync_location) self.rsync_to_remote(self.rsync_args, temp_dir, rsync_location)
def _rsync_from_remote(self, rsync_location, temp_dir): def _rsync_from_remote(self, rsync_args, rsync_location, temp_dir):
os.chdir(temp_dir) os.chdir(temp_dir)
print("rsync: %s -> %s" % (rsync_location, temp_dir)) print("rsync %s %s %s" % (rsync_args, rsync_location, temp_dir))
output = run_command("rsync -rlvz %s %s" % (rsync_location, temp_dir)) output = run_command("rsync %s %s %s" % (rsync_args, rsync_location, temp_dir))
debug(output) debug(output)
def rsync_to_remote(self, temp_dir, rsync_location): def rsync_to_remote(self, rsync_args, temp_dir, rsync_location):
print("rsync: %s -> %s" % (temp_dir, rsync_location)) print("rsync %s --delete %s/ %s" % (rsync_args, temp_dir, rsync_location))
os.chdir(temp_dir) os.chdir(temp_dir)
# TODO: configurable rsync options? # TODO: configurable rsync options?
cmd = "rsync -rlvz --delete %s/ %s" % (temp_dir, rsync_location) cmd = "rsync %s --delete %s/ %s" % (rsync_args, temp_dir, rsync_location)
if self.dry_run: if self.dry_run:
self.print_dry_run_warning(cmd) self.print_dry_run_warning(cmd)
else: else: