mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 17:31:52 -05:00
Moved downloaded db unpacking to the backend files, to easier allow conversion
from db to whatever format we need.
This commit is contained in:
parent
ea9e9ae22e
commit
e8275fa964
@ -364,7 +364,7 @@ int alpm_db_update(int force, PM_DB *db)
|
|||||||
_alpm_log(PM_LOG_ERROR, _("could not remove database entry %s/%s"), db->treename,
|
_alpm_log(PM_LOG_ERROR, _("could not remove database entry %s/%s"), db->treename,
|
||||||
((pmpkg_t *)lp->data)->name);
|
((pmpkg_t *)lp->data)->name);
|
||||||
}
|
}
|
||||||
RET_ERR(PM_ERR_DB_REMOVE, 1);
|
RET_ERR(PM_ERR_DB_REMOVE, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,20 +372,9 @@ int alpm_db_update(int force, PM_DB *db)
|
|||||||
_alpm_db_free_pkgcache(db);
|
_alpm_db_free_pkgcache(db);
|
||||||
|
|
||||||
/* uncompress the sync database */
|
/* uncompress the sync database */
|
||||||
/* ORE
|
if(_alpm_db_install(db, path) == -1) {
|
||||||
we should not simply unpack the archive, but better parse it and
|
return -1;
|
||||||
db_write each entry (see sync_load_dbarchive to get archive content) */
|
|
||||||
_alpm_log(PM_LOG_FLOW2, _("unpacking %s"), path);
|
|
||||||
if(_alpm_unpack(path, db->path, NULL)) {
|
|
||||||
RET_ERR(PM_ERR_SYSTEM, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove the .tar.gz */
|
|
||||||
/* aaron: let's not do this... we'll keep the DB around to be read for the
|
|
||||||
* "new and improved" db routines
|
|
||||||
|
|
||||||
unlink(path);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -44,15 +44,33 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "handle.h"
|
#include "handle.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* This function is used to convert the downloaded db file to the proper backend
|
||||||
|
* format
|
||||||
|
*/
|
||||||
|
int _alpm_db_install(pmdb_t *db, const char *dbfile)
|
||||||
|
{
|
||||||
|
/* ORE
|
||||||
|
we should not simply unpack the archive, but better parse it and
|
||||||
|
db_write each entry (see sync_load_dbarchive to get archive content) */
|
||||||
|
_alpm_log(PM_LOG_FLOW2, _("unpacking database '%s'"), dbfile);
|
||||||
|
|
||||||
|
if(_alpm_unpack(dbfile, db->path, NULL)) {
|
||||||
|
RET_ERR(PM_ERR_SYSTEM, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return unlink(dbfile);
|
||||||
|
}
|
||||||
|
|
||||||
int _alpm_db_open(pmdb_t *db)
|
int _alpm_db_open(pmdb_t *db)
|
||||||
{
|
{
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
return(-1);
|
RET_ERR(PM_ERR_DB_NULL, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
db->handle = opendir(db->path);
|
db->handle = opendir(db->path);
|
||||||
if(db->handle == NULL) {
|
if(db->handle == NULL) {
|
||||||
return(-1);
|
RET_ERR(PM_ERR_DB_OPEN, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
@ -90,7 +108,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
|
|||||||
pmpkg_t *pkg;
|
pmpkg_t *pkg;
|
||||||
|
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
return(NULL);
|
RET_ERR(PM_ERR_DB_NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target != NULL) {
|
if(target != NULL) {
|
||||||
@ -166,7 +184,12 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
|
|||||||
pmlist_t *tmplist;
|
pmlist_t *tmplist;
|
||||||
char *foo;
|
char *foo;
|
||||||
|
|
||||||
if(db == NULL || info == NULL || info->name[0] == 0 || info->version[0] == 0) {
|
if(db == NULL) {
|
||||||
|
RET_ERR(PM_ERR_DB_NULL, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info == NULL || info->name[0] == 0 || info->version[0] == 0) {
|
||||||
|
_alpm_log(PM_LOG_ERROR, _("invalid package entry provided to _alpm_db_read"));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,38 +629,13 @@ cleanup:
|
|||||||
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info)
|
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
int local = 0;
|
|
||||||
|
|
||||||
if(db == NULL || info == NULL) {
|
if(db == NULL || info == NULL) {
|
||||||
return(-1);
|
RET_ERR(PM_ERR_DB_NULL, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(db->treename, "local") == 0) {
|
snprintf(path, PATH_MAX, "%s/%s-%s", db->path, info->name, info->version);
|
||||||
local = 1;
|
if(_alpm_rmrf(path) == -1) {
|
||||||
}
|
|
||||||
|
|
||||||
/* DESC */
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s-%s/desc", db->path, info->name, info->version);
|
|
||||||
unlink(path);
|
|
||||||
/* DEPENDS */
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s-%s/depends", db->path, info->name, info->version);
|
|
||||||
unlink(path);
|
|
||||||
if(local) {
|
|
||||||
/* FILES */
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s-%s/files", db->path, info->name, info->version);
|
|
||||||
unlink(path);
|
|
||||||
/* INSTALL */
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s-%s/install", db->path, info->name, info->version);
|
|
||||||
unlink(path);
|
|
||||||
/* CHANGELOG */
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s-%s/changelog", db->path, info->name, info->version);
|
|
||||||
unlink(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Package directory */
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s-%s",
|
|
||||||
db->path, info->name, info->version);
|
|
||||||
if(rmdir(path) == -1) {
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,9 @@ pmdb_t *_alpm_db_new(char *root, char *dbpath, char *treename);
|
|||||||
void _alpm_db_free(void *data);
|
void _alpm_db_free(void *data);
|
||||||
int _alpm_db_cmp(const void *db1, const void *db2);
|
int _alpm_db_cmp(const void *db1, const void *db2);
|
||||||
pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles);
|
pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles);
|
||||||
|
|
||||||
/* Prototypes for backends functions */
|
/* Prototypes for backends functions */
|
||||||
|
int _alpm_db_install(pmdb_t *db, const char *dbfile);
|
||||||
int _alpm_db_open(pmdb_t *db);
|
int _alpm_db_open(pmdb_t *db);
|
||||||
void _alpm_db_close(pmdb_t *db);
|
void _alpm_db_close(pmdb_t *db);
|
||||||
void _alpm_db_rewind(pmdb_t *db);
|
void _alpm_db_rewind(pmdb_t *db);
|
||||||
|
@ -259,7 +259,7 @@ int _alpm_lckrm(char *file)
|
|||||||
/* Compression functions
|
/* Compression functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int _alpm_unpack(char *archive, const char *prefix, const char *fn)
|
int _alpm_unpack(const char *archive, const char *prefix, const char *fn)
|
||||||
{
|
{
|
||||||
register struct archive *_archive;
|
register struct archive *_archive;
|
||||||
struct archive_entry *entry;
|
struct archive_entry *entry;
|
||||||
|
@ -60,7 +60,7 @@ char *_alpm_strtoupper(char *str);
|
|||||||
char *_alpm_strtrim(char *str);
|
char *_alpm_strtrim(char *str);
|
||||||
int _alpm_lckmk(char *file);
|
int _alpm_lckmk(char *file);
|
||||||
int _alpm_lckrm(char *file);
|
int _alpm_lckrm(char *file);
|
||||||
int _alpm_unpack(char *archive, const char *prefix, const char *fn);
|
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
|
||||||
int _alpm_rmrf(char *path);
|
int _alpm_rmrf(char *path);
|
||||||
int _alpm_logaction(unsigned char usesyslog, FILE *f, char *fmt, ...);
|
int _alpm_logaction(unsigned char usesyslog, FILE *f, char *fmt, ...);
|
||||||
int _alpm_ldconfig(char *root);
|
int _alpm_ldconfig(char *root);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user