- create directory structure for rpmbuild prior to build if it doesn't

exist (#455387)
- create _topdir if it doesn't exist when installing SRPM
- don't generate broken cpio in case of hardlink pointing on softlink,
    thanks to pixel@mandriva.com
This commit is contained in:
Jindrich Novy 2008-09-11 06:16:20 +00:00
parent 2b2e2bf0cb
commit 507434f781
4 changed files with 141 additions and 1 deletions

View File

@ -0,0 +1,47 @@
commit 5c71ced2da7d99b870a07a83dd8f7e8d1f1b7e4b
Author: Jindrich Novy <jnovy@redhat.com>
Date: Wed Sep 10 15:04:57 2008 +0200
Don't generate broken cpio in case of hardlink pointing on softlink
- thanks to Pixel
diff --git a/lib/fsm.c b/lib/fsm.c
index 0905e3c..8175f82 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1573,7 +1573,7 @@ static int fsmStage(FSM_t fsm, fileStage stage)
fsm->postpone = XFA_SKIPPING(fsm->action);
if (fsm->goal == FSM_PKGINSTALL || fsm->goal == FSM_PKGBUILD) {
/* FIX: saveHardLink can modify fsm */
- if (!S_ISDIR(st->st_mode) && st->st_nlink > 1)
+ if (S_ISREG(st->st_mode) && st->st_nlink > 1)
fsm->postpone = saveHardLink(fsm);
}
break;
@@ -1599,7 +1599,7 @@ static int fsmStage(FSM_t fsm, fileStage stage)
if (fsm->goal == FSM_PKGBUILD) {
if (fsm->fflags & RPMFILE_GHOST) /* XXX Don't if %ghost file. */
break;
- if (!S_ISDIR(st->st_mode) && st->st_nlink > 1) {
+ if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
hardLink_t li, prev;
if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
@@ -1699,7 +1699,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
if (!IS_DEV_LOG(fsm->path))
rc = CPIOERR_UNKNOWN_FILETYPE;
}
- if (!S_ISDIR(st->st_mode) && st->st_nlink > 1) {
+ if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
fsm->li->createdPath = fsm->li->linkIndex;
rc = fsmMakeLinks(fsm);
}
@@ -1743,7 +1743,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
case FSM_FINI:
if (!fsm->postpone && fsm->commit) {
if (fsm->goal == FSM_PKGINSTALL)
- rc = ((!S_ISDIR(st->st_mode) && st->st_nlink > 1)
+ rc = ((S_ISREG(st->st_mode) && st->st_nlink > 1)
? fsmCommitLinks(fsm) : fsmNext(fsm, FSM_COMMIT));
if (fsm->goal == FSM_PKGCOMMIT)
rc = fsmNext(fsm, FSM_COMMIT);

View File

@ -0,0 +1,48 @@
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;
}

33
rpm-4.5.90-topdir.patch Normal file
View File

@ -0,0 +1,33 @@
commit b16df5b3089e36cf0bd697177983dcae11b849ec
Author: Jindrich Novy <jnovy@redhat.com>
Date: Mon Sep 1 14:31:33 2008 +0200
Create _topdir if it doesn't exist when installing SRPM
- otherwise creating _sourcedir and _specdir fails
diff --git a/lib/psm.c b/lib/psm.c
index d4bea69..046964b 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -231,6 +231,7 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
{
int scareMem = 1;
rpmfi fi = NULL;
+ char * _topdir = NULL;
char * _sourcedir = NULL;
char * _specdir = NULL;
char * specFile = NULL;
@@ -335,6 +336,13 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
}
}
+ _topdir = rpmGenPath(rpmtsRootDir(ts), "%{_topdir}", "");
+ rpmrc = rpmMkdirPath(_topdir, "_topdir");
+ if (rpmrc) {
+ rpmrc = RPMRC_FAIL;
+ goto exit;
+ }
+
_sourcedir = rpmGenPath(rpmtsRootDir(ts), "%{_sourcedir}", "");
rpmrc = rpmMkdirPath(_sourcedir, "_sourcedir");
if (rpmrc) {

View File

@ -18,7 +18,7 @@
Summary: The RPM package management system Summary: The RPM package management system
Name: rpm Name: rpm
Version: %{rpmver} Version: %{rpmver}
Release: 0.%{snapver}.5 Release: 0.%{snapver}.6
Group: System Environment/Base Group: System Environment/Base
Url: http://www.rpm.org/ Url: http://www.rpm.org/
Source0: http://rpm.org/releases/testing/%{name}-%{srcver}.tar.bz2 Source0: http://rpm.org/releases/testing/%{name}-%{srcver}.tar.bz2
@ -37,6 +37,9 @@ Patch201: rpm-4.5.90-noarch-subpackages.patch
Patch202: rpm-4.5.90-segfault.patch Patch202: rpm-4.5.90-segfault.patch
Patch203: rpm-4.5.90-macrofix.patch Patch203: rpm-4.5.90-macrofix.patch
Patch204: rpm-4.5.90-patches.patch Patch204: rpm-4.5.90-patches.patch
Patch205: rpm-4.5.90-topdir.patch
Patch206: rpm-4.5.90-rpmbuild-dirs.patch
Patch207: rpm-4.5.90-cpio-hardlink.patch
# These are not yet upstream # These are not yet upstream
Patch300: rpm-4.5.90-posttrans.patch Patch300: rpm-4.5.90-posttrans.patch
@ -172,6 +175,9 @@ that will manipulate RPM packages and databases.
%patch202 -p1 -b .segfault %patch202 -p1 -b .segfault
%patch203 -p1 -b .macrofix %patch203 -p1 -b .macrofix
%patch204 -p1 -b .patches %patch204 -p1 -b .patches
%patch205 -p1 -b .topdir
%patch206 -p1 -b .rpmbuild-dirs
%patch207 -p1 -b .cpio-hardlink
# needs a bit of upstream love first... # needs a bit of upstream love first...
#%patch300 -p1 -b .posttrans #%patch300 -p1 -b .posttrans
@ -350,6 +356,12 @@ exit 0
%doc doc/librpm/html/* %doc doc/librpm/html/*
%changelog %changelog
* Thu Sep 11 2008 Jindrich Novy <jnovy@redhat.com>
- create directory structure for rpmbuild prior to build if it doesn't exist (#455387)
- create _topdir if it doesn't exist when installing SRPM
- don't generate broken cpio in case of hardlink pointing on softlink,
thanks to pixel@mandriva.com
* Sat Sep 06 2008 Jindrich Novy <jnovy@redhat.com> * Sat Sep 06 2008 Jindrich Novy <jnovy@redhat.com>
- fail hard if patch isn't found (#461347) - fail hard if patch isn't found (#461347)