Blob Blame History Raw
commit ff7bfd9a32d672f8582ea334ee351af8c32229ad
Author: Jindrich Novy <jnovy@redhat.com>
Date:   Mon Sep 1 14:35:34 2008 +0200

    Create directory structure for rpmbuild prior to build if it doesn't exist
    - creates all needed directories that rpmbuild uses for input and output

diff --git a/build.c b/build.c
index faa09c5..83aaf20 100644
--- a/build.c
+++ b/build.c
@@ -16,6 +16,7 @@
 #include <rpm/rpmts.h>
 #include <rpm/rpmfileutil.h>
 #include <rpm/rpmlog.h>
+#include <lib/misc.h>
 
 #include "build.h"
 #include "debug.h"
@@ -253,6 +254,28 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
 	goto exit;
     }
 
+    /* Be sure all required directories exist, attempt to create them if not */
+    {
+	char *_topdir = rpmGenPath(rpmtsRootDir(ts), "%{_topdir}", ""),
+	     *_builddir = rpmGenPath(rpmtsRootDir(ts), "%{_builddir}", ""),
+	     *_buildrootdir = rpmGenPath(rpmtsRootDir(ts), "%{_buildrootdir}", ""),
+	     *_sourcedir = rpmGenPath(rpmtsRootDir(ts), "%{_sourcedir}", ""),
+	     *_rpmdir = rpmGenPath(rpmtsRootDir(ts), "%{_rpmdir}", ""),
+	     *_specdir = rpmGenPath(rpmtsRootDir(ts), "%{_specdir}", ""),
+	     *_srcrpmdir = rpmGenPath(rpmtsRootDir(ts), "%{_srcrpmdir}", "");
+
+	if ( rpmMkdirPath(_topdir, "_topdir") ||
+	     rpmMkdirPath(_builddir, "_builddir") ||
+	     rpmMkdirPath(_buildrootdir, "_buildrootdir") ||
+	     rpmMkdirPath(_sourcedir, "_sourcedir") ||
+	     rpmMkdirPath(_rpmdir, "_rpmdir") ||
+	     rpmMkdirPath(_specdir, "_specdir") ||
+	     rpmMkdirPath(_srcrpmdir, "_srcrpmdir")
+	) {
+	    goto exit;
+	}
+    }
+
     if (buildSpec(ts, spec, buildAmount, ba->noBuild)) {
 	goto exit;
     }