summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--lib/rpmlock.c37
-rw-r--r--macros.in14
-rw-r--r--rpm.spec.in3
4 files changed, 38 insertions, 18 deletions
diff --git a/CHANGES b/CHANGES
index dcfff8a53..180098af5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -64,6 +64,8 @@
- fix: segfault on --verifydb (#138589).
- sparcv8: optflags changed to -mtune=ultrasparc (#140420).
- port to internal file-4.10 libmagic rather than libfmagic.
+ - move global /var/lock/rpm/transaction to dbpath.
+ - permit fcntl path to be configured through rpmlock_path macro.
4.3.1 -> 4.3.2:
- use /etc/selinux/targeted/contexts/files/file_contexts for now.
diff --git a/lib/rpmlock.c b/lib/rpmlock.c
index 4045a0b08..23a959197 100644
--- a/lib/rpmlock.c
+++ b/lib/rpmlock.c
@@ -1,21 +1,21 @@
#include "system.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-
#include <rpmlib.h>
+#include <rpmmacro.h>
#include "rpmts.h"
-
#include "rpmlock.h"
+#include "debug.h"
+
/* Internal interface */
-#define RPMLOCK_FILE "/var/lock/rpm/transaction"
+#define RPMLOCK_PATH "/var/lock/rpm/transaction"
+/*@unchecked@*/ /*@observer@*/
+static const char * rpmlock_path_default = "%{?_rpmlock_path}";
+/*@unchecked@*/
+static const char * rpmlock_path = NULL;
/*@observer@*/ /*@unchecked@*/
static const char * _rpmlock_file = RPMLOCK_FILE;
@@ -37,14 +37,23 @@ static rpmlock rpmlock_new(/*@unused@*/ const char *rootdir)
/*@modifies fileSystem @*/
{
rpmlock lock = (rpmlock) malloc(sizeof(*lock));
- if (lock) {
+
+ /* XXX oneshot to determine path for fcntl lock. */
+ if (rpmlock_path == NULL) {
+ char * t = rpmExpand(rpmlock_path_default, NULL);
+ if (t == NULL || *t == '\0' || *t == '%')
+ t = RPMLOCK_PATH;
+ rpmlock_path = xstrdup(t);
+ t = _free(t);
+ }
+ if (lock != NULL) {
mode_t oldmask = umask(022);
- lock->fd = open(RPMLOCK_FILE, O_RDWR|O_CREAT, 0644);
+ lock->fd = open(rpmlock_path, O_RDWR|O_CREAT, 0644);
(void) umask(oldmask);
/*@-branchstate@*/
if (lock->fd == -1) {
- lock->fd = open(RPMLOCK_FILE, O_RDONLY);
+ lock->fd = open(rpmlock_path, O_RDONLY);
if (lock->fd == -1) {
free(lock);
lock = NULL;
@@ -128,14 +137,14 @@ void *rpmtsAcquireLock(rpmts ts)
lock = rpmlock_new(rootDir);
/*@-branchstate@*/
if (!lock) {
- rpmMessage(RPMMESS_ERROR, _("can't create transaction lock\n"));
+ rpmMessage(RPMMESS_ERROR, _("can't create transaction lock on %s\n"), rpmlock_path);
} else if (!rpmlock_acquire(lock, RPMLOCK_WRITE)) {
if (lock->openmode & RPMLOCK_WRITE)
rpmMessage(RPMMESS_WARNING,
- _("waiting for transaction lock\n"));
+ _("waiting for transaction lock on %s\n"), rpmlock_path);
if (!rpmlock_acquire(lock, RPMLOCK_WRITE|RPMLOCK_WAIT)) {
rpmMessage(RPMMESS_ERROR,
- _("can't create transaction lock\n"));
+ _("can't create transaction lock on %s\n"), rpmlock_path);
rpmlock_free(lock);
lock = NULL;
}
diff --git a/macros.in b/macros.in
index 27bf0c17d..a1dde3074 100644
--- a/macros.in
+++ b/macros.in
@@ -1,7 +1,7 @@
#/*! \page config_macros Default configuration: @RPMCONFIGDIR@/macros
# \verbatim
#
-# $Id: macros.in,v 1.154.2.2 2004/12/05 20:05:46 jbj Exp $
+# $Id: macros.in,v 1.154.2.3 2005/01/26 04:05:34 jbj Exp $
#
# This is a global RPM configuration file. All changes made here will
# be lost when the rpm package is upgraded. Any per-system configuration
@@ -833,6 +833,18 @@ print (t)\
# XXX Note: escaped %% for use in headerSprintf()
%_query_all_fmt %%{name}-%%{version}-%%{release}
+#
+# Default path to the file used for transaction fcmtl lock.
+#
+# The previous, FHS clompliant, name was /var/lock/run/transaction,
+# but the transaction lock needs to be per-database, not global, for
+# some rpmdb operations.
+#
+# XXX Note: the file name is chosesn as __db.000 to expedite
+# support issues, many users are doing "rm -f /var/lib/rpm/__db*"
+# these days.
+%_rpmlock_path %{_dbpath}/__db.000
+
#==============================================================================
# ---- Cache configuration macros.
# Macro(s) used to configure the universe of headers used to
diff --git a/rpm.spec.in b/rpm.spec.in
index 49e773fe9..eacecf3d1 100644
--- a/rpm.spec.in
+++ b/rpm.spec.in
@@ -183,8 +183,6 @@ do
touch $RPM_BUILD_ROOT/var/lib/rpm/$dbi
done
-# - serialize rpmtsRun() using fcntl on /var/lock/rpm/transaction.
-mkdir -p ${RPM_BUILD_ROOT}/var/lock/rpm
%endif
%if %{with_apidocs}
@@ -278,7 +276,6 @@ exit 0
#%config(noreplace,missingok) /etc/rpm/macros.*
%attr(0755, @RPMUSER@, @RPMGROUP@) %dir /var/lib/rpm
%attr(0755, @RPMUSER@, @RPMGROUP@) %dir /var/spool/repackage
-%attr(0755, @RPMUSER@, @RPMGROUP@) %dir /var/lock/rpm
%define rpmdbattr %attr(0644, @RPMUSER@, @RPMGROUP@) %verify(not md5 size mtime) %ghost %config(missingok,noreplace)
%rpmdbattr /var/lib/rpm/*