Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-06-27 23:25:04 -0400
committerDan McGee <dan@archlinux.org>2007-06-27 23:34:38 -0400
commit7daa6708d2afc710bebbb2dc30f4371f9d67120c (patch)
tree2321ad0d697ce56b4cad0e16222b3888cd31ac2f /lib/libalpm
parent7bdb904af5b664c1d6e47977f21f0e6bc3f8e3b0 (diff)
Remove lockfile configuration from frontend, make it job of libalpm
I previously introduced some patches to make just about every path in pacman/libalpm configurable; doing this with the lockfile seemed a bit too far and we really should just place the lockfile where it belongs- with the DB that needs locking. More details in this thread: http://archlinux.org/pipermail/pacman-dev/2007-June/008499.html Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/Makefile.am5
-rw-r--r--lib/libalpm/alpm.h2
-rw-r--r--lib/libalpm/handle.c17
-rw-r--r--lib/libalpm/util.c9
4 files changed, 11 insertions, 22 deletions
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index afbfed0e..be49c297 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -2,11 +2,6 @@ AUTOMAKE_OPTIONS = gnu
SUBDIRS = po
-# paths set at make time
-lockfile = ${localstatedir}/run/pacman.lck
-dbpath = ${localstatedir}/lib/pacman/
-cachedir = ${localstatedir}/cache/pacman/pkg/
-
lib_LTLIBRARIES = libalpm.la
include_HEADERS = alpm_list.h alpm.h
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index add835d2..d1363803 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -106,7 +106,7 @@ const char *alpm_option_get_logfile();
void alpm_option_set_logfile(const char *logfile);
const char *alpm_option_get_lockfile();
-void alpm_option_set_lockfile(const char *lockfile);
+/* no set_lockfile, path is determined from dbpath */
unsigned short alpm_option_get_usesyslog();
void alpm_option_set_usesyslog(unsigned short usesyslog);
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 6f9e3330..7cee5020 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -181,6 +181,7 @@ void SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
ALPM_LOG_FUNC;
if(handle->dbpath) FREE(handle->dbpath);
+ if(handle->lockfile) FREE(handle->lockfile);
if(dbpath) {
/* verify dbpath ends in a '/' */
int dbpathlen = strlen(dbpath);
@@ -190,7 +191,13 @@ void SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
handle->dbpath = calloc(dbpathlen+1, sizeof(char));
strncpy(handle->dbpath, dbpath, dbpathlen);
handle->dbpath[dbpathlen-1] = '/';
+
+ const char *lf = "db.lck";
+ int lockfilelen = strlen(handle->dbpath) + strlen(lf);
+ handle->lockfile = calloc(lockfilelen + 1, sizeof(char));
+ snprintf(handle->lockfile, lockfilelen, "%s%s", handle->dbpath, lf);
}
+
}
void SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
@@ -235,16 +242,6 @@ void SYMEXPORT alpm_option_set_logfile(const char *logfile)
}
}
-void SYMEXPORT alpm_option_set_lockfile(const char *lockfile)
-{
- ALPM_LOG_FUNC;
-
- if(handle->lockfile) FREE(handle->lockfile);
- if(lockfile) {
- handle->lockfile = strdup(lockfile);
- }
-}
-
void SYMEXPORT alpm_option_set_usesyslog(unsigned short usesyslog)
{
handle->usesyslog = usesyslog;
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index e67a13ad..ec6c1df1 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -264,8 +264,7 @@ char *_alpm_strreplace(const char *str, const char *needle, const char *replace)
}
-/* Create a lock file
-*/
+/* Create a lock file */
int _alpm_lckmk()
{
int fd, count = 0;
@@ -293,8 +292,7 @@ int _alpm_lckmk()
return(fd > 0 ? fd : -1);
}
-/* Remove a lock file
-*/
+/* Remove a lock file */
int _alpm_lckrm()
{
const char *file = alpm_option_get_lockfile();
@@ -304,8 +302,7 @@ int _alpm_lckrm()
return(0);
}
-/* Compression functions
-*/
+/* Compression functions */
int _alpm_unpack(const char *archive, const char *prefix, const char *fn)
{