mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Restrict visibility of checkdbdir and get_pkgpath
These functions are only needed by be_local and were only promoted to db.{h,c} as part of the splitting of handling the local and sync dbs. Move them into be_local.c and make them static again. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
5717c7d508
commit
448f78c067
@ -322,6 +322,25 @@ static struct pkg_operations local_pkg_ops = {
|
||||
.changelog_close = _cache_changelog_close,
|
||||
};
|
||||
|
||||
static int checkdbdir(pmdb_t *db)
|
||||
{
|
||||
struct stat buf;
|
||||
const char *path = _alpm_db_path(db);
|
||||
|
||||
if(stat(path, &buf) != 0) {
|
||||
_alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n",
|
||||
path);
|
||||
if(_alpm_makepath(path) != 0) {
|
||||
RET_ERR(PM_ERR_SYSTEM, -1);
|
||||
}
|
||||
} else if(!S_ISDIR(buf.st_mode)) {
|
||||
_alpm_log(PM_LOG_WARNING, _("removing invalid database: %s\n"), path);
|
||||
if(unlink(path) != 0 || _alpm_makepath(path) != 0) {
|
||||
RET_ERR(PM_ERR_SYSTEM, -1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int is_dir(const char *path, struct dirent *entry)
|
||||
{
|
||||
@ -411,6 +430,21 @@ int _alpm_local_db_populate(pmdb_t *db)
|
||||
return(count);
|
||||
}
|
||||
|
||||
/* Note: the return value must be freed by the caller */
|
||||
static char *get_pkgpath(pmdb_t *db, pmpkg_t *info)
|
||||
{
|
||||
size_t len;
|
||||
char *pkgpath;
|
||||
const char *dbpath;
|
||||
|
||||
dbpath = _alpm_db_path(db);
|
||||
len = strlen(dbpath) + strlen(info->name) + strlen(info->version) + 3;
|
||||
MALLOC(pkgpath, len, RET_ERR(PM_ERR_MEMORY, NULL));
|
||||
sprintf(pkgpath, "%s%s-%s/", dbpath, info->name, info->version);
|
||||
return(pkgpath);
|
||||
}
|
||||
|
||||
|
||||
int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
@ -796,41 +796,4 @@ int splitname(const char *target, pmpkg_t *pkg)
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: move these two functions to be_local once be_sync no longer uses them */
|
||||
|
||||
int checkdbdir(pmdb_t *db)
|
||||
{
|
||||
struct stat buf;
|
||||
const char *path = _alpm_db_path(db);
|
||||
|
||||
if(stat(path, &buf) != 0) {
|
||||
_alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n",
|
||||
path);
|
||||
if(_alpm_makepath(path) != 0) {
|
||||
RET_ERR(PM_ERR_SYSTEM, -1);
|
||||
}
|
||||
} else if(!S_ISDIR(buf.st_mode)) {
|
||||
_alpm_log(PM_LOG_WARNING, _("removing invalid database: %s\n"), path);
|
||||
if(unlink(path) != 0 || _alpm_makepath(path) != 0) {
|
||||
RET_ERR(PM_ERR_SYSTEM, -1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Note: the return value must be freed by the caller */
|
||||
char *get_pkgpath(pmdb_t *db, pmpkg_t *info)
|
||||
{
|
||||
size_t len;
|
||||
char *pkgpath;
|
||||
const char *dbpath;
|
||||
|
||||
dbpath = _alpm_db_path(db);
|
||||
len = strlen(dbpath) + strlen(info->name) + strlen(info->version) + 3;
|
||||
MALLOC(pkgpath, len, RET_ERR(PM_ERR_MEMORY, NULL));
|
||||
sprintf(pkgpath, "%s%s-%s/", dbpath, info->name, info->version);
|
||||
return(pkgpath);
|
||||
}
|
||||
|
||||
/* vim: set ts=2 sw=2 noet: */
|
||||
|
@ -101,8 +101,6 @@ alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db);
|
||||
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target);
|
||||
|
||||
int splitname(const char *target, pmpkg_t *pkg);
|
||||
int checkdbdir(pmdb_t *db);
|
||||
char *get_pkgpath(pmdb_t *db, pmpkg_t *info);
|
||||
|
||||
#endif /* _ALPM_DB_H */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user