1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-10 11:35:00 -05:00

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}) sysconfdir : $(eval echo ${sysconfdir})
conf file : $(eval echo ${sysconfdir})/pacman.conf conf file : $(eval echo ${sysconfdir})/pacman.conf
localstatedir : $(eval echo ${localstatedir}) localstatedir : $(eval echo ${localstatedir})
lock file : $(eval echo ${localstatedir})/run/pacman.lck
database dir : $(eval echo ${localstatedir})/lib/pacman/ database dir : $(eval echo ${localstatedir})/lib/pacman/
cache dir : $(eval echo ${localstatedir})/cache/pacman/pkg/ cache dir : $(eval echo ${localstatedir})/cache/pacman/pkg/
compiler : ${CC} compiler : ${CC}

View File

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

View File

@ -2,11 +2,6 @@ AUTOMAKE_OPTIONS = gnu
SUBDIRS = po 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 lib_LTLIBRARIES = libalpm.la
include_HEADERS = alpm_list.h alpm.h 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); void alpm_option_set_logfile(const char *logfile);
const char *alpm_option_get_lockfile(); 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(); unsigned short alpm_option_get_usesyslog();
void alpm_option_set_usesyslog(unsigned short 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; ALPM_LOG_FUNC;
if(handle->dbpath) FREE(handle->dbpath); if(handle->dbpath) FREE(handle->dbpath);
if(handle->lockfile) FREE(handle->lockfile);
if(dbpath) { if(dbpath) {
/* verify dbpath ends in a '/' */ /* verify dbpath ends in a '/' */
int dbpathlen = strlen(dbpath); int dbpathlen = strlen(dbpath);
@ -190,7 +191,13 @@ void SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
handle->dbpath = calloc(dbpathlen+1, sizeof(char)); handle->dbpath = calloc(dbpathlen+1, sizeof(char));
strncpy(handle->dbpath, dbpath, dbpathlen); strncpy(handle->dbpath, dbpath, dbpathlen);
handle->dbpath[dbpathlen-1] = '/'; 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) 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) void SYMEXPORT alpm_option_set_usesyslog(unsigned short usesyslog)
{ {
handle->usesyslog = 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 _alpm_lckmk()
{ {
int fd, count = 0; int fd, count = 0;
@ -293,8 +292,7 @@ int _alpm_lckmk()
return(fd > 0 ? fd : -1); return(fd > 0 ? fd : -1);
} }
/* Remove a lock file /* Remove a lock file */
*/
int _alpm_lckrm() int _alpm_lckrm()
{ {
const char *file = alpm_option_get_lockfile(); const char *file = alpm_option_get_lockfile();
@ -304,8 +302,7 @@ int _alpm_lckrm()
return(0); return(0);
} }
/* Compression functions /* Compression functions */
*/
int _alpm_unpack(const char *archive, const char *prefix, const char *fn) int _alpm_unpack(const char *archive, const char *prefix, const char *fn)
{ {

View File

@ -192,13 +192,12 @@ class pmtest:
cmd.append("libtool gdb --args") cmd.append("libtool gdb --args")
if pacman["valgrind"]: if pacman["valgrind"]:
cmd.append("valgrind --tool=memcheck --leak-check=full --show-reachable=yes") 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"], % (pacman["bin"],
os.path.join(self.root, PACCONF), os.path.join(self.root, PACCONF),
self.root, self.root,
os.path.join(self.root, PM_DBPATH), os.path.join(self.root, PM_DBPATH),
os.path.join(self.root, PM_CACHEDIR), os.path.join(self.root, PM_CACHEDIR)))
os.path.join(self.root, PM_LOCK) ))
if not pacman["manual-confirm"]: if not pacman["manual-confirm"]:
cmd.append("--noconfirm") cmd.append("--noconfirm")
if pacman["debug"]: if pacman["debug"]:

View File

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

View File

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

View File

@ -2,7 +2,6 @@ SUBDIRS = po
# paths set at make time # paths set at make time
conffile = ${sysconfdir}/pacman.conf conffile = ${sysconfdir}/pacman.conf
lockfile = ${localstatedir}/run/pacman.lck
bin_PROGRAMS = pacman pacman.static 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(_(" -r, --root <path> set an alternate installation root\n"));
printf(_(" -b, --dbpath <path> set an alternate database location\n")); printf(_(" -b, --dbpath <path> set an alternate database location\n"));
printf(_(" --cachedir <dir> set an alternate package cache 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}, {"noscriptlet", no_argument, 0, 1005},
{"ask", required_argument, 0, 1006}, {"ask", required_argument, 0, 1006},
{"cachedir", required_argument, 0, 1007}, {"cachedir", required_argument, 0, 1007},
{"lock", required_argument, 0, 1008},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
struct stat st; struct stat st;
@ -347,9 +345,6 @@ static int parseargs(int argc, char *argv[])
} }
alpm_option_add_cachedir(optarg); alpm_option_add_cachedir(optarg);
break; break;
case 1008:
alpm_option_set_lockfile(optarg);
break;
case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break; case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
case 'F': case 'F':
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE); 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); alpm_option_set_logfile(ptr);
pm_printf(PM_LOG_DEBUG, _("config: logfile: %s\n"), 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) { } else if (strcmp(key, "XferCommand") == 0 || strcmp(upperkey, "XFERCOMMAND") == 0) {
alpm_option_set_xfercommand(ptr); alpm_option_set_xfercommand(ptr);
pm_printf(PM_LOG_DEBUG, _("config: xfercommand: %s\n"), ptr); pm_printf(PM_LOG_DEBUG, _("config: xfercommand: %s\n"), ptr);