Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c19
-rw-r--r--lib/libalpm/alpm.h33
-rw-r--r--lib/libalpm/be_files.c2
-rw-r--r--lib/libalpm/cache.c31
-rw-r--r--lib/libalpm/conflict.c6
-rw-r--r--lib/libalpm/db.c4
-rw-r--r--lib/libalpm/db.h2
-rw-r--r--lib/libalpm/delta.c4
-rw-r--r--lib/libalpm/deps.c20
-rw-r--r--lib/libalpm/dload.c68
-rw-r--r--lib/libalpm/error.c12
-rw-r--r--lib/libalpm/handle.c41
-rw-r--r--lib/libalpm/handle.h1
-rw-r--r--lib/libalpm/package.c9
-rw-r--r--lib/libalpm/remove.c16
-rw-r--r--lib/libalpm/sync.c101
-rw-r--r--lib/libalpm/sync.h3
-rw-r--r--lib/libalpm/trans.c22
-rw-r--r--lib/libalpm/trans.h1
-rw-r--r--lib/libalpm/util.c19
20 files changed, 155 insertions, 259 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 1e8ec9f2..264a28ee 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -114,7 +114,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
/* look for unsatisfied dependencies */
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
- lp = alpm_checkdeps(db, 1, NULL, trans->packages);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, NULL, trans->packages);
if(lp != NULL) {
if(data) {
*data = lp;
@@ -456,8 +456,8 @@ static int extract_single_file(struct archive *archive,
return(1);
}
- hash_local = alpm_get_md5sum(filename);
- hash_pkg = alpm_get_md5sum(checkfile);
+ hash_local = alpm_compute_md5sum(filename);
+ hash_pkg = alpm_compute_md5sum(checkfile);
/* append the new md5 hash to it's respective entry
* in newpkg's backup (it will be the new orginal) */
@@ -618,7 +618,7 @@ static int extract_single_file(struct archive *archive,
}
_alpm_log(PM_LOG_DEBUG, "appending backup entry for %s\n", filename);
- hash = alpm_get_md5sum(filename);
+ hash = alpm_compute_md5sum(filename);
MALLOC(backup, backup_len, RET_ERR(PM_ERR_MEMORY, -1));
sprintf(backup, "%s\t%s", oldbackup, hash);
@@ -650,17 +650,18 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
if(local) {
is_upgrade = 1;
- EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, NULL);
- _alpm_log(PM_LOG_DEBUG, "upgrading package %s-%s\n",
- newpkg->name, newpkg->version);
-
/* we'll need to save some record for backup checks later */
oldpkg = _alpm_pkg_dup(local);
/* make sure all infos are loaded because the database entry
* will be removed soon */
_alpm_db_read(oldpkg->origin_data.db, oldpkg, INFRQ_ALL);
+
+ EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg);
+ _alpm_log(PM_LOG_DEBUG, "upgrading package %s-%s\n",
+ newpkg->name, newpkg->version);
+
/* copy over the install reason */
- newpkg->reason = alpm_pkg_get_reason(local);
+ newpkg->reason = alpm_pkg_get_reason(oldpkg);
/* pre_upgrade scriptlet */
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 16b48a0a..7b7ca4e7 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -132,11 +132,6 @@ void alpm_option_add_ignorepkg(const char *pkg);
void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
int alpm_option_remove_ignorepkg(const char *pkg);
-alpm_list_t *alpm_option_get_holdpkgs();
-void alpm_option_add_holdpkg(const char *pkg);
-void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs);
-int alpm_option_remove_holdpkg(const char *pkg);
-
alpm_list_t *alpm_option_get_ignoregrps();
void alpm_option_add_ignoregrp(const char *grp);
void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
@@ -170,10 +165,10 @@ int alpm_db_setserver(pmdb_t *db, const char *url);
int alpm_db_update(int level, pmdb_t *db);
pmpkg_t *alpm_db_get_pkg(pmdb_t *db, const char *name);
-alpm_list_t *alpm_db_getpkgcache(pmdb_t *db);
+alpm_list_t *alpm_db_get_pkgcache(pmdb_t *db);
pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name);
-alpm_list_t *alpm_db_getgrpcache(pmdb_t *db);
+alpm_list_t *alpm_db_get_grpcache(pmdb_t *db);
alpm_list_t *alpm_db_search(pmdb_t *db, const alpm_list_t* needles);
/*
@@ -218,6 +213,7 @@ alpm_list_t *alpm_pkg_get_deltas(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_replaces(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg);
+pmdb_t *alpm_pkg_get_db(pmpkg_t *pkg);
void *alpm_pkg_changelog_open(pmpkg_t *pkg);
size_t alpm_pkg_changelog_read(void *ptr, size_t size,
const pmpkg_t *pkg, const void *fp);
@@ -253,8 +249,6 @@ alpm_list_t *alpm_grp_get_pkgs(const pmgrp_t *grp);
pmpkg_t *alpm_sync_get_pkg(const pmsyncpkg_t *sync);
alpm_list_t *alpm_sync_get_removes(const pmsyncpkg_t *sync);
pmpkg_t *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync);
-int alpm_sync_sysupgrade(pmdb_t *db_local,
- alpm_list_t *dbs_sync, alpm_list_t **syncpkgs);
/*
* Transactions
@@ -282,7 +276,7 @@ typedef enum _pmtransflag_t {
PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
PM_TRANS_FLAG_NOCONFLICTS = 0x800,
- PM_TRANS_FLAG_PRINTURIS = 0x1000,
+ /* 0x1000 flag can go here */
PM_TRANS_FLAG_NEEDED = 0x2000,
PM_TRANS_FLAG_ALLEXPLICIT = 0x4000,
PM_TRANS_FLAG_UNNEEDED = 0x8000,
@@ -364,10 +358,6 @@ typedef enum _pmtransevt_t {
* A line of text is passed to the callback.
*/
PM_TRANS_EVT_SCRIPTLET_INFO,
- /** Print URI.
- * The database's URI and the package's filename are passed to the callback.
- */
- PM_TRANS_EVT_PRINTURI,
/** Files will be downloaded from a repository.
* The repository's tree name is passed to the callback.
*/
@@ -381,9 +371,7 @@ typedef enum _pmtransconv_t {
PM_TRANS_CONV_REPLACE_PKG = 0x02,
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
PM_TRANS_CONV_CORRUPTED_PKG = 0x08,
- PM_TRANS_CONV_LOCAL_NEWER = 0x10,
- /* 0x20 flag can go here */
- PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
+ PM_TRANS_CONV_LOCAL_NEWER = 0x10
} pmtransconv_t;
/* Transaction Progress */
@@ -431,7 +419,7 @@ typedef enum _pmdepmod_t {
} pmdepmod_t;
int alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep);
-alpm_list_t *alpm_checkdeps(pmdb_t *db, int reversedeps,
+alpm_list_t *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
alpm_list_t *remove, alpm_list_t *upgrade);
alpm_list_t *alpm_deptest(pmdb_t *db, alpm_list_t *targets);
@@ -439,7 +427,7 @@ const char *alpm_miss_get_target(const pmdepmissing_t *miss);
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss);
-alpm_list_t *alpm_checkdbconflicts(pmdb_t *db_local);
+alpm_list_t *alpm_checkconflicts(alpm_list_t *pkglist);
const char *alpm_conflict_get_package1(pmconflict_t *conflict);
const char *alpm_conflict_get_package2(pmconflict_t *conflict);
@@ -447,7 +435,7 @@ const char *alpm_conflict_get_package2(pmconflict_t *conflict);
pmdepmod_t alpm_dep_get_mod(const pmdepend_t *dep);
const char *alpm_dep_get_name(const pmdepend_t *dep);
const char *alpm_dep_get_version(const pmdepend_t *dep);
-char *alpm_dep_get_string(const pmdepend_t *dep);
+char *alpm_dep_compute_string(const pmdepend_t *dep);
/*
* File conflicts
@@ -468,7 +456,7 @@ const char *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict);
*/
/* checksums */
-char *alpm_get_md5sum(const char *name);
+char *alpm_compute_md5sum(const char *name);
/*
* Errors
@@ -527,11 +515,10 @@ enum _pmerrno_t {
PM_ERR_INTERNAL_ERROR,
PM_ERR_DB_SYNC,
PM_ERR_RETRIEVE,
- PM_ERR_PKG_HOLD,
PM_ERR_INVALID_REGEX,
/* External library errors */
PM_ERR_LIBARCHIVE,
- PM_ERR_LIBDOWNLOAD,
+ PM_ERR_LIBFETCH,
PM_ERR_EXTERNAL_DOWNLOAD
};
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 31b23172..de906eb7 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -826,7 +826,7 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
if(info->depends) {
fputs("%DEPENDS%\n", fp);
for(lp = info->depends; lp; lp = lp->next) {
- char *depstring = alpm_dep_get_string(lp->data);
+ char *depstring = alpm_dep_compute_string(lp->data);
fprintf(fp, "%s\n", depstring);
free(depstring);
}
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index 10857792..8d18f3ee 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -54,6 +54,7 @@ int _alpm_db_load_pkgcache(pmdb_t *db)
return(-1);
}
+ db->pkgcache_loaded = 1;
return(0);
}
@@ -61,7 +62,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
{
ALPM_LOG_FUNC;
- if(db == NULL || db->pkgcache == NULL) {
+ if(db == NULL || !db->pkgcache_loaded) {
return;
}
@@ -71,10 +72,9 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
alpm_list_free_inner(db->pkgcache, (alpm_list_fn_free)_alpm_pkg_free);
alpm_list_free(db->pkgcache);
db->pkgcache = NULL;
+ db->pkgcache_loaded = 0;
- if(db->grpcache) {
- _alpm_db_free_grpcache(db);
- }
+ _alpm_db_free_grpcache(db);
}
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db)
@@ -85,13 +85,13 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db)
return(NULL);
}
- if(!db->pkgcache) {
+ if(!db->pkgcache_loaded) {
_alpm_db_load_pkgcache(db);
}
/* hmmm, still NULL ?*/
if(!db->pkgcache) {
- _alpm_log(PM_LOG_DEBUG, "error: pkgcache is NULL for db '%s'\n", db->treename);
+ _alpm_log(PM_LOG_DEBUG, "warning: pkgcache is NULL for db '%s'\n", db->treename);
}
return(db->pkgcache);
@@ -104,7 +104,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
ALPM_LOG_FUNC;
- if(db == NULL || pkg == NULL) {
+ if(db == NULL || !db->pkgcache_loaded || pkg == NULL) {
return(-1);
}
@@ -139,7 +139,7 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
ALPM_LOG_FUNC;
- if(db == NULL || pkg == NULL) {
+ if(db == NULL || !db->pkgcache_loaded || pkg == NULL) {
return(-1);
}
@@ -172,7 +172,7 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target)
alpm_list_t *pkgcache = _alpm_db_get_pkgcache(db);
if(!pkgcache) {
- _alpm_log(PM_LOG_DEBUG, "error: failed to get '%s' from NULL pkgcache\n",
+ _alpm_log(PM_LOG_DEBUG, "warning: failed to get '%s' from NULL pkgcache\n",
target);
return(NULL);
}
@@ -192,10 +192,6 @@ int _alpm_db_load_grpcache(pmdb_t *db)
return(-1);
}
- if(db->pkgcache == NULL) {
- _alpm_db_load_pkgcache(db);
- }
-
_alpm_log(PM_LOG_DEBUG, "loading group cache for repository '%s'\n",
db->treename);
@@ -230,6 +226,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
}
}
+ db->grpcache_loaded = 1;
return(0);
}
@@ -239,15 +236,19 @@ void _alpm_db_free_grpcache(pmdb_t *db)
ALPM_LOG_FUNC;
- if(db == NULL || db->grpcache == NULL) {
+ if(db == NULL || !db->grpcache_loaded) {
return;
}
+ _alpm_log(PM_LOG_DEBUG, "freeing group cache for repository '%s'\n",
+ db->treename);
+
for(lg = db->grpcache; lg; lg = lg->next) {
_alpm_grp_free(lg->data);
lg->data = NULL;
}
FREELIST(db->grpcache);
+ db->grpcache_loaded = 0;
}
alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db)
@@ -258,7 +259,7 @@ alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db)
return(NULL);
}
- if(db->grpcache == NULL) {
+ if(!db->grpcache_loaded) {
_alpm_db_load_grpcache(db);
}
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index a044fc60..499e55a4 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -218,11 +218,11 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
/** Check the package conflicts in a database
*
- * @param db_local the database to check
+ * @param pkglist the list of packages to check
* @return an alpm_list_t of pmconflict_t
*/
-alpm_list_t SYMEXPORT *alpm_checkdbconflicts(pmdb_t *db_local) {
- return(_alpm_innerconflicts(_alpm_db_get_pkgcache(db_local)));
+alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_list_t *pkglist) {
+ return(_alpm_innerconflicts(pkglist));
}
/* Returns a alpm_list_t* of file conflicts.
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 5632ffac..9b91ce47 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -263,7 +263,7 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name)
* @param db pointer to the package database to get the package from
* @return the list of packages on success, NULL on error
*/
-alpm_list_t SYMEXPORT *alpm_db_getpkgcache(pmdb_t *db)
+alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db)
{
ALPM_LOG_FUNC;
@@ -295,7 +295,7 @@ pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name)
* @param db pointer to the package database to get the group from
* @return the list of groups on success, NULL on error
*/
-alpm_list_t SYMEXPORT *alpm_db_getgrpcache(pmdb_t *db)
+alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db)
{
ALPM_LOG_FUNC;
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 25b90b5f..edc4c93e 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -42,7 +42,9 @@ struct __pmdb_t {
char *path;
char *treename;
void *handle;
+ unsigned short pkgcache_loaded;
alpm_list_t *pkgcache;
+ unsigned short grpcache_loaded;
alpm_list_t *grpcache;
alpm_list_t *servers;
};
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 8dce7e3b..ff77501e 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -95,7 +95,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas)
/* determine whether the delta file already exists */
fpath = _alpm_filecache_find(vdelta->delta);
- md5sum = alpm_get_md5sum(fpath);
+ md5sum = alpm_compute_md5sum(fpath);
if(fpath && md5sum && strcmp(md5sum, vdelta->delta_md5) == 0) {
vdelta->download_size = 0;
}
@@ -104,7 +104,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas)
/* determine whether a base 'from' file exists */
fpath = _alpm_filecache_find(vdelta->from);
- md5sum = alpm_get_md5sum(fpath);
+ md5sum = alpm_compute_md5sum(fpath);
if(fpath && md5sum && strcmp(md5sum, vdelta->from_md5) == 0) {
v->weight = vdelta->download_size;
}
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index c667daa2..940f12ce 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -229,13 +229,13 @@ alpm_list_t SYMEXPORT *alpm_deptest(pmdb_t *db, alpm_list_t *targets)
/** Checks dependencies and returns missing ones in a list.
* Dependencies can include versions with depmod operators.
- * @param db pointer to the local package database
+ * @param pkglist the list of local packages
* @param reversedeps handles the backward dependencies
* @param remove an alpm_list_t* of packages to be removed
* @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade)
* @return an alpm_list_t* of pmpkg_t* of missing_t pointers.
*/
-alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
+alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
alpm_list_t *remove, alpm_list_t *upgrade)
{
alpm_list_t *i, *j;
@@ -245,12 +245,8 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
ALPM_LOG_FUNC;
- if(db == NULL) {
- return(NULL);
- }
-
targets = alpm_list_join(alpm_list_copy(remove), alpm_list_copy(upgrade));
- for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
+ for(i = pkglist; i; i = i->next) {
void *pkg = i->data;
if(alpm_list_find(targets, pkg, _alpm_pkg_cmp)) {
modified = alpm_list_add(modified, pkg);
@@ -273,7 +269,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
if(!_alpm_find_dep_satisfier(upgrade, depend) &&
!_alpm_find_dep_satisfier(dblist, depend)) {
/* Unsatisfied dependency in the upgrade list */
- char *missdepstring = alpm_dep_get_string(depend);
+ char *missdepstring = alpm_dep_compute_string(depend);
_alpm_log(PM_LOG_DEBUG, "checkdeps: missing dependency '%s' for package '%s'\n",
missdepstring, alpm_pkg_get_name(tp));
free(missdepstring);
@@ -297,7 +293,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
if(causingpkg &&
!_alpm_find_dep_satisfier(upgrade, depend) &&
!_alpm_find_dep_satisfier(dblist, depend)) {
- char *missdepstring = alpm_dep_get_string(depend);
+ char *missdepstring = alpm_dep_compute_string(depend);
_alpm_log(PM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n",
missdepstring, alpm_pkg_get_name(lp));
free(missdepstring);
@@ -572,7 +568,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, alpm_list_t *list,
for(i = list; i; i = i->next) {
pmpkg_t *tpkg = i->data;
targ = alpm_list_add(NULL, tpkg);
- deps = alpm_checkdeps(local, 0, remove, targ);
+ deps = alpm_checkdeps(_alpm_db_get_pkgcache(local), 0, remove, targ);
alpm_list_free(targ);
for(j = deps; j; j = j->next) {
pmdepmissing_t *miss = j->data;
@@ -585,7 +581,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, alpm_list_t *list,
pmpkg_t *spkg = _alpm_resolvedep(missdep, dbs_sync, list, tpkg);
if(!spkg) {
pm_errno = PM_ERR_UNSATISFIED_DEPS;
- char *missdepstring = alpm_dep_get_string(missdep);
+ char *missdepstring = alpm_dep_compute_string(missdep);
_alpm_log(PM_LOG_ERROR, _("cannot resolve \"%s\", a dependency of \"%s\"\n"),
missdepstring, tpkg->name);
free(missdepstring);
@@ -689,7 +685,7 @@ const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep)
* @param dep the depend to turn into a string
* @return a string-formatted dependency with operator if necessary
*/
-char SYMEXPORT *alpm_dep_get_string(const pmdepend_t *dep)
+char SYMEXPORT *alpm_dep_compute_string(const pmdepend_t *dep)
{
char *name, *opr, *ver, *str = NULL;
size_t len;
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index ca13652e..5b0a691f 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <signal.h>
#include <limits.h>
/* the following two are needed on BSD for libfetch */
#if defined(HAVE_SYS_SYSLIMITS_H)
@@ -33,16 +34,8 @@
#include <sys/param.h> /* MAXHOSTNAMELEN */
#endif
-#if defined(HAVE_LIBDOWNLOAD)
-#include <download.h>
-#elif defined(HAVE_LIBFETCH)
+#if defined(INTERNAL_DOWNLOAD)
#include <fetch.h>
-#define downloadFreeURL fetchFreeURL
-#define downloadLastErrCode fetchLastErrCode
-#define downloadLastErrString fetchLastErrString
-#define downloadParseURL fetchParseURL
-#define downloadTimeout fetchTimeout
-#define downloadXGet fetchXGet
#endif
/* libalpm */
@@ -86,7 +79,7 @@ static char *get_tempfile(const char *path, const char *filename) {
static struct url *url_for_string(const char *url)
{
struct url *ret = NULL;
- ret = downloadParseURL(url);
+ ret = fetchParseURL(url);
if(!ret) {
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
RET_ERR(PM_ERR_SERVER_BAD_URL, NULL);
@@ -108,12 +101,14 @@ static struct url *url_for_string(const char *url)
static int download_internal(const char *url, const char *localpath,
time_t mtimeold, time_t *mtimenew) {
- FILE *dlf, *localf = NULL;
+ fetchIO *dlf = NULL;
+ FILE *localf = NULL;
struct url_stat ust;
struct stat st;
int chk_resume = 0, ret = 0;
size_t dl_thisfile = 0, nread = 0;
char *tempfile, *destfile, *filename;
+ struct sigaction new_action, old_action;
struct url *fileurl = url_for_string(url);
char buffer[PM_DLBUF_LEN];
@@ -148,23 +143,29 @@ static int download_internal(const char *url, const char *localpath,
_alpm_log(PM_LOG_DEBUG, "FTP_PROXY: %s\n", getenv("FTP_PROXY"));
_alpm_log(PM_LOG_DEBUG, "ftp_proxy: %s\n", getenv("ftp_proxy"));
- /* libdownload does not reset the error code, reset it in
- * the case of previous errors */
- downloadLastErrCode = 0;
+ /* libfetch does not reset the error code */
+ fetchLastErrCode = 0;
/* 10s timeout - TODO make a config option */
- downloadTimeout = 10000;
+ fetchTimeout = 10000;
+
+ /* ignore any SIGPIPE signals- these may occur if our FTP socket dies or
+ * something along those lines. Store the old signal handler first. */
+ new_action.sa_handler = SIG_IGN;
+ sigemptyset(&new_action.sa_mask);
+ sigaction(SIGPIPE, NULL, &old_action);
+ sigaction(SIGPIPE, &new_action, NULL);
- dlf = downloadXGet(fileurl, &ust, (handle->nopassiveftp ? "" : "p"));
+ dlf = fetchXGet(fileurl, &ust, (handle->nopassiveftp ? "" : "p"));
- if(downloadLastErrCode != 0 || dlf == NULL) {
+ if(fetchLastErrCode != 0 || dlf == NULL) {
const char *host = _("disk");
if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) {
host = fileurl->host;
}
- pm_errno = PM_ERR_LIBDOWNLOAD;
+ pm_errno = PM_ERR_LIBFETCH;
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
- filename, host, downloadLastErrString);
+ filename, host, fetchLastErrString);
ret = -1;
goto cleanup;
} else {
@@ -206,16 +207,8 @@ static int download_internal(const char *url, const char *localpath,
handle->dlcb(filename, 0, ust.size);
}
- while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) {
+ while((nread = fetchIO_read(dlf, buffer, PM_DLBUF_LEN)) > 0) {
size_t nwritten = 0;
- if(ferror(dlf)) {
- pm_errno = PM_ERR_LIBDOWNLOAD;
- _alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s\n"),
- filename, downloadLastErrString);
- ret = -1;
- goto cleanup;
- }
-
while(nwritten < nread) {
nwritten += fwrite(buffer, 1, (nread - nwritten), localf);
if(ferror(localf)) {
@@ -231,27 +224,40 @@ static int download_internal(const char *url, const char *localpath,
handle->dlcb(filename, dl_thisfile, ust.size);
}
}
+
+ /* did the transfer complete normally? */
+ if (ust.size != -1 && dl_thisfile < ust.size) {
+ pm_errno = PM_ERR_LIBFETCH;
+ _alpm_log(PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
+ filename, (intmax_t)dl_thisfile, (intmax_t)ust.size);
+ ret = -1;
+ goto cleanup;
+ }
+
/* probably safer to close the file descriptors now before renaming the file,
* for example to make sure the buffers are flushed.
*/
fclose(localf);
localf = NULL;
- fclose(dlf);
+ fetchIO_close(dlf);
dlf = NULL;
rename(tempfile, destfile);
ret = 0;
cleanup:
+ /* restore any existing SIGPIPE signal handler */
+ sigaction(SIGPIPE, &old_action, NULL);
+
FREE(tempfile);
FREE(destfile);
if(localf != NULL) {
fclose(localf);
}
if(dlf != NULL) {
- fclose(dlf);
+ fetchIO_close(dlf);
}
- downloadFreeURL(fileurl);
+ fetchFreeURL(fileurl);
return(ret);
}
#endif
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index 05caf8ec..1f605806 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -30,11 +30,8 @@
#include <sys/param.h> /* MAXHOSTNAMELEN */
#endif
-#if defined(HAVE_LIBDOWNLOAD)
-#include <download.h> /* downloadLastErrString */
-#elif defined(HAVE_LIBFETCH)
+#if defined(INTERNAL_DOWNLOAD)
#include <fetch.h> /* fetchLastErrString */
-#define downloadLastErrString fetchLastErrString
#endif
/* libalpm */
@@ -143,9 +140,6 @@ const char SYMEXPORT *alpm_strerror(int err)
return _("user aborted the operation");
case PM_ERR_INTERNAL_ERROR:
return _("internal error");
- case PM_ERR_PKG_HOLD:
- /* TODO wow this is not descriptive at all... what does this mean? */
- return _("not confirmed");
case PM_ERR_INVALID_REGEX:
return _("invalid regular expression");
/* Errors from external libraries- our own wrapper error */
@@ -154,9 +148,9 @@ const char SYMEXPORT *alpm_strerror(int err)
* requires the archive struct, so we can't. Just use a generic
* error string instead. */
return _("libarchive error");
- case PM_ERR_LIBDOWNLOAD:
+ case PM_ERR_LIBFETCH:
#if defined(INTERNAL_DOWNLOAD)
- return downloadLastErrString;
+ return fetchLastErrString;
#else
/* obviously shouldn't get here... */
return _("download library error");
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index af1cc78b..813f4399 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -48,16 +48,7 @@ pmhandle_t *_alpm_handle_new()
ALPM_LOG_FUNC;
CALLOC(handle, 1, sizeof(pmhandle_t), RET_ERR(PM_ERR_MEMORY, NULL));
-
handle->lckfd = -1;
- handle->logstream = NULL;
-
- handle->root = NULL;
- handle->dbpath = NULL;
- handle->cachedirs = NULL;
- handle->lockfile = NULL;
- handle->logfile = NULL;
- handle->usedelta = 0;
return(handle);
}
@@ -92,7 +83,6 @@ void _alpm_handle_free(pmhandle_t *handle)
FREELIST(handle->noupgrade);
FREELIST(handle->noextract);
FREELIST(handle->ignorepkg);
- FREELIST(handle->holdpkg);
FREELIST(handle->ignoregrp);
FREE(handle);
}
@@ -205,15 +195,6 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignorepkgs()
return handle->ignorepkg;
}
-alpm_list_t SYMEXPORT *alpm_option_get_holdpkgs()
-{
- if (handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
- return handle->holdpkg;
-}
-
alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps()
{
if (handle == NULL) {
@@ -516,28 +497,6 @@ int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
return(0);
}
-void SYMEXPORT alpm_option_add_holdpkg(const char *pkg)
-{
- handle->holdpkg = alpm_list_add(handle->holdpkg, strdup(pkg));
-}
-
-void SYMEXPORT alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
-{
- if(handle->holdpkg) FREELIST(handle->holdpkg);
- if(holdpkgs) handle->holdpkg = holdpkgs;
-}
-
-int SYMEXPORT alpm_option_remove_holdpkg(const char *pkg)
-{
- char *vdata = NULL;
- handle->holdpkg = alpm_list_remove_str(handle->holdpkg, pkg, &vdata);
- if(vdata != NULL) {
- FREE(vdata);
- return(1);
- }
- return(0);
-}
-
void SYMEXPORT alpm_option_add_ignoregrp(const char *grp)
{
handle->ignoregrp = alpm_list_add(handle->ignoregrp, strdup(grp));
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index bec0a6f1..ad7666dc 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -52,7 +52,6 @@ typedef struct _pmhandle_t {
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
alpm_list_t *noextract; /* List of files NOT to extract */
alpm_list_t *ignorepkg; /* List of packages to ignore */
- alpm_list_t *holdpkg; /* List of packages which 'hold' pacman */
alpm_list_t *ignoregrp; /* List of groups to ignore */
/* options */
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a9f4b43d..ee0ff6f5 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -422,6 +422,15 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_backup(pmpkg_t *pkg)
return pkg->backup;
}
+pmdb_t SYMEXPORT *alpm_pkg_get_db(pmpkg_t *pkg)
+{
+ /* Sanity checks */
+ ASSERT(pkg != NULL, return(NULL));
+ ASSERT(pkg->origin == PKG_FROM_CACHE, return(NULL));
+
+ return(pkg->origin_data.db);
+}
+
/**
* Open a package changelog for reading. Similar to fopen in functionality,
* except that the returned 'file stream' could really be from an archive
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 0bec5229..9dfff9c3 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -65,16 +65,6 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
}
- /* ignore holdpkgs on upgrade */
- if((trans == handle->trans)
- && alpm_list_find_str(handle->holdpkg, info->name)) {
- int resp = 0;
- QUESTION(trans, PM_TRANS_CONV_REMOVE_HOLDPKG, info, NULL, NULL, &resp);
- if(!resp) {
- RET_ERR(PM_ERR_PKG_HOLD, -1);
- }
- }
-
_alpm_log(PM_LOG_DEBUG, "adding %s in the targets list\n", info->name);
trans->packages = alpm_list_add(trans->packages, _alpm_pkg_dup(info));
@@ -104,7 +94,7 @@ static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db,
}
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp);
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
}
}
@@ -134,7 +124,7 @@ static void remove_prepare_keep_needed(pmtrans_t *trans, pmdb_t *db,
}
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp);
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
}
}
@@ -161,7 +151,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 4a705b57..b458874d 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -77,17 +77,12 @@ void _alpm_sync_free(pmsyncpkg_t *sync)
/* Find recommended replacements for packages during a sync.
*/
-static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
- alpm_list_t *dbs_sync, alpm_list_t **syncpkgs)
+static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync)
{
alpm_list_t *i, *j, *k; /* wow */
ALPM_LOG_FUNC;
- if(syncpkgs == NULL) {
- return(-1);
- }
-
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_DEBUG, "checking for package replacements\n");
for(i = dbs_sync; i; i = i->next) {
@@ -113,13 +108,10 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
} else {
- /* get confirmation for the replacement */
- if(trans) {
- int doreplace = 0;
- QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace);
- if(!doreplace) {
- continue;
- }
+ int doreplace = 0;
+ QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace);
+ if(!doreplace) {
+ continue;
}
/* if confirmed, add this to the 'final' list, designating 'lpkg' as
@@ -129,7 +121,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
/* check if spkg->name is already in the packages list. */
/* TODO: same package name doesn't mean same package */
- sync = _alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg));
+ sync = _alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg));
if(sync) {
/* found it -- just append to the removes list */
sync->removes = alpm_list_add(sync->removes, lpkg);
@@ -143,15 +135,12 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
sync = _alpm_sync_new(alpm_pkg_get_reason(lpkg), spkg, NULL);
if(sync == NULL) {
pm_errno = PM_ERR_MEMORY;
- alpm_list_free_inner(*syncpkgs, (alpm_list_fn_free)_alpm_sync_free);
- alpm_list_free(*syncpkgs);
- *syncpkgs = NULL;
return(-1);
}
sync->removes = alpm_list_add(NULL, lpkg);
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
- *syncpkgs = alpm_list_add(*syncpkgs, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
_alpm_log(PM_LOG_DEBUG, "%s-%s elected for removal (to be replaced by %s-%s)\n",
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
@@ -199,33 +188,19 @@ pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
return(NULL);
}
-/** Get a list of upgradable packages on the current system
- * Adds out of date packages to *list.
- * @arg list pointer to a list of pmsyncpkg_t.
- */
-int SYMEXPORT alpm_sync_sysupgrade(pmdb_t *db_local,
- alpm_list_t *dbs_sync, alpm_list_t **syncpkgs)
-{
- return(_alpm_sync_sysupgrade(NULL, db_local, dbs_sync, syncpkgs));
-}
-
-int _alpm_sync_sysupgrade(pmtrans_t *trans,
- pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **syncpkgs)
+int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync)
{
alpm_list_t *i, *j, *replaced = NULL;
ALPM_LOG_FUNC;
- if(syncpkgs == NULL) {
- return(-1);
- }
/* check for "recommended" package replacements */
- if(find_replacements(trans, db_local, dbs_sync, syncpkgs)) {
+ if(find_replacements(trans, db_local, dbs_sync)) {
return(-1);
}
/* compute the to-be-replaced packages for efficiency */
- for(i = *syncpkgs; i; i = i->next) {
+ for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
for(j = sync->removes; j; j = j->next) {
replaced = alpm_list_add(replaced, j->data);
@@ -255,22 +230,19 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans,
}
/* add the upgrade package to our pmsyncpkg_t list */
- if(_alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg))) {
+ if(_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) {
/* avoid duplicated targets */
continue;
}
/* we can set any reason here, it will be overridden by add_commit */
pmsyncpkg_t *sync = _alpm_sync_new(PM_PKG_REASON_EXPLICIT, spkg, NULL);
if(sync == NULL) {
- alpm_list_free_inner(*syncpkgs, (alpm_list_fn_free)_alpm_sync_free);
- alpm_list_free(*syncpkgs);
- *syncpkgs = NULL;
alpm_list_free(replaced);
return(-1);
}
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
- *syncpkgs = alpm_list_add(*syncpkgs, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
}
@@ -497,8 +469,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
}
- /* We don't care about conflicts if we're just printing uris */
- if(!(trans->flags & (PM_TRANS_FLAG_NOCONFLICTS | PM_TRANS_FLAG_PRINTURIS))) {
+ if(!(trans->flags & PM_TRANS_FLAG_NOCONFLICTS)) {
/* check for inter-conflicts and whatnot */
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
@@ -631,7 +602,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
}
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
- deps = alpm_checkdeps(db_local, 1, remove, list);
+ deps = alpm_checkdeps(_alpm_db_get_pkgcache(db_local), 1, remove, list);
if(deps) {
pm_errno = PM_ERR_UNSATISFIED_DEPS;
ret = -1;
@@ -838,32 +809,27 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
fname = alpm_pkg_get_filename(spkg);
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
- if(trans->flags & PM_TRANS_FLAG_PRINTURIS) {
- EVENT(trans, PM_TRANS_EVT_PRINTURI, (char *)alpm_db_get_url(current),
- (char *)fname);
- } else {
- if(spkg->download_size != 0) {
- alpm_list_t *delta_path = spkg->delta_path;
- if(delta_path) {
- alpm_list_t *dlts = NULL;
-
- for(dlts = delta_path; dlts; dlts = dlts->next) {
- pmdelta_t *d = dlts->data;
-
- if(d->download_size != 0) {
- /* add the delta filename to the download list if
- * it's not in the cache */
- files = alpm_list_add(files, strdup(d->delta));
- }
-
- /* keep a list of the delta files for md5sums */
- deltas = alpm_list_add(deltas, d);
+ if(spkg->download_size != 0) {
+ alpm_list_t *delta_path = spkg->delta_path;
+ if(delta_path) {
+ alpm_list_t *dlts = NULL;
+
+ for(dlts = delta_path; dlts; dlts = dlts->next) {
+ pmdelta_t *d = dlts->data;
+
+ if(d->download_size != 0) {
+ /* add the delta filename to the download list if
+ * it's not in the cache */
+ files = alpm_list_add(files, strdup(d->delta));
}
- } else {
- /* not using deltas, so add the file to the download list */
- files = alpm_list_add(files, strdup(fname));
+ /* keep a list of the delta files for md5sums */
+ deltas = alpm_list_add(deltas, d);
}
+
+ } else {
+ /* not using deltas, so add the file to the download list */
+ files = alpm_list_add(files, strdup(fname));
}
}
}
@@ -880,9 +846,6 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
FREELIST(files);
}
}
- if(trans->flags & PM_TRANS_FLAG_PRINTURIS) {
- return(0);
- }
/* clear out value to let callback know we are done */
if(handle->totaldlcb) {
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index b71f0ef2..b6a4bbff 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -33,8 +33,7 @@ struct __pmsyncpkg_t {
pmsyncpkg_t *_alpm_sync_new(pmpkgreason_t newreason, pmpkg_t *spkg, alpm_list_t *removes);
void _alpm_sync_free(pmsyncpkg_t *data);
-int _alpm_sync_sysupgrade(pmtrans_t *trans,
- pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **syncpkgs);
+int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync);
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name);
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index acad84e8..4b831193 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -100,7 +100,7 @@ int SYMEXPORT alpm_trans_sysupgrade()
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
ASSERT(trans->type == PM_TRANS_TYPE_SYNC, RET_ERR(PM_ERR_TRANS_TYPE, -1));
- return(_alpm_trans_sysupgrade(trans));
+ return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync));
}
/** Add a target to the transaction.
@@ -226,15 +226,6 @@ pmtrans_t *_alpm_trans_new()
ALPM_LOG_FUNC;
CALLOC(trans, 1, sizeof(pmtrans_t), RET_ERR(PM_ERR_MEMORY, NULL));
-
- trans->packages = NULL;
- trans->skip_add = NULL;
- trans->skip_remove = NULL;
- trans->type = 0;
- trans->flags = 0;
- trans->cb_event = NULL;
- trans->cb_conv = NULL;
- trans->cb_progress = NULL;
trans->state = STATE_IDLE;
return(trans);
@@ -280,17 +271,6 @@ int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, pmtransflag_t flags,
return(0);
}
-int _alpm_trans_sysupgrade(pmtrans_t *trans)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
-
- return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync,
- &(trans->packages)));
-}
-
/** Add a target to the transaction.
* @param trans the current transaction
* @param target the name of the target to add
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index d74c3e90..48996573 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -71,7 +71,6 @@ void _alpm_trans_free(pmtrans_t *trans);
int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, pmtransflag_t flags,
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress progress);
-int _alpm_trans_sysupgrade(pmtrans_t *trans);
int _alpm_trans_addtarget(pmtrans_t *trans, char *target);
int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data);
int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data);
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index da3463b0..5e6ca0c0 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -242,7 +242,8 @@ char *_alpm_strreplace(const char *str, const char *needle, const char *replace)
int _alpm_lckmk()
{
int fd;
- char *dir, *ptr;
+ pid_t pid;
+ char *dir, *ptr, *spid = NULL;
const char *file = alpm_option_get_lockfile();
/* create the dir of the lockfile first */
@@ -256,7 +257,17 @@ int _alpm_lckmk()
while((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000)) == -1
&& errno == EINTR);
- return(fd > 0 ? fd : -1);
+ if(fd > 0) {
+ pid = getpid();
+ size_t len = snprintf(spid, 0, "%ld\n", (long)pid) + 1;
+ spid = malloc(len);
+ snprintf(spid, len, "%ld\n", (long)pid);
+ while(write(fd, (void *)spid, len) == -1 && errno == EINTR);
+ fsync(fd);
+ free(spid);
+ return(fd);
+ }
+ return(-1);
}
/* Remove a lock file */
@@ -539,7 +550,7 @@ int _alpm_lstat(const char *path, struct stat *buf)
* @return the checksum on success, NULL on error
* @addtogroup alpm_misc
*/
-char SYMEXPORT *alpm_get_md5sum(const char *filename)
+char SYMEXPORT *alpm_compute_md5sum(const char *filename)
{
unsigned char output[16];
char *md5sum;
@@ -573,7 +584,7 @@ int _alpm_test_md5sum(const char *filepath, const char *md5sum)
char *md5sum2;
int ret;
- md5sum2 = alpm_get_md5sum(filepath);
+ md5sum2 = alpm_compute_md5sum(filepath);
if(md5sum == NULL || md5sum2 == NULL) {
ret = -1;