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>
This commit is contained in:
Dan McGee 2007-06-27 23:25:04 -04:00
parent 7bdb904af5
commit 7daa6708d2
11 changed files with 15 additions and 40 deletions

View File

@ -255,7 +255,6 @@ $PACKAGE_STRING:
sysconfdir : $(eval echo ${sysconfdir})
conf file : $(eval echo ${sysconfdir})/pacman.conf
localstatedir : $(eval echo ${localstatedir})
lock file : $(eval echo ${localstatedir})/run/pacman.lck
database dir : $(eval echo ${localstatedir})/lib/pacman/
cache dir : $(eval echo ${localstatedir})/cache/pacman/pkg/
compiler : ${CC}

View File

@ -10,7 +10,6 @@
RootDir = @ROOTDIR@
DBPath = @localstatedir@/lib/pacman/
CacheDir = @localstatedir@/cache/pacman/pkg/
LockFile = @localstatedir@/run/pacman.lck
LogFile = @localstatedir@/log/pacman.log
HoldPkg = pacman glibc
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -192,13 +192,12 @@ def run(self, pacman):
cmd.append("libtool gdb --args")
if pacman["valgrind"]:
cmd.append("valgrind --tool=memcheck --leak-check=full --show-reachable=yes")
cmd.append("%s --config=%s --root=%s --dbpath=%s --cachedir=%s --lock=%s" \
cmd.append("%s --config=%s --root=%s --dbpath=%s --cachedir=%s" \
% (pacman["bin"],
os.path.join(self.root, PACCONF),
self.root,
os.path.join(self.root, PM_DBPATH),
os.path.join(self.root, PM_CACHEDIR),
os.path.join(self.root, PM_LOCK) ))
os.path.join(self.root, PM_CACHEDIR)))
if not pacman["manual-confirm"]:
cmd.append("--noconfirm")
if pacman["debug"]:

View File

@ -27,8 +27,8 @@
# ALPM
PM_ROOT = "/"
PM_DBPATH = "var/lib/pacman"
PM_LOCK = "var/lib/pacman/db.lck"
PM_CACHEDIR = "var/cache/pacman/pkg"
PM_LOCK = "var/run/pacman.lck"
PM_EXT_PKG = ".pkg.tar.gz"
PM_EXT_DB = ".db.tar.gz"
PM_PACNEW = ".pacnew"

View File

@ -27,7 +27,7 @@ export TEXTDOMAINDIR='@localedir@'
myver='@PACKAGE_VERSION@'
dbroot='@localstatedir@/lib/pacman/'
lockfile='@localstatedir@/run/pacman.lck'
lockfile="${dbroot}db.lck"
msg() {
local mesg=$1; shift

View File

@ -2,7 +2,6 @@ SUBDIRS = po
# paths set at make time
conffile = ${sysconfdir}/pacman.conf
lockfile = ${localstatedir}/run/pacman.lck
bin_PROGRAMS = pacman pacman.static

View File

@ -149,7 +149,6 @@ static void usage(int op, char *myname)
printf(_(" -r, --root <path> set an alternate installation root\n"));
printf(_(" -b, --dbpath <path> set an alternate database location\n"));
printf(_(" --cachedir <dir> set an alternate package cache location\n"));
printf(_(" --lock <file> set an alternate lockfile location\n"));
}
}
@ -293,7 +292,6 @@ static int parseargs(int argc, char *argv[])
{"noscriptlet", no_argument, 0, 1005},
{"ask", required_argument, 0, 1006},
{"cachedir", required_argument, 0, 1007},
{"lock", required_argument, 0, 1008},
{0, 0, 0, 0}
};
struct stat st;
@ -347,9 +345,6 @@ static int parseargs(int argc, char *argv[])
}
alpm_option_add_cachedir(optarg);
break;
case 1008:
alpm_option_set_lockfile(optarg);
break;
case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
case 'F':
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE);
@ -636,11 +631,6 @@ static int _parseconfig(const char *file, const char *givensection,
alpm_option_set_logfile(ptr);
pm_printf(PM_LOG_DEBUG, _("config: logfile: %s\n"), ptr);
}
} else if (strcmp(key, "LockFile") == 0 || strcmp(upperkey, "LOCKFILE") == 0) {
if(alpm_option_get_lockfile() == NULL) {
alpm_option_set_lockfile(ptr);
pm_printf(PM_LOG_DEBUG, _("config: lockfile: %s\n"), ptr);
}
} else if (strcmp(key, "XferCommand") == 0 || strcmp(upperkey, "XFERCOMMAND") == 0) {
alpm_option_set_xfercommand(ptr);
pm_printf(PM_LOG_DEBUG, _("config: xfercommand: %s\n"), ptr);