[Rpm-maint] [PATCH] RPM 4.8.1 stop making unwanted %{name}-%{version} directory
Jason Harvey
madasafan at gmail.com
Thu Jan 20 01:22:27 UTC 2011
Forgive me if this has been discussed before and isn't appropriate for fixing...
When .rpmmacros includes
%_sourcedir %{_topdir}/SOURCES/%{name}-%{version}
rpmbuild -bp ~/rpmbuild/SPECS/rpm.spec has no problem finding the source files in ~/rpmbuild/SOURCES/rpm-4.8.1/
but creates directory "~/rpmbuild/SOURCES/%{name}-%{version}" in the process.
The problem was reported in bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=489104
I think the following commit is where the change occured.
http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=aa509e3c5e68ed905a80743bd3e8f3e26aa67590
In moving the build tree generation earlier to cater for tarbuilds the generation precedes parsing
the spec file so the tags for name and version are undefined.
Patch below resolves this by moving build tree generation back to after parsing and handles the tarbuilding too.
Regards,
Jason Harvey
--- build.c.movemkdirs.patch 2010-06-11 09:45:34.000000000 +0100
+++ build.c 2011-01-19 11:26:22.000000000 +0000
@@ -110,8 +110,8 @@
int gotspec = 0, res;
static const char *tryspec[] = { "Specfile", "\\*.spec", NULL };
- specDir = rpmGetPath("%{_specdir}", NULL);
- tmpSpecFile = rpmGetPath("%{_specdir}/", "rpm-spec.XXXXXX", NULL);
+ specDir = rpmGetPath("%{_tmppath}", NULL);
+ tmpSpecFile = rpmGetPath("%{_tmppath}/", "rpm-spec.XXXXXX", NULL);
(void) close(mkstemp(tmpSpecFile));
@@ -192,13 +192,6 @@
if (ba->buildRootOverride)
buildRootURL = rpmGenPath(NULL, ba->buildRootOverride, NULL);
- /* Create build tree if necessary */
- const char * buildtree = "%{_topdir}:%{_specdir}:%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}";
- const char * rootdir = rpmtsRootDir(ts);
- if (rpmMkdirs(!rstreq(rootdir, "/") ? rootdir : NULL , buildtree)) {
- goto exit;
- }
-
if (ba->buildMode == 't') {
char *srcdir = NULL, *dir;
@@ -272,6 +265,35 @@
rc = unlink(specFile);
goto exit;
}
+
+ /* Create build tree if necessary */
+ const char * buildtree = "%{_topdir}:%{_specdir}:%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}";
+ const char * rootdir = rpmtsRootDir(ts);
+ if (rpmMkdirs(!rstreq(rootdir, "/") ? rootdir : NULL , buildtree)) {
+ goto exit;
+ }
+
+ /*move the spec file into the specdir */
+ if (ba->buildMode == 't') {
+
+ char *cmd;
+ char * tmpSpecFile = rpmGenPath("%{_specdir}", basename(specFile), NULL);
+
+ cmd = rpmExpand("mv ", specFile, " ", tmpSpecFile, NULL);
+
+ if (system(cmd)) {
+ rpmlog(RPMLOG_ERR, _("Failed to move %s to %s: %m\n"),
+ specFile, tmpSpecFile);
+ free(tmpSpecFile);
+ }
+ else
+ {
+ free(specFile);
+ spec->specFile = specFile = tmpSpecFile;
+ }
+ free(cmd);
+
+ }
/* Assemble source header from parsed components */
initSourceHeader(spec);
More information about the Rpm-maint
mailing list