[cowdancer] 05/06: qemubuilder: Copy files back as the correct user/group
James Clarke
jrtc27-guest at moszumanska.debian.org
Sun May 1 18:33:34 UTC 2016
This is an automated email from the git hooks/post-receive script.
jrtc27-guest pushed a commit to branch master
in repository cowdancer.
commit 23425eb83d837436e6fda82054cd359fd8933a61
Author: James Clarke <jrtc27 at jrtc27.com>
Date: Sun May 1 18:03:45 2016 +0100
qemubuilder: Copy files back as the correct user/group
---
parameter.c | 25 +++++++++++++++++++++++++
parameter.h | 3 +++
qemubuilder.c | 19 +++++++++++++++++--
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/parameter.c b/parameter.c
index 409c8ae..d7ba842 100644
--- a/parameter.c
+++ b/parameter.c
@@ -211,6 +211,14 @@ int load_config_file(const char* config, pbuilderconfig* pc)
{
pc->allow_untrusted=!strcmp(delim, "yes");
}
+ else if (!strcmp(buf, "BUILDRESULTUID"))
+ {
+ pc->buildresultuid=atoi(delim);
+ }
+ else if (!strcmp(buf, "BUILDRESULTGID"))
+ {
+ pc->buildresultgid=atoi(delim);
+ }
}
}
@@ -263,6 +271,9 @@ int cpbuilder_dumpconfig(pbuilderconfig* pc)
DUMPSTRARRAY(inputfile);
DUMPSTRARRAY(outputfile);
+ DUMPINT(buildresultuid);
+ DUMPINT(buildresultgid);
+
DUMPINT(no_cowdancer_update);
DUMPSTR(kernel_image);
@@ -617,6 +628,20 @@ int parse_parameter(int ac, char** av,
if (!pc.distribution)
pc.distribution=strdup("sid");
+ if (!pc.buildresultuid)
+ {
+ const char* sudo_uid = getenv("SUDO_UID");
+ if (sudo_uid)
+ pc.buildresultuid = atoi(sudo_uid);
+ }
+
+ if (!pc.buildresultgid)
+ {
+ const char* sudo_gid = getenv("SUDO_GID");
+ if (sudo_gid)
+ pc.buildresultgid = atoi(sudo_gid);
+ }
+
if (!pc.memory_megs)
pc.memory_megs=128;
diff --git a/parameter.h b/parameter.h
index 2f27391..71077ca 100644
--- a/parameter.h
+++ b/parameter.h
@@ -51,6 +51,9 @@ typedef struct pbuilderconfig
char* inputfile[MAX_CUSTOM_FILES+1];
char* outputfile[MAX_CUSTOM_FILES+1];
+ int buildresultuid;
+ int buildresultgid;
+
/* cow-specific options */
int no_cowdancer_update; /* --no-cowdancer-update */
int debian_etch_workaround; /* --debian-etch-workaround */
diff --git a/qemubuilder.c b/qemubuilder.c
index 99cc0af..65266e5 100755
--- a/qemubuilder.c
+++ b/qemubuilder.c
@@ -1081,8 +1081,23 @@ int cpbuilder_build(const struct pbuilderconfig* pc, const char* dscfile)
no other file will have _. */
asprintf(&hoststr2,
- "cp -p \"%s\"/*_* \"%s\" 2>/dev/null || true",
- pc->buildplace, pc->buildresult);
+ "BUILDPLACE='%s'\n"
+ "BUILDRESULT='%s'\n"
+ "BUILDRESULTUID=%d\n"
+ "BUILDRESULTGID=%d\n"
+ "if [ -d \"${BUILDRESULT}\" ]; then\n"
+ " chown \"${BUILDRESULTUID}:${BUILDRESULTGID}\" \"${BUILDPLACE}$BUILDDIR/\"*\n"
+ " chgrp \"${BUILDRESULTGID}\" \"${BUILDPLACE}$BUILDDIR/\"*\n"
+ " for FILE in \"${BUILDPLACE}$BUILDDIR\"/*; do\n"
+ " if [ -f \"${FILE}\" ]; then\n"
+ " cp -p \"${FILE}\" \"${BUILDRESULT}\" || true\n"
+ " fi\n"
+ " done\n"
+ "else\n"
+ " echo \"E: BUILDRESULT=[$BUILDRESULT] is not a directory.\"\n"
+ "fi\n",
+ pc->buildplace, pc->buildresult,
+ pc->buildresultuid, pc->buildresultgid);
ret=run_second_stage_script
(0, 0,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/cowdancer.git
More information about the Pbuilder-maint
mailing list