Move DB and cache dirs away from there dependence on ROOTDIR
This change allows us to use all autoconf specified paths, most notably $(localstatedir). It is quite a change and touches a lot of files, as all references to the DB and cache were done with the ROOTDIR as a prefix. * add --lock command-line option to pacman to specify the location of the lockfile (this can now be specified at configure time by setting the $localstatedir path). * Rip quite a few settings out of configure.ac as they are now picked by setting the paths during configure or make. * Fix bug with /tmp fallback for sync downloads not working correctly (related to root location, now the system tmp dir is used). * Simplified the parameters to some libalpm functions, and added get/set for the new lockfile option. * Renamed several of the DEFS to names without the PM_ prefix. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
722db4535a
commit
7bd2ff6851
62
configure.ac
62
configure.ac
|
@ -33,26 +33,6 @@ AC_ARG_WITH(root-dir,
|
||||||
AC_HELP_STRING([--with-root-dir=path], [Set the location of pacman's root operating directory]),
|
AC_HELP_STRING([--with-root-dir=path], [Set the location of pacman's root operating directory]),
|
||||||
[ROOTDIR=$withval], [ROOTDIR=/])
|
[ROOTDIR=$withval], [ROOTDIR=/])
|
||||||
|
|
||||||
# Help line for database path
|
|
||||||
AC_ARG_WITH(db-path,
|
|
||||||
AC_HELP_STRING([--with-db-path=path], [Set the location of pacman's database]),
|
|
||||||
[DBPATH=$withval], [DBPATH=var/lib/pacman/])
|
|
||||||
|
|
||||||
# Help line for cache directory
|
|
||||||
AC_ARG_WITH(cache-dir,
|
|
||||||
AC_HELP_STRING([--with-cache-dir=path], [Set the location of pacman's cache directory]),
|
|
||||||
[CACHEDIR=$withval], [CACHEDIR=var/cache/pacman/pkg/])
|
|
||||||
|
|
||||||
# Help line for lock file
|
|
||||||
AC_ARG_WITH(lock-file,
|
|
||||||
AC_HELP_STRING([--with-lock-file=path], [Set the location of pacman's lock file]),
|
|
||||||
[LOCKFILE=$withval], [LOCKFILE=var/run/pacman.lck])
|
|
||||||
|
|
||||||
# Help line for config file
|
|
||||||
AC_ARG_WITH(config-file,
|
|
||||||
AC_HELP_STRING([--with-config-file=path], [Set the location of pacman's config file]),
|
|
||||||
[CONFIGFILE=$withval], [CONFIGFILE=etc/pacman.conf])
|
|
||||||
|
|
||||||
# Help line for package extension
|
# Help line for package extension
|
||||||
AC_ARG_WITH(pkg-ext,
|
AC_ARG_WITH(pkg-ext,
|
||||||
AC_HELP_STRING([--with-pkg-ext=ext], [Set the file extension used by packages]),
|
AC_HELP_STRING([--with-pkg-ext=ext], [Set the file extension used by packages]),
|
||||||
|
@ -209,32 +189,12 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set root directory
|
# Set root directory
|
||||||
AC_DEFINE_UNQUOTED([PM_ROOT], "$ROOTDIR", [Location of pacman's default root directory])
|
AC_DEFINE_UNQUOTED([ROOTDIR], "$ROOTDIR", [Location of pacman's default root di
|
||||||
AC_SUBST(ROOTDIR)
|
rectory])
|
||||||
|
|
||||||
# Set database path
|
|
||||||
AC_DEFINE_UNQUOTED([PM_DBPATH], "$DBPATH", [Location of pacman database])
|
|
||||||
AC_SUBST(DBPATH)
|
|
||||||
|
|
||||||
# Set cache directory
|
|
||||||
AC_DEFINE_UNQUOTED([PM_CACHEDIR], "$CACHEDIR", [Location of pacman's package cache])
|
|
||||||
AC_SUBST(CACHEDIR)
|
|
||||||
|
|
||||||
# Set lock file location
|
|
||||||
AC_DEFINE_UNQUOTED([PM_LOCK], "$LOCKFILE", [Location of pacman lock file])
|
|
||||||
AC_SUBST(LOCKFILE)
|
|
||||||
|
|
||||||
# Set configuration file location
|
|
||||||
AC_DEFINE_UNQUOTED([PM_CONF], "$CONFIGFILE", [Location of pacman configuration file])
|
|
||||||
AC_SUBST(CONFIGFILE)
|
|
||||||
|
|
||||||
# Set package file extension
|
# Set package file extension
|
||||||
AC_DEFINE_UNQUOTED([PM_EXT_PKG], "$PKGEXT", [The file extension used by pacman packages])
|
AC_DEFINE_UNQUOTED([PKGEXT], "$PKGEXT", [The file extension used by pacman packages])
|
||||||
AC_SUBST(PKGEXT)
|
|
||||||
|
|
||||||
# Set database file extension
|
# Set database file extension
|
||||||
AC_DEFINE_UNQUOTED([PM_EXT_DB], "$DBEXT", [The file extension used by pacman databases])
|
AC_DEFINE_UNQUOTED([DBEXT], "$DBEXT", [The file extension used by pacman databases])
|
||||||
AC_SUBST(DBEXT)
|
|
||||||
|
|
||||||
# Configuration files
|
# Configuration files
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
|
@ -257,9 +217,15 @@ AC_OUTPUT
|
||||||
echo "
|
echo "
|
||||||
$PACKAGE_STRING:
|
$PACKAGE_STRING:
|
||||||
|
|
||||||
|
Build information:
|
||||||
|
source code location : ${srcdir}
|
||||||
prefix : ${prefix}
|
prefix : ${prefix}
|
||||||
sysconfdir : $(eval echo ${sysconfdir})
|
sysconfdir : $(eval echo ${sysconfdir})
|
||||||
source code location : ${srcdir}
|
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}
|
compiler : ${CC}
|
||||||
compiler flags : ${CFLAGS}
|
compiler flags : ${CFLAGS}
|
||||||
defines : ${DEFS}
|
defines : ${DEFS}
|
||||||
|
@ -272,11 +238,7 @@ $PACKAGE_STRING:
|
||||||
pacman version : ${PACKAGE_VERSION}
|
pacman version : ${PACKAGE_VERSION}
|
||||||
|
|
||||||
Directory and file information:
|
Directory and file information:
|
||||||
root directory : ${ROOTDIR}
|
root working directory : ${ROOTDIR}
|
||||||
database path : ${ROOTDIR}${DBPATH}
|
|
||||||
cache directory : ${ROOTDIR}${CACHEDIR}
|
|
||||||
lock file location : ${ROOTDIR}${LOCKFILE}
|
|
||||||
conf file location : ${ROOTDIR}${CONFIGFILE}
|
|
||||||
package extension : ${PKGEXT}
|
package extension : ${PKGEXT}
|
||||||
database extension : ${DBEXT}
|
database extension : ${DBEXT}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,19 @@ 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
|
||||||
|
|
||||||
localedir = $(datadir)/locale
|
DEFS = -DLOCALEDIR=\"@localedir@\" \
|
||||||
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
|
-DLOCKFILE=\"$(lockfile)\" \
|
||||||
|
-DDBPATH=\"$(dbpath)\" \
|
||||||
|
-DCACHEDIR=\"$(cachedir)\" \
|
||||||
|
@DEFS@
|
||||||
|
|
||||||
AM_CFLAGS = -fvisibility=hidden -pedantic -D_GNU_SOURCE
|
AM_CFLAGS = -fvisibility=hidden -pedantic -D_GNU_SOURCE
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
||||||
alpm_list_t *files = NULL;
|
alpm_list_t *files = NULL;
|
||||||
char newmtime[16] = "";
|
char newmtime[16] = "";
|
||||||
char lastupdate[16] = "";
|
char lastupdate[16] = "";
|
||||||
|
const char *dbpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
@ -275,12 +276,12 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build a one-element list */
|
/* build a one-element list */
|
||||||
snprintf(path, PATH_MAX, "%s" PM_EXT_DB, db->treename);
|
snprintf(path, PATH_MAX, "%s" DBEXT, db->treename);
|
||||||
files = alpm_list_add(files, strdup(path));
|
files = alpm_list_add(files, strdup(path));
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s%s", handle->root, handle->dbpath);
|
dbpath = alpm_option_get_dbpath();
|
||||||
|
|
||||||
ret = _alpm_downloadfiles_forreal(db->servers, path, files, lastupdate, newmtime);
|
ret = _alpm_downloadfiles_forreal(db->servers, dbpath, files, lastupdate, newmtime);
|
||||||
FREELIST(files);
|
FREELIST(files);
|
||||||
if(ret == 1) {
|
if(ret == 1) {
|
||||||
/* mtimes match, do nothing */
|
/* mtimes match, do nothing */
|
||||||
|
@ -296,7 +297,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
||||||
_alpm_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s"), db->treename, newmtime);
|
_alpm_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s"), db->treename, newmtime);
|
||||||
_alpm_db_setlastupdate(db, newmtime);
|
_alpm_db_setlastupdate(db, newmtime);
|
||||||
}
|
}
|
||||||
snprintf(path, PATH_MAX, "%s%s%s" PM_EXT_DB, handle->root, handle->dbpath, db->treename);
|
snprintf(path, PATH_MAX, "%s%s" DBEXT, dbpath, db->treename);
|
||||||
|
|
||||||
/* remove the old dir */
|
/* remove the old dir */
|
||||||
_alpm_log(PM_LOG_DEBUG, _("flushing database %s%s"), db->path);
|
_alpm_log(PM_LOG_DEBUG, _("flushing database %s%s"), db->path);
|
||||||
|
@ -466,8 +467,7 @@ int alpm_pkg_checksha1sum(pmpkg_t *pkg)
|
||||||
ASSERT(pkg->origin == PKG_FROM_CACHE, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
ASSERT(pkg->origin == PKG_FROM_CACHE, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
||||||
ASSERT(pkg->data != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
ASSERT(pkg->data != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s%s/%s-%s" PM_EXT_PKG,
|
snprintf(path, PATH_MAX, "%s/%s-%s" PKGEXT, handle->cachedir,
|
||||||
handle->root, handle->cachedir,
|
|
||||||
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
|
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
|
||||||
|
|
||||||
sha1sum = _alpm_SHAFile(path);
|
sha1sum = _alpm_SHAFile(path);
|
||||||
|
@ -510,8 +510,7 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
|
||||||
ASSERT(pkg->origin == PKG_FROM_CACHE, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
ASSERT(pkg->origin == PKG_FROM_CACHE, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
||||||
ASSERT(pkg->data != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
ASSERT(pkg->data != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1));
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s%s/%s-%s" PM_EXT_PKG,
|
snprintf(path, PATH_MAX, "%s/%s-%s" PKGEXT, handle->cachedir,
|
||||||
handle->root, handle->cachedir,
|
|
||||||
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
|
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
|
||||||
|
|
||||||
md5sum = _alpm_MDFile(path);
|
md5sum = _alpm_MDFile(path);
|
||||||
|
@ -639,8 +638,6 @@ int SYMEXPORT alpm_trans_init(pmtranstype_t type, pmtransflag_t flags,
|
||||||
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
|
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
|
||||||
alpm_trans_cb_progress progress)
|
alpm_trans_cb_progress progress)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
@ -649,8 +646,7 @@ int SYMEXPORT alpm_trans_init(pmtranstype_t type, pmtransflag_t flags,
|
||||||
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1));
|
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1));
|
||||||
|
|
||||||
/* lock db */
|
/* lock db */
|
||||||
snprintf(path, PATH_MAX, "%s%s", handle->root, PM_LOCK);
|
handle->lckfd = _alpm_lckmk();
|
||||||
handle->lckfd = _alpm_lckmk(path);
|
|
||||||
if(handle->lckfd == -1) {
|
if(handle->lckfd == -1) {
|
||||||
RET_ERR(PM_ERR_HANDLE_LOCK, -1);
|
RET_ERR(PM_ERR_HANDLE_LOCK, -1);
|
||||||
}
|
}
|
||||||
|
@ -752,7 +748,6 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data)
|
||||||
int SYMEXPORT alpm_trans_release()
|
int SYMEXPORT alpm_trans_release()
|
||||||
{
|
{
|
||||||
pmtrans_t *trans;
|
pmtrans_t *trans;
|
||||||
char path[PATH_MAX];
|
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
|
||||||
|
@ -780,10 +775,11 @@ int SYMEXPORT alpm_trans_release()
|
||||||
close(handle->lckfd);
|
close(handle->lckfd);
|
||||||
handle->lckfd = -1;
|
handle->lckfd = -1;
|
||||||
}
|
}
|
||||||
snprintf(path, PATH_MAX, "%s%s", handle->root, PM_LOCK);
|
if(_alpm_lckrm()) {
|
||||||
if(_alpm_lckrm(path)) {
|
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s"),
|
||||||
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s"), path);
|
alpm_option_get_lockfile());
|
||||||
alpm_logaction(_("warning: could not remove lock file %s"), path);
|
alpm_logaction(_("warning: could not remove lock file %s"),
|
||||||
|
alpm_option_get_lockfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
|
@ -106,6 +106,9 @@ void alpm_option_set_cachedir(const char *cachedir);
|
||||||
const char *alpm_option_get_logfile();
|
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();
|
||||||
|
void alpm_option_set_lockfile(const char *lockfile);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,10 @@
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "alpm.h"
|
#include "alpm.h"
|
||||||
|
|
||||||
pmdb_t *_alpm_db_new(const char *root, const char *dbpath, const char *treename)
|
pmdb_t *_alpm_db_new(const char *dbpath, const char *treename)
|
||||||
{
|
{
|
||||||
pmdb_t *db;
|
pmdb_t *db;
|
||||||
|
const size_t pathsize = strlen(dbpath) + strlen(treename) + 2;
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
|
||||||
|
@ -65,14 +66,14 @@ pmdb_t *_alpm_db_new(const char *root, const char *dbpath, const char *treename)
|
||||||
RET_ERR(PM_ERR_MEMORY, NULL);
|
RET_ERR(PM_ERR_MEMORY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
db->path = calloc(1, strlen(root)+strlen(dbpath)+strlen(treename)+2);
|
db->path = calloc(1, pathsize);
|
||||||
if(db->path == NULL) {
|
if(db->path == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
|
_alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
|
||||||
strlen(root)+strlen(dbpath)+strlen(treename)+2);
|
pathsize);
|
||||||
FREE(db);
|
FREE(db);
|
||||||
RET_ERR(PM_ERR_MEMORY, NULL);
|
RET_ERR(PM_ERR_MEMORY, NULL);
|
||||||
}
|
}
|
||||||
sprintf(db->path, "%s%s%s/", root, dbpath, treename);
|
sprintf(db->path, "%s%s/", dbpath, treename);
|
||||||
|
|
||||||
strncpy(db->treename, treename, PATH_MAX);
|
strncpy(db->treename, treename, PATH_MAX);
|
||||||
|
|
||||||
|
@ -160,6 +161,7 @@ pmdb_t *_alpm_db_register(const char *treename, alpm_cb_db_register callback)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
pmdb_t *db;
|
pmdb_t *db;
|
||||||
|
const char *dbpath;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
@ -183,15 +185,17 @@ pmdb_t *_alpm_db_register(const char *treename, alpm_cb_db_register callback)
|
||||||
_alpm_log(PM_LOG_DEBUG, _("registering database '%s'"), treename);
|
_alpm_log(PM_LOG_DEBUG, _("registering database '%s'"), treename);
|
||||||
|
|
||||||
/* make sure the database directory exists */
|
/* make sure the database directory exists */
|
||||||
snprintf(path, PATH_MAX, "%s%s/%s", handle->root, handle->dbpath, treename);
|
dbpath = alpm_option_get_dbpath();
|
||||||
|
snprintf(path, PATH_MAX, "%s%s", dbpath, treename);
|
||||||
if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) {
|
if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, _("database directory '%s' does not exist, creating it"), path);
|
_alpm_log(PM_LOG_DEBUG, _("database directory '%s' does not exist, creating it"),
|
||||||
|
path);
|
||||||
if(_alpm_makepath(path) != 0) {
|
if(_alpm_makepath(path) != 0) {
|
||||||
RET_ERR(PM_ERR_SYSTEM, NULL);
|
RET_ERR(PM_ERR_SYSTEM, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db = _alpm_db_new(handle->root, handle->dbpath, treename);
|
db = _alpm_db_new(handle->dbpath, treename);
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
RET_ERR(PM_ERR_DB_CREATE, NULL);
|
RET_ERR(PM_ERR_DB_CREATE, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct __pmdb_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* db.c, database general calls */
|
/* db.c, database general calls */
|
||||||
pmdb_t *_alpm_db_new(const char *root, const char *dbpath, const char *treename);
|
pmdb_t *_alpm_db_new(const char *dbpath, const char *treename);
|
||||||
void _alpm_db_free(pmdb_t *db);
|
void _alpm_db_free(pmdb_t *db);
|
||||||
int _alpm_db_cmp(const void *db1, const void *db2);
|
int _alpm_db_cmp(const void *db1, const void *db2);
|
||||||
alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles);
|
alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles);
|
||||||
|
|
|
@ -79,9 +79,10 @@ pmhandle_t *_alpm_handle_new()
|
||||||
handle->access = PM_ACCESS_RW;
|
handle->access = PM_ACCESS_RW;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
handle->root = strdup(PM_ROOT);
|
handle->root = strdup(ROOTDIR);
|
||||||
handle->dbpath = strdup(PM_DBPATH);
|
handle->dbpath = strdup(DBPATH);
|
||||||
handle->cachedir = strdup(PM_CACHEDIR);
|
handle->cachedir = strdup(CACHEDIR);
|
||||||
|
handle->lockfile = strdup(LOCKFILE);
|
||||||
handle->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
|
handle->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
|
||||||
|
|
||||||
return(handle);
|
return(handle);
|
||||||
|
@ -111,6 +112,7 @@ void _alpm_handle_free(pmhandle_t *handle)
|
||||||
FREE(handle->dbpath);
|
FREE(handle->dbpath);
|
||||||
FREE(handle->cachedir);
|
FREE(handle->cachedir);
|
||||||
FREE(handle->logfile);
|
FREE(handle->logfile);
|
||||||
|
FREE(handle->lockfile);
|
||||||
FREE(handle->xfercommand);
|
FREE(handle->xfercommand);
|
||||||
FREELIST(handle->dbs_sync);
|
FREELIST(handle->dbs_sync);
|
||||||
FREELIST(handle->noupgrade);
|
FREELIST(handle->noupgrade);
|
||||||
|
@ -126,7 +128,8 @@ unsigned short SYMEXPORT alpm_option_get_logmask() { return handle->logmask; }
|
||||||
const char SYMEXPORT *alpm_option_get_root() { return handle->root; }
|
const char SYMEXPORT *alpm_option_get_root() { return handle->root; }
|
||||||
const char SYMEXPORT *alpm_option_get_dbpath() { return handle->dbpath; }
|
const char SYMEXPORT *alpm_option_get_dbpath() { return handle->dbpath; }
|
||||||
const char SYMEXPORT *alpm_option_get_cachedir() { return handle->cachedir; }
|
const char SYMEXPORT *alpm_option_get_cachedir() { return handle->cachedir; }
|
||||||
const char *alpm_option_get_logfile() { return handle->logfile; }
|
const char SYMEXPORT *alpm_option_get_logfile() { return handle->logfile; }
|
||||||
|
const char SYMEXPORT *alpm_option_get_lockfile() { return handle->lockfile; }
|
||||||
unsigned short alpm_option_get_usesyslog() { return handle->usesyslog; }
|
unsigned short alpm_option_get_usesyslog() { return handle->usesyslog; }
|
||||||
alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
|
alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
|
||||||
alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
|
alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
|
||||||
|
@ -228,6 +231,14 @@ void alpm_option_set_logfile(const char *logfile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SYMEXPORT alpm_option_set_lockfile(const char *lockfile)
|
||||||
|
{
|
||||||
|
if(handle->lockfile) FREE(handle->lockfile);
|
||||||
|
if(lockfile) {
|
||||||
|
handle->lockfile = strdup(lockfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void alpm_option_set_usesyslog(unsigned short usesyslog)
|
void alpm_option_set_usesyslog(unsigned short usesyslog)
|
||||||
{
|
{
|
||||||
handle->usesyslog = usesyslog;
|
handle->usesyslog = usesyslog;
|
||||||
|
|
|
@ -52,6 +52,7 @@ typedef struct _pmhandle_t {
|
||||||
char *dbpath; /* Base path to pacman's DBs */
|
char *dbpath; /* Base path to pacman's DBs */
|
||||||
char *cachedir; /* Base path to pacman's cache */
|
char *cachedir; /* Base path to pacman's cache */
|
||||||
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
|
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
|
||||||
|
char *lockfile; /* Name of the lock file */
|
||||||
unsigned short usesyslog; /* Use syslog instead of logfile? */
|
unsigned short usesyslog; /* Use syslog instead of logfile? */
|
||||||
|
|
||||||
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
|
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
|
||||||
|
|
|
@ -52,7 +52,7 @@ char* _alpm_MDFile(char *filename)
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
|
||||||
if((file = fopen(filename, "rb")) == NULL) {
|
if((file = fopen(filename, "rb")) == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("%s can't be opened\n"), filename);
|
_alpm_log(PM_LOG_ERROR, _("md5: %s can't be opened\n"), filename);
|
||||||
} else {
|
} else {
|
||||||
char *ret;
|
char *ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -502,7 +502,7 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha
|
||||||
}
|
}
|
||||||
strncpy(tmp, t, PKG_FULLNAME_LEN+7);
|
strncpy(tmp, t, PKG_FULLNAME_LEN+7);
|
||||||
/* trim file extension (if any) */
|
/* trim file extension (if any) */
|
||||||
if((p = strstr(tmp, PM_EXT_PKG))) {
|
if((p = strstr(tmp, PKGEXT))) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,10 +589,10 @@ const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg)
|
||||||
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
||||||
}
|
}
|
||||||
if(pkg->arch && strlen(pkg->arch) > 0) {
|
if(pkg->arch && strlen(pkg->arch) > 0) {
|
||||||
snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PM_EXT_PKG,
|
snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PKGEXT,
|
||||||
pkg->name, pkg->version, pkg->arch);
|
pkg->name, pkg->version, pkg->arch);
|
||||||
} else {
|
} else {
|
||||||
snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s" PM_EXT_PKG,
|
snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s" PKGEXT,
|
||||||
pkg->name, pkg->version);
|
pkg->name, pkg->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
|
||||||
|
|
||||||
/* Try to get JUST the name of the package from the filename */
|
/* Try to get JUST the name of the package from the filename */
|
||||||
memset(pkgname, 0, PKG_NAME_LEN);
|
memset(pkgname, 0, PKG_NAME_LEN);
|
||||||
if((p = strstr(fn, PM_EXT_PKG))) {
|
if((p = strstr(fn, PKGEXT))) {
|
||||||
_alpm_pkg_splitname(fn, pkgname, NULL, 1);
|
_alpm_pkg_splitname(fn, pkgname, NULL, 1);
|
||||||
}
|
}
|
||||||
if(!strlen(pkgname)) {
|
if(!strlen(pkgname)) {
|
||||||
|
|
|
@ -777,7 +777,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||||
alpm_list_t *i, *j, *files = NULL;
|
alpm_list_t *i, *j, *files = NULL;
|
||||||
pmtrans_t *tr = NULL;
|
pmtrans_t *tr = NULL;
|
||||||
int replaces = 0, retval = 0;
|
int replaces = 0, retval = 0;
|
||||||
char ldir[PATH_MAX];
|
const char *cachedir;
|
||||||
int varcache = 1;
|
int varcache = 1;
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
@ -787,7 +787,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||||
|
|
||||||
trans->state = STATE_DOWNLOADING;
|
trans->state = STATE_DOWNLOADING;
|
||||||
/* group sync records by repository and download */
|
/* group sync records by repository and download */
|
||||||
snprintf(ldir, PATH_MAX, "%s%s", handle->root, handle->cachedir);
|
cachedir = alpm_option_get_cachedir();
|
||||||
|
|
||||||
for(i = handle->dbs_sync; i; i = i->next) {
|
for(i = handle->dbs_sync; i; i = i->next) {
|
||||||
pmdb_t *current = i->data;
|
pmdb_t *current = i->data;
|
||||||
|
@ -806,7 +806,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||||
EVENT(trans, PM_TRANS_EVT_PRINTURI, (char *)alpm_db_get_url(current), (char *)fname);
|
EVENT(trans, PM_TRANS_EVT_PRINTURI, (char *)alpm_db_get_url(current), (char *)fname);
|
||||||
} else {
|
} else {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
snprintf(path, PATH_MAX, "%s/%s", ldir, fname);
|
snprintf(path, PATH_MAX, "%s/%s", cachedir, fname);
|
||||||
if(stat(path, &buf)) {
|
if(stat(path, &buf)) {
|
||||||
/* file is not in the cache dir, so add it to the list */
|
/* file is not in the cache dir, so add it to the list */
|
||||||
files = alpm_list_add(files, strdup(fname));
|
files = alpm_list_add(files, strdup(fname));
|
||||||
|
@ -820,22 +820,23 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||||
if(files) {
|
if(files) {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
|
EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
|
||||||
if(stat(ldir, &buf)) {
|
if(stat(cachedir, &buf)) {
|
||||||
/* no cache directory.... try creating it */
|
/* no cache directory.... try creating it */
|
||||||
_alpm_log(PM_LOG_WARNING, _("no %s cache exists, creating...\n"), ldir);
|
_alpm_log(PM_LOG_WARNING, _("no %s cache exists, creating...\n"), cachedir);
|
||||||
alpm_logaction(_("warning: no %s cache exists, creating..."), ldir);
|
alpm_logaction(_("warning: no %s cache exists, creating..."), cachedir);
|
||||||
if(_alpm_makepath(ldir)) {
|
if(_alpm_makepath(cachedir)) {
|
||||||
/* couldn't mkdir the cache directory, so fall back to /tmp and unlink
|
/* couldn't mkdir the cache directory, so fall back to /tmp and unlink
|
||||||
* the package afterwards.
|
* the package afterwards.
|
||||||
*/
|
*/
|
||||||
_alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
|
_alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
|
||||||
alpm_logaction(_("warning: couldn't create package cache, using /tmp instead"));
|
alpm_logaction(_("warning: couldn't create package cache, using /tmp instead"));
|
||||||
snprintf(ldir, PATH_MAX, "%stmp", alpm_option_get_root());
|
alpm_option_set_cachedir("/tmp");
|
||||||
alpm_option_set_cachedir(ldir);
|
cachedir = alpm_option_get_cachedir();
|
||||||
varcache = 0;
|
varcache = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_alpm_downloadfiles(current->servers, ldir, files)) {
|
if(_alpm_downloadfiles(current->servers, alpm_option_get_cachedir(),
|
||||||
|
files)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"), current->treename);
|
_alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"), current->treename);
|
||||||
RET_ERR(PM_ERR_RETRIEVE, -1);
|
RET_ERR(PM_ERR_RETRIEVE, -1);
|
||||||
}
|
}
|
||||||
|
@ -871,7 +872,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||||
retval = 1;
|
retval = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
snprintf(str, PATH_MAX, "%s%s%s", handle->root, handle->cachedir, pkgname);
|
snprintf(str, PATH_MAX, "%s%s", alpm_option_get_cachedir(), pkgname);
|
||||||
md5sum2 = _alpm_MDFile(str);
|
md5sum2 = _alpm_MDFile(str);
|
||||||
sha1sum2 = _alpm_SHAFile(str);
|
sha1sum2 = _alpm_SHAFile(str);
|
||||||
if(md5sum2 == NULL && sha1sum2 == NULL) {
|
if(md5sum2 == NULL && sha1sum2 == NULL) {
|
||||||
|
@ -895,7 +896,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||||
}
|
}
|
||||||
if(doremove) {
|
if(doremove) {
|
||||||
char str[PATH_MAX];
|
char str[PATH_MAX];
|
||||||
snprintf(str, PATH_MAX, "%s%s%s", handle->root, handle->cachedir, pkgname);
|
snprintf(str, PATH_MAX, "%s%s", alpm_option_get_cachedir(), pkgname);
|
||||||
unlink(str);
|
unlink(str);
|
||||||
snprintf(ptr, 512, _("archive %s was corrupted (bad MD5 or SHA1 checksum)\n"), pkgname);
|
snprintf(ptr, 512, _("archive %s was corrupted (bad MD5 or SHA1 checksum)\n"), pkgname);
|
||||||
} else {
|
} else {
|
||||||
|
@ -981,7 +982,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||||
char str[PATH_MAX];
|
char str[PATH_MAX];
|
||||||
|
|
||||||
fname = alpm_pkg_get_filename(spkg);
|
fname = alpm_pkg_get_filename(spkg);
|
||||||
snprintf(str, PATH_MAX, "%s%s%s", handle->root, handle->cachedir, fname);
|
snprintf(str, PATH_MAX, "%s%s", alpm_option_get_cachedir(), fname);
|
||||||
if(_alpm_trans_addtarget(tr, str) == -1) {
|
if(_alpm_trans_addtarget(tr, str) == -1) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,10 +252,11 @@ char *_alpm_strreplace(const char *str, const char *needle, const char *replace)
|
||||||
|
|
||||||
/* Create a lock file
|
/* Create a lock file
|
||||||
*/
|
*/
|
||||||
int _alpm_lckmk(const char *file)
|
int _alpm_lckmk()
|
||||||
{
|
{
|
||||||
int fd, count = 0;
|
int fd, count = 0;
|
||||||
char *dir, *ptr;
|
char *dir, *ptr;
|
||||||
|
const char *file = alpm_option_get_lockfile();
|
||||||
|
|
||||||
/* create the dir of the lockfile first */
|
/* create the dir of the lockfile first */
|
||||||
dir = strdup(file);
|
dir = strdup(file);
|
||||||
|
@ -280,8 +281,9 @@ int _alpm_lckmk(const char *file)
|
||||||
|
|
||||||
/* Remove a lock file
|
/* Remove a lock file
|
||||||
*/
|
*/
|
||||||
int _alpm_lckrm(const char *file)
|
int _alpm_lckrm()
|
||||||
{
|
{
|
||||||
|
const char *file = alpm_option_get_lockfile();
|
||||||
if(unlink(file) == -1 && errno != ENOENT) {
|
if(unlink(file) == -1 && errno != ENOENT) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ int _alpm_copyfile(const char *src, const char *dest);
|
||||||
char *_alpm_strtoupper(char *str);
|
char *_alpm_strtoupper(char *str);
|
||||||
char *_alpm_strtrim(char *str);
|
char *_alpm_strtrim(char *str);
|
||||||
char *_alpm_strreplace(const char *str, const char *needle, const char *replace);
|
char *_alpm_strreplace(const char *str, const char *needle, const char *replace);
|
||||||
int _alpm_lckmk(const char *file);
|
int _alpm_lckmk();
|
||||||
int _alpm_lckrm(const char *file);
|
int _alpm_lckrm();
|
||||||
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
|
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
|
||||||
int _alpm_rmrf(const char *path);
|
int _alpm_rmrf(const char *path);
|
||||||
int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
|
int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
|
||||||
|
|
|
@ -192,8 +192,13 @@ def run(self, pacman):
|
||||||
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" \
|
cmd.append("%s --config=%s --root=%s --dbpath=%s --cachedir=%s --lock=%s" \
|
||||||
% (pacman["bin"], os.path.join(self.root, PACCONF), self.root))
|
% (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) ))
|
||||||
if not pacman["manual-confirm"]:
|
if not pacman["manual-confirm"]:
|
||||||
cmd.append("--noconfirm")
|
cmd.append("--noconfirm")
|
||||||
if pacman["debug"]:
|
if pacman["debug"]:
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
PM_ROOT = "/"
|
PM_ROOT = "/"
|
||||||
PM_DBPATH = "var/lib/pacman"
|
PM_DBPATH = "var/lib/pacman"
|
||||||
PM_CACHEDIR = "var/cache/pacman/pkg"
|
PM_CACHEDIR = "var/cache/pacman/pkg"
|
||||||
PM_LOCK = "/tmp/pacman.lck"
|
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"
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
SUBDIRS = po
|
SUBDIRS = po
|
||||||
|
|
||||||
|
# paths set at make time
|
||||||
|
conffile = ${sysconfdir}/pacman.conf
|
||||||
|
lockfile = ${localstatedir}/run/pacman.lck
|
||||||
|
|
||||||
bin_PROGRAMS = pacman pacman.static
|
bin_PROGRAMS = pacman pacman.static
|
||||||
|
|
||||||
localedir = $(datadir)/locale
|
DEFS = -DLOCALEDIR=\"@localedir@\" \
|
||||||
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
|
-DCONFFILE=\"$(conffile)\" \
|
||||||
|
-DLOCKFILE=\"$(lockfile)\" \
|
||||||
|
@DEFS@
|
||||||
INCLUDES = -I$(top_srcdir)/lib/libalpm
|
INCLUDES = -I$(top_srcdir)/lib/libalpm
|
||||||
|
|
||||||
AM_CFLAGS = -pedantic -D_GNU_SOURCE
|
AM_CFLAGS = -pedantic -D_GNU_SOURCE
|
||||||
|
|
|
@ -95,8 +95,7 @@ int pacman_add(alpm_list_t *targets)
|
||||||
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
||||||
/* TODO this and the 2 other places should probably be on stderr */
|
/* TODO this and the 2 other places should probably be on stderr */
|
||||||
printf(_(" if you're sure a package manager is not already\n"
|
printf(_(" if you're sure a package manager is not already\n"
|
||||||
" running, you can remove %s%s.\n"),
|
" running, you can remove %s.\n"), LOCKFILE);
|
||||||
alpm_option_get_root(), PM_LOCK);
|
|
||||||
}
|
}
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,7 +550,7 @@ void cb_dl_progress(const char *filename, int xfered, int total)
|
||||||
fname = strdup(filename);
|
fname = strdup(filename);
|
||||||
/* strip extension if it's there
|
/* strip extension if it's there
|
||||||
* NOTE: in the case of package files, only the pkgname is sent now */
|
* NOTE: in the case of package files, only the pkgname is sent now */
|
||||||
if((p = strstr(fname, PM_EXT_PKG)) || (p = strstr(fname, PM_EXT_DB))) {
|
if((p = strstr(fname, PKGEXT)) || (p = strstr(fname, DBEXT))) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
if(strlen(fname) > FILENAME_TRIM_LEN) {
|
if(strlen(fname) > FILENAME_TRIM_LEN) {
|
||||||
|
|
|
@ -159,6 +159,7 @@ 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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +303,7 @@ 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;
|
||||||
|
@ -360,6 +362,9 @@ static int parseargs(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
alpm_option_set_cachedir(optarg);
|
alpm_option_set_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);
|
||||||
|
@ -519,7 +524,7 @@ int main(int argc, char *argv[])
|
||||||
(config->op_s_search || config->group || config->op_q_list || config->op_q_info
|
(config->op_s_search || config->group || config->op_q_list || config->op_q_info
|
||||||
|| config->flags & PM_TRANS_FLAG_PRINTURIS))
|
|| config->flags & PM_TRANS_FLAG_PRINTURIS))
|
||||||
|| (config->op == PM_OP_DEPTEST && config->op_d_resolve)
|
|| (config->op == PM_OP_DEPTEST && config->op_d_resolve)
|
||||||
|| (strcmp(alpm_option_get_root(), PM_ROOT) != 0)) {
|
|| (strcmp(alpm_option_get_root(), ROOTDIR) != 0)) {
|
||||||
/* special case: PM_OP_SYNC can be used w/ config->op_s_search by any user */
|
/* special case: PM_OP_SYNC can be used w/ config->op_s_search by any user */
|
||||||
/* special case: ignore root user check if -r is specified, fall back on
|
/* special case: ignore root user check if -r is specified, fall back on
|
||||||
* normal FS checking */
|
* normal FS checking */
|
||||||
|
@ -535,7 +540,7 @@ int main(int argc, char *argv[])
|
||||||
alpm_option_set_logcb(cb_log);
|
alpm_option_set_logcb(cb_log);
|
||||||
|
|
||||||
if(config->configfile == NULL) {
|
if(config->configfile == NULL) {
|
||||||
config->configfile = strdup(PM_ROOT PM_CONF);
|
config->configfile = strdup(CONFFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(alpm_parse_config(config->configfile, NULL, "") != 0) {
|
if(alpm_parse_config(config->configfile, NULL, "") != 0) {
|
||||||
|
@ -548,10 +553,13 @@ int main(int argc, char *argv[])
|
||||||
alpm_option_set_dlcb(cb_dl_progress);
|
alpm_option_set_dlcb(cb_dl_progress);
|
||||||
|
|
||||||
if(config->verbose > 0) {
|
if(config->verbose > 0) {
|
||||||
printf("Root : %s\n", alpm_option_get_root());
|
printf("Root : %s\n", alpm_option_get_root());
|
||||||
printf("DBPath : %s\n", alpm_option_get_dbpath());
|
printf("Conf File : %s\n", config->configfile);
|
||||||
printf("CacheDir : %s\n", alpm_option_get_cachedir());
|
printf("Lock File : %s\n", alpm_option_get_lockfile());
|
||||||
list_display(_("Targets :"), pm_targets);
|
printf("Root : %s\n", alpm_option_get_root());
|
||||||
|
printf("DBPath : %s\n", alpm_option_get_dbpath());
|
||||||
|
printf("CacheDir : %s\n", alpm_option_get_cachedir());
|
||||||
|
list_display("Targets :", pm_targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Opening local database */
|
/* Opening local database */
|
||||||
|
|
|
@ -311,8 +311,9 @@ int pacman_query(alpm_list_t *targets)
|
||||||
}
|
}
|
||||||
if(config->op_q_changelog) {
|
if(config->op_q_changelog) {
|
||||||
char changelog[PATH_MAX];
|
char changelog[PATH_MAX];
|
||||||
snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
|
/* TODO should be done in the backend- no raw DB stuff up front */
|
||||||
alpm_option_get_root(), alpm_option_get_dbpath(),
|
snprintf(changelog, PATH_MAX, "%s/%s/%s-%s/changelog",
|
||||||
|
alpm_option_get_dbpath(),
|
||||||
alpm_db_get_name(db_local),
|
alpm_db_get_name(db_local),
|
||||||
alpm_pkg_get_name(info),
|
alpm_pkg_get_name(info),
|
||||||
alpm_pkg_get_version(info));
|
alpm_pkg_get_version(info));
|
||||||
|
|
|
@ -86,8 +86,7 @@ int pacman_remove(alpm_list_t *targets)
|
||||||
alpm_strerror(pm_errno));
|
alpm_strerror(pm_errno));
|
||||||
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
||||||
printf(_(" if you're sure a package manager is not already\n"
|
printf(_(" if you're sure a package manager is not already\n"
|
||||||
" running, you can remove %s%s.\n"),
|
" running, you can remove %s.\n"), LOCKFILE);
|
||||||
alpm_option_get_root(), PM_LOCK);
|
|
||||||
}
|
}
|
||||||
FREELIST(finaltargs);
|
FREELIST(finaltargs);
|
||||||
return(1);
|
return(1);
|
||||||
|
|
|
@ -61,7 +61,7 @@ static int split_pkgname(char *target, char *name, char *version)
|
||||||
}
|
}
|
||||||
strncpy(tmp, p, 512);
|
strncpy(tmp, p, 512);
|
||||||
/* trim file extension (if any) */
|
/* trim file extension (if any) */
|
||||||
if((p = strstr(tmp, PM_EXT_PKG))) {
|
if((p = strstr(tmp, PKGEXT))) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
/* trim architecture */
|
/* trim architecture */
|
||||||
|
@ -89,13 +89,7 @@ static int split_pkgname(char *target, char *name, char *version)
|
||||||
|
|
||||||
static int sync_cleancache(int level)
|
static int sync_cleancache(int level)
|
||||||
{
|
{
|
||||||
const char *root, *cachedir;
|
const char *cachedir = alpm_option_get_cachedir();
|
||||||
char dirpath[PATH_MAX];
|
|
||||||
|
|
||||||
root = alpm_option_get_root();
|
|
||||||
cachedir = alpm_option_get_cachedir();
|
|
||||||
|
|
||||||
snprintf(dirpath, PATH_MAX, "%s%s", root, cachedir);
|
|
||||||
|
|
||||||
if(level == 1) {
|
if(level == 1) {
|
||||||
/* incomplete cleanup: we keep latest packages and partial downloads */
|
/* incomplete cleanup: we keep latest packages and partial downloads */
|
||||||
|
@ -106,7 +100,7 @@ static int sync_cleancache(int level)
|
||||||
if(!yesno(_("Do you want to remove old packages from cache? [Y/n] ")))
|
if(!yesno(_("Do you want to remove old packages from cache? [Y/n] ")))
|
||||||
return(0);
|
return(0);
|
||||||
printf(_("removing old packages from cache... "));
|
printf(_("removing old packages from cache... "));
|
||||||
dir = opendir(dirpath);
|
dir = opendir(cachedir);
|
||||||
if(dir == NULL) {
|
if(dir == NULL) {
|
||||||
fprintf(stderr, _("error: could not access cache directory\n"));
|
fprintf(stderr, _("error: could not access cache directory\n"));
|
||||||
return(1);
|
return(1);
|
||||||
|
@ -124,12 +118,12 @@ static int sync_cleancache(int level)
|
||||||
char *str = alpm_list_getdata(i);
|
char *str = alpm_list_getdata(i);
|
||||||
char name[256], version[64];
|
char name[256], version[64];
|
||||||
|
|
||||||
if(strstr(str, PM_EXT_PKG) == NULL) {
|
if(strstr(str, PKGEXT) == NULL) {
|
||||||
clean = alpm_list_add(clean, strdup(str));
|
clean = alpm_list_add(clean, strdup(str));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* we keep partially downloaded files */
|
/* we keep partially downloaded files */
|
||||||
if(strstr(str, PM_EXT_PKG ".part")) {
|
if(strstr(str, PKGEXT ".part")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(split_pkgname(str, name, version) != 0) {
|
if(split_pkgname(str, name, version) != 0) {
|
||||||
|
@ -140,10 +134,10 @@ static int sync_cleancache(int level)
|
||||||
char *s = alpm_list_getdata(j);
|
char *s = alpm_list_getdata(j);
|
||||||
char n[256], v[64];
|
char n[256], v[64];
|
||||||
|
|
||||||
if(strstr(s, PM_EXT_PKG) == NULL) {
|
if(strstr(s, PKGEXT) == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(strstr(s, PM_EXT_PKG ".part")) {
|
if(strstr(s, PKGEXT ".part")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(split_pkgname(s, n, v) != 0) {
|
if(split_pkgname(s, n, v) != 0) {
|
||||||
|
@ -163,7 +157,7 @@ static int sync_cleancache(int level)
|
||||||
for(i = clean; i; i = alpm_list_next(i)) {
|
for(i = clean; i; i = alpm_list_next(i)) {
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s", dirpath, (char *)alpm_list_getdata(i));
|
snprintf(path, PATH_MAX, "%s/%s", cachedir, (char *)alpm_list_getdata(i));
|
||||||
unlink(path);
|
unlink(path);
|
||||||
}
|
}
|
||||||
FREELIST(clean);
|
FREELIST(clean);
|
||||||
|
@ -173,12 +167,12 @@ static int sync_cleancache(int level)
|
||||||
return(0);
|
return(0);
|
||||||
printf(_("removing all packages from cache... "));
|
printf(_("removing all packages from cache... "));
|
||||||
|
|
||||||
if(rmrf(dirpath)) {
|
if(rmrf(cachedir)) {
|
||||||
fprintf(stderr, _("error: could not remove cache directory\n"));
|
fprintf(stderr, _("error: could not remove cache directory\n"));
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(makepath(dirpath)) {
|
if(makepath(cachedir)) {
|
||||||
fprintf(stderr, _("error: could not create new cache directory\n"));
|
fprintf(stderr, _("error: could not create new cache directory\n"));
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
@ -492,8 +486,7 @@ int pacman_sync(alpm_list_t *targets)
|
||||||
alpm_strerror(pm_errno));
|
alpm_strerror(pm_errno));
|
||||||
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
||||||
printf(_(" if you're sure a package manager is not already\n"
|
printf(_(" if you're sure a package manager is not already\n"
|
||||||
" running, you can remove %s%s.\n"),
|
" running, you can remove %s.\n"), LOCKFILE);
|
||||||
alpm_option_get_root(), PM_LOCK);
|
|
||||||
}
|
}
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ int getcols()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does the same thing as 'mkdir -p' */
|
/* does the same thing as 'mkdir -p' */
|
||||||
int makepath(char *path)
|
int makepath(const char *path)
|
||||||
{
|
{
|
||||||
char *orig, *str, *ptr;
|
char *orig, *str, *ptr;
|
||||||
char full[PATH_MAX+1] = "";
|
char full[PATH_MAX+1] = "";
|
||||||
|
@ -112,7 +112,7 @@ int makepath(char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does the same thing as 'rm -rf' */
|
/* does the same thing as 'rm -rf' */
|
||||||
int rmrf(char *path)
|
int rmrf(const char *path)
|
||||||
{
|
{
|
||||||
int errflag = 0;
|
int errflag = 0;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int getcols();
|
int getcols();
|
||||||
int makepath(char *path);
|
int makepath(const char *path);
|
||||||
int rmrf(char *path);
|
int rmrf(const char *path);
|
||||||
void indentprint(const char *str, int indent);
|
void indentprint(const char *str, int indent);
|
||||||
char *strtoupper(char *str);
|
char *strtoupper(char *str);
|
||||||
char *strtrim(char *str);
|
char *strtrim(char *str);
|
||||||
|
|
Loading…
Reference in New Issue