summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_local.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-28 11:43:23 +0200
committerDan McGee <dan@archlinux.org>2011-09-30 17:55:58 +0200
commit39b0ac43fcbe35897f616a8e202ae9f3bcb1ee5c (patch)
treee390376bfdc7818a7f5a21a3797be2cc951d7de8 /lib/libalpm/be_local.c
parent73139ccb3c47ed1ebb1a62a27deb080b66d92bf4 (diff)
downloadpacman-39b0ac43fcbe35897f616a8e202ae9f3bcb1ee5c.tar.gz
pacman-39b0ac43fcbe35897f616a8e202ae9f3bcb1ee5c.tar.xz
Revamp scriptlet path formation for scriptlets in local database
Expose the current static get_pkgpath() function internally to the rest of the library as _alpm_local_db_pkgpath(). This allows use of this convenience function in add.c and remove.c when forming the path to the scriptlet location. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_local.c')
-rw-r--r--lib/libalpm/be_local.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 109aaaf2..88ecec0c 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -475,7 +475,7 @@ static int local_db_populate(alpm_db_t *db)
}
/* Note: the return value must be freed by the caller */
-static char *get_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename)
+char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename)
{
size_t len;
char *pkgpath;
@@ -544,7 +544,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n",
info->name, inforeq);
- pkgpath = get_pkgpath(db, info, NULL);
+ pkgpath = _alpm_local_db_pkgpath(db, info, NULL);
if(!pkgpath || access(pkgpath, F_OK)) {
/* directory doesn't exist or can't be opened */
_alpm_log(db->handle, ALPM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n",
@@ -558,7 +558,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
/* DESC */
if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) {
- char *path = get_pkgpath(db, info, "desc");
+ char *path = _alpm_local_db_pkgpath(db, info, "desc");
if(!path || (fp = fopen(path, "r")) == NULL) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
free(path);
@@ -628,7 +628,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
/* FILES */
if(inforeq & INFRQ_FILES && !(info->infolevel & INFRQ_FILES)) {
- char *path = get_pkgpath(db, info, "files");
+ char *path = _alpm_local_db_pkgpath(db, info, "files");
if(!path || (fp = fopen(path, "r")) == NULL) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
free(path);
@@ -685,7 +685,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
/* INSTALL */
if(inforeq & INFRQ_SCRIPTLET && !(info->infolevel & INFRQ_SCRIPTLET)) {
- char *path = get_pkgpath(db, info, "install");
+ char *path = _alpm_local_db_pkgpath(db, info, "install");
if(access(path, F_OK) == 0) {
info->scriptlet = 1;
}
@@ -714,7 +714,7 @@ int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info)
}
oldmask = umask(0000);
- pkgpath = get_pkgpath(db, info, NULL);
+ pkgpath = _alpm_local_db_pkgpath(db, info, NULL);
if((retval = mkdir(pkgpath, 0755)) != 0) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not create directory %s: %s\n"),
@@ -746,7 +746,7 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
char *path;
_alpm_log(db->handle, ALPM_LOG_DEBUG, "writing %s-%s DESC information back to db\n",
info->name, info->version);
- path = get_pkgpath(db, info, "desc");
+ path = _alpm_local_db_pkgpath(db, info, "desc");
if(!path || (fp = fopen(path, "w")) == NULL) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"),
path, strerror(errno));
@@ -857,7 +857,7 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
char *path;
_alpm_log(db->handle, ALPM_LOG_DEBUG, "writing %s-%s FILES information back to db\n",
info->name, info->version);
- path = get_pkgpath(db, info, "files");
+ path = _alpm_local_db_pkgpath(db, info, "files");
if(!path || (fp = fopen(path, "w")) == NULL) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"),
path, strerror(errno));
@@ -903,8 +903,9 @@ cleanup:
int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info)
{
int ret = 0;
- char *pkgpath = get_pkgpath(db, info, NULL);
+ char *pkgpath = _alpm_local_db_pkgpath(db, info, NULL);
+ /* TODO explicit file removes and then an rmdir? */
ret = _alpm_rmrf(pkgpath);
free(pkgpath);
if(ret != 0) {