From 507434f78143b778bb60e29959fc127b4d809d4e Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Thu, 11 Sep 2008 06:16:20 +0000 Subject: [PATCH] - 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 --- rpm-4.5.90-cpio-hardlink.patch | 47 +++++++++++++++++++++++++++++++++ rpm-4.5.90-rpmbuild-dirs.patch | 48 ++++++++++++++++++++++++++++++++++ rpm-4.5.90-topdir.patch | 33 +++++++++++++++++++++++ rpm.spec | 14 +++++++++- 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 rpm-4.5.90-cpio-hardlink.patch create mode 100644 rpm-4.5.90-rpmbuild-dirs.patch create mode 100644 rpm-4.5.90-topdir.patch diff --git a/rpm-4.5.90-cpio-hardlink.patch b/rpm-4.5.90-cpio-hardlink.patch new file mode 100644 index 0000000..cb3af5d --- /dev/null +++ b/rpm-4.5.90-cpio-hardlink.patch @@ -0,0 +1,47 @@ +commit 5c71ced2da7d99b870a07a83dd8f7e8d1f1b7e4b +Author: Jindrich Novy +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); diff --git a/rpm-4.5.90-rpmbuild-dirs.patch b/rpm-4.5.90-rpmbuild-dirs.patch new file mode 100644 index 0000000..63454ba --- /dev/null +++ b/rpm-4.5.90-rpmbuild-dirs.patch @@ -0,0 +1,48 @@ +commit ff7bfd9a32d672f8582ea334ee351af8c32229ad +Author: Jindrich Novy +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 + #include + #include ++#include + + #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; + } diff --git a/rpm-4.5.90-topdir.patch b/rpm-4.5.90-topdir.patch new file mode 100644 index 0000000..bb94c8b --- /dev/null +++ b/rpm-4.5.90-topdir.patch @@ -0,0 +1,33 @@ +commit b16df5b3089e36cf0bd697177983dcae11b849ec +Author: Jindrich Novy +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) { diff --git a/rpm.spec b/rpm.spec index af40ddb..e3332be 100644 --- a/rpm.spec +++ b/rpm.spec @@ -18,7 +18,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: 0.%{snapver}.5 +Release: 0.%{snapver}.6 Group: System Environment/Base Url: http://www.rpm.org/ 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 Patch203: rpm-4.5.90-macrofix.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 Patch300: rpm-4.5.90-posttrans.patch @@ -172,6 +175,9 @@ that will manipulate RPM packages and databases. %patch202 -p1 -b .segfault %patch203 -p1 -b .macrofix %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... #%patch300 -p1 -b .posttrans @@ -350,6 +356,12 @@ exit 0 %doc doc/librpm/html/* %changelog +* Thu Sep 11 2008 Jindrich Novy +- 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 - fail hard if patch isn't found (#461347)