Jindrich Novy 507434
commit ff7bfd9a32d672f8582ea334ee351af8c32229ad
Jindrich Novy 507434
Author: Jindrich Novy <jnovy@redhat.com>
Jindrich Novy 507434
Date:   Mon Sep 1 14:35:34 2008 +0200
Jindrich Novy 507434
Jindrich Novy 507434
    Create directory structure for rpmbuild prior to build if it doesn't exist
Jindrich Novy 507434
    - creates all needed directories that rpmbuild uses for input and output
Jindrich Novy 507434
Jindrich Novy 507434
diff --git a/build.c b/build.c
Jindrich Novy 507434
index faa09c5..83aaf20 100644
Jindrich Novy 507434
--- a/build.c
Jindrich Novy 507434
+++ b/build.c
Jindrich Novy 507434
@@ -16,6 +16,7 @@
Jindrich Novy 507434
 #include <rpm/rpmts.h>
Jindrich Novy 507434
 #include <rpm/rpmfileutil.h>
Jindrich Novy 507434
 #include <rpm/rpmlog.h>
Jindrich Novy 507434
+#include <lib/misc.h>
Jindrich Novy 507434
 
Jindrich Novy 507434
 #include "build.h"
Jindrich Novy 507434
 #include "debug.h"
Jindrich Novy 507434
@@ -253,6 +254,28 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
Jindrich Novy 507434
 	goto exit;
Jindrich Novy 507434
     }
Jindrich Novy 507434
 
Jindrich Novy 507434
+    /* Be sure all required directories exist, attempt to create them if not */
Jindrich Novy 507434
+    {
Jindrich Novy 507434
+	char *_topdir = rpmGenPath(rpmtsRootDir(ts), "%{_topdir}", ""),
Jindrich Novy 507434
+	     *_builddir = rpmGenPath(rpmtsRootDir(ts), "%{_builddir}", ""),
Jindrich Novy 507434
+	     *_buildrootdir = rpmGenPath(rpmtsRootDir(ts), "%{_buildrootdir}", ""),
Jindrich Novy 507434
+	     *_sourcedir = rpmGenPath(rpmtsRootDir(ts), "%{_sourcedir}", ""),
Jindrich Novy 507434
+	     *_rpmdir = rpmGenPath(rpmtsRootDir(ts), "%{_rpmdir}", ""),
Jindrich Novy 507434
+	     *_specdir = rpmGenPath(rpmtsRootDir(ts), "%{_specdir}", ""),
Jindrich Novy 507434
+	     *_srcrpmdir = rpmGenPath(rpmtsRootDir(ts), "%{_srcrpmdir}", "");
Jindrich Novy 507434
+
Jindrich Novy 507434
+	if ( rpmMkdirPath(_topdir, "_topdir") ||
Jindrich Novy 507434
+	     rpmMkdirPath(_builddir, "_builddir") ||
Jindrich Novy 507434
+	     rpmMkdirPath(_buildrootdir, "_buildrootdir") ||
Jindrich Novy 507434
+	     rpmMkdirPath(_sourcedir, "_sourcedir") ||
Jindrich Novy 507434
+	     rpmMkdirPath(_rpmdir, "_rpmdir") ||
Jindrich Novy 507434
+	     rpmMkdirPath(_specdir, "_specdir") ||
Jindrich Novy 507434
+	     rpmMkdirPath(_srcrpmdir, "_srcrpmdir")
Jindrich Novy 507434
+	) {
Jindrich Novy 507434
+	    goto exit;
Jindrich Novy 507434
+	}
Jindrich Novy 507434
+    }
Jindrich Novy 507434
+
Jindrich Novy 507434
     if (buildSpec(ts, spec, buildAmount, ba->noBuild)) {
Jindrich Novy 507434
 	goto exit;
Jindrich Novy 507434
     }