rpms/rpm/F-7 rpm-4.4.2.1-checksignals.patch, NONE, 1.1 rpm-4.4.2.1-checkterminate-noexit.patch, NONE, 1.1 rpm-4.4.2.1-checkterminate.patch, NONE, 1.1 rpm-4.4.2.1-config-mtime.patch, NONE, 1.1 rpm-4.4.2.1-python-exithook.patch, NONE, 1.1 rpm-4.4.2.1-strict-docdir.patch, NONE, 1.1

Panu Matilainen (pmatilai) fedora-extras-commits at redhat.com
Mon Aug 13 07:12:48 UTC 2007


Author: pmatilai

Update of /cvs/pkgs/rpms/rpm/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv25492

Added Files:
	rpm-4.4.2.1-checksignals.patch 
	rpm-4.4.2.1-checkterminate-noexit.patch 
	rpm-4.4.2.1-checkterminate.patch 
	rpm-4.4.2.1-config-mtime.patch 
	rpm-4.4.2.1-python-exithook.patch 
	rpm-4.4.2.1-strict-docdir.patch 
Log Message:
- remember to add new patches...


rpm-4.4.2.1-checksignals.patch:

--- NEW FILE rpm-4.4.2.1-checksignals.patch ---
changeset:   6176:c0237c16e2e3
user:        Panu Matilainen <pmatilai at redhat.com>
date:        Fri Jul 20 10:41:15 2007 +0300
files:       python/rpmmodule.c
description:
Add python methods for checking pending signals from rpmsqCaught.
- a thin wrapper for rpmdbCheckSignals() from rpm5.org / Jeff Johnson
- a function taking a list of signals to check and returning list caught
  signals (python doesn't know about signal sets so rpmsqCaught needs
  wrapping)


diff -r d8e2ec20c948 -r c0237c16e2e3 python/rpmmodule.c
--- a/python/rpmmodule.c	Wed Jul 18 16:05:56 2007 +0300
+++ b/python/rpmmodule.c	Fri Jul 20 10:41:15 2007 +0300
@@ -7,6 +7,7 @@
 #include <rpmio_internal.h>
 #include <rpmcli.h>	/* XXX for rpmCheckSig */
 #include <rpmdb.h>
+#include <rpmsq.h>
 
 #include "legacy.h"
 #include "misc.h"
