From: Markus Lehtonen Date: Mon, 16 Feb 2015 14:28:27 +0000 (+0200) Subject: Set correct ownership of the exported files X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d25ffed512b3db4b993a57311d8c9377534c12c;p=services%2Fobs-service-git-buildpackage.git Set correct ownership of the exported files Change-Id: I3652dd3027576744335abcd6c4f4b0cde2b7592c Signed-off-by: Markus Lehtonen (cherry picked from commit 5ccc4df5abe500e4c561096fa964b1f54627cea2) --- diff --git a/obs_service_gbp/command.py b/obs_service_gbp/command.py index cc14c4f..c217bd0 100644 --- a/obs_service_gbp/command.py +++ b/obs_service_gbp/command.py @@ -98,6 +98,15 @@ def read_config(filenames): # We only use keys from one section, for now return dict(parser.items('general')) +def move_dir_content(source, target): + """Move files from dir to another and change ownership""" + euid = os.geteuid() + egid = os.getegid() + for fname in os.listdir(source): + tgt_path = os.path.join(target, fname) + shutil.move(os.path.join(source, fname), tgt_path) + os.lchown(tgt_path, euid, egid) + def gbp_export(repo, args, config): """Export sources with GBP""" # Create output directories @@ -139,9 +148,7 @@ def gbp_export(repo, args, config): LOGGER.error('Git-buildpackage failed, unable to export Debian ' 'sources package files') return 3 - for fname in os.listdir(tmp_out): - shutil.move(os.path.join(tmp_out, fname), - os.path.join(args.outdir, fname)) + move_dir_content(tmp_out, args.outdir) except GbpChildBTError as err: LOGGER.error('Unhandled exception in GBP:\n' '%s', err.prettyprint_tb())