summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/Makefile.am10
-rw-r--r--src/pacman/add.c3
-rw-r--r--src/pacman/callback.c2
-rw-r--r--src/pacman/pacman.c20
-rw-r--r--src/pacman/query.c5
-rw-r--r--src/pacman/remove.c3
-rw-r--r--src/pacman/sync.c29
-rw-r--r--src/pacman/util.c4
-rw-r--r--src/pacman/util.h4
9 files changed, 43 insertions, 37 deletions
diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am
index 06d1b447..5248abf3 100644
--- a/src/pacman/Makefile.am
+++ b/src/pacman/Makefile.am
@@ -1,9 +1,15 @@
SUBDIRS = po
+# paths set at make time
+conffile = ${sysconfdir}/pacman.conf
+lockfile = ${localstatedir}/run/pacman.lck
+
bin_PROGRAMS = pacman pacman.static
-localedir = $(datadir)/locale
-DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
+DEFS = -DLOCALEDIR=\"@localedir@\" \
+ -DCONFFILE=\"$(conffile)\" \
+ -DLOCKFILE=\"$(lockfile)\" \
+ @DEFS@
INCLUDES = -I$(top_srcdir)/lib/libalpm
AM_CFLAGS = -pedantic -D_GNU_SOURCE
diff --git a/src/pacman/add.c b/src/pacman/add.c
index cf636234..ef84a398 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -95,8 +95,7 @@ int pacman_add(alpm_list_t *targets)
if(pm_errno == PM_ERR_HANDLE_LOCK) {
/* TODO this and the 2 other places should probably be on stderr */
printf(_(" if you're sure a package manager is not already\n"
- " running, you can remove %s%s.\n"),
- alpm_option_get_root(), PM_LOCK);
+ " running, you can remove %s.\n"), LOCKFILE);
}
return(1);
}
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 5f391306..e13a7e7d 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -550,7 +550,7 @@ void cb_dl_progress(const char *filename, int xfered, int total)
fname = strdup(filename);
/* strip extension if it's there
* 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';
}
if(strlen(fname) > FILENAME_TRIM_LEN) {
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 58e85b22..e3656830 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -159,6 +159,7 @@ 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"));
}
}
@@ -302,6 +303,7 @@ 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;
@@ -360,6 +362,9 @@ static int parseargs(int argc, char *argv[])
}
alpm_option_set_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);
@@ -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->flags & PM_TRANS_FLAG_PRINTURIS))
|| (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: ignore root user check if -r is specified, fall back on
* normal FS checking */
@@ -535,7 +540,7 @@ int main(int argc, char *argv[])
alpm_option_set_logcb(cb_log);
if(config->configfile == NULL) {
- config->configfile = strdup(PM_ROOT PM_CONF);
+ config->configfile = strdup(CONFFILE);
}
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);
if(config->verbose > 0) {
- 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);
+ printf("Root : %s\n", alpm_option_get_root());
+ printf("Conf File : %s\n", config->configfile);
+ printf("Lock File : %s\n", alpm_option_get_lockfile());
+ 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 */
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 57850e8f..a4a42075 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -311,8 +311,9 @@ int pacman_query(alpm_list_t *targets)
}
if(config->op_q_changelog) {
char changelog[PATH_MAX];
- snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
- alpm_option_get_root(), alpm_option_get_dbpath(),
+ /* TODO should be done in the backend- no raw DB stuff up front */
+ snprintf(changelog, PATH_MAX, "%s/%s/%s-%s/changelog",
+ alpm_option_get_dbpath(),
alpm_db_get_name(db_local),
alpm_pkg_get_name(info),
alpm_pkg_get_version(info));
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index e4f34886..9cdfb0d8 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -86,8 +86,7 @@ int pacman_remove(alpm_list_t *targets)
alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
printf(_(" if you're sure a package manager is not already\n"
- " running, you can remove %s%s.\n"),
- alpm_option_get_root(), PM_LOCK);
+ " running, you can remove %s.\n"), LOCKFILE);
}
FREELIST(finaltargs);
return(1);
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index f013d45f..d04c7da9 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -61,7 +61,7 @@ static int split_pkgname(char *target, char *name, char *version)
}
strncpy(tmp, p, 512);
/* trim file extension (if any) */
- if((p = strstr(tmp, PM_EXT_PKG))) {
+ if((p = strstr(tmp, PKGEXT))) {
*p = '\0';
}
/* trim architecture */
@@ -89,13 +89,7 @@ static int split_pkgname(char *target, char *name, char *version)
static int sync_cleancache(int level)
{
- const char *root, *cachedir;
- char dirpath[PATH_MAX];
-
- root = alpm_option_get_root();
- cachedir = alpm_option_get_cachedir();
-
- snprintf(dirpath, PATH_MAX, "%s%s", root, cachedir);
+ const char *cachedir = alpm_option_get_cachedir();
if(level == 1) {
/* 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] ")))
return(0);
printf(_("removing old packages from cache... "));
- dir = opendir(dirpath);
+ dir = opendir(cachedir);
if(dir == NULL) {
fprintf(stderr, _("error: could not access cache directory\n"));
return(1);
@@ -124,12 +118,12 @@ static int sync_cleancache(int level)
char *str = alpm_list_getdata(i);
char name[256], version[64];
- if(strstr(str, PM_EXT_PKG) == NULL) {
+ if(strstr(str, PKGEXT) == NULL) {
clean = alpm_list_add(clean, strdup(str));
continue;
}
/* we keep partially downloaded files */
- if(strstr(str, PM_EXT_PKG ".part")) {
+ if(strstr(str, PKGEXT ".part")) {
continue;
}
if(split_pkgname(str, name, version) != 0) {
@@ -140,10 +134,10 @@ static int sync_cleancache(int level)
char *s = alpm_list_getdata(j);
char n[256], v[64];
- if(strstr(s, PM_EXT_PKG) == NULL) {
+ if(strstr(s, PKGEXT) == NULL) {
continue;
}
- if(strstr(s, PM_EXT_PKG ".part")) {
+ if(strstr(s, PKGEXT ".part")) {
continue;
}
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)) {
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);
}
FREELIST(clean);
@@ -173,12 +167,12 @@ static int sync_cleancache(int level)
return(0);
printf(_("removing all packages from cache... "));
- if(rmrf(dirpath)) {
+ if(rmrf(cachedir)) {
fprintf(stderr, _("error: could not remove cache directory\n"));
return(1);
}
- if(makepath(dirpath)) {
+ if(makepath(cachedir)) {
fprintf(stderr, _("error: could not create new cache directory\n"));
return(1);
}
@@ -492,8 +486,7 @@ int pacman_sync(alpm_list_t *targets)
alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
printf(_(" if you're sure a package manager is not already\n"
- " running, you can remove %s%s.\n"),
- alpm_option_get_root(), PM_LOCK);
+ " running, you can remove %s.\n"), LOCKFILE);
}
return(1);
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index f38be60c..e48ea10f 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -80,7 +80,7 @@ int getcols()
}
/* does the same thing as 'mkdir -p' */
-int makepath(char *path)
+int makepath(const char *path)
{
char *orig, *str, *ptr;
char full[PATH_MAX+1] = "";
@@ -112,7 +112,7 @@ int makepath(char *path)
}
/* does the same thing as 'rm -rf' */
-int rmrf(char *path)
+int rmrf(const char *path)
{
int errflag = 0;
struct dirent *dp;
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 45c8b07d..755b30e1 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -38,8 +38,8 @@
#endif
int getcols();
-int makepath(char *path);
-int rmrf(char *path);
+int makepath(const char *path);
+int rmrf(const char *path);
void indentprint(const char *str, int indent);
char *strtoupper(char *str);
char *strtrim(char *str);