[cowdancer] 03/11: qemubuilder.c: Detect out of date pbuilder-run init script
James Clarke
jrtc27-guest at moszumanska.debian.org
Mon May 2 01:19:59 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 232681230a027a43d37ec16b87223b1f90e60743
Author: James Clarke <jrtc27 at jrtc27.com>
Date: Sun May 1 22:58:34 2016 +0100
qemubuilder.c: Detect out of date pbuilder-run init script
---
qemubuilder.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/qemubuilder.c b/qemubuilder.c
index faa5e8a..e4bf6e0 100755
--- a/qemubuilder.c
+++ b/qemubuilder.c
@@ -40,6 +40,10 @@
#include "qemuarch.h"
#include "file.h"
+#define STR(x) #x
+#define XSTR(x) STR(x)
+
+#define PBUILDER_INIT_VERSION 1
#define BUILDDIR "/build"
#define CHROOT_HOOKDIR BUILDDIR"/hooks"
@@ -668,6 +672,7 @@ static void write_first_stage(FILE *f, const struct pbuilderconfig* pc)
"#!/bin/bash\n"
"echo \n"
"echo ' -> qemu-pbuilder first-stage' \n"
+ "export PBUILDER_INIT_VERSION="XSTR(PBUILDER_INIT_VERSION)"\n"
"export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\n"
"mount -n /proc /proc -t proc\n"
"ln -s /dev/shm /run/shm\n"
@@ -750,6 +755,16 @@ static int run_second_stage_script
"echo \n"
"echo ' -> qemu-pbuilder second-stage' \n"
//"mount -n /proc /proc -t proc\n" // this is done in first stage.
+ "if [ \"${PBUILDER_INIT_VERSION:-0}\" -lt "XSTR(PBUILDER_INIT_VERSION)" ]; then\n"
+ " echo \"E: qemubuilder init script is out of date (${PBUILDER_INIT_VERSION:-0} < "XSTR(PBUILDER_INIT_VERSION)")\"\n"
+ " echo \"E: Please run qemubuilder --update\"\n"
+ " exit_from_qemu 1\n"
+ "elif [ \"${PBUILDER_INIT_VERSION:-0}\" -gt "XSTR(PBUILDER_INIT_VERSION)" ]; then\n"
+ " echo \"E: qemubuilder init script is newer than expected (${PBUILDER_INIT_VERSION:-0} < "XSTR(PBUILDER_INIT_VERSION)")\"\n"
+ " exit_from_qemu 1\n"
+ "fi\n"
+ // Remove compatibility symlink
+ "rm \"$BUILDDIR\"/run-pbuilder\n"
"echo ' -> setting time to %s' \n"
"date --set=\"%s\"\n"
"echo ' -> configuring network' \n"
@@ -769,6 +784,28 @@ static int run_second_stage_script
pc->hookdir && pc->hookdir[0] ? "mkdir -p \""CHROOT_HOOKDIR"\"" : "",
commandline);
fclose(f);
+ {
+ char *compat_symlink;
+ if (0>asprintf(&compat_symlink,
+ "%s/pbuilder-run",
+ pc->buildplace))
+ {
+ fprintf(stderr,
+ "E: Failed to allocate string for compatibility symlink path '%s/pbuilder-run': %s\n",
+ pc->buildplace,
+ strerror(errno));
+ goto out;
+ }
+ if (symlink("input/pbuilder-run", compat_symlink))
+ {
+ fprintf(stderr,
+ "E: Failed to create compatibility symlink: %s\n",
+ strerror(errno));
+ free(compat_symlink);
+ goto out;
+ }
+ free(compat_symlink);
+ }
/* copy files script */
f = create_script(pc->buildplace, "input/run-copyfiles");
--
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