mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-01 01:41:52 -05:00
Numerous changes:
* Furthered the "lazy caching" to force the pkgcache to read nothing (INFRQ_NONE) by default. Anything requiring package data should now check the infolevel of each package and attempt to update it. This could be ironed out a bit more later (by using the front-end get_info function * Switched to libfetch. Drastic changes to the download code and the callback progress bar functions. Also fixed the return value of _alpm_downloadfiles_forreal. Downloading now supports http, ftp, https, and files urls, along with 'mtime's and numerous other fancy features from libfetch.
This commit is contained in:
parent
78c0badc9b
commit
af2fb3324a
@ -1,7 +1,6 @@
|
|||||||
AUTOMAKE_OPTIONS = gnu
|
AUTOMAKE_OPTIONS = gnu
|
||||||
DEFINES = -pedantic -D_GNU_SOURCE
|
DEFINES = -pedantic -D_GNU_SOURCE
|
||||||
AM_CFLAGS = $(DEFINES) \
|
AM_CFLAGS = $(DEFINES) -I$(top_srcdir)/lib/libfetch
|
||||||
-I$(top_srcdir)/lib/libftp
|
|
||||||
SUBDIRS = po
|
SUBDIRS = po
|
||||||
|
|
||||||
localedir = $(datadir)/locale
|
localedir = $(datadir)/locale
|
||||||
@ -38,8 +37,8 @@ include_HEADERS = alpm.h
|
|||||||
|
|
||||||
libalpm_la_SOURCES = $(TARGETS)
|
libalpm_la_SOURCES = $(TARGETS)
|
||||||
|
|
||||||
libalpm_la_LDFLAGS = -no-undefined -version-info $(PM_VERSION_INFO)
|
libalpm_la_LDFLAGS = -no-undefined -version-info $(PM_VERSION_INFO) -L$(top_srcdir)/lib/libfetch
|
||||||
libalpm_la_LIBADD = $(top_srcdir)/lib/libftp/libftp.la
|
libalpm_la_LIBADD = -lfetch
|
||||||
|
|
||||||
if HAS_DOXYGEN
|
if HAS_DOXYGEN
|
||||||
all: doxygen.in
|
all: doxygen.in
|
||||||
|
@ -306,7 +306,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
|
|||||||
int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
||||||
{
|
{
|
||||||
int i, ret = 0, errors = 0, needdisp = 0;
|
int i, ret = 0, errors = 0, needdisp = 0;
|
||||||
double percent;
|
double percent = 0.0;
|
||||||
register struct archive *archive;
|
register struct archive *archive;
|
||||||
struct archive_entry *entry;
|
struct archive_entry *entry;
|
||||||
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
|
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
|
||||||
@ -360,7 +360,6 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
|||||||
|
|
||||||
/* copy over the install reason */
|
/* copy over the install reason */
|
||||||
if(!(local->infolevel & INFRQ_DESC)) {
|
if(!(local->infolevel & INFRQ_DESC)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, _("loading DESC info for '%s'"), local->name);
|
|
||||||
_alpm_db_read(db, INFRQ_DESC, local);
|
_alpm_db_read(db, INFRQ_DESC, local);
|
||||||
}
|
}
|
||||||
info->reason = local->reason;
|
info->reason = local->reason;
|
||||||
@ -732,7 +731,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
|||||||
|
|
||||||
/* Update the requiredby field by scanning the whole database
|
/* Update the requiredby field by scanning the whole database
|
||||||
* looking for packages depending on the package to add */
|
* looking for packages depending on the package to add */
|
||||||
for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) {
|
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); lp; lp = lp->next) {
|
||||||
pmpkg_t *tmpp = lp->data;
|
pmpkg_t *tmpp = lp->data;
|
||||||
pmlist_t *tmppm = NULL;
|
pmlist_t *tmppm = NULL;
|
||||||
if(tmpp == NULL) {
|
if(tmpp == NULL) {
|
||||||
|
@ -197,8 +197,8 @@ int alpm_db_unregister(pmdb_t *db)
|
|||||||
handle->db_local = NULL;
|
handle->db_local = NULL;
|
||||||
found = 1;
|
found = 1;
|
||||||
} else {
|
} else {
|
||||||
pmdb_t *data;
|
void *data;
|
||||||
handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, db, _alpm_db_cmp, (void **)&data);
|
handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, db, _alpm_db_cmp, &data);
|
||||||
if(data) {
|
if(data) {
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
@ -240,12 +240,8 @@ void *alpm_db_getinfo(PM_DB *db, unsigned char parm)
|
|||||||
case PM_DB_TREENAME: data = db->treename; break;
|
case PM_DB_TREENAME: data = db->treename; break;
|
||||||
case PM_DB_FIRSTSERVER:
|
case PM_DB_FIRSTSERVER:
|
||||||
server = (pmserver_t*)db->servers->data;
|
server = (pmserver_t*)db->servers->data;
|
||||||
if(!strcmp(server->protocol, "file")) {
|
snprintf(path, PATH_MAX, "%s://%s%s", server->s_url->scheme,
|
||||||
snprintf(path, PATH_MAX, "%s://%s", server->protocol, server->path);
|
server->s_url->host, server->s_url->doc);
|
||||||
} else {
|
|
||||||
snprintf(path, PATH_MAX, "%s://%s%s", server->protocol,
|
|
||||||
server->server, server->path);
|
|
||||||
}
|
|
||||||
data = strdup(path);
|
data = strdup(path);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -292,7 +288,7 @@ int alpm_db_setserver(pmdb_t *db, char *url)
|
|||||||
}
|
}
|
||||||
db->servers = _alpm_list_add(db->servers, server);
|
db->servers = _alpm_list_add(db->servers, server);
|
||||||
_alpm_log(PM_LOG_FLOW2, _("adding new server to database '%s': protocol '%s', server '%s', path '%s'"),
|
_alpm_log(PM_LOG_FLOW2, _("adding new server to database '%s': protocol '%s', server '%s', path '%s'"),
|
||||||
db->treename, server->protocol, server->server, server->path);
|
db->treename, server->s_url->scheme, server->s_url->host, server->s_url->doc);
|
||||||
} else {
|
} else {
|
||||||
FREELIST(db->servers);
|
FREELIST(db->servers);
|
||||||
_alpm_log(PM_LOG_FLOW2, _("serverlist flushed for '%s'"), db->treename);
|
_alpm_log(PM_LOG_FLOW2, _("serverlist flushed for '%s'"), db->treename);
|
||||||
@ -343,12 +339,15 @@ int alpm_db_update(int force, PM_DB *db)
|
|||||||
|
|
||||||
ret = _alpm_downloadfiles_forreal(db->servers, path, files, lastupdate, newmtime);
|
ret = _alpm_downloadfiles_forreal(db->servers, path, files, lastupdate, newmtime);
|
||||||
FREELIST(files);
|
FREELIST(files);
|
||||||
if(ret != 0) {
|
if(ret == 1) {
|
||||||
if(ret > 0) {
|
/* mtimes match, do nothing */
|
||||||
_alpm_log(PM_LOG_DEBUG, _("failed to sync db: %s [%d]\n"), alpm_strerror(ret), ret);
|
pm_errno = 0;
|
||||||
pm_errno = PM_ERR_DB_SYNC;
|
return(1);
|
||||||
}
|
} else if(ret == -1) {
|
||||||
return(ret);
|
/* we use fetchLastErrString and fetchLastErrCode here, error returns from
|
||||||
|
* libfetch */
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("failed to sync db: %s [%d]\n"), fetchLastErrString, fetchLastErrCode);
|
||||||
|
RET_ERR(PM_ERR_DB_SYNC, -1);
|
||||||
} else {
|
} else {
|
||||||
if(strlen(newmtime)) {
|
if(strlen(newmtime)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s\n"), db->treename, newmtime);
|
_alpm_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s\n"), db->treename, newmtime);
|
||||||
@ -358,7 +357,7 @@ int alpm_db_update(int force, PM_DB *db)
|
|||||||
|
|
||||||
/* remove the old dir */
|
/* remove the old dir */
|
||||||
_alpm_log(PM_LOG_FLOW2, _("flushing database %s/%s"), handle->dbpath, db->treename);
|
_alpm_log(PM_LOG_FLOW2, _("flushing database %s/%s"), handle->dbpath, db->treename);
|
||||||
for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) {
|
for(lp = _alpm_db_get_pkgcache(db, INFRQ_NONE); lp; lp = lp->next) {
|
||||||
if(_alpm_db_remove(db, lp->data) == -1) {
|
if(_alpm_db_remove(db, lp->data) == -1) {
|
||||||
if(lp->data) {
|
if(lp->data) {
|
||||||
_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,
|
||||||
@ -405,7 +404,7 @@ pmlist_t *alpm_db_getpkgcache(pmdb_t *db)
|
|||||||
ASSERT(handle != NULL, return(NULL));
|
ASSERT(handle != NULL, return(NULL));
|
||||||
ASSERT(db != NULL, return(NULL));
|
ASSERT(db != NULL, return(NULL));
|
||||||
|
|
||||||
return(_alpm_db_get_pkgcache(db));
|
return(_alpm_db_get_pkgcache(db, INFRQ_NONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the list of packages that a package provides
|
/** Get the list of packages that a package provides
|
||||||
@ -496,7 +495,6 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* Depends entry */
|
/* Depends entry */
|
||||||
/* not needed: the cache is loaded with DEPENDS by default
|
|
||||||
case PM_PKG_DEPENDS:
|
case PM_PKG_DEPENDS:
|
||||||
case PM_PKG_REQUIREDBY:
|
case PM_PKG_REQUIREDBY:
|
||||||
case PM_PKG_CONFLICTS:
|
case PM_PKG_CONFLICTS:
|
||||||
@ -506,7 +504,7 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
|
|||||||
_alpm_log(PM_LOG_DEBUG, "loading DEPENDS info for '%s'", pkg->name);
|
_alpm_log(PM_LOG_DEBUG, "loading DEPENDS info for '%s'", pkg->name);
|
||||||
_alpm_db_read(pkg->data, INFRQ_DEPENDS, pkg);
|
_alpm_db_read(pkg->data, INFRQ_DEPENDS, pkg);
|
||||||
}
|
}
|
||||||
break;*/
|
break;
|
||||||
/* Files entry */
|
/* Files entry */
|
||||||
case PM_PKG_FILES:
|
case PM_PKG_FILES:
|
||||||
case PM_PKG_BACKUP:
|
case PM_PKG_BACKUP:
|
||||||
@ -832,7 +830,7 @@ int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event
|
|||||||
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);
|
snprintf(path, PATH_MAX, "%s%s", handle->root, PM_LOCK);
|
||||||
handle->lckfd = _alpm_lckmk(path);
|
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);
|
||||||
@ -949,7 +947,7 @@ int 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);
|
snprintf(path, PATH_MAX, "%s%s", handle->root, PM_LOCK);
|
||||||
if(_alpm_lckrm(path)) {
|
if(_alpm_lckrm(path)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s"), path);
|
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s"), path);
|
||||||
alpm_logaction(_("warning: could not remove lock file %s"), path);
|
alpm_logaction(_("warning: could not remove lock file %s"), path);
|
||||||
@ -1373,7 +1371,6 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
|
|||||||
} else {
|
} else {
|
||||||
if(!strcmp(key, "SERVER")) {
|
if(!strcmp(key, "SERVER")) {
|
||||||
/* add to the list */
|
/* add to the list */
|
||||||
_alpm_log(PM_LOG_DEBUG, _("config: %s: server: %s\n"), section, ptr);
|
|
||||||
if(alpm_db_setserver(db, strdup(ptr)) != 0) {
|
if(alpm_db_setserver(db, strdup(ptr)) != 0) {
|
||||||
/* pm_errno is set by alpm_set_option */
|
/* pm_errno is set by alpm_set_option */
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -35,7 +35,7 @@ extern "C" {
|
|||||||
#define PM_ROOT "/"
|
#define PM_ROOT "/"
|
||||||
#define PM_DBPATH "var/lib/pacman"
|
#define PM_DBPATH "var/lib/pacman"
|
||||||
#define PM_CACHEDIR "var/cache/pacman/pkg"
|
#define PM_CACHEDIR "var/cache/pacman/pkg"
|
||||||
#define PM_LOCK "/tmp/pacman.lck"
|
#define PM_LOCK "tmp/pacman.lck"
|
||||||
|
|
||||||
|
|
||||||
#define PM_EXT_PKG ".pkg.tar.gz"
|
#define PM_EXT_PKG ".pkg.tar.gz"
|
||||||
@ -444,6 +444,7 @@ extern enum __pmerrno_t {
|
|||||||
PM_ERR_PKG_CANT_FRESH,
|
PM_ERR_PKG_CANT_FRESH,
|
||||||
PM_ERR_PKG_INVALID_NAME,
|
PM_ERR_PKG_INVALID_NAME,
|
||||||
PM_ERR_PKG_CORRUPTED,
|
PM_ERR_PKG_CORRUPTED,
|
||||||
|
PM_ERR_PKG_REPO_NOT_FOUND,
|
||||||
/* Groups */
|
/* Groups */
|
||||||
PM_ERR_GRP_NOT_FOUND,
|
PM_ERR_GRP_NOT_FOUND,
|
||||||
/* Dependencies */
|
/* Dependencies */
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
/* pacman */
|
/* pacman */
|
||||||
#include "backup.h"
|
#include "backup.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
/* Look for a filename in a pmpkg_t.backup list. If we find it,
|
/* Look for a filename in a pmpkg_t.backup list. If we find it,
|
||||||
* then we return the md5 or sha1 hash (parsed from the same line)
|
* then we return the md5 or sha1 hash (parsed from the same line)
|
||||||
@ -47,7 +48,7 @@ char *_alpm_needbackup(char *file, pmlist_t *backup)
|
|||||||
/* tab delimiter */
|
/* tab delimiter */
|
||||||
ptr = strchr(str, '\t');
|
ptr = strchr(str, '\t');
|
||||||
if(ptr == NULL) {
|
if(ptr == NULL) {
|
||||||
free(str);
|
FREE(str);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
@ -55,10 +56,10 @@ char *_alpm_needbackup(char *file, pmlist_t *backup)
|
|||||||
/* now str points to the filename and ptr points to the md5 or sha1 hash */
|
/* now str points to the filename and ptr points to the md5 or sha1 hash */
|
||||||
if(!strcmp(file, str)) {
|
if(!strcmp(file, str)) {
|
||||||
char *md5 = strdup(ptr);
|
char *md5 = strdup(ptr);
|
||||||
free(str);
|
FREE(str);
|
||||||
return(md5);
|
return(md5);
|
||||||
}
|
}
|
||||||
free(str);
|
FREE(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -196,6 +196,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
|
|||||||
snprintf(path, PATH_MAX, "%s/%s-%s", db->path, info->name, info->version);
|
snprintf(path, PATH_MAX, "%s/%s-%s", db->path, info->name, info->version);
|
||||||
if(stat(path, &buf)) {
|
if(stat(path, &buf)) {
|
||||||
/* directory doesn't exist or can't be opened */
|
/* directory doesn't exist or can't be opened */
|
||||||
|
_alpm_log(PM_LOG_ERROR, _("cannot find '%s-%s' in db '%s'"), info->name, info->version, db->treename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "alpm.h"
|
#include "alpm.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "error.h"
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
@ -40,11 +41,11 @@
|
|||||||
/* Returns a new package cache from db.
|
/* Returns a new package cache from db.
|
||||||
* It frees the cache if it already exists.
|
* It frees the cache if it already exists.
|
||||||
*/
|
*/
|
||||||
int _alpm_db_load_pkgcache(pmdb_t *db)
|
int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel)
|
||||||
{
|
{
|
||||||
pmpkg_t *info;
|
pmpkg_t *info;
|
||||||
/* The group cache needs INFRQ_DESC as well */
|
/* The group cache needs INFRQ_DESC as well */
|
||||||
unsigned char infolevel = INFRQ_DEPENDS | INFRQ_DESC;
|
/*unsigned char infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
|
||||||
|
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -82,19 +83,43 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db)
|
pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
|
||||||
{
|
{
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(db->pkgcache == NULL) {
|
if(db->pkgcache == NULL) {
|
||||||
_alpm_db_load_pkgcache(db);
|
_alpm_db_load_pkgcache(db, infolevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_alpm_db_ensure_pkgcache(db, infolevel);
|
||||||
|
|
||||||
return(db->pkgcache);
|
return(db->pkgcache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel)
|
||||||
|
{
|
||||||
|
int reloaded = 0;
|
||||||
|
/* for each pkg, check and reload if the requested
|
||||||
|
* info is not already cached
|
||||||
|
*/
|
||||||
|
|
||||||
|
pmlist_t *p;
|
||||||
|
for(p = db->pkgcache; p; p = p->next) {
|
||||||
|
pmpkg_t *pkg = (pmpkg_t *)p->data;
|
||||||
|
if(infolevel != INFRQ_NONE && !(pkg->infolevel & infolevel)) {
|
||||||
|
_alpm_db_read(db, infolevel, pkg);
|
||||||
|
reloaded = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(reloaded) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("package cache reloaded (infolevel=%#x) for repository '%s'"),
|
||||||
|
infolevel, db->treename);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
|
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
pmpkg_t *newpkg;
|
pmpkg_t *newpkg;
|
||||||
@ -117,13 +142,15 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
|
|||||||
|
|
||||||
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
|
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
|
void *vdata;
|
||||||
pmpkg_t *data;
|
pmpkg_t *data;
|
||||||
|
|
||||||
if(db == NULL || pkg == NULL) {
|
if(db == NULL || pkg == NULL) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
db->pkgcache = _alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, (void **)&data);
|
db->pkgcache = _alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, &vdata);
|
||||||
|
data = vdata;
|
||||||
if(data == NULL) {
|
if(data == NULL) {
|
||||||
/* package not found */
|
/* package not found */
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -143,7 +170,7 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target)
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(_alpm_pkg_isin(target, _alpm_db_get_pkgcache(db)));
|
return(_alpm_pkg_isin(target, _alpm_db_get_pkgcache(db, INFRQ_NONE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a new group cache from db.
|
/* Returns a new group cache from db.
|
||||||
@ -157,19 +184,15 @@ int _alpm_db_load_grpcache(pmdb_t *db)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(db->pkgcache == NULL) {
|
if(db->pkgcache == NULL) {
|
||||||
_alpm_db_load_pkgcache(db);
|
_alpm_db_load_pkgcache(db, INFRQ_DESC);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename);
|
_alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename);
|
||||||
|
|
||||||
for(lp = db->pkgcache; lp; lp = lp->next) {
|
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DESC); lp; lp = lp->next) {
|
||||||
pmlist_t *i;
|
pmlist_t *i;
|
||||||
pmpkg_t *pkg = lp->data;
|
pmpkg_t *pkg = lp->data;
|
||||||
|
|
||||||
if(!(pkg->infolevel & INFRQ_DESC)) {
|
|
||||||
_alpm_db_read(pkg->data, INFRQ_DESC, pkg);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = pkg->groups; i; i = i->next) {
|
for(i = pkg->groups; i; i = i->next) {
|
||||||
if(!_alpm_list_is_strin(i->data, db->grpcache)) {
|
if(!_alpm_list_is_strin(i->data, db->grpcache)) {
|
||||||
pmgrp_t *grp = _alpm_grp_new();
|
pmgrp_t *grp = _alpm_grp_new();
|
||||||
|
@ -27,11 +27,12 @@
|
|||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
/* packages */
|
/* packages */
|
||||||
int _alpm_db_load_pkgcache(pmdb_t *db);
|
int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel);
|
||||||
void _alpm_db_free_pkgcache(pmdb_t *db);
|
void _alpm_db_free_pkgcache(pmdb_t *db);
|
||||||
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
|
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
|
||||||
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
|
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
|
||||||
pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db);
|
pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
|
||||||
|
int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel);
|
||||||
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
|
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
|
||||||
/* groups */
|
/* groups */
|
||||||
int _alpm_db_load_grpcache(pmdb_t *db);
|
int _alpm_db_load_grpcache(pmdb_t *db);
|
||||||
|
@ -70,7 +70,7 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
|
|||||||
}
|
}
|
||||||
/* CHECK 1: check targets against database */
|
/* CHECK 1: check targets against database */
|
||||||
_alpm_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs db"), tp->name);
|
_alpm_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs db"), tp->name);
|
||||||
for(k = _alpm_db_get_pkgcache(db); k; k = k->next) {
|
for(k = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); k; k = k->next) {
|
||||||
pmpkg_t *dp = (pmpkg_t *)k->data;
|
pmpkg_t *dp = (pmpkg_t *)k->data;
|
||||||
if(!strcmp(dp->name, tp->name)) {
|
if(!strcmp(dp->name, tp->name)) {
|
||||||
/* a package cannot conflict with itself -- that's just not nice */
|
/* a package cannot conflict with itself -- that's just not nice */
|
||||||
@ -142,7 +142,7 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
|
|||||||
}
|
}
|
||||||
/* CHECK 3: check database against targets */
|
/* CHECK 3: check database against targets */
|
||||||
_alpm_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name);
|
_alpm_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name);
|
||||||
for(k = _alpm_db_get_pkgcache(db); k; k = k->next) {
|
for(k = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); k; k = k->next) {
|
||||||
pmlist_t *conflicts = NULL;
|
pmlist_t *conflicts = NULL;
|
||||||
int usenewconflicts = 0;
|
int usenewconflicts = 0;
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ void _alpm_db_free(void *data)
|
|||||||
pmdb_t *db = data;
|
pmdb_t *db = data;
|
||||||
|
|
||||||
FREELISTSERVERS(db->servers);
|
FREELISTSERVERS(db->servers);
|
||||||
free(db->path);
|
FREE(db->path);
|
||||||
free(db);
|
FREE(db);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles)
|
|||||||
targ = strdup(i->data);
|
targ = strdup(i->data);
|
||||||
_alpm_log(PM_LOG_DEBUG, "searching for target '%s'\n", targ);
|
_alpm_log(PM_LOG_DEBUG, "searching for target '%s'\n", targ);
|
||||||
|
|
||||||
for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
|
for(j = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS); j; j = j->next) {
|
||||||
pmpkg_t *pkg = j->data;
|
pmpkg_t *pkg = j->data;
|
||||||
char *haystack;
|
char *haystack;
|
||||||
int match = 0;
|
int match = 0;
|
||||||
|
@ -127,6 +127,8 @@ pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
|
|||||||
/* run thru targets, moving up packages as necessary */
|
/* run thru targets, moving up packages as necessary */
|
||||||
for(i = newtargs; i; i = i->next) {
|
for(i = newtargs; i; i = i->next) {
|
||||||
pmpkg_t *p = (pmpkg_t*)i->data;
|
pmpkg_t *p = (pmpkg_t*)i->data;
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "sorting %s", p->name);
|
||||||
|
_alpm_db_read(p->data, INFRQ_DEPENDS, p);
|
||||||
for(j = p->depends; j; j = j->next) {
|
for(j = p->depends; j; j = j->next) {
|
||||||
pmdepend_t dep;
|
pmdepend_t dep;
|
||||||
pmpkg_t *q = NULL;
|
pmpkg_t *q = NULL;
|
||||||
@ -208,6 +210,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
|
|||||||
if((oldpkg = _alpm_db_get_pkgfromcache(db, tp->name)) == NULL) {
|
if((oldpkg = _alpm_db_get_pkgfromcache(db, tp->name)) == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
_alpm_db_read(db, INFRQ_DEPENDS, oldpkg);
|
||||||
for(j = oldpkg->requiredby; j; j = j->next) {
|
for(j = oldpkg->requiredby; j; j = j->next) {
|
||||||
char *ver;
|
char *ver;
|
||||||
pmpkg_t *p;
|
pmpkg_t *p;
|
||||||
@ -220,6 +223,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
|
|||||||
/* this package is also in the upgrade list, so don't worry about it */
|
/* this package is also in the upgrade list, so don't worry about it */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
_alpm_db_read(db, INFRQ_DEPENDS, p);
|
||||||
for(k = p->depends; k && !found; k = k->next) {
|
for(k = p->depends; k && !found; k = k->next) {
|
||||||
/* find the dependency info in p->depends */
|
/* find the dependency info in p->depends */
|
||||||
_alpm_splitdep(k->data, &depend);
|
_alpm_splitdep(k->data, &depend);
|
||||||
@ -276,12 +280,19 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ensure package has depends data */
|
||||||
|
pmdb_t *pkgdb = tp->data;
|
||||||
|
_alpm_db_read(pkgdb, INFRQ_DEPENDS, tp);
|
||||||
|
if(!tp->depends) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("no dependencies for target '%s'"), tp->name);
|
||||||
|
}
|
||||||
|
|
||||||
for(j = tp->depends; j; j = j->next) {
|
for(j = tp->depends; j; j = j->next) {
|
||||||
/* split into name/version pairs */
|
/* split into name/version pairs */
|
||||||
_alpm_splitdep((char *)j->data, &depend);
|
_alpm_splitdep((char *)j->data, &depend);
|
||||||
found = 0;
|
found = 0;
|
||||||
/* check database for literal packages */
|
/* check database for literal packages */
|
||||||
for(k = _alpm_db_get_pkgcache(db); k && !found; k = k->next) {
|
for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS); k && !found; k = k->next) {
|
||||||
pmpkg_t *p = (pmpkg_t *)k->data;
|
pmpkg_t *p = (pmpkg_t *)k->data;
|
||||||
if(!strcmp(p->name, depend.name)) {
|
if(!strcmp(p->name, depend.name)) {
|
||||||
if(depend.mod == PM_DEP_MOD_ANY) {
|
if(depend.mod == PM_DEP_MOD_ANY) {
|
||||||
@ -493,7 +504,13 @@ pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(i = targs; i; i = i->next) {
|
for(i = targs; i; i = i->next) {
|
||||||
for(j = ((pmpkg_t *)i->data)->depends; j; j = j->next) {
|
pmpkg_t *pkg = i->data;
|
||||||
|
if(pkg) {
|
||||||
|
_alpm_db_read(db, INFRQ_DEPENDS, pkg);
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(j = pkg->depends; j; j = j->next) {
|
||||||
pmdepend_t depend;
|
pmdepend_t depend;
|
||||||
pmpkg_t *dep;
|
pmpkg_t *dep;
|
||||||
int needed = 0;
|
int needed = 0;
|
||||||
@ -569,6 +586,7 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("started resolving dependencies"));
|
||||||
targ = _alpm_list_add(NULL, syncpkg);
|
targ = _alpm_list_add(NULL, syncpkg);
|
||||||
deps = _alpm_checkdeps(trans, local, PM_TRANS_TYPE_ADD, targ);
|
deps = _alpm_checkdeps(trans, local, PM_TRANS_TYPE_ADD, targ);
|
||||||
FREELISTPTR(targ);
|
FREELISTPTR(targ);
|
||||||
@ -599,6 +617,7 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
|
|||||||
/* check literals */
|
/* check literals */
|
||||||
for(j = dbs_sync; !sync && j; j = j->next) {
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
||||||
sync = _alpm_db_get_pkgfromcache(j->data, miss->depend.name);
|
sync = _alpm_db_get_pkgfromcache(j->data, miss->depend.name);
|
||||||
|
_alpm_db_read(j->data, INFRQ_DEPENDS, sync);
|
||||||
}
|
}
|
||||||
/* check provides */
|
/* check provides */
|
||||||
for(j = dbs_sync; !sync && j; j = j->next) {
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
||||||
@ -670,6 +689,8 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
|
|||||||
_alpm_log(PM_LOG_DEBUG, _("dependency cycle detected: %s"), sync->name);
|
_alpm_log(PM_LOG_DEBUG, _("dependency cycle detected: %s"), sync->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("finished resolving dependencies"));
|
||||||
|
|
||||||
FREELIST(deps);
|
FREELIST(deps);
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ char *alpm_strerror(int err)
|
|||||||
return _("package name is not valid");
|
return _("package name is not valid");
|
||||||
case PM_ERR_PKG_CORRUPTED:
|
case PM_ERR_PKG_CORRUPTED:
|
||||||
return _("corrupted package");
|
return _("corrupted package");
|
||||||
|
case PM_ERR_PKG_REPO_NOT_FOUND:
|
||||||
|
return _("no such repository");
|
||||||
/* Groups */
|
/* Groups */
|
||||||
case PM_ERR_GRP_NOT_FOUND:
|
case PM_ERR_GRP_NOT_FOUND:
|
||||||
return _("group not found");
|
return _("group not found");
|
||||||
|
@ -57,7 +57,7 @@ void _alpm_grp_free(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FREELIST(grp->packages);
|
FREELIST(grp->packages);
|
||||||
free(grp);
|
FREE(grp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ftplib.h>
|
/////#include <ftplib.h>
|
||||||
/* pacman */
|
/* pacman */
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@ -113,7 +113,7 @@ int _alpm_handle_free(pmhandle_t *handle)
|
|||||||
FREELIST(handle->ignorepkg);
|
FREELIST(handle->ignorepkg);
|
||||||
FREELIST(handle->holdpkg);
|
FREELIST(handle->holdpkg);
|
||||||
FREELIST(handle->needles);
|
FREELIST(handle->needles);
|
||||||
free(handle);
|
FREE(handle);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -224,9 +224,9 @@ int _alpm_handle_set_option(pmhandle_t *handle, unsigned char val, unsigned long
|
|||||||
pm_logcb = (alpm_cb_log)data;
|
pm_logcb = (alpm_cb_log)data;
|
||||||
break;
|
break;
|
||||||
case PM_OPT_DLCB:
|
case PM_OPT_DLCB:
|
||||||
pm_dlcb = (FtpCallback)data;
|
pm_dlcb = (download_progress_cb)data;
|
||||||
break;
|
break;
|
||||||
case PM_OPT_DLFNM:
|
/* case PM_OPT_DLFNM:
|
||||||
pm_dlfnm = (char *)data;
|
pm_dlfnm = (char *)data;
|
||||||
break;
|
break;
|
||||||
case PM_OPT_DLOFFSET:
|
case PM_OPT_DLOFFSET:
|
||||||
@ -253,6 +253,7 @@ int _alpm_handle_set_option(pmhandle_t *handle, unsigned char val, unsigned long
|
|||||||
case PM_OPT_DLETA_S:
|
case PM_OPT_DLETA_S:
|
||||||
pm_dleta_s = (unsigned char *)data;
|
pm_dleta_s = (unsigned char *)data;
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
case PM_OPT_UPGRADEDELAY:
|
case PM_OPT_UPGRADEDELAY:
|
||||||
handle->upgradedelay = data;
|
handle->upgradedelay = data;
|
||||||
break;
|
break;
|
||||||
@ -331,6 +332,7 @@ int _alpm_handle_get_option(pmhandle_t *handle, unsigned char val, long *data)
|
|||||||
case PM_OPT_DLCB: *data = (long)pm_dlcb; break;
|
case PM_OPT_DLCB: *data = (long)pm_dlcb; break;
|
||||||
case PM_OPT_UPGRADEDELAY: *data = (long)handle->upgradedelay; break;
|
case PM_OPT_UPGRADEDELAY: *data = (long)handle->upgradedelay; break;
|
||||||
case PM_OPT_LOGMASK: *data = pm_logmask; break;
|
case PM_OPT_LOGMASK: *data = pm_logmask; break;
|
||||||
|
/*
|
||||||
case PM_OPT_DLFNM: *data = (long)pm_dlfnm; break;
|
case PM_OPT_DLFNM: *data = (long)pm_dlfnm; break;
|
||||||
case PM_OPT_DLOFFSET: *data = (long)pm_dloffset; break;
|
case PM_OPT_DLOFFSET: *data = (long)pm_dloffset; break;
|
||||||
case PM_OPT_DLT0: *data = (long)pm_dlt0; break;
|
case PM_OPT_DLT0: *data = (long)pm_dlt0; break;
|
||||||
@ -340,6 +342,7 @@ int _alpm_handle_get_option(pmhandle_t *handle, unsigned char val, long *data)
|
|||||||
case PM_OPT_DLETA_H: *data = (long)pm_dleta_h; break;
|
case PM_OPT_DLETA_H: *data = (long)pm_dleta_h; break;
|
||||||
case PM_OPT_DLETA_M: *data = (long)pm_dleta_m; break;
|
case PM_OPT_DLETA_M: *data = (long)pm_dleta_m; break;
|
||||||
case PM_OPT_DLETA_S: *data = (long)pm_dleta_s; break;
|
case PM_OPT_DLETA_S: *data = (long)pm_dleta_s; break;
|
||||||
|
*/
|
||||||
case PM_OPT_PROXYHOST: *data = (long)handle->proxyhost; break;
|
case PM_OPT_PROXYHOST: *data = (long)handle->proxyhost; break;
|
||||||
case PM_OPT_PROXYPORT: *data = handle->proxyport; break;
|
case PM_OPT_PROXYPORT: *data = handle->proxyport; break;
|
||||||
case PM_OPT_XFERCOMMAND: *data = (long)handle->xfercommand; break;
|
case PM_OPT_XFERCOMMAND: *data = (long)handle->xfercommand; break;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
/* pacman */
|
/* pacman */
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
pmlist_t *_alpm_list_new()
|
pmlist_t *_alpm_list_new()
|
||||||
{
|
{
|
||||||
@ -48,10 +49,10 @@ void _alpm_list_free(pmlist_t *list, _alpm_fn_free fn)
|
|||||||
|
|
||||||
while(it) {
|
while(it) {
|
||||||
ptr = it->next;
|
ptr = it->next;
|
||||||
if(fn) {
|
if(fn && it->data) {
|
||||||
fn(it->data);
|
fn(it->data);
|
||||||
}
|
}
|
||||||
free(it);
|
FREE(it);
|
||||||
it = ptr;
|
it = ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +181,7 @@ pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, v
|
|||||||
*data = i->data;
|
*data = i->data;
|
||||||
}
|
}
|
||||||
i->data = NULL;
|
i->data = NULL;
|
||||||
free(i);
|
FREE(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(haystack);
|
return(haystack);
|
||||||
|
@ -156,7 +156,7 @@ void _alpm_pkg_free(void *data)
|
|||||||
if(pkg->origin == PKG_FROM_FILE) {
|
if(pkg->origin == PKG_FROM_FILE) {
|
||||||
FREE(pkg->data);
|
FREE(pkg->data);
|
||||||
}
|
}
|
||||||
free(pkg);
|
FREE(pkg);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) {
|
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); lp; lp = lp->next) {
|
||||||
pmpkg_t *info = lp->data;
|
pmpkg_t *info = lp->data;
|
||||||
|
|
||||||
if(_alpm_list_is_strin(package, info->provides)) {
|
if(_alpm_list_is_strin(package, info->provides)) {
|
||||||
|
@ -192,7 +192,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
|
|||||||
/* iterate through the list backwards, unlinking files */
|
/* iterate through the list backwards, unlinking files */
|
||||||
for(lp = _alpm_list_last(info->files); lp; lp = lp->prev) {
|
for(lp = _alpm_list_last(info->files); lp; lp = lp->prev) {
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
double percent;
|
double percent = 0.0;
|
||||||
char *file = lp->data;
|
char *file = lp->data;
|
||||||
char *md5 =_alpm_needbackup(file, info->backup);
|
char *md5 =_alpm_needbackup(file, info->backup);
|
||||||
char *sha1 =_alpm_needbackup(file, info->backup);
|
char *sha1 =_alpm_needbackup(file, info->backup);
|
||||||
@ -294,6 +294,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
|
|||||||
for(lp = info->depends; lp; lp = lp->next) {
|
for(lp = info->depends; lp; lp = lp->next) {
|
||||||
pmpkg_t *depinfo = NULL;
|
pmpkg_t *depinfo = NULL;
|
||||||
pmdepend_t depend;
|
pmdepend_t depend;
|
||||||
|
void *vdata;
|
||||||
char *data;
|
char *data;
|
||||||
if(_alpm_splitdep((char*)lp->data, &depend)) {
|
if(_alpm_splitdep((char*)lp->data, &depend)) {
|
||||||
continue;
|
continue;
|
||||||
@ -324,7 +325,8 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* splice out this entry from requiredby */
|
/* splice out this entry from requiredby */
|
||||||
depinfo->requiredby = _alpm_list_remove(depinfo->requiredby, info->name, str_cmp, (void **)&data);
|
depinfo->requiredby = _alpm_list_remove(depinfo->requiredby, info->name, str_cmp, &vdata);
|
||||||
|
data = vdata;
|
||||||
FREE(data);
|
FREE(data);
|
||||||
_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), depinfo->name);
|
_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), depinfo->name);
|
||||||
if(_alpm_db_write(db, depinfo, INFRQ_DEPENDS)) {
|
if(_alpm_db_write(db, depinfo, INFRQ_DEPENDS)) {
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <ftplib.h>
|
|
||||||
|
|
||||||
/* pacman */
|
/* pacman */
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
@ -37,20 +36,14 @@
|
|||||||
#include "alpm.h"
|
#include "alpm.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "handle.h"
|
#include "handle.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
FtpCallback pm_dlcb = NULL;
|
download_progress_cb pm_dlcb = NULL;
|
||||||
/* progress bar */
|
|
||||||
char *pm_dlfnm=NULL;
|
|
||||||
int *pm_dloffset=NULL;
|
|
||||||
struct timeval *pm_dlt0=NULL, *pm_dlt=NULL;
|
|
||||||
float *pm_dlrate=NULL;
|
|
||||||
int *pm_dlxfered1=NULL;
|
|
||||||
unsigned char *pm_dleta_h=NULL, *pm_dleta_m=NULL, *pm_dleta_s=NULL;
|
|
||||||
|
|
||||||
pmserver_t *_alpm_server_new(char *url)
|
pmserver_t *_alpm_server_new(char *url)
|
||||||
{
|
{
|
||||||
|
struct url *u;
|
||||||
pmserver_t *server;
|
pmserver_t *server;
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
server = (pmserver_t *)malloc(sizeof(pmserver_t));
|
server = (pmserver_t *)malloc(sizeof(pmserver_t));
|
||||||
if(server == NULL) {
|
if(server == NULL) {
|
||||||
@ -59,56 +52,28 @@ pmserver_t *_alpm_server_new(char *url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(server, 0, sizeof(pmserver_t));
|
memset(server, 0, sizeof(pmserver_t));
|
||||||
|
u = fetchParseURL(url);
|
||||||
/* parse our special url */
|
if(!u) {
|
||||||
ptr = strstr(url, "://");
|
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid, ignoring"), url);
|
||||||
if(ptr == NULL) {
|
return(NULL);
|
||||||
RET_ERR(PM_ERR_SERVER_BAD_LOCATION, NULL);
|
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
if(strlen(u->scheme) == 0) {
|
||||||
ptr++; ptr++; ptr++;
|
_alpm_log(PM_LOG_WARNING, _("url scheme not specified, assuming http"));
|
||||||
if(ptr == NULL || *ptr == '\0') {
|
strcpy(u->scheme, "http");
|
||||||
RET_ERR(PM_ERR_SERVER_BAD_LOCATION, NULL);
|
|
||||||
}
|
|
||||||
server->protocol = strdup(url);
|
|
||||||
if(!strcmp(server->protocol, "ftp") || !strcmp(server->protocol, "http")) {
|
|
||||||
char *slash;
|
|
||||||
/* split the url into domain and path */
|
|
||||||
slash = strchr(ptr, '/');
|
|
||||||
if(slash == NULL) {
|
|
||||||
/* no path included, default to / */
|
|
||||||
server->path = strdup("/");
|
|
||||||
} else {
|
|
||||||
/* add a trailing slash if we need to */
|
|
||||||
if(slash[strlen(slash)-1] == '/') {
|
|
||||||
server->path = strdup(slash);
|
|
||||||
} else {
|
|
||||||
if((server->path = (char *)malloc(strlen(slash)+2)) == NULL) {
|
|
||||||
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(strlen(slash+2)));
|
|
||||||
RET_ERR(PM_ERR_MEMORY, NULL);
|
|
||||||
}
|
|
||||||
sprintf(server->path, "%s/", slash);
|
|
||||||
}
|
|
||||||
*slash = '\0';
|
|
||||||
}
|
|
||||||
server->server = strdup(ptr);
|
|
||||||
} else if(!strcmp(server->protocol, "file")){
|
|
||||||
/* add a trailing slash if we need to */
|
|
||||||
if(ptr[strlen(ptr)-1] == '/') {
|
|
||||||
server->path = strdup(ptr);
|
|
||||||
} else {
|
|
||||||
server->path = (char *)malloc(strlen(ptr)+2);
|
|
||||||
if(server->path == NULL) {
|
|
||||||
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(strlen(ptr+2)));
|
|
||||||
RET_ERR(PM_ERR_MEMORY, NULL);
|
|
||||||
}
|
|
||||||
sprintf(server->path, "%s/", ptr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
RET_ERR(PM_ERR_SERVER_PROTOCOL_UNSUPPORTED, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(server);
|
if(strcmp(u->scheme,"ftp") == 0 && strlen(u->user) == 0) {
|
||||||
|
strcpy(u->user, "anonymous");
|
||||||
|
strcpy(u->pwd, "libalpm@guest");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This isn't needed... we can actually kill the whole pmserver_t interface
|
||||||
|
* and replace it with libfetch's 'struct url'
|
||||||
|
*/
|
||||||
|
server->s_url = u;
|
||||||
|
server->path = strdup(u->doc);
|
||||||
|
|
||||||
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _alpm_server_free(void *data)
|
void _alpm_server_free(void *data)
|
||||||
@ -120,10 +85,9 @@ void _alpm_server_free(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* free memory */
|
/* free memory */
|
||||||
FREE(server->protocol);
|
|
||||||
FREE(server->server);
|
|
||||||
FREE(server->path);
|
FREE(server->path);
|
||||||
free(server);
|
fetchFreeURL(server->s_url);
|
||||||
|
FREE(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -134,7 +98,7 @@ void _alpm_server_free(void *data)
|
|||||||
*/
|
*/
|
||||||
int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files)
|
int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files)
|
||||||
{
|
{
|
||||||
return(!!_alpm_downloadfiles_forreal(servers, localpath, files, NULL, NULL));
|
return(_alpm_downloadfiles_forreal(servers, localpath, files, NULL, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -147,14 +111,13 @@ int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *file
|
|||||||
* of the remote file (from MDTM FTP cmd or Last-Modified HTTP header).
|
* of the remote file (from MDTM FTP cmd or Last-Modified HTTP header).
|
||||||
*
|
*
|
||||||
* RETURN: 0 for successful download
|
* RETURN: 0 for successful download
|
||||||
* -1 if the mtimes are identical
|
* 1 if the mtimes are identical
|
||||||
* 1 on error
|
* -1 on error
|
||||||
*/
|
*/
|
||||||
int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
|
int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
|
||||||
pmlist_t *files, const char *mtime1, char *mtime2)
|
pmlist_t *files, const char *mtime1, char *mtime2)
|
||||||
{
|
{
|
||||||
int fsz;
|
int dltotal_bytes = 0;
|
||||||
netbuf *control = NULL;
|
|
||||||
pmlist_t *lp;
|
pmlist_t *lp;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
pmlist_t *complete = NULL;
|
pmlist_t *complete = NULL;
|
||||||
@ -164,74 +127,122 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("server check, %d\n"),servers);
|
|
||||||
for(i = servers; i && !done; i = i->next) {
|
for(i = servers; i && !done; i = i->next) {
|
||||||
_alpm_log(PM_LOG_DEBUG, _("server check, done? %d\n"),done);
|
|
||||||
pmserver_t *server = (pmserver_t*)i->data;
|
pmserver_t *server = (pmserver_t*)i->data;
|
||||||
|
|
||||||
if(!handle->xfercommand && strcmp(server->protocol, "file")) {
|
|
||||||
if(!strcmp(server->protocol, "ftp") && !handle->proxyhost) {
|
|
||||||
FtpInit();
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("connecting to %s:21\n"), server->server);
|
|
||||||
if(!FtpConnect(server->server, &control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("cannot connect to %s\n"), server->server);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!FtpLogin("anonymous", "libalpm@guest", control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("anonymous login failed\n"));
|
|
||||||
FtpQuit(control);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!FtpChdir(server->path, control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("could not cwd to %s: %s\n"), server->path, FtpLastResponse(control));
|
|
||||||
FtpQuit(control);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!handle->nopassiveftp) {
|
|
||||||
if(!FtpOptions(FTPLIB_CONNMODE, FTPLIB_PASSIVE, control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to set passive mode\n"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("FTP passive mode not set\n"));
|
|
||||||
}
|
|
||||||
} else if(handle->proxyhost) {
|
|
||||||
char *host;
|
|
||||||
unsigned port;
|
|
||||||
host = (handle->proxyhost) ? handle->proxyhost : server->server;
|
|
||||||
port = (handle->proxyport) ? handle->proxyport : 80;
|
|
||||||
if(strchr(host, ':')) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("connecting to %s\n"), host);
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("connecting to %s:%u\n"), host, port);
|
|
||||||
}
|
|
||||||
if(!HttpConnect(host, port, &control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("cannot connect to %s\n"), host);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set up our progress bar's callback (and idle timeout) */
|
|
||||||
if(strcmp(server->protocol, "file") && control) {
|
|
||||||
if(pm_dlcb) {
|
|
||||||
FtpOptions(FTPLIB_CALLBACK, (long)pm_dlcb, control);
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("downloadfiles: progress bar's callback is not set\n"));
|
|
||||||
}
|
|
||||||
FtpOptions(FTPLIB_IDLETIME, (long)1000, control);
|
|
||||||
FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control);
|
|
||||||
FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get each file in the list */
|
/* get each file in the list */
|
||||||
for(lp = files; lp; lp = lp->next) {
|
for(lp = files; lp; lp = lp->next) {
|
||||||
|
char realfile[PATH_MAX];
|
||||||
|
char output[PATH_MAX];
|
||||||
char *fn = (char *)lp->data;
|
char *fn = (char *)lp->data;
|
||||||
|
|
||||||
|
snprintf(realfile, PATH_MAX, "%s/%s", localpath, fn);
|
||||||
|
snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
|
||||||
|
|
||||||
if(_alpm_list_is_strin(fn, complete)) {
|
if(_alpm_list_is_strin(fn, complete)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(handle->xfercommand && strcmp(server->protocol, "file")) {
|
if(!handle->xfercommand) {
|
||||||
|
FILE *dlf, *localf = NULL;
|
||||||
|
struct url_stat ust;
|
||||||
|
struct stat st;
|
||||||
|
int chk_resume = 0;
|
||||||
|
|
||||||
|
if(stat(output, &st) == 0 && st.st_size > 0) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("existing file found, using it\n"));
|
||||||
|
server->s_url->offset = (off_t)st.st_size;
|
||||||
|
dltotal_bytes = st.st_size;
|
||||||
|
localf = fopen(output, "a");
|
||||||
|
chk_resume = 1;
|
||||||
|
} else {
|
||||||
|
server->s_url->offset = (off_t)0;
|
||||||
|
dltotal_bytes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FREE(server->s_url->doc);
|
||||||
|
int len = strlen(server->path) + strlen(fn) + 2;
|
||||||
|
server->s_url->doc = (char *)malloc(len);
|
||||||
|
snprintf(server->s_url->doc, len, "%s/%s", server->path, fn);
|
||||||
|
|
||||||
|
/* libfetch does not reset the error code, reset it in the case of previous errors */
|
||||||
|
fetchLastErrCode = 0;
|
||||||
|
|
||||||
|
/* 10s timeout - TODO make a config option */
|
||||||
|
fetchTimeout = 10000;
|
||||||
|
|
||||||
|
/* Make libfetch super verbose... worthwhile for testing */
|
||||||
|
if(pm_logmask & PM_LOG_DEBUG) {
|
||||||
|
fetchDebug = 1;
|
||||||
|
dlf = fetchXGet(server->s_url, &ust, (handle->nopassiveftp ? "v" : "vp"));
|
||||||
|
} else {
|
||||||
|
dlf = fetchXGet(server->s_url, &ust, (handle->nopassiveftp ? "" : "p"));
|
||||||
|
}
|
||||||
|
if(fetchLastErrCode != 0 || dlf == NULL) {
|
||||||
|
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from '%s://%s%s', %d : %s\n"), fn,
|
||||||
|
server->s_url->scheme, server->s_url->host, server->s_url->doc, fetchLastErrCode,
|
||||||
|
fetchLastErrString);
|
||||||
|
if(localf != NULL) {
|
||||||
|
fclose(localf);
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
} else {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("server connection to %s complete"), server->s_url->host);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ust.mtime && mtime1) {
|
||||||
|
char strtime[15];
|
||||||
|
_alpm_time2string(ust.mtime, strtime);
|
||||||
|
if(strcmp(mtime1, strtime) == 0) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("mtimes are identical, skipping %s\n"), fn);
|
||||||
|
complete = _alpm_list_add(complete, fn);
|
||||||
|
if(localf != NULL) {
|
||||||
|
fclose(localf);
|
||||||
|
}
|
||||||
|
if(dlf != NULL) {
|
||||||
|
fclose(dlf);
|
||||||
|
}
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ust.mtime && mtime2) {
|
||||||
|
_alpm_time2string(ust.mtime, mtime2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chk_resume && server->s_url->offset == 0) {
|
||||||
|
_alpm_log(PM_LOG_WARNING, _("cannot resume download, starting over"));
|
||||||
|
if(localf != NULL) {
|
||||||
|
fclose(localf);
|
||||||
|
localf = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localf == NULL) {
|
||||||
|
_alpm_rmrf(output);
|
||||||
|
server->s_url->offset = (off_t)0;
|
||||||
|
dltotal_bytes = 0;
|
||||||
|
localf = fopen(output, "w");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Progress 0 - initialize */
|
||||||
|
if(pm_dlcb) pm_dlcb(fn, 0, ust.size);
|
||||||
|
|
||||||
|
int nread = 0;
|
||||||
|
char buffer[PM_DLBUF_LEN];
|
||||||
|
while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) {
|
||||||
|
int nwritten = 0;
|
||||||
|
while((nwritten += fwrite(buffer, 1, (nread - nwritten), localf)) < nread) ;
|
||||||
|
dltotal_bytes += nread;
|
||||||
|
|
||||||
|
if(pm_dlcb) pm_dlcb(fn, dltotal_bytes, ust.size);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(localf);
|
||||||
|
fclose(dlf);
|
||||||
|
rename(output, realfile);
|
||||||
|
complete = _alpm_list_add(complete, fn);
|
||||||
|
} else {
|
||||||
int ret;
|
int ret;
|
||||||
int usepart = 0;
|
int usepart = 0;
|
||||||
char *ptr1, *ptr2;
|
char *ptr1, *ptr2;
|
||||||
@ -240,8 +251,8 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
|
|||||||
char url[PATH_MAX];
|
char url[PATH_MAX];
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
/* build the full download url */
|
/* build the full download url */
|
||||||
snprintf(url, PATH_MAX, "%s://%s%s%s", server->protocol, server->server,
|
snprintf(url, PATH_MAX, "%s://%s%s/%s", server->s_url->scheme, server->s_url->host,
|
||||||
server->path, fn);
|
server->s_url->doc, fn);
|
||||||
/* replace all occurrences of %o with fn.part */
|
/* replace all occurrences of %o with fn.part */
|
||||||
strncpy(origCmd, handle->xfercommand, sizeof(origCmd));
|
strncpy(origCmd, handle->xfercommand, sizeof(origCmd));
|
||||||
ptr1 = origCmd;
|
ptr1 = origCmd;
|
||||||
@ -291,213 +302,6 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
chdir(cwd);
|
chdir(cwd);
|
||||||
} else {
|
|
||||||
char output[PATH_MAX];
|
|
||||||
unsigned int j;
|
|
||||||
int filedone = 0;
|
|
||||||
char *ptr;
|
|
||||||
struct stat st;
|
|
||||||
snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
|
|
||||||
if(pm_dlfnm) {
|
|
||||||
strncpy(pm_dlfnm, fn, PM_DLFNM_LEN);
|
|
||||||
}
|
|
||||||
/* drop filename extension */
|
|
||||||
ptr = strstr(fn, PM_EXT_DB);
|
|
||||||
if(pm_dlfnm && ptr && (ptr-fn) < PM_DLFNM_LEN) {
|
|
||||||
pm_dlfnm[ptr-fn] = '\0';
|
|
||||||
}
|
|
||||||
ptr = strstr(fn, PM_EXT_PKG);
|
|
||||||
if(ptr && (ptr-fn) < PM_DLFNM_LEN) {
|
|
||||||
pm_dlfnm[ptr-fn] = '\0';
|
|
||||||
}
|
|
||||||
if(pm_dlfnm) {
|
|
||||||
for(j = strlen(pm_dlfnm); j < PM_DLFNM_LEN; j++) {
|
|
||||||
(pm_dlfnm)[j] = ' ';
|
|
||||||
}
|
|
||||||
pm_dlfnm[PM_DLFNM_LEN] = '\0';
|
|
||||||
}
|
|
||||||
if(pm_dloffset) {
|
|
||||||
*pm_dloffset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ETA setup */
|
|
||||||
if(pm_dlt0 && pm_dlt && pm_dlrate && pm_dlxfered1 && pm_dleta_h && pm_dleta_m && pm_dleta_s) {
|
|
||||||
gettimeofday(pm_dlt0, NULL);
|
|
||||||
*pm_dlt = *pm_dlt0;
|
|
||||||
*pm_dlrate = 0;
|
|
||||||
*pm_dlxfered1 = 0;
|
|
||||||
*pm_dleta_h = 0;
|
|
||||||
*pm_dleta_m = 0;
|
|
||||||
*pm_dleta_s = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!strcmp(server->protocol, "ftp") && !handle->proxyhost) {
|
|
||||||
if(!FtpSize(fn, &fsz, FTPLIB_IMAGE, control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to get filesize for %s\n"), fn);
|
|
||||||
}
|
|
||||||
/* check mtimes */
|
|
||||||
if(mtime1) {
|
|
||||||
char fmtime[64];
|
|
||||||
if(!FtpModDate(fn, fmtime, sizeof(fmtime)-1, control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to get mtime for %s\n"), fn);
|
|
||||||
} else {
|
|
||||||
_alpm_strtrim(fmtime);
|
|
||||||
if(mtime1 && !strcmp(mtime1, fmtime)) {
|
|
||||||
/* mtimes are identical, skip this file */
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("mtimes are identical, skipping %s\n"), fn);
|
|
||||||
filedone = -1;
|
|
||||||
complete = _alpm_list_add(complete, fn);
|
|
||||||
} else {
|
|
||||||
if(mtime2) {
|
|
||||||
strncpy(mtime2, fmtime, 15); /* YYYYMMDDHHMMSS (=14b) */
|
|
||||||
mtime2[14] = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!filedone) {
|
|
||||||
if(!stat(output, &st)) {
|
|
||||||
*pm_dloffset = (int)st.st_size;
|
|
||||||
if(!FtpRestart(*pm_dloffset, control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to resume download -- restarting\n"));
|
|
||||||
/* can't resume: */
|
|
||||||
/* unlink the file in order to restart download from scratch */
|
|
||||||
unlink(output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!FtpGet(output, fn, FTPLIB_IMAGE, control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("\nfailed downloading %s from %s: %s\n"),
|
|
||||||
fn, server->server, FtpLastResponse(control));
|
|
||||||
/* we leave the partially downloaded file in place so it can be resumed later */
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("downloaded %s from %s\n"),
|
|
||||||
fn, server->server);
|
|
||||||
filedone = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(!strcmp(server->protocol, "http") || (handle->proxyhost && strcmp(server->protocol, "file"))) {
|
|
||||||
char src[PATH_MAX];
|
|
||||||
char *host;
|
|
||||||
unsigned port;
|
|
||||||
struct tm fmtime1;
|
|
||||||
struct tm fmtime2;
|
|
||||||
memset(&fmtime1, 0, sizeof(struct tm));
|
|
||||||
memset(&fmtime2, 0, sizeof(struct tm));
|
|
||||||
if(!strcmp(server->protocol, "http") && !handle->proxyhost) {
|
|
||||||
/* HTTP servers hang up after each request (but not proxies), so
|
|
||||||
* we have to re-connect for each file.
|
|
||||||
*/
|
|
||||||
host = (handle->proxyhost) ? handle->proxyhost : server->server;
|
|
||||||
port = (handle->proxyhost) ? handle->proxyport : 80;
|
|
||||||
if(strchr(host, ':')) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("connecting to %s\n"), host);
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("connecting to %s:%u\n"), host, port);
|
|
||||||
}
|
|
||||||
if(!HttpConnect(host, port, &control)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("cannot connect to %s\n"), host);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* set up our progress bar's callback (and idle timeout) */
|
|
||||||
if(strcmp(server->protocol, "file") && control) {
|
|
||||||
if(pm_dlcb) {
|
|
||||||
FtpOptions(FTPLIB_CALLBACK, (long)pm_dlcb, control);
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("downloadfiles: progress bar's callback is not set\n"));
|
|
||||||
}
|
|
||||||
FtpOptions(FTPLIB_IDLETIME, (long)1000, control);
|
|
||||||
FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control);
|
|
||||||
FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!stat(output, &st)) {
|
|
||||||
*pm_dloffset = (int)st.st_size;
|
|
||||||
}
|
|
||||||
if(!handle->proxyhost) {
|
|
||||||
snprintf(src, PATH_MAX, "%s%s", server->path, fn);
|
|
||||||
} else {
|
|
||||||
snprintf(src, PATH_MAX, "%s://%s%s%s", server->protocol, server->server, server->path, fn);
|
|
||||||
}
|
|
||||||
if(mtime1 && strlen(mtime1)) {
|
|
||||||
struct tm tmref;
|
|
||||||
time_t t, tref;
|
|
||||||
int diff;
|
|
||||||
/* date conversion from YYYYMMDDHHMMSS to "rfc1123-date" */
|
|
||||||
sscanf(mtime1, "%4d%2d%2d%2d%2d%2d",
|
|
||||||
&fmtime1.tm_year, &fmtime1.tm_mon, &fmtime1.tm_mday,
|
|
||||||
&fmtime1.tm_hour, &fmtime1.tm_min, &fmtime1.tm_sec);
|
|
||||||
fmtime1.tm_year -= 1900;
|
|
||||||
fmtime1.tm_mon--;
|
|
||||||
/* compute the week day because some web servers (like lighttpd) need them. */
|
|
||||||
/* we set tmref to "Thu, 01 Jan 1970 00:00:00" */
|
|
||||||
memset(&tmref, 0, sizeof(struct tm));
|
|
||||||
tmref.tm_mday = 1;
|
|
||||||
tref = mktime(&tmref);
|
|
||||||
/* then we compute the difference with mtime1 */
|
|
||||||
t = mktime(&fmtime1);
|
|
||||||
diff = ((t-tref)/3600/24)%7;
|
|
||||||
fmtime1.tm_wday = diff+(diff >= 3 ? -3 : 4);
|
|
||||||
|
|
||||||
}
|
|
||||||
fmtime2.tm_year = 0;
|
|
||||||
if(!HttpGet(server->server, output, src, &fsz, control, *pm_dloffset,
|
|
||||||
(mtime1) ? &fmtime1 : NULL, (mtime2) ? &fmtime2 : NULL)) {
|
|
||||||
if(strstr(FtpLastResponse(control), "304")) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("mtimes are identical, skipping %s\n"), fn);
|
|
||||||
filedone = -1;
|
|
||||||
complete = _alpm_list_add(complete, fn);
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("\nfailed downloading %s from %s: %s\n"),
|
|
||||||
src, server->server, FtpLastResponse(control));
|
|
||||||
/* we leave the partially downloaded file in place so it can be resumed later */
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(mtime2) {
|
|
||||||
if(fmtime2.tm_year) {
|
|
||||||
/* date conversion from "rfc1123-date" to YYYYMMDDHHMMSS */
|
|
||||||
sprintf(mtime2, "%4d%02d%02d%02d%02d%02d",
|
|
||||||
fmtime2.tm_year+1900, fmtime2.tm_mon+1, fmtime2.tm_mday,
|
|
||||||
fmtime2.tm_hour, fmtime2.tm_min, fmtime2.tm_sec);
|
|
||||||
} else {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to get mtime for %s\n"), fn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filedone = 1;
|
|
||||||
}
|
|
||||||
} else if(!strcmp(server->protocol, "file")) {
|
|
||||||
char src[PATH_MAX];
|
|
||||||
snprintf(src, PATH_MAX, "%s%s", server->path, fn);
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("copying %s to %s/%s\n"), src, localpath, fn);
|
|
||||||
/* local repository, just copy the file */
|
|
||||||
if(_alpm_copyfile(src, output)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed copying %s\n"), src);
|
|
||||||
} else {
|
|
||||||
filedone = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(filedone > 0) {
|
|
||||||
char completefile[PATH_MAX];
|
|
||||||
if(!strcmp(server->protocol, "file")) {
|
|
||||||
EVENT(handle->trans, PM_TRANS_EVT_RETRIEVE_LOCAL, pm_dlfnm, server->path);
|
|
||||||
} else if(pm_dlcb) {
|
|
||||||
pm_dlcb(control, fsz-*pm_dloffset, &fsz);
|
|
||||||
}
|
|
||||||
complete = _alpm_list_add(complete, fn);
|
|
||||||
/* rename "output.part" file to "output" file */
|
|
||||||
snprintf(completefile, PATH_MAX, "%s/%s", localpath, fn);
|
|
||||||
rename(output, completefile);
|
|
||||||
} else if(filedone < 0) {
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!handle->xfercommand) {
|
|
||||||
if(!strcmp(server->protocol, "ftp") && !handle->proxyhost) {
|
|
||||||
FtpQuit(control);
|
|
||||||
} else if(!strcmp(server->protocol, "http") || (handle->proxyhost && strcmp(server->protocol, "file"))) {
|
|
||||||
HttpQuit(control);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,42 +310,32 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, _("end _alpm_downloadfiles_forreal - return %d"),!done);
|
|
||||||
return(!done);
|
return(!done);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *_alpm_fetch_pkgurl(char *target)
|
char *_alpm_fetch_pkgurl(char *target)
|
||||||
{
|
{
|
||||||
char spath[PATH_MAX];
|
struct stat st;
|
||||||
char url[PATH_MAX];
|
struct url *s_url;
|
||||||
char *host, *path, *fn;
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
strncpy(url, target, PATH_MAX);
|
s_url = fetchParseURL(target);
|
||||||
host = strstr(url, "://");
|
if(!s_url) {
|
||||||
*host = '\0';
|
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid, ignoring"), target);
|
||||||
host += 3;
|
return(NULL);
|
||||||
path = strchr(host, '/');
|
}
|
||||||
*path = '\0';
|
if(strlen(s_url->scheme) == 0) {
|
||||||
path++;
|
_alpm_log(PM_LOG_WARNING, _("url scheme not specified, assuming http"));
|
||||||
fn = strrchr(path, '/');
|
strcpy(s_url->scheme, "http");
|
||||||
if(fn) {
|
|
||||||
*fn = '\0';
|
|
||||||
if(path[0] == '/') {
|
|
||||||
snprintf(spath, PATH_MAX, "%s/", path);
|
|
||||||
} else {
|
|
||||||
snprintf(spath, PATH_MAX, "/%s/", path);
|
|
||||||
}
|
|
||||||
fn++;
|
|
||||||
} else {
|
|
||||||
fn = path;
|
|
||||||
strcpy(spath, "/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do not download the file if it exists in the current dir
|
if(strcmp(s_url->scheme,"ftp") == 0 && strlen(s_url->user) == 0) {
|
||||||
*/
|
strcpy(s_url->user, "anonymous");
|
||||||
if(stat(fn, &buf) == 0) {
|
strcpy(s_url->pwd, "libalpm@guest");
|
||||||
_alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory\n"), fn);
|
}
|
||||||
|
|
||||||
|
/* do not download the file if it exists in the current dir */
|
||||||
|
if(stat(s_url->doc, &st) == 0) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory\n"), s_url->doc);
|
||||||
} else {
|
} else {
|
||||||
pmserver_t *server;
|
pmserver_t *server;
|
||||||
pmlist_t *servers = NULL;
|
pmlist_t *servers = NULL;
|
||||||
@ -551,27 +345,21 @@ char *_alpm_fetch_pkgurl(char *target)
|
|||||||
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t));
|
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
server->protocol = url;
|
server->s_url = s_url;
|
||||||
server->server = host;
|
server->path = strdup(s_url->doc);
|
||||||
server->path = spath;
|
|
||||||
servers = _alpm_list_add(servers, server);
|
servers = _alpm_list_add(servers, server);
|
||||||
|
|
||||||
files = _alpm_list_add(NULL, fn);
|
files = _alpm_list_add(NULL, s_url->doc);
|
||||||
if(_alpm_downloadfiles(servers, ".", files)) {
|
if(_alpm_downloadfiles(servers, ".", files)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to download %s\n"), target);
|
_alpm_log(PM_LOG_WARNING, _("failed to download %s\n"), target);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
FREELISTPTR(files);
|
FREELISTPTR(files);
|
||||||
|
|
||||||
FREELIST(servers);
|
FREELIST(servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the target with the raw filename, no URL */
|
/* return the target with the raw filename, no URL */
|
||||||
#if defined(__OpenBSD__) || defined(__APPLE__)
|
return(strdup(s_url->doc));
|
||||||
return(strdup(fn));
|
|
||||||
#else
|
|
||||||
return(strndup(fn, PATH_MAX));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ftplib.h>
|
|
||||||
|
#include <fetch.h>
|
||||||
|
|
||||||
#define FREESERVER(p) \
|
#define FREESERVER(p) \
|
||||||
do { \
|
do { \
|
||||||
@ -37,11 +38,14 @@ do { \
|
|||||||
|
|
||||||
/* Servers */
|
/* Servers */
|
||||||
typedef struct __pmserver_t {
|
typedef struct __pmserver_t {
|
||||||
char *protocol;
|
|
||||||
char *server;
|
|
||||||
char *path;
|
char *path;
|
||||||
|
struct url *s_url;
|
||||||
} pmserver_t;
|
} pmserver_t;
|
||||||
|
|
||||||
|
#define PM_DLBUF_LEN (1024 * 10)
|
||||||
|
|
||||||
|
typedef void (*download_progress_cb)(const char *filename, int xfered, int total);
|
||||||
|
|
||||||
pmserver_t *_alpm_server_new(char *url);
|
pmserver_t *_alpm_server_new(char *url);
|
||||||
void _alpm_server_free(void *data);
|
void _alpm_server_free(void *data);
|
||||||
int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files);
|
int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files);
|
||||||
@ -50,15 +54,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
|
|||||||
|
|
||||||
char *_alpm_fetch_pkgurl(char *target);
|
char *_alpm_fetch_pkgurl(char *target);
|
||||||
|
|
||||||
extern FtpCallback pm_dlcb;
|
extern download_progress_cb pm_dlcb;
|
||||||
|
|
||||||
/* progress bar */
|
|
||||||
extern char *pm_dlfnm;
|
|
||||||
extern int *pm_dloffset;
|
|
||||||
extern struct timeval *pm_dlt0, *pm_dlt;
|
|
||||||
extern float *pm_dlrate;
|
|
||||||
extern int *pm_dlxfered1;
|
|
||||||
extern unsigned char *pm_dleta_h, *pm_dleta_m, *pm_dleta_s;
|
|
||||||
|
|
||||||
#endif /* _ALPM_SERVER_H */
|
#endif /* _ALPM_SERVER_H */
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void _alpm_sync_free(void *data)
|
|||||||
} else {
|
} else {
|
||||||
FREEPKG(sync->data);
|
FREEPKG(sync->data);
|
||||||
}
|
}
|
||||||
free(sync);
|
FREE(sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test for existence of a package in a pmlist_t* of pmsyncpkg_t*
|
/* Test for existence of a package in a pmlist_t* of pmsyncpkg_t*
|
||||||
@ -125,13 +125,13 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync
|
|||||||
/* check for "recommended" package replacements */
|
/* check for "recommended" package replacements */
|
||||||
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
|
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
|
||||||
for(i = dbs_sync; i; i = i->next) {
|
for(i = dbs_sync; i; i = i->next) {
|
||||||
for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) {
|
for(j = _alpm_db_get_pkgcache(i->data, INFRQ_DESC); j; j = j->next) {
|
||||||
pmpkg_t *spkg = j->data;
|
pmpkg_t *spkg = j->data;
|
||||||
for(k = spkg->replaces; k; k = k->next) {
|
for(k = spkg->replaces; k; k = k->next) {
|
||||||
pmlist_t *m;
|
pmlist_t *m;
|
||||||
for(m = _alpm_db_get_pkgcache(db_local); m; m = m->next) {
|
for(m = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); m; m = m->next) {
|
||||||
pmpkg_t *lpkg = m->data;
|
pmpkg_t *lpkg = m->data;
|
||||||
if(!strcmp(k->data, lpkg->name)) {
|
if(strcmp(k->data, lpkg->name) == 0) {
|
||||||
_alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name);
|
_alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name);
|
||||||
if(_alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
|
if(_alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"),
|
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"),
|
||||||
@ -181,7 +181,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync
|
|||||||
|
|
||||||
/* match installed packages with the sync dbs and compare versions */
|
/* match installed packages with the sync dbs and compare versions */
|
||||||
_alpm_log(PM_LOG_FLOW1, _("checking for package upgrades"));
|
_alpm_log(PM_LOG_FLOW1, _("checking for package upgrades"));
|
||||||
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) {
|
for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) {
|
||||||
int cmp;
|
int cmp;
|
||||||
int replace=0;
|
int replace=0;
|
||||||
pmpkg_t *local = i->data;
|
pmpkg_t *local = i->data;
|
||||||
@ -262,7 +262,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync,
|
|||||||
pmpkg_t *local;
|
pmpkg_t *local;
|
||||||
pmpkg_t *spkg = NULL;
|
pmpkg_t *spkg = NULL;
|
||||||
pmsyncpkg_t *sync;
|
pmsyncpkg_t *sync;
|
||||||
int cmp;
|
int cmp, repo_found = 0;
|
||||||
|
|
||||||
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||||
@ -273,9 +273,11 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync,
|
|||||||
if(targ) {
|
if(targ) {
|
||||||
*targ = '\0';
|
*targ = '\0';
|
||||||
targ++;
|
targ++;
|
||||||
|
_alpm_log(PM_LOG_DEBUG, _("searching for target in repo '%s'"), targline);
|
||||||
for(j = dbs_sync; j && !spkg; j = j->next) {
|
for(j = dbs_sync; j && !spkg; j = j->next) {
|
||||||
pmdb_t *dbs = j->data;
|
pmdb_t *dbs = j->data;
|
||||||
if(strcmp(dbs->treename, targline) == 0) {
|
if(strcmp(dbs->treename, targline) == 0) {
|
||||||
|
repo_found = 1;
|
||||||
spkg = _alpm_db_get_pkgfromcache(dbs, targ);
|
spkg = _alpm_db_get_pkgfromcache(dbs, targ);
|
||||||
if(spkg == NULL) {
|
if(spkg == NULL) {
|
||||||
/* Search provides */
|
/* Search provides */
|
||||||
@ -291,6 +293,10 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!repo_found) {
|
||||||
|
_alpm_log(PM_LOG_ERROR, _("repository '%s' not found"), targline);
|
||||||
|
RET_ERR(PM_ERR_PKG_REPO_NOT_FOUND, -1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
targ = targline;
|
targ = targline;
|
||||||
for(j = dbs_sync; j && !spkg; j = j->next) {
|
for(j = dbs_sync; j && !spkg; j = j->next) {
|
||||||
@ -396,7 +402,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
|
|||||||
|
|
||||||
/* Resolve targets dependencies */
|
/* Resolve targets dependencies */
|
||||||
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
|
||||||
_alpm_log(PM_LOG_FLOW1, _("resolving targets dependencies"));
|
_alpm_log(PM_LOG_FLOW1, _("resolving target's dependencies"));
|
||||||
for(i = trans->packages; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
pmpkg_t *spkg = ((pmsyncpkg_t *)i->data)->pkg;
|
pmpkg_t *spkg = ((pmsyncpkg_t *)i->data)->pkg;
|
||||||
if(_alpm_resolvedeps(db_local, dbs_sync, spkg, list, trail, trans, data) == -1) {
|
if(_alpm_resolvedeps(db_local, dbs_sync, spkg, list, trail, trans, data) == -1) {
|
||||||
@ -421,8 +427,10 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
|
|||||||
} else {
|
} else {
|
||||||
/* remove the original targets from the list if requested */
|
/* remove the original targets from the list if requested */
|
||||||
if((trans->flags & PM_TRANS_FLAG_DEPENDSONLY)) {
|
if((trans->flags & PM_TRANS_FLAG_DEPENDSONLY)) {
|
||||||
|
void *vp;
|
||||||
pmpkg_t *p;
|
pmpkg_t *p;
|
||||||
trans->packages = _alpm_list_remove(trans->packages, spkg, pkg_cmp, (void**)&p);
|
trans->packages = _alpm_list_remove(trans->packages, spkg, pkg_cmp, &vp);
|
||||||
|
p = vp;
|
||||||
FREEPKG(p);
|
FREEPKG(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,10 +558,10 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
|
|||||||
}
|
}
|
||||||
if(rmpkg) {
|
if(rmpkg) {
|
||||||
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
|
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
|
||||||
pmsyncpkg_t *spkg = NULL;
|
void *vpkg;
|
||||||
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg);
|
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg);
|
||||||
trans->packages = _alpm_list_remove(trans->packages, rsync, ptr_cmp, (void **)&spkg);
|
trans->packages = _alpm_list_remove(trans->packages, rsync, ptr_cmp, &vpkg);
|
||||||
FREESYNC(spkg);
|
FREESYNC(vpkg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -587,10 +595,10 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
|
|||||||
sync->data = _alpm_list_add(sync->data, q);
|
sync->data = _alpm_list_add(sync->data, q);
|
||||||
if(rsync) {
|
if(rsync) {
|
||||||
/* remove it from the target list */
|
/* remove it from the target list */
|
||||||
pmsyncpkg_t *spkg = NULL;
|
void *vpkg;
|
||||||
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), miss->depend.name);
|
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), miss->depend.name);
|
||||||
trans->packages = _alpm_list_remove(trans->packages, rsync, ptr_cmp, (void **)&spkg);
|
trans->packages = _alpm_list_remove(trans->packages, rsync, ptr_cmp, &vpkg);
|
||||||
FREESYNC(spkg);
|
FREESYNC(vpkg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* abort */
|
/* abort */
|
||||||
|
@ -82,7 +82,7 @@ void _alpm_trans_free(void *data)
|
|||||||
|
|
||||||
FREELIST(trans->skiplist);
|
FREELIST(trans->skiplist);
|
||||||
|
|
||||||
free(trans);
|
FREE(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
|
int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
|
||||||
|
@ -138,14 +138,14 @@ int _alpm_makepath(char *path)
|
|||||||
strcat(full, ptr);
|
strcat(full, ptr);
|
||||||
if(stat(full, &buf)) {
|
if(stat(full, &buf)) {
|
||||||
if(mkdir(full, 0755)) {
|
if(mkdir(full, 0755)) {
|
||||||
free(orig);
|
FREE(orig);
|
||||||
umask(oldmask);
|
umask(oldmask);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(orig);
|
FREE(orig);
|
||||||
umask(oldmask);
|
umask(oldmask);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -302,37 +302,36 @@ int _alpm_rmrf(char *path)
|
|||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
char name[PATH_MAX];
|
char name[PATH_MAX];
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
if(!unlink(path)) {
|
if(stat(path, &st) == 0) {
|
||||||
return(0);
|
if(S_ISREG(st.st_mode)) {
|
||||||
} else {
|
if(!unlink(path)) {
|
||||||
if(errno == ENOENT) {
|
return(0);
|
||||||
return(0);
|
} else {
|
||||||
} else if(errno == EPERM) {
|
if(errno == ENOENT) {
|
||||||
/* fallthrough */
|
return(0);
|
||||||
} else if(errno == EISDIR) {
|
} else {
|
||||||
/* fallthrough */
|
/* not a directory */
|
||||||
} else if(errno == ENOTDIR) {
|
return(1);
|
||||||
return(1);
|
|
||||||
} else {
|
|
||||||
/* not a directory */
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((dirp = opendir(path)) == (DIR *)-1) {
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
|
|
||||||
if(dp->d_ino) {
|
|
||||||
sprintf(name, "%s/%s", path, dp->d_name);
|
|
||||||
if(strcmp(dp->d_name, "..") && strcmp(dp->d_name, ".")) {
|
|
||||||
errflag += _alpm_rmrf(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if(S_ISDIR(st.st_mode)) {
|
||||||
closedir(dirp);
|
if((dirp = opendir(path)) == (DIR *)-1) {
|
||||||
if(rmdir(path)) {
|
return(1);
|
||||||
errflag++;
|
}
|
||||||
|
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
|
||||||
|
if(dp->d_ino) {
|
||||||
|
sprintf(name, "%s/%s", path, dp->d_name);
|
||||||
|
if(strcmp(dp->d_name, "..") && strcmp(dp->d_name, ".")) {
|
||||||
|
errflag += _alpm_rmrf(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(dirp);
|
||||||
|
if(rmdir(path)) {
|
||||||
|
errflag++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(errflag);
|
return(errflag);
|
||||||
}
|
}
|
||||||
@ -605,6 +604,7 @@ int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* match a string against a regular expression */
|
/* match a string against a regular expression */
|
||||||
int _alpm_reg_match(char *string, char *pattern)
|
int _alpm_reg_match(char *string, char *pattern)
|
||||||
@ -620,6 +620,18 @@ int _alpm_reg_match(char *string, char *pattern)
|
|||||||
return(!(result));
|
return(!(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
/* convert a time_t to a string - buffer MUST be large enough for
|
||||||
|
* YYYYMMDDHHMMSS - 15 chars */
|
||||||
|
void _alpm_time2string(time_t t, char *buffer)
|
||||||
|
{
|
||||||
|
if(buffer) {
|
||||||
|
struct tm *lt;
|
||||||
|
lt = localtime(&t);
|
||||||
|
sprintf(buffer, "%4d%02d%02d%02d%02d%02d",
|
||||||
|
lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
|
||||||
|
lt->tm_hour, lt->tm_min, lt->tm_sec);
|
||||||
|
buffer[14] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
@ -71,6 +71,7 @@ int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
int _alpm_reg_match(char *string, char *pattern);
|
int _alpm_reg_match(char *string, char *pattern);
|
||||||
|
void _alpm_time2string(time_t t, char *buffer);
|
||||||
#ifdef __sun__
|
#ifdef __sun__
|
||||||
char* strsep(char** str, const char* delims);
|
char* strsep(char** str, const char* delims);
|
||||||
char* mkdtemp(char *template);
|
char* mkdtemp(char *template);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user