Please disregard the previous patch; it created the directory if it
didn't exist, but would fail if it existed already. This should work
fine, unless a file with the same name as the directory exists already.
--
Benoît Knecht
diff --git a/qemubuilder.c b/qemubuilder.c
index eec8afa..3cae7fa 100755
--- a/qemubuilder.c
+++ b/qemubuilder.c
@@ -33,6 +33,7 @@
#include <termios.h>
#include <time.h>
#include <locale.h>
+#include <errno.h>
#include "parameter.h"
#include "qemuipsanitize.h"
#include "qemuarch.h"
@@ -800,6 +801,14 @@ int cpbuilder_build(const struct pbuilderconfig* pc, const char* dscfile)
const char* buildopt="--binary-all"; /* TODO: add --binary-arch option */
+ /* Make sure we'll be able to copy the built package to pc->buildresult. */
+ if (mkdir(pc->buildresult,0777) && errno != EEXIST)
+ {
+ /* could not create the buildresult here. */
+ perror("mkdir");
+ goto out;
+ }
+
hoststr=copy_dscfile(dscfile, pc->buildplace);
asprintf(&commandline,
@@ -826,6 +835,7 @@ int cpbuilder_build(const struct pbuilderconfig* pc, const char* dscfile)
hoststr,
hoststr2);
+ out:
if(hoststr2) free(hoststr2);
if(hoststr) free(hoststr);
if(commandline) free(commandline);