@@ -58,6 +59,50 @@ static PyObject * archScore(PyObject * s
 }
 
 /**
+ *  */
+static PyObject * signalsCaught(PyObject * self, PyObject * check)
+{
+    PyObject *caught, *o;
+    Py_ssize_t llen;
+    int signum, i;
+    sigset_t newMask, oldMask;
+
+    if (!PyList_Check(check)) {
+	PyErr_SetString(PyExc_TypeError, "list expected");
+	return NULL;
+    }
+
+    llen = PyList_Size(check);
+    caught = PyList_New(0);
+
+    /* block signals while checking for them */
+    (void) sigfillset(&newMask);
+    (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
+
+    for (i = 0; i < llen; i++) {
+	o = PyList_GetItem(check, i);
+	signum = PyInt_AsLong(o);
+	if (sigismember(&rpmsqCaught, signum)) {
+	    PyList_Append(caught, o);
+	}
+    }
+    (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
+
+    return caught;
+}
+
+/**
+ *  */
+static PyObject * checkSignals(PyObject * self, PyObject * args)
+{
+    if (!PyArg_ParseTuple(args, ":checkSignals")) return NULL;
+    rpmdbCheckSignals();
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+
+/**
  */
 static PyObject * setLogFile (PyObject * self, PyObject * args, PyObject *kwds)
 {
@@ -145,6 +190,11 @@ static PyMethodDef rpmModuleMethods[] = 
 
     { "archscore", (PyCFunction) archScore, METH_VARARGS|METH_KEYWORDS,
 	NULL },
+
+    { "signalsCaught", (PyCFunction) signalsCaught, METH_O, 
+	NULL },
+    { "checkSignals", (PyCFunction) checkSignals, METH_VARARGS,
+        NULL },
 
     { "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS|METH_KEYWORDS,
 	NULL },


rpm-4.4.2.1-checkterminate-noexit.patch:

--- NEW FILE rpm-4.4.2.1-checkterminate-noexit.patch ---
changeset:   6179:fb37e4dccbf3
tag:         tip
user:        Panu Matilainen <pmatilai at redhat.com>
date:        Sat Jul 21 15:05:19 2007 +0300
files:       python/rpmmodule.c rpmdb/rpmdb.c rpmdb/rpmdb.h
description:
Make rpmdbCheckTerminate() non-terminating.
This allows use in exit handler without affecting exit code, and permits
caller to do its own cleanup if necessary.


diff -r e9ced408b17f -r fb37e4dccbf3 python/rpmmodule.c
--- a/python/rpmmodule.c	Fri Jul 20 11:23:11 2007 +0300
+++ b/python/rpmmodule.c	Sat Jul 21 15:05:19 2007 +0300
@@ -229,8 +229,6 @@ static PyMethodDef rpmModuleMethods[] = 
 
 /*
 * Force clean up of open iterators and dbs on exit.
-* This ends up calling exit() while we're already exiting but exit
-* handlers will only get called once so it wont loop.
 */
 static void rpm_exithook(void)
 {
diff -r e9ced408b17f -r fb37e4dccbf3 rpmdb/rpmdb.c
--- a/rpmdb/rpmdb.c	Fri Jul 20 11:23:11 2007 +0300
+++ b/rpmdb/rpmdb.c	Sat Jul 21 15:05:19 2007 +0300
@@ -707,7 +707,7 @@ int rpmdbCheckTerminate(int terminate)
     sigset_t newMask, oldMask;
     static int terminating = 0;
 
-    if (terminating) return 0;
+    if (terminating) return 1;
 
     (void) sigfillset(&newMask);		/* block all signals */
     (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
@@ -724,10 +724,6 @@ int rpmdbCheckTerminate(int terminate)
 	rpmdb db;
 	rpmdbMatchIterator mi;
 
-/*@-abstract@*/ /* sigset_t is abstract type */
-	rpmMessage(RPMMESS_DEBUG, "Exiting on signal(0x%lx) ...\n", *((unsigned long *)&rpmsqCaught));
-/*@=abstract@*/
-
 /*@-branchstate@*/
 	while ((mi = rpmmiRock) != NULL) {
 /*@i@*/	    rpmmiRock = mi->mi_next;
@@ -743,14 +739,20 @@ int rpmdbCheckTerminate(int terminate)
 	    (void) rpmdbClose(db);
 	}
 /*@=newreftrans@*/
+    }
+    sigprocmask(SIG_SETMASK, &oldMask, NULL);
+    return terminating;
+}
+
+int rpmdbCheckSignals(void)
+{
+    if (rpmdbCheckTerminate(0)) {
+/*@-abstract@*/ /* sigset_t is abstract type */
+	rpmMessage(RPMMESS_DEBUG, "Exiting on signal(0x%lx) ...\n", *((unsigned long *)&rpmsqCaught));
 	exit(EXIT_FAILURE);
-    }
-    return sigprocmask(SIG_SETMASK, &oldMask, NULL);
-}
-
-int rpmdbCheckSignals(void)
-{
-    return rpmdbCheckTerminate(0);
+/*@=abstract@*/
+    }
+    return 0;
 }
 
 /**
diff -r e9ced408b17f -r fb37e4dccbf3 rpmdb/rpmdb.h
--- a/rpmdb/rpmdb.h	Fri Jul 20 11:23:11 2007 +0300
+++ b/rpmdb/rpmdb.h	Sat Jul 21 15:05:19 2007 +0300
@@ -1039,8 +1039,7 @@ Header rpmdbNextIterator(/*@null@*/ rpmd
 	/*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/;
 
 /** \ingroup rpmdb
- * Check rpmdb signal handler for trapped signal exit. Just a compatibility
- * wrapper for rpmdbCheckTerminate()
+ * Check for and exit on termination signals.
  */
 /*@mayexit@*/
 int rpmdbCheckSignals(void)
@@ -1048,10 +1047,13 @@ int rpmdbCheckSignals(void)
 	/*@modifies fileSystem, internalState @*/;
 
 /** \ingroup rpmdb
- * Check rpmdb signal handler for trapped signal or requested exit.
+ * Check rpmdb signal handler for trapped signal and/or requested exit,
+ * clean up any open iterators and databases on termination condition.
+ * On non-zero exit any open references to rpmdb are invalid and cannot
+ * be accessed anymore, calling process should terminate immediately.
  * @param terminate	0 to only check for signals, 1 to terminate anyway
- */
-/*@mayexit@*/
+ * @return 		0 to continue, 1 if termination cleanup was done.
+ */
 int rpmdbCheckTerminate(int terminate);
 
 /** \ingroup rpmdb


rpm-4.4.2.1-checkterminate.patch:

--- NEW FILE rpm-4.4.2.1-checkterminate.patch ---
changeset:   6177:6acd7701e4df
user:        Panu Matilainen <pmatilai at redhat.com>
date:        Fri Jul 20 11:19:56 2007 +0300
files:       rpmdb/rpmdb.c rpmdb/rpmdb.h
description:
Support explicitly asking from rpmdb cleanup + termination.
New rpmdbCheckTerminate() function which checks for termination signals
and allows requesting termination via parameter as well. Make
rpmdbCheckSignals() just a wrapper that calls it with terminate=0.


diff -r c0237c16e2e3 -r 6acd7701e4df rpmdb/rpmdb.c
--- a/rpmdb/rpmdb.c	Fri Jul 20 10:41:15 2007 +0300
+++ b/rpmdb/rpmdb.c	Fri Jul 20 11:19:56 2007 +0300
@@ -700,14 +700,14 @@ static rpmdb rpmdbRock;
 /*@unchecked@*/ /*@exposed@*/ /*@null@*/
 static rpmdbMatchIterator rpmmiRock;
 
-int rpmdbCheckSignals(void)
+int rpmdbCheckTerminate(int terminate)
 	/*@globals rpmdbRock, rpmmiRock @*/
 	/*@modifies rpmdbRock, rpmmiRock @*/
 {
     sigset_t newMask, oldMask;
-    static int terminate = 0;
-
-    if (terminate) return 0;
+    static int terminating = 0;
+
+    if (terminating) return 0;
 
     (void) sigfillset(&newMask);		/* block all signals */
     (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
@@ -716,10 +716,11 @@ int rpmdbCheckSignals(void)
      || sigismember(&rpmsqCaught, SIGQUIT)
      || sigismember(&rpmsqCaught, SIGHUP)
      || sigismember(&rpmsqCaught, SIGTERM)
-     || sigismember(&rpmsqCaught, SIGPIPE))
-	terminate = 1;
-
-    if (terminate) {
+     || sigismember(&rpmsqCaught, SIGPIPE)
+     || terminate)
+	terminating = 1;
+
+    if (terminating) {
 	rpmdb db;
 	rpmdbMatchIterator mi;
 
@@ -745,6 +746,11 @@ int rpmdbCheckSignals(void)
 	exit(EXIT_FAILURE);
     }
     return sigprocmask(SIG_SETMASK, &oldMask, NULL);
+}
+
+int rpmdbCheckSignals(void)
+{
+    return rpmdbCheckTerminate(0);
 }
 
 /**
diff -r c0237c16e2e3 -r 6acd7701e4df rpmdb/rpmdb.h
--- a/rpmdb/rpmdb.h	Fri Jul 20 10:41:15 2007 +0300
+++ b/rpmdb/rpmdb.h	Fri Jul 20 11:19:56 2007 +0300
@@ -1039,12 +1039,20 @@ Header rpmdbNextIterator(/*@null@*/ rpmd
 	/*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/;
 
 /** \ingroup rpmdb
- * Check rpmdb signal handler for trapped signal exit.
+ * Check rpmdb signal handler for trapped signal exit. Just a compatibility
+ * wrapper for rpmdbCheckTerminate()
  */
 /*@mayexit@*/
 int rpmdbCheckSignals(void)
 	/*@globals fileSystem, internalState @*/
 	/*@modifies fileSystem, internalState @*/;
+
+/** \ingroup rpmdb
+ * Check rpmdb signal handler for trapped signal or requested exit.
+ * @param terminate	0 to only check for signals, 1 to terminate anyway
+ */
+/*@mayexit@*/
+int rpmdbCheckTerminate(int terminate);
 
 /** \ingroup rpmdb
  * Destroy rpm database iterator.


rpm-4.4.2.1-config-mtime.patch:

--- NEW FILE rpm-4.4.2.1-config-mtime.patch ---
changeset:   6235:0d4b8cfd8dc9
tag:         tip
user:        Panu Matilainen <pmatilai at redhat.com>
date:        Thu Aug 09 15:15:24 2007 +0300
files:       lib/rpmfi.c lib/rpmfi.h lib/transaction.c
description:
Avoid unnecessary .rpmnew and .rpmsave files (rhbz#128622)
Don't create .rpmnew and .rpmsave files when file/symlink on disk differs
just by timestamp. Patch by Tomas Mraz.


diff -r debbc872bbb3 -r 0d4b8cfd8dc9 lib/rpmfi.c
--- a/lib/rpmfi.c	Thu Aug 09 14:18:11 2007 +0300
+++ b/lib/rpmfi.c	Thu Aug 09 15:15:24 2007 +0300
@@ -22,6 +22,7 @@
 #include "rpmte.h"
 #include "rpmts.h"
 
+#include "legacy.h"     /* XXX domd5 */
 #include "misc.h"	/* XXX stripTrailingChar */
 #include "rpmmacro.h"	/* XXX rpmCleanPath */
 #include "legacy.h"
@@ -625,6 +626,49 @@ fileAction rpmfiDecideFate(const rpmfi o
      * merge the difference ala CVS, but...
      */
     return save;
+}
+/*@=boundsread@*/
+
+/*@-boundsread@*/
+int rpmfiConfigConflict(const rpmfi fi)
+{
+    const char * fn = rpmfiFN(fi);
+    int flags = rpmfiFFlags(fi);
+    char buffer[1024];
+    fileTypes newWhat, diskWhat;
+    struct stat sb;
+
+    if (!(flags & RPMFILE_CONFIG) || lstat(fn, &sb)) {
+	return 0;
+    }
+
+    diskWhat = whatis((int_16)sb.st_mode);
+    newWhat = whatis(rpmfiFMode(fi));
+
+    if (newWhat != LINK && newWhat != REG)
+	return 1;
+
+    if (diskWhat != newWhat)
+	return 1;
+    
+    memset(buffer, 0, sizeof(buffer));
+    if (newWhat == REG) {
+	const unsigned char * nmd5;
+	if (domd5(fn, (unsigned char *)buffer, 0, NULL))
+	    return 0;	/* assume file has been removed */
+	nmd5 = rpmfiMD5(fi);
+	if (nmd5 && !memcmp(nmd5, buffer, 16))
+	    return 0;	/* unmodified config file */
+    } else /* newWhat == LINK */ {
+	const char * nFLink;
+	if (readlink(fn, buffer, sizeof(buffer) - 1) == -1)
+	    return 0;	/* assume file has been removed */
+	nFLink = rpmfiFLink(fi);
+	if (nFLink && !strcmp(nFLink, buffer))
+	    return 0;	/* unmodified config file */
+    }
+
+    return 1;
 }
 /*@=boundsread@*/
 
diff -r debbc872bbb3 -r 0d4b8cfd8dc9 lib/rpmfi.h
--- a/lib/rpmfi.h	Thu Aug 09 14:18:11 2007 +0300
+++ b/lib/rpmfi.h	Thu Aug 09 15:15:24 2007 +0300
@@ -620,6 +620,14 @@ fileAction rpmfiDecideFate(const rpmfi o
 	/*@modifies nfi, fileSystem, internalState @*/;
 
 /**
+ * Return whether file is conflicting config
+ * @param fi		file info
+ * @return		1 if config file and file on disk conflicts
+ */
+int rpmfiConfigConflict(const rpmfi fi)
+	/*@*/;
+
+/**
  * Return formatted string representation of package disposition.
  * @param fi		file info set
  * @return		formatted string
diff -r debbc872bbb3 -r 0d4b8cfd8dc9 lib/transaction.c
--- a/lib/transaction.c	Thu Aug 09 14:18:11 2007 +0300
+++ b/lib/transaction.c	Thu Aug 09 15:15:24 2007 +0300
@@ -547,7 +547,7 @@ static void handleOverlappedFiles(const 
 /*@-boundswrite@*/
 	switch (rpmteType(p)) {
 	case TR_ADDED:
-	  { struct stat sb;
+	  {
 	    int reportConflicts =
 		!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACENEWFILES);
 	    int done = 0;
@@ -556,7 +556,7 @@ static void handleOverlappedFiles(const 
 		/* XXX is this test still necessary? */
 		if (fi->actions[i] != FA_UNKNOWN)
 		    /*@switchbreak@*/ break;
-		if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
+		if (rpmfiConfigConflict(fi)) {
 		    /* Here is a non-overlapped pre-existing config file. */
 		    fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
 			? FA_ALTNAME : FA_BACKUP;
@@ -613,7 +613,7 @@ assert(otherFi != NULL);
 	    /* Try to get the disk accounting correct even if a conflict. */
 	    fixupSize = rpmfiFSize(otherFi);
 
-	    if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
+	    if (rpmfiConfigConflict(fi)) {
 		/* Here is an overlapped  pre-existing config file. */
 		fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
 			? FA_ALTNAME : FA_SKIP;


rpm-4.4.2.1-python-exithook.patch:

--- NEW FILE rpm-4.4.2.1-python-exithook.patch ---
changeset:   6178:e9ced408b17f
tag:         tip
user:        Panu Matilainen <pmatilai at redhat.com>
date:        Fri Jul 20 11:23:11 2007 +0300
files:       python/rpmmodule.c
description:
Force rpmdb clean termination on exit from python.
Python process tracebacking with active iterators can and will otherwise leave
stale locks around (as is presumably the reason for rhbz#235389 and various
other locking issues)


diff -r 6acd7701e4df -r e9ced408b17f python/rpmmodule.c
--- a/python/rpmmodule.c	Fri Jul 20 11:19:56 2007 +0300
+++ b/python/rpmmodule.c	Fri Jul 20 11:23:11 2007 +0300
@@ -227,6 +227,16 @@ static PyMethodDef rpmModuleMethods[] = 
     { NULL }
 } ;
 
+/*
+* Force clean up of open iterators and dbs on exit.
+* This ends up calling exit() while we're already exiting but exit
+* handlers will only get called once so it wont loop.
+*/
+static void rpm_exithook(void)
+{
+   rpmdbCheckTerminate(1);
+}
+
 /**
  */
 static char rpm__doc__[] =
@@ -263,6 +273,13 @@ void init_rpm(void)
 
     m = Py_InitModule3("_rpm", rpmModuleMethods, rpm__doc__);
     if (m == NULL)
+	return;
+
+    /* 
+     * treat error to register rpm cleanup hook as fatal, tracebacks
+     * can and will leave stale locks around if we can't clean up
+     */
+    if (Py_AtExit(rpm_exithook) == -1)
 	return;
 
     rpmReadConfigFiles(NULL, NULL);


rpm-4.4.2.1-strict-docdir.patch:

--- NEW FILE rpm-4.4.2.1-strict-docdir.patch ---
diff -r e1802883bd62 -r cf3b54441b8a build/files.c
--- a/build/files.c	Sat Jul 21 15:48:03 2007 +0300
+++ b/build/files.c	Mon Jul 23 10:02:54 2007 +0300
@@ -1065,7 +1065,6 @@ static int compareFileListRecs(const voi
 
 /**
  * Test if file is located in a %docdir.
- * @bug Use of strstr(3) might result in false positives.
  * @param fl		package file tree walk data
  * @param fileName	file path
  * @return		1 if doc file, 0 if not
@@ -1073,9 +1072,12 @@ static int isDoc(FileList fl, const char
 static int isDoc(FileList fl, const char * fileName)	/*@*/
 {
     int x = fl->docDirCount;
-
+    size_t k, l;
+
+    k = strlen(fileName);
     while (x--) {
-	if (strstr(fileName, fl->docDirs[x]) == fileName)
+	l = strlen(fl->docDirs[x]);
+	if (l < k && strncmp(fileName, fl->docDirs[x], l) == 0 && fileName[l] == '/')
 	    return 1;
     }
     return 0;




More information about the fedora-extras-commits mailing list