Pacman-dev
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- 2 participants
- 7336 discussions
I was starting to hack a bit today on the files and backup lists we have in the
package to make them a bit more full featured:
* files lists would have mode and size fields
* backup entries would be split ahead of time, like deps and deltas
And realized I didn't want to add another 30 methods to the API just to follow
the current trend. So here is my patch series at reversing the status quo and
bringing a hint of sanity back into how we do things. There are now only four
opaque struct types left, and I don't see those changing anytime soon
(pmhandle_t, pmtrans_t, pmpkg_t, pmdb_t).
Feedback welcome.
Dan McGee (5):
Make pmfileconflict_t type public
Make struct pmconflict_t public
Make pmdepend_t and pmdepmissing_t public
Make pmdelta_t public
Make pmgrp_t public
lib/libalpm/alpm.h | 162 ++++++++++++++++++++++++-----------------------
lib/libalpm/conflict.c | 42 ------------
lib/libalpm/conflict.h | 13 ----
lib/libalpm/delta.c | 43 ++-----------
lib/libalpm/delta.h | 15 -----
lib/libalpm/deps.c | 38 +-----------
lib/libalpm/deps.h | 15 -----
lib/libalpm/group.c | 12 ----
lib/libalpm/group.h | 7 --
lib/libalpm/sync.c | 10 +--
src/pacman/query.c | 15 ++---
src/pacman/remove.c | 8 +--
src/pacman/sync.c | 36 +++++------
src/pacman/upgrade.c | 28 +++-----
src/util/pactree.c | 8 +-
src/util/testdb.c | 9 +--
16 files changed, 137 insertions(+), 324 deletions(-)
--
1.7.5.4
2
6
[pacman-dev] [PATCH 1/3] Changed all references to signature verification level in libalpm symbols to 'verifysig'. Removed references to PGP in libalpm symbols. Signed-off-by: Kerrick Staley <mail@kerrickstaley.com>
by Kerrick Staley 19 Jun '11
by Kerrick Staley 19 Jun '11
19 Jun '11
---
lib/libalpm/alpm.h | 24 ++++++++++++------------
lib/libalpm/be_package.c | 10 +++++-----
lib/libalpm/be_sync.c | 10 +++++-----
lib/libalpm/db.c | 6 +++---
lib/libalpm/db.h | 2 +-
lib/libalpm/dload.c | 6 +++---
lib/libalpm/handle.c | 14 +++++++-------
lib/libalpm/handle.h | 2 +-
lib/libalpm/package.h | 2 +-
lib/libalpm/signing.c | 14 +++++++-------
lib/libalpm/signing.h | 2 +-
lib/libalpm/sync.c | 4 ++--
src/pacman/conf.c | 24 ++++++++++++------------
src/pacman/query.c | 2 +-
src/pacman/sync.c | 2 +-
src/pacman/upgrade.c | 2 +-
src/util/testpkg.c | 2 +-
17 files changed, 64 insertions(+), 64 deletions(-)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 5af843c..c779a06 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -63,12 +63,12 @@ typedef enum _pmpkgreason_t {
/**
* GPG signature verification options
*/
-typedef enum _pgp_verify_t {
- PM_PGP_VERIFY_UNKNOWN,
- PM_PGP_VERIFY_NEVER,
- PM_PGP_VERIFY_OPTIONAL,
- PM_PGP_VERIFY_ALWAYS
-} pgp_verify_t;
+typedef enum pmverifysig_t {
+ PM_VERIFYSIG_UNKNOWN,
+ PM_VERIFYSIG_NEVER,
+ PM_VERIFYSIG_OPTIONAL,
+ PM_VERIFYSIG_ALWAYS
+} pmverifysig_t;
/*
* Structures
@@ -263,8 +263,8 @@ int alpm_option_set_usedelta(int usedelta);
int alpm_option_get_checkspace(void);
int alpm_option_set_checkspace(int checkspace);
-pgp_verify_t alpm_option_get_default_sigverify(void);
-int alpm_option_set_default_sigverify(pgp_verify_t level);
+pmverifysig_t alpm_option_get_default_verifysig(void);
+int alpm_option_set_default_verifysig(pmverifysig_t level);
/** @} */
@@ -389,7 +389,7 @@ int alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason);
* @param pkg address of the package pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_pkg_load(const char *filename, int full, pgp_verify_t check_sig,
+int alpm_pkg_load(const char *filename, int full, pmverifysig_t check_sig,
pmpkg_t **pkg);
/** Free a package.
@@ -626,10 +626,10 @@ alpm_list_t *alpm_pkg_unused_deltas(pmpkg_t *pkg);
* Signatures
*/
-int alpm_pkg_check_pgp_signature(pmpkg_t *pkg);
+int alpm_pkg_check_signature(pmpkg_t *pkg);
-int alpm_db_check_pgp_signature(pmdb_t *db);
-int alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify);
+int alpm_db_check_signature(pmdb_t *db);
+int alpm_db_set_verifysig(pmdb_t *db, pmverifysig_t verify);
/*
* Deltas
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 9e59d69..173bd4b 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -227,7 +227,7 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
* @return An information filled pmpkg_t struct
*/
pmpkg_t *_alpm_pkg_load_internal(const char *pkgfile, int full,
- const char *md5sum, const char *base64_sig, pgp_verify_t check_sig)
+ const char *md5sum, const char *base64_sig, pmverifysig_t check_sig)
{
int ret;
int config = 0;
@@ -266,11 +266,11 @@ pmpkg_t *_alpm_pkg_load_internal(const char *pkgfile, int full,
}
_alpm_log(PM_LOG_DEBUG, "base64_sig: %s\n", base64_sig);
- if(check_sig != PM_PGP_VERIFY_NEVER) {
+ if(check_sig != PM_VERIFYSIG_NEVER) {
_alpm_log(PM_LOG_DEBUG, "checking signature for %s\n", pkgfile);
ret = _alpm_gpgme_checksig(pkgfile, base64_sig);
- if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
- (check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
+ if((check_sig == PM_VERIFYSIG_ALWAYS && ret != 0) ||
+ (check_sig == PM_VERIFYSIG_OPTIONAL && ret == 1)) {
RET_ERR(PM_ERR_SIG_INVALID, NULL);
}
}
@@ -381,7 +381,7 @@ error:
}
int SYMEXPORT alpm_pkg_load(const char *filename, int full,
- pgp_verify_t check_sig, pmpkg_t **pkg)
+ pmverifysig_t check_sig, pmpkg_t **pkg)
{
ALPM_LOG_FUNC;
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 9d85a45..3294f45 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -85,7 +85,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
size_t len;
int ret = -1;
mode_t oldmask;
- pgp_verify_t check_sig;
+ pmverifysig_t check_sig;
ALPM_LOG_FUNC;
@@ -117,7 +117,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
}
}
- check_sig = _alpm_db_get_sigverify_level(db);
+ check_sig = _alpm_db_get_verifysig(db);
for(i = db->servers; i; i = i->next) {
const char *server = i->data;
@@ -132,9 +132,9 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
ret = _alpm_download(fileurl, syncpath, force, 0, 0);
- if(ret == 0 && (check_sig == PM_PGP_VERIFY_ALWAYS ||
- check_sig == PM_PGP_VERIFY_OPTIONAL)) {
- int errors_ok = (check_sig == PM_PGP_VERIFY_OPTIONAL);
+ if(ret == 0 && (check_sig == PM_VERIFYSIG_ALWAYS ||
+ check_sig == PM_VERIFYSIG_OPTIONAL)) {
+ int errors_ok = (check_sig == PM_VERIFYSIG_OPTIONAL);
/* if we downloaded a DB, we want the .sig from the same server */
snprintf(fileurl, len, "%s/%s.db.sig", server, db->treename);
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 3133614..d062a92 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -225,17 +225,17 @@ int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url)
}
/** Set the verify gpg signature option for a database.
* @param db database pointer
- * @param verify enum pgp_verify_t
+ * @param verify enum pmverifysig_t
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int SYMEXPORT alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify)
+int SYMEXPORT alpm_db_set_verifysig(pmdb_t *db, pmverifysig_t verify)
{
ALPM_LOG_FUNC;
/* Sanity checks */
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
- db->pgp_verify = verify;
+ db->verifysig = verify;
_alpm_log(PM_LOG_DEBUG, "adding VerifySig option to database '%s': %d\n",
db->treename, verify);
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 399e2d5..23dffb7 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -63,7 +63,7 @@ struct __pmdb_t {
pmpkghash_t *pkgcache;
alpm_list_t *grpcache;
alpm_list_t *servers;
- pgp_verify_t pgp_verify;
+ pmverifysig_t verifysig;
struct db_operations *ops;
};
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index d024c73..9d44ce7 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -351,11 +351,11 @@ char SYMEXPORT *alpm_fetch_pkgurl(const char *url)
_alpm_log(PM_LOG_DEBUG, "successfully downloaded %s\n", url);
/* attempt to download the signature */
- if(ret == 0 && (handle->sigverify == PM_PGP_VERIFY_ALWAYS ||
- handle->sigverify == PM_PGP_VERIFY_OPTIONAL)) {
+ if(ret == 0 && (handle->verifysig == PM_VERIFYSIG_ALWAYS ||
+ handle->verifysig == PM_VERIFYSIG_OPTIONAL)) {
char *sig_url;
size_t len;
- int errors_ok = (handle->sigverify == PM_PGP_VERIFY_OPTIONAL);
+ int errors_ok = (handle->verifysig == PM_VERIFYSIG_OPTIONAL);
len = strlen(url) + 5;
CALLOC(sig_url, len, sizeof(char), RET_ERR(PM_ERR_MEMORY, NULL));
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 39b3b60..4999244 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -46,7 +46,7 @@ pmhandle_t *_alpm_handle_new()
CALLOC(handle, 1, sizeof(pmhandle_t), RET_ERR(PM_ERR_MEMORY, NULL));
- handle->sigverify = PM_PGP_VERIFY_OPTIONAL;
+ handle->verifysig = PM_VERIFYSIG_OPTIONAL;
return handle;
}
@@ -627,18 +627,18 @@ int SYMEXPORT alpm_option_set_checkspace(int checkspace)
return 0;
}
-int SYMEXPORT alpm_option_set_default_sigverify(pgp_verify_t level)
+int SYMEXPORT alpm_option_set_default_verifysig(pmverifysig_t level)
{
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- ASSERT(level != PM_PGP_VERIFY_UNKNOWN, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- handle->sigverify = level;
+ ASSERT(level != PM_VERIFYSIG_UNKNOWN, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+ handle->verifysig = level;
return 0;
}
-pgp_verify_t SYMEXPORT alpm_option_get_default_sigverify()
+pmverifysig_t SYMEXPORT alpm_option_get_default_verifysig()
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, PM_PGP_VERIFY_UNKNOWN));
- return handle->sigverify;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, PM_VERIFYSIG_UNKNOWN));
+ return handle->verifysig;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index aa00b6f..5bd41f1 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -72,7 +72,7 @@ typedef struct _pmhandle_t {
char *arch; /* Architecture of packages we should allow */
int usedelta; /* Download deltas if possible */
int checkspace; /* Check disk space before installing */
- pgp_verify_t sigverify; /* Default signature verification level */
+ pmverifysig_t verifysig; /* Default signature verification level */
} pmhandle_t;
/* global handle variable */
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index debb239..f3b3d26 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -141,7 +141,7 @@ void _alpm_pkg_free(pmpkg_t *pkg);
void _alpm_pkg_free_trans(pmpkg_t *pkg);
pmpkg_t *_alpm_pkg_load_internal(const char *filename, int full,
- const char *md5sum, const char *base64_sig, pgp_verify_t check_sig);
+ const char *md5sum, const char *base64_sig, pmverifysig_t check_sig);
int _alpm_pkg_cmp(const void *p1, const void *p2);
int _alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg);
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 9bb9d0a..1a99c8f 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -369,15 +369,15 @@ int _alpm_gpgme_checksig(const char *path, const char *base64_sig)
*
* @return signature verification level
*/
-pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
+pmverifysig_t _alpm_db_get_verifysig(pmdb_t *db)
{
ALPM_LOG_FUNC;
- ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, PM_PGP_VERIFY_UNKNOWN));
+ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, PM_VERIFYSIG_UNKNOWN));
- if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) {
- return db->pgp_verify;
+ if(db->verifysig != PM_VERIFYSIG_UNKNOWN) {
+ return db->verifysig;
} else {
- return alpm_option_get_default_sigverify();
+ return alpm_option_get_default_verifysig();
}
}
@@ -386,7 +386,7 @@ pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
* @param pkg the package to check
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
*/
-int SYMEXPORT alpm_pkg_check_pgp_signature(pmpkg_t *pkg)
+int SYMEXPORT alpm_pkg_check_signature(pmpkg_t *pkg)
{
ALPM_LOG_FUNC;
ASSERT(pkg != NULL, return 0);
@@ -399,7 +399,7 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(pmpkg_t *pkg)
* @param db the database to check
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
*/
-int SYMEXPORT alpm_db_check_pgp_signature(pmdb_t *db)
+int SYMEXPORT alpm_db_check_signature(pmdb_t *db)
{
ALPM_LOG_FUNC;
ASSERT(db != NULL, return 0);
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index 8d8c164..253a919 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -22,7 +22,7 @@
#include "alpm.h"
int _alpm_gpgme_checksig(const char *path, const char *base64_sig);
-pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db);
+pmverifysig_t _alpm_db_get_verifysig(pmdb_t *db);
#endif /* _ALPM_SIGNING_H */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 8dd51aa..6b99e08 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -866,7 +866,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
int percent = (current * 100) / numtargs;
const char *filename;
char *filepath;
- pgp_verify_t check_sig;
+ pmverifysig_t check_sig;
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
numtargs, current);
@@ -877,7 +877,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
filename = alpm_pkg_get_filename(spkg);
filepath = _alpm_filecache_find(filename);
pmdb_t *sdb = alpm_pkg_get_db(spkg);
- check_sig = _alpm_db_get_sigverify_level(sdb);
+ check_sig = _alpm_db_get_verifysig(sdb);
/* load the package file and replace pkgcache entry with it in the target list */
/* TODO: alpm_pkg_get_db() will not work on this target anymore */
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 370ec51..a872d3f 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -214,17 +214,17 @@ int config_set_arch(const char *arch)
}
}
-static pgp_verify_t option_verifysig(const char *value)
+static pmverifysig_t option_verifysig(const char *value)
{
- pgp_verify_t level;
+ pmverifysig_t level;
if(strcmp(value, "Always") == 0) {
- level = PM_PGP_VERIFY_ALWAYS;
+ level = PM_VERIFYSIG_ALWAYS;
} else if(strcmp(value, "Optional") == 0) {
- level = PM_PGP_VERIFY_OPTIONAL;
+ level = PM_VERIFYSIG_OPTIONAL;
} else if(strcmp(value, "Never") == 0) {
- level = PM_PGP_VERIFY_NEVER;
+ level = PM_VERIFYSIG_NEVER;
} else {
- level = PM_PGP_VERIFY_UNKNOWN;
+ level = PM_VERIFYSIG_UNKNOWN;
}
pm_printf(PM_LOG_DEBUG, "config: VerifySig = %s (%d)\n", value, level);
return level;
@@ -359,9 +359,9 @@ static int _parse_options(const char *key, char *value,
} else if(strcmp(key, "CleanMethod") == 0) {
setrepeatingoption(value, "CleanMethod", option_add_cleanmethod);
} else if(strcmp(key, "VerifySig") == 0) {
- pgp_verify_t level = option_verifysig(value);
- if(level != PM_PGP_VERIFY_UNKNOWN) {
- alpm_option_set_default_sigverify(level);
+ pmverifysig_t level = option_verifysig(value);
+ if(level != PM_VERIFYSIG_UNKNOWN) {
+ alpm_option_set_default_verifysig(level);
} else {
pm_printf(PM_LOG_ERROR,
_("config file %s, line %d: directive '%s' has invalid value '%s'\n"),
@@ -634,9 +634,9 @@ static int _parseconfig(const char *file, int parse_options,
goto cleanup;
}
} else if(strcmp(key, "VerifySig") == 0) {
- pgp_verify_t level = option_verifysig(value);
- if(level != PM_PGP_VERIFY_UNKNOWN) {
- ret = alpm_db_set_pgp_verify(db, level);
+ pmverifysig_t level = option_verifysig(value);
+ if(level != PM_VERIFYSIG_UNKNOWN) {
+ ret = alpm_db_set_verifysig(db, level);
if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("could not add set verify option for database '%s': %s (%s)\n"),
alpm_db_get_name(db), value, alpm_strerrorlast());
diff --git a/src/pacman/query.c b/src/pacman/query.c
index d1105b4..87f06c4 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -551,7 +551,7 @@ int pacman_query(alpm_list_t *targets)
char *strname = alpm_list_getdata(i);
if(config->op_q_isfile) {
- alpm_pkg_load(strname, 1, PM_PGP_VERIFY_OPTIONAL, &pkg);
+ alpm_pkg_load(strname, 1, PM_VERIFYSIG_OPTIONAL, &pkg);
} else {
pkg = alpm_db_get_pkg(db_local, strname);
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 884504f..8e2c236 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -219,7 +219,7 @@ static int sync_cleancache(int level)
/* attempt to load the package, prompt removal on failures as we may have
* files here that aren't valid packages. we also don't need a full
* load of the package, just the metadata. */
- if(alpm_pkg_load(path, 0, PM_PGP_VERIFY_NEVER, &localpkg) != 0
+ if(alpm_pkg_load(path, 0, PM_VERIFYSIG_NEVER, &localpkg) != 0
|| localpkg == NULL) {
if(yesno(_("File %s does not seem to be a valid package, remove it?"),
path)) {
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 0ffc94c..7a955e2 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -42,7 +42,7 @@
int pacman_upgrade(alpm_list_t *targets)
{
alpm_list_t *i, *data = NULL;
- pgp_verify_t check_sig = alpm_option_get_default_sigverify();
+ pmverifysig_t check_sig = alpm_option_get_default_verifysig();
int retval = 0;
if(targets == NULL) {
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index ad6ec30..4568262 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
/* let us get log messages from libalpm */
alpm_option_set_logcb(output_cb);
- if(alpm_pkg_load(argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
+ if(alpm_pkg_load(argv[1], 1, PM_VERIFYSIG_OPTIONAL, &pkg) == -1
|| pkg == NULL) {
switch(pm_errno) {
case PM_ERR_PKG_OPEN:
--
1.7.5.2
5
30
Signed-off-by: Florian Pritz <bluewind(a)xinu.at>
---
scripts/makepkg.sh.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index dfb7976..78cd4cf 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -977,7 +977,7 @@ find_libprovides() {
soarch=$(LC_ALL=C readelf -h "$filename" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
# get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
- [ -z "$sofile" ] && sofile="${$filename##*/}"
+ [ -z "$sofile" ] && sofile="${filename##*/}"
# extract the library name: libfoo.so
soname="${sofile%%\.so\.*}.so"
--
1.7.5.4
2
1
[pacman-dev] Package checking options (was: Changed all references to signature verification level in libalpm symbols to 'verifysig'.)
by Dan McGee 17 Jun '11
by Dan McGee 17 Jun '11
17 Jun '11
On Sun, Jun 12, 2011 at 3:15 AM, Kerrick Staley <mail(a)kerrickstaley.com> wrote:
> I inadvertently broke my email account when I configured
> git-send-mail, and I only just realized it. Everything I've sent to
> the list since then didn't go through, so I'm resending this message,
> originally sent June 5 (I edited/updated it).
>
> Whatever we call the variable doesn't really matter; I like SigLevel.
>
> I'm working on a patch that will implement the below behavior. It's
> just taking a while because it's somewhat complicated.
>
> ========
>
> Config:
>
> # Action to take (warn or abort) when packages and databases are
> unsigned but were previously signed
> SigPreviouslySigned = warn
>
> # Action to take (accept, warn, or abort) when neither the package nor
> the database have a signature
> SigNoSignature = warn
>
> # Action to take (accept, warn, or abort) when a package is signed but
> the database is unsigned
> # SigDatabaseUnsigned = accept
>
> # Action to take (accept, warn, or abort) when a package is unsigned
> but has a SHA256 hash in a signed database
> # SigHashed = accept
This is absurd as far as configuration goes. Why would we have 126
separate directives for what boils down to one thing, which as Allan
and I said, could be called "CheckLevel"?
~~~~
CheckLevel = Required SignedPackage SignedDatabase NoAllowUnknown
[another-repo]
CheckLevel = Optional
[someones-repo]
CheckLevel = NoSignedDatabase AllowUnknown
[insecureRepo]
CheckLevel = Never
~~~~
SigPreviouslySigned- an interesting thought, but definitely not
something we need on first pass- there are also a multitude of issues
here considering everyone starts from a different point. If you want
to be protected against this kind of attack, just use
Required/Always/whatever we call it.
SigHashed- covered by my previous suggestion; here it would be
"CheckLevel = Required SignedDatabase NoSignedPackage"
> ========
>
> A) When handling a given situation, there are three actions that can be taken:
> 1. The situation is accepted silently.
> 2. The situation is accepted with a warning.
> 3. Installation/update is aborted, unless an override flag is passed,
> in which case a warning will be given.
>
> B) For a database, consider whether it should have a signature:
> 1. If SigDatabaseUnsigned = abort, but the .sig file cannot be
> downloaded, then keep checking servers until a .sig can be gotten, and
> give a warning each time a .sig download returns a 404.
> 2. If not (1) but, based on the various config settings, having an
> unsigned database would result in more warnings or aborts than a
> signed one, then check servers for a .sig until you get a .sig or you
> get 3 404's; if you get 3 404's, rescan through the list from the
> beginning, not checking for .sig's this time. Again, give a warning
> whenever a 404 happens.
> 3. If not (1)/(2), don't check for .sig's.
>
> C) For a package, consider whether it should have a signature:
> 1. If the package was previously signed but now isn't, act based on
> SigPreviouslySigned.
> 2. For local packages, if the package indicates it should have a
> signature (mechanism to be implemented) but it doesn't, abort.
>
> D) Outcomes for package/database signature validity ("signed" means
> GPGME_SIGSUM_VALID w/ GPGME_VALIDITY_{FULL,ULTIMATE}; "unsigned" means
> GPGME_SIGSUM_KEY_MISSING or no signature present, "bad" means anything
> else):
> 1. The package or database or both have bad signatures. Abort
> (could happen during database unpacking; the rest only happen on
> package check).
> 2. The package and database are signed. Accept.
> 3. The package is unsigned but the database is signed and the database
> uses SHA256. Act based on SigHashed.
> 4. The package is signed but the database is unsigned. Act based on
> SigDatabaseUnsigned.
> 5. The package is unsigned and the database is unsigned. Act based on
> SigNoSignature.
>
> ========
>
> Notes:
>
> I invented the config names more or less randomly; if you have strong
> objections, we'll change them, otherwise let's go with these.
I have objections on your way of going about business here. I present
what i thought was a reasonable approach, got some feedback by Allan,
and then you attempt to throw something completely different at us
without really responding to what is wrong with my proposal.
I'm trying my hardest to not get seen as a stick in the mud and
impediment to progress here, but it is damn hard to keep my cool when
my years of experience with this codebase gets shoved aside without so
much as a "I don't think you considered this" bit of feedback. My
ideas tend to be backed by those years of experience, and adding
config options is not something we like to do willy-nilly, nor do we
want a complicated config file.
> I've made pmsiglevel_t into a struct with 4 enum members; I'm
> currently passing it around by value (not with pointers); please give
> me a heads-up if you don't think I should do it this way.
The usual preference in C is to use bitflags for things like this.
> No marginal signatures should come up, because I don't think we should
> use such signatures during the interim when not all developers have
> fully validated keys; a developer's key can just be excluded from
> pacman-keyring until it is fully validated.
That is a pretty bold assumption. You do realize there are more repos
out there that are not provided by a distro that people might want to
use and have signatures involved, right?
-Dan
3
4
This is a proposed new siglevel enum that will allow configuration of
all the various combinations of signature checking. It is done via
bitflags. To get any checking at all, at least one of PM_CHECK_PACKAGE
or PM_CHECK_DATABASE must be flipped on. These can be made optional on
an independent basis. Additional flags exist for UNKNOWN and MARGINAL
signatures.
Proof of concept only; still missing pieces here to be implemented like
the actual handling of UNKNOWN/MARGINAL.
---
lib/libalpm/alpm.h | 37 ++++++++++++++++++++++++-------------
lib/libalpm/be_package.c | 12 ++++++------
lib/libalpm/be_sync.c | 23 +++++++++++------------
lib/libalpm/db.c | 33 +++++++++++++--------------------
lib/libalpm/db.h | 4 ++--
lib/libalpm/dload.c | 5 ++---
lib/libalpm/handle.c | 14 +++++++-------
lib/libalpm/handle.h | 2 +-
lib/libalpm/package.h | 2 +-
lib/libalpm/signing.c | 15 ---------------
lib/libalpm/signing.h | 1 -
lib/libalpm/sync.c | 6 +++---
src/pacman/conf.c | 38 ++++++++++++++++++++------------------
src/pacman/conf.h | 2 +-
src/pacman/query.c | 2 +-
src/pacman/sync.c | 2 +-
src/pacman/upgrade.c | 4 ++--
src/util/cleanupdelta.c | 3 ++-
src/util/testdb.c | 3 ++-
src/util/testpkg.c | 3 ++-
20 files changed, 101 insertions(+), 110 deletions(-)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index b62c62d..bdb2383 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -63,12 +63,16 @@ typedef enum _pmpkgreason_t {
/**
* GPG signature verification options
*/
-typedef enum _pgp_verify_t {
- PM_PGP_VERIFY_UNKNOWN,
- PM_PGP_VERIFY_NEVER,
- PM_PGP_VERIFY_OPTIONAL,
- PM_PGP_VERIFY_ALWAYS
-} pgp_verify_t;
+typedef enum _pmsiglevel_t {
+ PM_SIG_PACKAGE = (1 << 0),
+ PM_SIG_PACKAGE_OPTIONAL = (1 << 1),
+ PM_SIG_DATABASE = (1 << 2),
+ PM_SIG_DATABASE_OPTIONAL = (1 << 3),
+ PM_SIG_UNKNOWN_OK = (1 << 4),
+ PM_SIG_MARGINAL_OK = (1 << 5),
+
+ PM_SIG_USE_DEFAULT = (1 << 31),
+} pmsiglevel_t;
/*
* Structures
@@ -247,8 +251,8 @@ int alpm_option_set_usedelta(pmhandle_t *handle, int usedelta);
int alpm_option_get_checkspace(pmhandle_t *handle);
int alpm_option_set_checkspace(pmhandle_t *handle, int checkspace);
-pgp_verify_t alpm_option_get_default_sigverify(pmhandle_t *handle);
-int alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t level);
+pmsiglevel_t alpm_option_get_default_siglevel(pmhandle_t *handle);
+int alpm_option_set_default_siglevel(pmhandle_t *handle, pmsiglevel_t level);
/** @} */
@@ -276,12 +280,12 @@ alpm_list_t *alpm_option_get_syncdbs(pmhandle_t *handle);
/** Register a sync database of packages.
* @param handle the context handle
* @param treename the name of the sync repository
- * @param check_sig what level of signature checking to perform on the
+ * @param level what level of signature checking to perform on the
* database; note that this must be a '.sig' file type verification
* @return a pmdb_t* on success (the value), NULL on error
*/
pmdb_t *alpm_db_register_sync(pmhandle_t *handle, const char *treename,
- pgp_verify_t check_sig);
+ pmsiglevel_t level);
/** Unregister a package database.
* @param db pointer to the package database to unregister
@@ -301,6 +305,14 @@ int alpm_db_unregister_all(pmhandle_t *handle);
*/
const char *alpm_db_get_name(const pmdb_t *db);
+/** Get the signature verification level for a database.
+ * Will return the default verification level if this database is set up
+ * with PM_SIG_USE_DEFAULT.
+ * @param db pointer to the package database
+ * @return the signature verification level
+ */
+pmsiglevel_t alpm_db_get_siglevel(pmdb_t *db);
+
/** Check the validity of a database.
* This is most useful for sync databases and verifying signature status.
* If invalid, the handle error code will be set accordingly.
@@ -377,13 +389,13 @@ int alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason);
* @param filename location of the package tarball
* @param full whether to stop the load after metadata is read or continue
* through the full archive
- * @param check_sig what level of package signature checking to perform on the
+ * @param level what level of package signature checking to perform on the
* package; note that this must be a '.sig' file type verification
* @param pkg address of the package pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int alpm_pkg_load(pmhandle_t *handle, const char *filename, int full,
- pgp_verify_t check_sig, pmpkg_t **pkg);
+ pmsiglevel_t level, pmpkg_t **pkg);
/** Free a package.
* @param pkg package pointer to free
@@ -622,7 +634,6 @@ alpm_list_t *alpm_pkg_unused_deltas(pmpkg_t *pkg);
int alpm_pkg_check_pgp_signature(pmpkg_t *pkg);
int alpm_db_check_pgp_signature(pmdb_t *db);
-int alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify);
/*
* Deltas
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index a0261d0..4e09d3a 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -230,7 +230,7 @@ static int parse_descfile(pmhandle_t *handle, struct archive *a, pmpkg_t *newpkg
*/
pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
int full, const char *md5sum, const char *base64_sig,
- pgp_verify_t check_sig)
+ pmsiglevel_t level)
{
int ret;
int config = 0;
@@ -267,11 +267,11 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
}
_alpm_log(handle, PM_LOG_DEBUG, "base64_sig: %s\n", base64_sig);
- if(check_sig != PM_PGP_VERIFY_NEVER) {
+ if(level & PM_SIG_PACKAGE) {
_alpm_log(handle, PM_LOG_DEBUG, "checking signature for %s\n", pkgfile);
ret = _alpm_gpgme_checksig(handle, pkgfile, base64_sig);
- if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
- (check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
+ if((!(level & PM_SIG_PACKAGE_OPTIONAL) && ret != 0) ||
+ ((level & PM_SIG_PACKAGE_OPTIONAL) && ret == 1)) {
alpm_pkg_free(newpkg);
RET_ERR(handle, PM_ERR_SIG_INVALID, NULL);
}
@@ -384,12 +384,12 @@ error:
}
int SYMEXPORT alpm_pkg_load(pmhandle_t *handle, const char *filename, int full,
- pgp_verify_t check_sig, pmpkg_t **pkg)
+ pmsiglevel_t level, pmpkg_t **pkg)
{
CHECK_HANDLE(handle, return -1);
ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
- *pkg = _alpm_pkg_load_internal(handle, filename, full, NULL, NULL, check_sig);
+ *pkg = _alpm_pkg_load_internal(handle, filename, full, NULL, NULL, level);
if(*pkg == NULL) {
/* pm_errno is set by pkg_load */
return -1;
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 3a8bde0..8602d5a 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -69,7 +69,7 @@ static char *get_sync_dir(pmhandle_t *handle)
static int sync_db_validate(pmdb_t *db)
{
- pgp_verify_t check_sig;
+ pmsiglevel_t level;
if(db->valid) {
return 0;
@@ -77,9 +77,9 @@ static int sync_db_validate(pmdb_t *db)
/* this takes into account the default verification level if UNKNOWN
* was assigned to this db */
- check_sig = _alpm_db_get_sigverify_level(db);
+ level = alpm_db_get_siglevel(db);
- if(check_sig != PM_PGP_VERIFY_NEVER) {
+ if(level & PM_SIG_DATABASE) {
int ret;
const char *dbpath = _alpm_db_path(db);
if(!dbpath) {
@@ -97,8 +97,8 @@ static int sync_db_validate(pmdb_t *db)
_alpm_log(db->handle, PM_LOG_DEBUG, "checking signature for %s\n",
db->treename);
ret = _alpm_gpgme_checksig(db->handle, dbpath, NULL);
- if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
- (check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
+ if((!(level & PM_SIG_DATABASE_OPTIONAL) && ret != 0) ||
+ ((level & PM_SIG_DATABASE_OPTIONAL) && ret == 1)) {
db->valid = 0;
RET_ERR(db->handle, PM_ERR_SIG_INVALID, -1);
}
@@ -154,7 +154,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
int ret = -1;
mode_t oldmask;
pmhandle_t *handle;
- pgp_verify_t check_sig;
+ pmsiglevel_t level;
/* Sanity checks */
ASSERT(db != NULL, return -1);
@@ -170,7 +170,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
if(!syncpath) {
return -1;
}
- check_sig = _alpm_db_get_sigverify_level(db);
+ level = alpm_db_get_siglevel(db);
for(i = db->servers; i; i = i->next) {
const char *server = i->data;
@@ -185,8 +185,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
ret = _alpm_download(handle, fileurl, syncpath, force, 0, 0);
- if(ret == 0 && (check_sig == PM_PGP_VERIFY_ALWAYS ||
- check_sig == PM_PGP_VERIFY_OPTIONAL)) {
+ if(ret == 0 && (level & PM_SIG_DATABASE)) {
/* an existing sig file is no good at this point */
char *sigpath = _alpm_db_sig_path(db);
if(!sigpath) {
@@ -196,7 +195,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
unlink(sigpath);
free(sigpath);
- int errors_ok = (check_sig == PM_PGP_VERIFY_OPTIONAL);
+ int errors_ok = (level & PM_SIG_DATABASE_OPTIONAL);
/* if we downloaded a DB, we want the .sig from the same server */
snprintf(fileurl, len, "%s/%s.db.sig", server, db->treename);
@@ -579,7 +578,7 @@ struct db_operations sync_db_ops = {
};
pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename,
- pgp_verify_t level)
+ pmsiglevel_t level)
{
pmdb_t *db;
@@ -591,7 +590,7 @@ pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename,
}
db->ops = &sync_db_ops;
db->handle = handle;
- db->pgp_verify = level;
+ db->siglevel = level;
sync_db_validate(db);
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 55c5bd4..37a2a6d 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -46,7 +46,7 @@
/** Register a sync database of packages. */
pmdb_t SYMEXPORT *alpm_db_register_sync(pmhandle_t *handle, const char *treename,
- pgp_verify_t check_sig)
+ pmsiglevel_t level)
{
/* Sanity checks */
CHECK_HANDLE(handle, return NULL);
@@ -55,7 +55,7 @@ pmdb_t SYMEXPORT *alpm_db_register_sync(pmhandle_t *handle, const char *treename
/* Do not register a database if a transaction is on-going */
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, NULL));
- return _alpm_db_register_sync(handle, treename, check_sig);
+ return _alpm_db_register_sync(handle, treename, level);
}
/* Helper function for alpm_db_unregister{_all} */
@@ -211,23 +211,6 @@ int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url)
return 1;
}
-/** Set the verify gpg signature option for a database.
- * @param db database pointer
- * @param verify enum pgp_verify_t
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
- */
-int SYMEXPORT alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify)
-{
- /* Sanity checks */
- ASSERT(db != NULL, return -1);
- db->handle->pm_errno = 0;
-
- db->pgp_verify = verify;
- _alpm_log(db->handle, PM_LOG_DEBUG, "adding VerifySig option to database '%s': %d\n",
- db->treename, verify);
-
- return 0;
-}
/** Get the name of a package database. */
const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db)
@@ -236,6 +219,16 @@ const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db)
return db->treename;
}
+/** Get the signature verification level for a database. */
+pmsiglevel_t SYMEXPORT alpm_db_get_siglevel(pmdb_t *db)
+{
+ if(db->siglevel & PM_SIG_USE_DEFAULT) {
+ return alpm_option_get_default_siglevel(db->handle);
+ } else {
+ return db->siglevel;
+ }
+}
+
/** Check the validity of a database. */
int SYMEXPORT alpm_db_valid(pmdb_t *db)
{
@@ -329,7 +322,7 @@ pmdb_t *_alpm_db_new(const char *treename, int is_local)
CALLOC(db, 1, sizeof(pmdb_t), return NULL);
STRDUP(db->treename, treename, return NULL);
db->is_local = is_local;
- db->pgp_verify = PM_PGP_VERIFY_UNKNOWN;
+ db->siglevel = 0;
return db;
}
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 5e9c9c1..af57b87 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -63,7 +63,7 @@ struct __pmdb_t {
pmpkghash_t *pkgcache;
alpm_list_t *grpcache;
alpm_list_t *servers;
- pgp_verify_t pgp_verify;
+ pmsiglevel_t siglevel;
struct db_operations *ops;
};
@@ -78,7 +78,7 @@ int _alpm_db_cmp(const void *d1, const void *d2);
alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles);
pmdb_t *_alpm_db_register_local(pmhandle_t *handle);
pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename,
- pgp_verify_t level);
+ pmsiglevel_t level);
void _alpm_db_unregister(pmdb_t *db);
/* be_*.c, backend specific calls */
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 9354562..3a5ceb7 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -353,11 +353,10 @@ char SYMEXPORT *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url)
_alpm_log(handle, PM_LOG_DEBUG, "successfully downloaded %s\n", url);
/* attempt to download the signature */
- if(ret == 0 && (handle->sigverify == PM_PGP_VERIFY_ALWAYS ||
- handle->sigverify == PM_PGP_VERIFY_OPTIONAL)) {
+ if(ret == 0 && (handle->siglevel & PM_SIG_PACKAGE)) {
char *sig_url;
size_t len;
- int errors_ok = (handle->sigverify == PM_PGP_VERIFY_OPTIONAL);
+ int errors_ok = (handle->siglevel & PM_SIG_PACKAGE_OPTIONAL);
len = strlen(url) + 5;
CALLOC(sig_url, len, sizeof(char), RET_ERR(handle, PM_ERR_MEMORY, NULL));
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index d2bb4f6..8cb8c08 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -43,7 +43,8 @@ pmhandle_t *_alpm_handle_new()
CALLOC(handle, 1, sizeof(pmhandle_t), return NULL);
- handle->sigverify = PM_PGP_VERIFY_OPTIONAL;
+ handle->siglevel = PM_SIG_PACKAGE | PM_SIG_PACKAGE_OPTIONAL |
+ PM_SIG_DATABASE | PM_SIG_DATABASE_OPTIONAL;
return handle;
}
@@ -520,18 +521,17 @@ int SYMEXPORT alpm_option_set_checkspace(pmhandle_t *handle, int checkspace)
return 0;
}
-int SYMEXPORT alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t level)
+int SYMEXPORT alpm_option_set_default_siglevel(pmhandle_t *handle, pmsiglevel_t level)
{
CHECK_HANDLE(handle, return -1);
- ASSERT(level != PM_PGP_VERIFY_UNKNOWN, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
- handle->sigverify = level;
+ handle->siglevel = level;
return 0;
}
-pgp_verify_t SYMEXPORT alpm_option_get_default_sigverify(pmhandle_t *handle)
+pmsiglevel_t SYMEXPORT alpm_option_get_default_siglevel(pmhandle_t *handle)
{
- CHECK_HANDLE(handle, return PM_PGP_VERIFY_UNKNOWN);
- return handle->sigverify;
+ CHECK_HANDLE(handle, return -1);
+ return handle->siglevel;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index bace805..1f81c74 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -69,7 +69,7 @@ struct __pmhandle_t {
char *arch; /* Architecture of packages we should allow */
int usedelta; /* Download deltas if possible */
int checkspace; /* Check disk space before installing */
- pgp_verify_t sigverify; /* Default signature verification level */
+ pmsiglevel_t siglevel; /* Default signature verification level */
/* error code */
enum _pmerrno_t pm_errno;
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index bc5b267..19b958f 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -144,7 +144,7 @@ void _alpm_pkg_free_trans(pmpkg_t *pkg);
pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
int full, const char *md5sum, const char *base64_sig,
- pgp_verify_t check_sig);
+ pmsiglevel_t level);
int _alpm_pkg_cmp(const void *p1, const void *p2);
int _alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg);
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 11886ec..2765756 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -358,21 +358,6 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
#endif
/**
- * Determines the necessity of checking for a valid PGP signature
- * @param db the sync database to query
- *
- * @return signature verification level
- */
-pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
-{
- if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) {
- return db->pgp_verify;
- } else {
- return alpm_option_get_default_sigverify(db->handle);
- }
-}
-
-/**
* Check the PGP signature for the given package file.
* @param pkg the package to check
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index fdf81fc..14b2ad7 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -23,7 +23,6 @@
int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
const char *base64_sig);
-pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db);
#endif /* _ALPM_SIGNING_H */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 0573573..4a52c5c 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -865,7 +865,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
int percent = (current * 100) / numtargs;
const char *filename;
char *filepath;
- pgp_verify_t check_sig;
+ pmsiglevel_t level;
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
numtargs, current);
@@ -876,7 +876,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
filename = alpm_pkg_get_filename(spkg);
filepath = _alpm_filecache_find(handle, filename);
pmdb_t *sdb = alpm_pkg_get_db(spkg);
- check_sig = _alpm_db_get_sigverify_level(sdb);
+ level = alpm_db_get_siglevel(sdb);
/* load the package file and replace pkgcache entry with it in the target list */
/* TODO: alpm_pkg_get_db() will not work on this target anymore */
@@ -884,7 +884,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
"replacing pkgcache entry with package file for target %s\n",
spkg->name);
pmpkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum,
- spkg->base64_sig, check_sig);
+ spkg->base64_sig, level);
if(!pkgfile) {
errors++;
*data = alpm_list_add(*data, strdup(filename));
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 1ea9e11..3ebab43 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -52,7 +52,7 @@ config_t *config_new(void)
newconfig->op = PM_OP_MAIN;
newconfig->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
newconfig->configfile = strdup(CONFFILE);
- newconfig->sigverify = PM_PGP_VERIFY_UNKNOWN;
+ newconfig->siglevel = PM_SIG_USE_DEFAULT;
return newconfig;
}
@@ -222,17 +222,18 @@ int config_set_arch(const char *arch)
return 0;
}
-static pgp_verify_t option_verifysig(const char *value)
+static pmsiglevel_t option_verifysig(const char *value)
{
- pgp_verify_t level;
+ pmsiglevel_t level;
if(strcmp(value, "Always") == 0) {
- level = PM_PGP_VERIFY_ALWAYS;
+ level = PM_SIG_PACKAGE | PM_SIG_DATABASE;
} else if(strcmp(value, "Optional") == 0) {
- level = PM_PGP_VERIFY_OPTIONAL;
+ level = PM_SIG_PACKAGE | PM_SIG_PACKAGE_OPTIONAL |
+ PM_SIG_DATABASE | PM_SIG_DATABASE_OPTIONAL;
} else if(strcmp(value, "Never") == 0) {
- level = PM_PGP_VERIFY_NEVER;
+ level = 0;
} else {
- level = PM_PGP_VERIFY_UNKNOWN;
+ return -1;
}
pm_printf(PM_LOG_DEBUG, "config: VerifySig = %s (%d)\n", value, level);
return level;
@@ -359,9 +360,9 @@ static int _parse_options(const char *key, char *value,
}
FREELIST(methods);
} else if(strcmp(key, "VerifySig") == 0) {
- pgp_verify_t level = option_verifysig(value);
- if(level != PM_PGP_VERIFY_UNKNOWN) {
- config->sigverify = level;
+ pmsiglevel_t level = option_verifysig(value);
+ if(level != -1) {
+ config->siglevel = level;
} else {
pm_printf(PM_LOG_ERROR,
_("config file %s, line %d: directive '%s' has invalid value '%s'\n"),
@@ -484,8 +485,8 @@ static int setup_libalpm(void)
alpm_option_set_cachedirs(handle, config->cachedirs);
}
- if(config->sigverify != PM_PGP_VERIFY_UNKNOWN) {
- alpm_option_set_default_sigverify(handle, config->sigverify);
+ if(config->siglevel != PM_SIG_USE_DEFAULT) {
+ alpm_option_set_default_siglevel(handle, config->siglevel);
}
if(config->xfercommand) {
@@ -518,7 +519,7 @@ struct section_t {
char *name;
int is_options;
/* db section option gathering */
- pgp_verify_t sigverify;
+ pmsiglevel_t siglevel;
alpm_list_t *servers;
};
@@ -545,7 +546,7 @@ static int finish_section(struct section_t *section, int parse_options)
}
/* if we are not looking at options sections only, register a db */
- db = alpm_db_register_sync(config->handle, section->name, section->sigverify);
+ db = alpm_db_register_sync(config->handle, section->name, section->siglevel);
if(db == NULL) {
pm_printf(PM_LOG_ERROR, _("could not register '%s' database (%s)\n"),
section->name, alpm_strerror(alpm_errno(config->handle)));
@@ -568,7 +569,7 @@ static int finish_section(struct section_t *section, int parse_options)
cleanup:
alpm_list_free(section->servers);
section->servers = NULL;
- section->sigverify = 0;
+ section->siglevel = PM_SIG_USE_DEFAULT;
free(section->name);
section->name = NULL;
return ret;
@@ -726,9 +727,9 @@ static int _parseconfig(const char *file, struct section_t *section,
}
section->servers = alpm_list_add(section->servers, strdup(value));
} else if(strcmp(key, "VerifySig") == 0) {
- pgp_verify_t level = option_verifysig(value);
- if(level != PM_PGP_VERIFY_UNKNOWN) {
- section->sigverify = level;
+ pmsiglevel_t level = option_verifysig(value);
+ if(level != -1) {
+ section->siglevel = level;
} else {
pm_printf(PM_LOG_ERROR,
_("config file %s, line %d: directive '%s' has invalid value '%s'\n"),
@@ -763,6 +764,7 @@ int parseconfig(const char *file)
int ret;
struct section_t section;
memset(§ion, 0, sizeof(struct section_t));
+ section.siglevel = PM_SIG_USE_DEFAULT;
/* the config parse is a two-pass affair. We first parse the entire thing for
* the [options] section so we can get all default and path options set.
* Next, we go back and parse everything but [options]. */
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 4c44bfd..5e1a5b1 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -71,7 +71,7 @@ typedef struct __config_t {
unsigned short noask;
unsigned int ask;
pmtransflag_t flags;
- pgp_verify_t sigverify;
+ pmsiglevel_t siglevel;
/* conf file options */
/* I Love Candy! */
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 38b3752..6b0011c 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -549,7 +549,7 @@ int pacman_query(alpm_list_t *targets)
char *strname = alpm_list_getdata(i);
if(config->op_q_isfile) {
- alpm_pkg_load(config->handle, strname, 1, PM_PGP_VERIFY_NEVER, &pkg);
+ alpm_pkg_load(config->handle, strname, 1, 0, &pkg);
} else {
pkg = alpm_db_get_pkg(db_local, strname);
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 539e651..24e5b24 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -220,7 +220,7 @@ static int sync_cleancache(int level)
/* attempt to load the package, prompt removal on failures as we may have
* files here that aren't valid packages. we also don't need a full
* load of the package, just the metadata. */
- if(alpm_pkg_load(config->handle, path, 0, PM_PGP_VERIFY_NEVER, &localpkg) != 0
+ if(alpm_pkg_load(config->handle, path, 0, 0, &localpkg) != 0
|| localpkg == NULL) {
if(yesno(_("File %s does not seem to be a valid package, remove it?"),
path)) {
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 35624eb..a08a9d6 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -42,7 +42,7 @@
int pacman_upgrade(alpm_list_t *targets)
{
alpm_list_t *i, *data = NULL;
- pgp_verify_t check_sig = alpm_option_get_default_sigverify(config->handle);
+ pmsiglevel_t level = alpm_option_get_default_siglevel(config->handle);
int retval = 0;
if(targets == NULL) {
@@ -76,7 +76,7 @@ int pacman_upgrade(alpm_list_t *targets)
char *targ = alpm_list_getdata(i);
pmpkg_t *pkg;
- if(alpm_pkg_load(config->handle, targ, 1, check_sig, &pkg) != 0) {
+ if(alpm_pkg_load(config->handle, targ, 1, level, &pkg) != 0) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerror(alpm_errno(config->handle)));
trans_release();
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 5ee59db..3809525 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -71,11 +71,12 @@ static void checkdbs(const char *dbpath, alpm_list_t *dbnames) {
char syncdbpath[PATH_MAX];
pmdb_t *db = NULL;
alpm_list_t *i;
+ const pmsiglevel_t level = PM_SIG_DATABASE | PM_SIG_DATABASE_OPTIONAL;
for(i = dbnames; i; i = alpm_list_next(i)) {
char *dbname = alpm_list_getdata(i);
snprintf(syncdbpath, PATH_MAX, "%s/sync/%s", dbpath, dbname);
- db = alpm_db_register_sync(handle, dbname, PM_PGP_VERIFY_OPTIONAL);
+ db = alpm_db_register_sync(handle, dbname, level);
if(db == NULL) {
fprintf(stderr, "error: could not register sync database (%s)\n",
alpm_strerror(alpm_errno(handle)));
diff --git a/src/util/testdb.c b/src/util/testdb.c
index f45b4a9..54a7040 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -149,10 +149,11 @@ static int check_syncdbs(alpm_list_t *dbnames) {
int ret = 0;
pmdb_t *db = NULL;
alpm_list_t *i, *pkglist, *syncpkglist = NULL;
+ const pmsiglevel_t level = PM_SIG_DATABASE | PM_SIG_DATABASE_OPTIONAL;
for(i = dbnames; i; i = alpm_list_next(i)) {
char *dbname = alpm_list_getdata(i);
- db = alpm_db_register_sync(handle, dbname, PM_PGP_VERIFY_OPTIONAL);
+ db = alpm_db_register_sync(handle, dbname, level);
if(db == NULL) {
fprintf(stderr, "error: could not register sync database (%s)\n",
alpm_strerror(alpm_errno(handle)));
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index c6f02e3..29effd9 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -43,6 +43,7 @@ int main(int argc, char *argv[])
pmhandle_t *handle;
enum _pmerrno_t err;
pmpkg_t *pkg = NULL;
+ const pmsiglevel_t level = PM_SIG_PACKAGE | PM_SIG_PACKAGE_OPTIONAL;
if(argc != 2) {
fprintf(stderr, "usage: %s <package file>\n", BASENAME);
@@ -58,7 +59,7 @@ int main(int argc, char *argv[])
/* let us get log messages from libalpm */
alpm_option_set_logcb(handle, output_cb);
- if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
+ if(alpm_pkg_load(handle, argv[1], 1, level, &pkg) == -1
|| pkg == NULL) {
enum _pmerrno_t err = alpm_errno(handle);
switch(err) {
--
1.7.5.4
2
1
This reworks the implmentation of libprovides for the following
benefits:
- Moves functionality from write_pkginfo() to find_libprovides()
- Only calculates the version for libraries specifically requested
and not all libraries. This has the disadvantage of running find
over the $pkgdir for as many libraries as needed, but is unlikely
to be an issue due to caching.
- The order of the provides array in the PKGBUILD is kept in the
package
- There are more warning messages when things fail and those that
were there are no longer errors (as I do not think failure of
libprovides should result in complete packaging failure)
- It is now modular so can be easy extended to other library types
other than ELF *.so.
Signed-off-by: Allan McRae <allan(a)archlinux.org>
---
I cut and pasted the actual finding of the soarch/soversion etc, but that obviously
needs fixed. WTF is the comment "# 64" supposed to mean? I also would like
documentation about why we need the [ -z "$sofile" ] test (reminder: needs adjusted
to double bracket format). Also, why do we extract "soname" when that should be
what was already given in the provides array?
scripts/makepkg.sh.in | 83 ++++++++++++++++++++++++++-----------------------
1 files changed, 44 insertions(+), 39 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 7527329..dae229a 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -980,30 +980,47 @@ find_libdepends() {
}
find_libprovides() {
- local libprovides
- find "$pkgdir" -type f -name \*.so\* | while read filename
- do
- # check if we really have a shared object
- if LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
- # 64
- soarch=$(LC_ALL=C readelf -h "$filename" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
- # get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
- sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
- [ -z "$sofile" ] && sofile="${$filename##*/}"
-
- # extract the library name: libfoo.so
- soname="${sofile%%\.so\.*}.so"
- # extract the major version: 1
- soversion="${sofile##*\.so\.}"
- if in_array "${soname}" ${provides[@]}; then
- if ! in_array "${soname}=${soversion}-${soarch}" ${libprovides[@]}; then
- # libfoo.so=1-64
- echo "${soname}=${soversion}-${soarch}"
- libprovides=(${libprovides[@]} "${soname}=${soversion}-${soarch}")
+ local libprovides missing
+ for p in ${provides[@]}; do
+ missing=0
+ case "$p" in
+ *.so)
+ filename=$(find "$pkgdir" -type f -name $p\*)
+ if [[ $filename ]]; then
+ # check if we really have a shared object
+ if LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
+ # 64
+ soarch=$(LC_ALL=C readelf -h "$filename" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
+ # get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
+ sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
+ [ -z "$sofile" ] && sofile="${$filename##*/}"
+
+ # extract the library name: libfoo.so
+ soname="${sofile%%\.so\.*}.so"
+ # extract the major version: 1
+ soversion="${sofile##*\.so\.}"
+
+ libprovides=(${libprovides[@]} "${soname}=${soversion}-${soarch}")
+ else
+ warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
+ libprovides=(${libprovides[@]} "$p")
+ fi
+ else
+ libprovides=(${libprovides[@]} "$p")
+ missing=1
fi
- fi
- fi
+ ;;
+ *)
+ libprovides=(${libprovides[@]} "$p")
+ ;;
+ esac
+
+ if (( missing )); then
+ warning "$(gettext "Can not find library listed in %s: %s")" "'provides'" "$p"
+ fi
done
+
+ echo ${libprovides[@]}
}
write_pkginfo() {
@@ -1037,13 +1054,15 @@ write_pkginfo() {
[[ $groups ]] && printf "group = %s\n" "${groups[@]}"
[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]}"
[[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}"
+
+ provides=("$(find_libprovides)")
+ [[ $provides ]] && printf "provides = %s\n" "${provides[@]}"
+
[[ $backup ]] && printf "backup = %s\n" "${backup[@]}"
- local it
- libprovides=$(find_libprovides)
+ local it
libdepends=$(find_libdepends)
- provides=("${provides[@]}" ${libprovides})
depends=("${depends[@]}" ${libdepends})
for it in "${depends[@]}"; do
@@ -1059,20 +1078,6 @@ write_pkginfo() {
fi
done
- for it in "${provides[@]}"; do
- # ignore versionless entires (those come from the PKGBUILD)
- if [[ $it = *.so ]]; then
- # check if the entry has been found by find_libprovides
- # if not, it's unneeded; tell the user so he can remove it
- if [[ ! $libprovides =~ (^|\s)${it}=.* ]]; then
- error "$(gettext "Can not find library listed in %s: %s")" "'provides'" "$it"
- return 1
- fi
- else
- echo "provides = $it"
- fi
- done
-
for it in "${packaging_options[@]}"; do
local ret="$(check_option $it)"
if [[ $ret != "?" ]]; then
--
1.7.5.4
2
1
[pacman-dev] [GIT] The official pacman repository branch, master, updated. v3.5.3-262-gd21f6ca
by danï¼ archlinux.org 15 Jun '11
by danï¼ archlinux.org 15 Jun '11
15 Jun '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The official pacman repository".
The branch, master has been updated
via d21f6ca4aa3209938fa312f29ac03446f57e6a66 (commit)
via 06cb713f3915cc858de0388b0a5232326101a9fa (commit)
via e27e658033d500c22b9dd4974fa3fbcc378f35b9 (commit)
via 53f4e431918fdfd4e2433c387da1c89c697613bf (commit)
via 4272b37d3d9f112b9f089dafc2e7538c4c24f7b2 (commit)
via 6f3a2145b0de7f27a1bf5932af3fe0a67171a881 (commit)
via 5f404f2cb78f48ddd90be0334fa2528961b17871 (commit)
via e92083798cdd98961e0d2befe25af7a8f96c9ab5 (commit)
via 5b33f48389531e47a0093e84feedce0f63a94c77 (commit)
via 700a5374f1c3ab87a194ad7e5472b72072d04454 (commit)
via 6eee3f6781b62f3a80697fbc7e3eeac0544e49e8 (commit)
via 4664a095a497de1b47d980863228860a6d19f286 (commit)
via 82a701401cd31621f87956dc60c97ab6fbee4add (commit)
via ef3ec2603dcef448399d20f1363b5d34c1443f56 (commit)
via 2f5f15727457260179c9328d96b6e2980b097f8c (commit)
via 71fd34e59603e95be79ab3399d9968b89f9df396 (commit)
via ee015f086f3c40390659bbc0129b7c08ffd0ed5f (commit)
via be972767358e6dfbb08686555d8e2c0176a55106 (commit)
via 76a991c117f3419e5cd630355b90876084d27c4b (commit)
via ba63e31cc7ecc9e7fccb68e9fa4e09c90a8d5c66 (commit)
via 0074cadb3bfdf5d89065e69eb93788ebcc9a6b58 (commit)
from c206b3a6d503e57691664b94e68ba85760bd0b6c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d21f6ca4aa3209938fa312f29ac03446f57e6a66
Author: Allan McRae <allan(a)archlinux.org>
Date: Wed Jun 15 16:02:22 2011 +1000
makepkg: create source package inside fakeroot
Create source package files inside the fakeroot environment to
ensure reasonable ownership of files within the archive.
Fixes FS#24330.
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 06cb713f3915cc858de0388b0a5232326101a9fa
Author: Allan McRae <allan(a)archlinux.org>
Date: Wed Jun 15 13:52:56 2011 +1000
Clean up makefile for script generation
We no longer have any python scripts in our scripts/ directory so
we can simplify the makefile a bit.
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit e27e658033d500c22b9dd4974fa3fbcc378f35b9
Author: Allan McRae <allan(a)archlinux.org>
Date: Mon Jun 13 22:36:41 2011 +1000
parse_options: adjust error messages
Provide consistent error messages for unknown long and short options.
Also get full string translation for the messages.
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 53f4e431918fdfd4e2433c387da1c89c697613bf
Author: Allan McRae <allan(a)archlinux.org>
Date: Thu Jun 9 21:08:40 2011 +1000
scripts/library: add README file
Add a README file to briefly document the code snippets in the scripts
library folder.
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 4272b37d3d9f112b9f089dafc2e7538c4c24f7b2
Author: Allan McRae <allan(a)archlinux.org>
Date: Thu Jun 9 20:43:25 2011 +1000
scripts: refactor output formatting functions
Move the common output formatting functions into a separate
library file and import that into each script. makepkg is
excluded due to its additional color formatting.
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 6f3a2145b0de7f27a1bf5932af3fe0a67171a881
Author: Allan McRae <allan(a)archlinux.org>
Date: Wed Jun 8 23:36:46 2011 +1000
makepkg: move option parsing code to separate file
This move the getopt replacement function parse_options out of
makepkg.sh.in and into a separate file. The code is inserted
into the relevant place in makepkg using m4.
This will allow the reuse of the option parsing code in other
scripts (i.e. pacman-key) while avoiding code duplication.
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 5f404f2cb78f48ddd90be0334fa2528961b17871
Merge: e920837 6eee3f6
Author: Dan McGee <dan(a)archlinux.org>
Date: Wed Jun 15 09:16:08 2011 -0500
Merge branch 'maint'
commit e92083798cdd98961e0d2befe25af7a8f96c9ab5
Author: Jakob Gruber <jakob.gruber(a)gmail.com>
Date: Wed Jun 15 11:04:09 2011 +0200
Ensure humanize_size works for negative values
Signed-off-by: Jakob Gruber <jakob.gruber(a)gmail.com>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 5b33f48389531e47a0093e84feedce0f63a94c77
Author: Jakob Gruber <jakob.gruber(a)gmail.com>
Date: Wed Jun 15 10:54:38 2011 +0200
Use pm_fprintpf in table_create_format
Signed-off-by: Jakob Gruber <jakob.gruber(a)gmail.com>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 700a5374f1c3ab87a194ad7e5472b72072d04454
Author: Allan McRae <allan(a)archlinux.org>
Date: Sat Jun 11 12:00:20 2011 +1000
makepkg: reword purge message
Clarfiy that it is unwanted files are being removed rather than "other"
files (whatever they are...).
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 82a701401cd31621f87956dc60c97ab6fbee4add
Author: Dan McGee <dan(a)archlinux.org>
Date: Tue Jun 14 10:31:51 2011 -0500
valgrind.supp: add known leak exposed by cURL
This one comes courtesy of OpenSSL and some static initialization.
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit ef3ec2603dcef448399d20f1363b5d34c1443f56
Author: Florian Pritz <bluewind(a)xinu.at>
Date: Thu Jun 9 23:17:06 2011 +0200
doc/PKGBUILD: misc changes
Acked-by: matt mooney <mfm(a)muteddisk.com>
Signed-off-by: Florian Pritz <bluewind(a)xinu.at>
commit 2f5f15727457260179c9328d96b6e2980b097f8c
Author: Dan McGee <dan(a)archlinux.org>
Date: Tue Jun 14 10:15:43 2011 -0500
Rename and rework signing helper methods
* Don't name static methods with a gpgme_ prefix to avoid confusion with
methods provided by the library. These are static and local to our
file so just give them sane non-prefixed names.
* Rework sigsum_test_bit() to not require assignment.
* Don't balk if there is more than one signature available (for now,
only check the first).
* Fix error codes in publicly visible methods to return -1, not 0, if pkg
or db are not provided.
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 71fd34e59603e95be79ab3399d9968b89f9df396
Author: Dan McGee <dan(a)archlinux.org>
Date: Tue Jun 14 10:09:35 2011 -0500
Alpm pkg accessors: ensure pkg argument is non-NULL
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit ee015f086f3c40390659bbc0129b7c08ffd0ed5f
Author: Dan McGee <dan(a)archlinux.org>
Date: Tue Jun 14 10:01:08 2011 -0500
Ensure handle is valid and pm_errno is reset when calling into API
We didn't do due diligence before and ensure prior pm_errno values
weren't influencing what happened in further ALPM calls. I observed one
case of early setup code setting pm_errno to PM_ERR_WRONG_ARGS and that
flag persisting the entire time we were calling library code.
Add a new CHECK_HANDLE() macro that does two things: 1) ensures the
handle variable passed to it is non-NULL and 2) clears any existing
pm_errno flag set on the handle. This macro can replace many places we
used the ASSERT(handle != NULL, ...) pattern before.
Several other other places only need a simple 'set to zero' of the
pm_errno field.
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit be972767358e6dfbb08686555d8e2c0176a55106
Author: Dan McGee <dan(a)archlinux.org>
Date: Tue Jun 14 09:32:39 2011 -0500
Avoid setting sigverify option twice
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 76a991c117f3419e5cd630355b90876084d27c4b
Author: Dan McGee <dan(a)archlinux.org>
Date: Tue Jun 14 09:30:46 2011 -0500
Conflict check and skip_remove code cleanups
* Move several variables into better scope
* const-ify a few variables
* Avoid duplicating filelists if it is unnecessary
* Better handling out out of memory condition when adding file conflicts
to our list
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit ba63e31cc7ecc9e7fccb68e9fa4e09c90a8d5c66
Author: Dan McGee <dan(a)archlinux.org>
Date: Thu Jun 9 15:23:24 2011 -0500
Small handle related cleanups
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 0074cadb3bfdf5d89065e69eb93788ebcc9a6b58
Author: Dan McGee <dan(a)archlinux.org>
Date: Thu Jun 9 15:18:47 2011 -0500
Add handle argument to _alpm_pkg_should_ignore()
This allows callers to retrieve it from wherever is convenient, which
may or may not be on the package object itself.
Signed-off-by: Dan McGee <dan(a)archlinux.org>
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile.am | 7 +-
doc/PKGBUILD.5.txt | 26 +++---
lib/libalpm/add.c | 5 +-
lib/libalpm/alpm.c | 2 +-
lib/libalpm/be_package.c | 5 +-
lib/libalpm/be_sync.c | 1 +
lib/libalpm/conflict.c | 85 +++++++++++++--------
lib/libalpm/db.c | 20 ++++-
lib/libalpm/deps.c | 9 ++-
lib/libalpm/dload.c | 2 +
lib/libalpm/handle.c | 94 ++++++++++++------------
lib/libalpm/package.c | 74 +++++++++++++++++--
lib/libalpm/package.h | 2 +-
lib/libalpm/remove.c | 12 ++--
lib/libalpm/signing.c | 76 +++++++++---------
lib/libalpm/sync.c | 23 +++---
lib/libalpm/trans.c | 16 ++--
lib/libalpm/util.h | 2 +
scripts/Makefile.am | 50 +++++++++----
scripts/library/README | 15 ++++
scripts/library/output_format.sh | 21 +++++
scripts/library/parse_options.sh | 87 +++++++++++++++++++++
scripts/makepkg.sh.in | 155 ++++++++++---------------------------
scripts/pacman-db-upgrade.sh.in | 9 +--
scripts/pacman-key.sh.in | 21 +-----
scripts/pkgdelta.sh.in | 16 +----
scripts/repo-add.sh.in | 22 +-----
src/pacman/conf.c | 1 -
src/pacman/util.c | 6 +-
valgrind.supp | 10 +++
30 files changed, 498 insertions(+), 376 deletions(-)
create mode 100644 scripts/library/README
create mode 100644 scripts/library/output_format.sh
create mode 100644 scripts/library/parse_options.sh
hooks/post-receive
--
The official pacman repository
1
0
[pacman-dev] [GIT] The official pacman repository branch, maint, updated. v3.5.3-5-g6eee3f6
by danï¼ archlinux.org 15 Jun '11
by danï¼ archlinux.org 15 Jun '11
15 Jun '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The official pacman repository".
The branch, maint has been updated
via 6eee3f6781b62f3a80697fbc7e3eeac0544e49e8 (commit)
via 4664a095a497de1b47d980863228860a6d19f286 (commit)
from 07e97a5f2c1e1039f35a7893d2be6abf07af690a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6eee3f6781b62f3a80697fbc7e3eeac0544e49e8
Author: Dan McGee <dan(a)archlinux.org>
Date: Wed Jun 15 09:10:33 2011 -0500
list_display: fix incorrect assignment
Commit 895a88886525d erroneously left this around.
Noticed-by: Jakob Gruber <jakob.gruber(a)gmail.com>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
commit 4664a095a497de1b47d980863228860a6d19f286
Author: Allan McRae <allan(a)archlinux.org>
Date: Mon Jun 13 21:53:23 2011 +1000
Fix man page generation for out of tree build
Fix failure at man page generation when building outside the source tree.
There may still be issues with other documentation types...
Signed-off-by: Allan McRae <allan(a)archlinux.org>
Signed-off-by: Dan McGee <dan(a)archlinux.org>
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile.am | 7 ++++---
src/pacman/util.c | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
hooks/post-receive
--
The official pacman repository
1
0
15 Jun '11
commit c1f742d7750a14 broke what was one of the tenants of out output-
if piping pacman output somewhere else, we shouldn't ever try to
line-wrap and indent print our output. This makes it easier for tools to
use output from pacman -Ss, -Qs, -Qi, etc. list_display() unfortunately
was given a default value of 80 rather than 0, so fix this.
Next, make some additional changes that ensure we don't insert an
unnecessary blank line if for some crazy reason the indent level (such
as on -Qi output) is greater than the number of columns. Accomplish this
by printing the first item unconditionally as we do in
list_display_linebreak().
Finally, teach indentprint to not wrap if the number of columns is less
than the indent level, this prevents some forms of ridiculous output
such as the following:
Install Date : Wed
08
Jun
2011
04:39:19
AM
CDT
Signed-off-by: Dan McGee <dan(a)archlinux.org>
---
For maint. Dave, looking forward to your feedback. :)
-Dan
src/pacman/util.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 508cc89..a6d150f 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -216,8 +216,9 @@ void indentprint(const char *str, int indent)
return;
}
- /* if we're not a tty, print without indenting */
- if(cols == 0) {
+ /* if we're not a tty, or our tty is not wide enough that wrapping even makes
+ * sense, print without indenting */
+ if(cols == 0 || indent > cols) {
printf("%s", str);
return;
}
@@ -450,12 +451,16 @@ void list_display(const char *title, const alpm_list_t *list)
if(!list) {
printf("%s\n", _("None"));
} else {
- int cols;
- const int maxcols = getcols(80);
- for(i = list, cols = len; i; i = alpm_list_next(i)) {
- char *str = alpm_list_getdata(i);
+ const int maxcols = getcols(0);
+ int cols = len;
+ const char *str = alpm_list_getdata(list);
+ printf("%s", str);
+ cols += string_length(str);
+ for(i = alpm_list_next(list), cols = len; i; i = alpm_list_next(i)) {
+ const char *str = alpm_list_getdata(i);
int s = string_length(str);
- if(cols + s + 2 >= maxcols) {
+ /* wrap only if we have enough usable column space */
+ if(maxcols > len && cols + s + 2 >= maxcols) {
int j;
cols = len;
printf("\n");
--
1.7.5.2
4
4
[pacman-dev] [PATCH 1/2] Ensure handle is valid and pm_errno is reset when calling into API
by Dan McGee 14 Jun '11
by Dan McGee 14 Jun '11
14 Jun '11
We didn't do due diligence before and ensure prior pm_errno values
weren't influencing what happened in further ALPM calls. I observed one
case of early setup code setting pm_errno to PM_ERR_WRONG_ARGS and that
flag persisting the entire time we were calling library code.
Add a new CHECK_HANDLE() macro that does two things: 1) ensures the
handle variable passed to it is non-NULL and 2) clears any existing
pm_errno flag set on the handle. This macro can replace many places we
used the ASSERT(handle != NULL, ...) pattern before.
Several other other places only need a simple 'set to zero' of the
pm_errno field.
Signed-off-by: Dan McGee <dan(a)archlinux.org>
---
lib/libalpm/add.c | 5 +-
lib/libalpm/alpm.c | 2 +-
lib/libalpm/be_package.c | 2 +-
lib/libalpm/be_sync.c | 1 +
lib/libalpm/conflict.c | 1 +
lib/libalpm/db.c | 20 ++++++++--
lib/libalpm/deps.c | 5 ++-
lib/libalpm/dload.c | 2 +
lib/libalpm/handle.c | 94 +++++++++++++++++++++++-----------------------
lib/libalpm/package.c | 36 +++++++++++++++++-
lib/libalpm/remove.c | 2 +-
lib/libalpm/signing.c | 2 +
lib/libalpm/sync.c | 7 ++-
lib/libalpm/trans.c | 16 ++++----
lib/libalpm/util.h | 2 +
15 files changed, 128 insertions(+), 69 deletions(-)
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 6f93c61..7b394a5 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -57,7 +57,7 @@ int SYMEXPORT alpm_add_pkg(pmhandle_t *handle, pmpkg_t *pkg)
pmpkg_t *local;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
ASSERT(handle == pkg->handle, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
trans = handle->trans;
@@ -715,11 +715,12 @@ int _alpm_upgrade_packages(pmhandle_t *handle)
/* loop through our package list adding/upgrading one at a time */
for(targ = trans->add; targ; targ = targ->next) {
+ pmpkg_t *newpkg = targ->data;
+
if(handle->trans->state == STATE_INTERRUPTED) {
return ret;
}
- pmpkg_t *newpkg = (pmpkg_t *)targ->data;
if(commit_single_pkg(handle, newpkg, pkg_current, pkg_count)) {
/* something screwed up on the commit, abort the trans */
trans->state = STATE_INTERRUPTED;
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 5d475ce..9b9719d 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -104,7 +104,7 @@ int SYMEXPORT alpm_release(pmhandle_t *myhandle)
int ret = 0;
pmdb_t *db;
- ASSERT(myhandle != NULL, return -1);
+ CHECK_HANDLE(myhandle, return -1);
/* close local database */
db = myhandle->db_local;
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 1f20989..a0261d0 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -386,7 +386,7 @@ error:
int SYMEXPORT alpm_pkg_load(pmhandle_t *handle, const char *filename, int full,
pgp_verify_t check_sig, pmpkg_t **pkg)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
*pkg = _alpm_pkg_load_internal(handle, filename, full, NULL, NULL, check_sig);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index ccc8fdb..bb10928 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -116,6 +116,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
/* Sanity checks */
ASSERT(db != NULL, return -1);
handle = db->handle;
+ handle->pm_errno = 0;
ASSERT(db != handle->db_local, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(handle, PM_ERR_SERVER_NONE, -1));
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index d2734d7..a6bbe09 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -214,6 +214,7 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
alpm_list_t SYMEXPORT *alpm_checkconflicts(pmhandle_t *handle,
alpm_list_t *pkglist)
{
+ CHECK_HANDLE(handle, return NULL);
return _alpm_innerconflicts(handle, pkglist);
}
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 0584a36..c3a7abd 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -48,7 +48,7 @@
pmdb_t SYMEXPORT *alpm_db_register_sync(pmhandle_t *handle, const char *treename)
{
/* Sanity checks */
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
ASSERT(treename != NULL && strlen(treename) != 0,
RET_ERR(handle, PM_ERR_WRONG_ARGS, NULL));
/* Do not register a database if a transaction is on-going */
@@ -75,7 +75,7 @@ int SYMEXPORT alpm_db_unregister_all(pmhandle_t *handle)
pmdb_t *db;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
/* Do not unregister a database if a transaction is on-going */
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, -1));
@@ -99,6 +99,7 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db)
ASSERT(db != NULL, return -1);
/* Do not unregister a database if a transaction is on-going */
handle = db->handle;
+ handle->pm_errno = 0;
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, -1));
if(db == handle->db_local) {
@@ -165,6 +166,7 @@ int SYMEXPORT alpm_db_add_server(pmdb_t *db, const char *url)
/* Sanity checks */
ASSERT(db != NULL, return -1);
+ db->handle->pm_errno = 0;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url);
@@ -190,6 +192,7 @@ int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url)
/* Sanity checks */
ASSERT(db != NULL, return -1);
+ db->handle->pm_errno = 0;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url);
@@ -216,6 +219,7 @@ int SYMEXPORT alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify)
{
/* Sanity checks */
ASSERT(db != NULL, return -1);
+ db->handle->pm_errno = 0;
db->pgp_verify = verify;
_alpm_log(db->handle, PM_LOG_DEBUG, "adding VerifySig option to database '%s': %d\n",
@@ -235,7 +239,9 @@ const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db)
pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name)
{
ASSERT(db != NULL, return NULL);
- ASSERT(name != NULL && strlen(name) != 0, return NULL);
+ db->handle->pm_errno = 0;
+ ASSERT(name != NULL && strlen(name) != 0,
+ RET_ERR(db->handle, PM_ERR_WRONG_ARGS, NULL));
return _alpm_db_get_pkgfromcache(db, name);
}
@@ -244,6 +250,7 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name)
alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db)
{
ASSERT(db != NULL, return NULL);
+ db->handle->pm_errno = 0;
return _alpm_db_get_pkgcache(db);
}
@@ -251,7 +258,9 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db)
pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name)
{
ASSERT(db != NULL, return NULL);
- ASSERT(name != NULL && strlen(name) != 0, return NULL);
+ db->handle->pm_errno = 0;
+ ASSERT(name != NULL && strlen(name) != 0,
+ RET_ERR(db->handle, PM_ERR_WRONG_ARGS, NULL));
return _alpm_db_get_grpfromcache(db, name);
}
@@ -260,6 +269,7 @@ pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name)
alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db)
{
ASSERT(db != NULL, return NULL);
+ db->handle->pm_errno = 0;
return _alpm_db_get_grpcache(db);
}
@@ -268,6 +278,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db)
alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles)
{
ASSERT(db != NULL, return NULL);
+ db->handle->pm_errno = 0;
return _alpm_db_search(db, needles);
}
@@ -276,6 +287,7 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles)
int SYMEXPORT alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason)
{
ASSERT(db != NULL, return -1);
+ db->handle->pm_errno = 0;
/* TODO assert db == db_local ? shouldn't need a db param at all here... */
ASSERT(name != NULL, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, -1));
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 2877640..10c0009 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -273,6 +273,8 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
alpm_list_t *baddeps = NULL;
int nodepversion;
+ CHECK_HANDLE(handle, return NULL);
+
targets = alpm_list_join(alpm_list_copy(remove), alpm_list_copy(upgrade));
for(i = pkglist; i; i = i->next) {
pmpkg_t *pkg = i->data;
@@ -657,7 +659,8 @@ pmpkg_t SYMEXPORT *alpm_find_dbs_satisfier(pmhandle_t *handle,
pmdepend_t *dep;
pmpkg_t *pkg;
- ASSERT(dbs, return NULL);
+ CHECK_HANDLE(handle, return NULL);
+ ASSERT(dbs, RET_ERR(handle, PM_ERR_WRONG_ARGS, NULL));
dep = _alpm_splitdep(depstring);
ASSERT(dep, return NULL);
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 46925a9..9354562 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -337,6 +337,8 @@ char SYMEXPORT *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url)
const char *filename, *cachedir;
int ret;
+ CHECK_HANDLE(handle, return NULL);
+
filename = get_filename(url);
/* find a valid cache dir to download to */
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 3c17e9d..d2bb4f6 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -88,148 +88,148 @@ void _alpm_handle_free(pmhandle_t *handle)
alpm_cb_log SYMEXPORT alpm_option_get_logcb(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->logcb;
}
alpm_cb_download SYMEXPORT alpm_option_get_dlcb(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->dlcb;
}
alpm_cb_fetch SYMEXPORT alpm_option_get_fetchcb(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->fetchcb;
}
alpm_cb_totaldl SYMEXPORT alpm_option_get_totaldlcb(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->totaldlcb;
}
const char SYMEXPORT *alpm_option_get_root(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->root;
}
const char SYMEXPORT *alpm_option_get_dbpath(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->dbpath;
}
alpm_list_t SYMEXPORT *alpm_option_get_cachedirs(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->cachedirs;
}
const char SYMEXPORT *alpm_option_get_logfile(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->logfile;
}
const char SYMEXPORT *alpm_option_get_lockfile(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->lockfile;
}
const char SYMEXPORT *alpm_option_get_signaturedir(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->signaturedir;
}
int SYMEXPORT alpm_option_get_usesyslog(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
return handle->usesyslog;
}
alpm_list_t SYMEXPORT *alpm_option_get_noupgrades(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->noupgrade;
}
alpm_list_t SYMEXPORT *alpm_option_get_noextracts(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->noextract;
}
alpm_list_t SYMEXPORT *alpm_option_get_ignorepkgs(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->ignorepkg;
}
alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->ignoregrp;
}
const char SYMEXPORT *alpm_option_get_arch(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->arch;
}
int SYMEXPORT alpm_option_get_usedelta(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
return handle->usedelta;
}
int SYMEXPORT alpm_option_get_checkspace(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
return handle->checkspace;
}
pmdb_t SYMEXPORT *alpm_option_get_localdb(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->db_local;
}
alpm_list_t SYMEXPORT *alpm_option_get_syncdbs(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
return handle->dbs_sync;
}
int SYMEXPORT alpm_option_set_logcb(pmhandle_t *handle, alpm_cb_log cb)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->logcb = cb;
return 0;
}
int SYMEXPORT alpm_option_set_dlcb(pmhandle_t *handle, alpm_cb_download cb)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->dlcb = cb;
return 0;
}
int SYMEXPORT alpm_option_set_fetchcb(pmhandle_t *handle, alpm_cb_fetch cb)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->fetchcb = cb;
return 0;
}
int SYMEXPORT alpm_option_set_totaldlcb(pmhandle_t *handle, alpm_cb_totaldl cb)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->totaldlcb = cb;
return 0;
}
@@ -284,7 +284,7 @@ int SYMEXPORT alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir)
{
char *newcachedir;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(!cachedir) {
handle->pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -301,7 +301,7 @@ int SYMEXPORT alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir)
int SYMEXPORT alpm_option_set_cachedirs(pmhandle_t *handle, alpm_list_t *cachedirs)
{
alpm_list_t *i;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(handle->cachedirs) {
FREELIST(handle->cachedirs);
}
@@ -319,7 +319,7 @@ int SYMEXPORT alpm_option_remove_cachedir(pmhandle_t *handle, const char *cached
char *vdata = NULL;
char *newcachedir;
size_t cachedirlen;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
/* verify cachedir ends in a '/' */
cachedirlen = strlen(cachedir);
if(cachedir[cachedirlen-1] != '/') {
@@ -341,7 +341,7 @@ int SYMEXPORT alpm_option_set_logfile(pmhandle_t *handle, const char *logfile)
{
char *oldlogfile = handle->logfile;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(!logfile) {
handle->pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -364,7 +364,7 @@ int SYMEXPORT alpm_option_set_logfile(pmhandle_t *handle, const char *logfile)
int SYMEXPORT alpm_option_set_signaturedir(pmhandle_t *handle, const char *signaturedir)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(!signaturedir) {
handle->pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -381,21 +381,21 @@ int SYMEXPORT alpm_option_set_signaturedir(pmhandle_t *handle, const char *signa
int SYMEXPORT alpm_option_set_usesyslog(pmhandle_t *handle, int usesyslog)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->usesyslog = usesyslog;
return 0;
}
int SYMEXPORT alpm_option_add_noupgrade(pmhandle_t *handle, const char *pkg)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
return 0;
}
int SYMEXPORT alpm_option_set_noupgrades(pmhandle_t *handle, alpm_list_t *noupgrade)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(handle->noupgrade) FREELIST(handle->noupgrade);
handle->noupgrade = alpm_list_strdup(noupgrade);
return 0;
@@ -404,7 +404,7 @@ int SYMEXPORT alpm_option_set_noupgrades(pmhandle_t *handle, alpm_list_t *noupgr
int SYMEXPORT alpm_option_remove_noupgrade(pmhandle_t *handle, const char *pkg)
{
char *vdata = NULL;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->noupgrade = alpm_list_remove_str(handle->noupgrade, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -415,14 +415,14 @@ int SYMEXPORT alpm_option_remove_noupgrade(pmhandle_t *handle, const char *pkg)
int SYMEXPORT alpm_option_add_noextract(pmhandle_t *handle, const char *pkg)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
return 0;
}
int SYMEXPORT alpm_option_set_noextracts(pmhandle_t *handle, alpm_list_t *noextract)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(handle->noextract) FREELIST(handle->noextract);
handle->noextract = alpm_list_strdup(noextract);
return 0;
@@ -431,7 +431,7 @@ int SYMEXPORT alpm_option_set_noextracts(pmhandle_t *handle, alpm_list_t *noextr
int SYMEXPORT alpm_option_remove_noextract(pmhandle_t *handle, const char *pkg)
{
char *vdata = NULL;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->noextract = alpm_list_remove_str(handle->noextract, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -442,14 +442,14 @@ int SYMEXPORT alpm_option_remove_noextract(pmhandle_t *handle, const char *pkg)
int SYMEXPORT alpm_option_add_ignorepkg(pmhandle_t *handle, const char *pkg)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
return 0;
}
int SYMEXPORT alpm_option_set_ignorepkgs(pmhandle_t *handle, alpm_list_t *ignorepkgs)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(handle->ignorepkg) FREELIST(handle->ignorepkg);
handle->ignorepkg = alpm_list_strdup(ignorepkgs);
return 0;
@@ -458,7 +458,7 @@ int SYMEXPORT alpm_option_set_ignorepkgs(pmhandle_t *handle, alpm_list_t *ignore
int SYMEXPORT alpm_option_remove_ignorepkg(pmhandle_t *handle, const char *pkg)
{
char *vdata = NULL;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->ignorepkg = alpm_list_remove_str(handle->ignorepkg, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -469,14 +469,14 @@ int SYMEXPORT alpm_option_remove_ignorepkg(pmhandle_t *handle, const char *pkg)
int SYMEXPORT alpm_option_add_ignoregrp(pmhandle_t *handle, const char *grp)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->ignoregrp = alpm_list_add(handle->ignoregrp, strdup(grp));
return 0;
}
int SYMEXPORT alpm_option_set_ignoregrps(pmhandle_t *handle, alpm_list_t *ignoregrps)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(handle->ignoregrp) FREELIST(handle->ignoregrp);
handle->ignoregrp = alpm_list_strdup(ignoregrps);
return 0;
@@ -485,7 +485,7 @@ int SYMEXPORT alpm_option_set_ignoregrps(pmhandle_t *handle, alpm_list_t *ignore
int SYMEXPORT alpm_option_remove_ignoregrp(pmhandle_t *handle, const char *grp)
{
char *vdata = NULL;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->ignoregrp = alpm_list_remove_str(handle->ignoregrp, grp, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -496,7 +496,7 @@ int SYMEXPORT alpm_option_remove_ignoregrp(pmhandle_t *handle, const char *grp)
int SYMEXPORT alpm_option_set_arch(pmhandle_t *handle, const char *arch)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
if(handle->arch) FREE(handle->arch);
if(arch) {
handle->arch = strdup(arch);
@@ -508,21 +508,21 @@ int SYMEXPORT alpm_option_set_arch(pmhandle_t *handle, const char *arch)
int SYMEXPORT alpm_option_set_usedelta(pmhandle_t *handle, int usedelta)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->usedelta = usedelta;
return 0;
}
int SYMEXPORT alpm_option_set_checkspace(pmhandle_t *handle, int checkspace)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
handle->checkspace = checkspace;
return 0;
}
int SYMEXPORT alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t level)
{
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
ASSERT(level != PM_PGP_VERIFY_UNKNOWN, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
handle->sigverify = level;
return 0;
@@ -530,7 +530,7 @@ int SYMEXPORT alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t
pgp_verify_t SYMEXPORT alpm_option_get_default_sigverify(pmhandle_t *handle)
{
- ASSERT(handle != NULL, return PM_PGP_VERIFY_UNKNOWN);
+ CHECK_HANDLE(handle, return PM_PGP_VERIFY_UNKNOWN);
return handle->sigverify;
}
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 014dedc..038c899 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -62,8 +62,10 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg)
int retval;
ASSERT(pkg != NULL, return -1);
+ pkg->handle->pm_errno = 0;
/* We only inspect packages from sync repositories */
- ASSERT(pkg->origin == PKG_FROM_SYNCDB, return -1);
+ ASSERT(pkg->origin == PKG_FROM_SYNCDB,
+ RET_ERR(pkg->handle, PM_ERR_WRONG_ARGS, -1));
fpath = _alpm_filecache_find(pkg->handle, alpm_pkg_get_filename(pkg));
@@ -162,116 +164,139 @@ struct pkg_operations default_pkg_ops = {
* package, which depend on where the package was loaded from. */
const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_filename(pkg);
}
const char SYMEXPORT *alpm_pkg_get_name(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->name;
}
const char SYMEXPORT *alpm_pkg_get_version(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->version;
}
const char SYMEXPORT *alpm_pkg_get_desc(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_desc(pkg);
}
const char SYMEXPORT *alpm_pkg_get_url(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_url(pkg);
}
time_t SYMEXPORT alpm_pkg_get_builddate(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_builddate(pkg);
}
time_t SYMEXPORT alpm_pkg_get_installdate(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_installdate(pkg);
}
const char SYMEXPORT *alpm_pkg_get_packager(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_packager(pkg);
}
const char SYMEXPORT *alpm_pkg_get_md5sum(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_md5sum(pkg);
}
const char SYMEXPORT *alpm_pkg_get_arch(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_arch(pkg);
}
off_t SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_size(pkg);
}
off_t SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_isize(pkg);
}
pmpkgreason_t SYMEXPORT alpm_pkg_get_reason(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_reason(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_licenses(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_groups(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_groups(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_depends(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_depends(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_optdepends(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_conflicts(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_provides(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_provides(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_replaces(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_deltas(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_deltas(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_files(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_files(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_backup(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->get_backup(pkg);
}
@@ -280,6 +305,7 @@ pmdb_t SYMEXPORT *alpm_pkg_get_db(pmpkg_t *pkg)
/* Sanity checks */
ASSERT(pkg != NULL, return NULL);
ASSERT(pkg->origin != PKG_FROM_FILE, return NULL);
+ pkg->handle->pm_errno = 0;
return pkg->origin_data.db;
}
@@ -287,6 +313,7 @@ pmdb_t SYMEXPORT *alpm_pkg_get_db(pmpkg_t *pkg)
/** Open a package changelog for reading. */
void SYMEXPORT *alpm_pkg_changelog_open(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->changelog_open(pkg);
}
@@ -294,6 +321,7 @@ void SYMEXPORT *alpm_pkg_changelog_open(pmpkg_t *pkg)
size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
const pmpkg_t *pkg, const void *fp)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->changelog_read(ptr, size, pkg, fp);
}
@@ -307,17 +335,21 @@ int SYMEXPORT alpm_pkg_changelog_feof(const pmpkg_t *pkg, void *fp)
/** Close a package changelog for reading. */
int SYMEXPORT alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->changelog_close(pkg, fp);
}
int SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
{
+ pkg->handle->pm_errno = 0;
return pkg->ops->has_scriptlet(pkg);
}
static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs)
{
const alpm_list_t *i;
+ pkg->handle->pm_errno = 0;
+
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
pmpkg_t *cachepkg = i->data;
alpm_list_t *i;
@@ -339,6 +371,8 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
alpm_list_t *reqs = NULL;
pmdb_t *db;
+ pkg->handle->pm_errno = 0;
+
if(pkg->origin == PKG_FROM_FILE) {
/* The sane option; search locally for things that require this. */
find_requiredby(pkg, pkg->handle->db_local, &reqs);
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index eada9b9..9f07501 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -50,7 +50,7 @@ int SYMEXPORT alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg)
pmtrans_t *trans;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
ASSERT(handle == pkg->handle, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
trans = handle->trans;
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 8124e67..62c8925 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -386,6 +386,7 @@ pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
int SYMEXPORT alpm_pkg_check_pgp_signature(pmpkg_t *pkg)
{
ASSERT(pkg != NULL, return 0);
+ pkg->handle->pm_errno = 0;
return _alpm_gpgme_checksig(pkg->handle, alpm_pkg_get_filename(pkg),
pkg->base64_sig);
@@ -399,6 +400,7 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(pmpkg_t *pkg)
int SYMEXPORT alpm_db_check_pgp_signature(pmdb_t *db)
{
ASSERT(db != NULL, return 0);
+ db->handle->pm_errno = 0;
return _alpm_gpgme_checksig(db->handle, _alpm_db_path(db), NULL);
}
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index d65f5e2..0573573 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -55,11 +55,12 @@
*/
pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
{
- ASSERT(pkg != NULL, return NULL);
-
alpm_list_t *i;
pmpkg_t *spkg = NULL;
+ ASSERT(pkg != NULL, return NULL);
+ pkg->handle->pm_errno = 0;
+
for(i = dbs_sync; !spkg && i; i = i->next) {
spkg = _alpm_db_get_pkgfromcache(i->data, alpm_pkg_get_name(pkg));
}
@@ -89,7 +90,7 @@ int SYMEXPORT alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade)
pmdb_t *db_local;
alpm_list_t *dbs_sync;
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
trans = handle->trans;
db_local = handle->db_local;
dbs_sync = handle->dbs_sync;
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index a95280c..f074493 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -105,7 +105,7 @@ int SYMEXPORT alpm_trans_init(pmhandle_t *handle, pmtransflag_t flags,
int db_version;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, -1));
/* lock db */
@@ -168,7 +168,7 @@ int SYMEXPORT alpm_trans_prepare(pmhandle_t *handle, alpm_list_t **data)
pmtrans_t *trans;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
ASSERT(data != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
trans = handle->trans;
@@ -212,7 +212,7 @@ int SYMEXPORT alpm_trans_commit(pmhandle_t *handle, alpm_list_t **data)
pmtrans_t *trans;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
trans = handle->trans;
@@ -251,7 +251,7 @@ int SYMEXPORT alpm_trans_interrupt(pmhandle_t *handle)
pmtrans_t *trans;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1));
@@ -269,7 +269,7 @@ int SYMEXPORT alpm_trans_release(pmhandle_t *handle)
pmtrans_t *trans;
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1));
@@ -414,7 +414,7 @@ cleanup:
pmtransflag_t SYMEXPORT alpm_trans_get_flags(pmhandle_t *handle)
{
/* Sanity checks */
- ASSERT(handle != NULL, return -1);
+ CHECK_HANDLE(handle, return -1);
ASSERT(handle->trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1));
return handle->trans->flags;
@@ -423,7 +423,7 @@ pmtransflag_t SYMEXPORT alpm_trans_get_flags(pmhandle_t *handle)
alpm_list_t SYMEXPORT *alpm_trans_get_add(pmhandle_t *handle)
{
/* Sanity checks */
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
ASSERT(handle->trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, NULL));
return handle->trans->add;
@@ -432,7 +432,7 @@ alpm_list_t SYMEXPORT *alpm_trans_get_add(pmhandle_t *handle)
alpm_list_t SYMEXPORT *alpm_trans_get_remove(pmhandle_t *handle)
{
/* Sanity checks */
- ASSERT(handle != NULL, return NULL);
+ CHECK_HANDLE(handle, return NULL);
ASSERT(handle->trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, NULL));
return handle->trans->remove;
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index e5fefe9..0549c81 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -71,6 +71,8 @@
#define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
+#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0)
+
/**
* Used as a buffer/state holder for _alpm_archive_fgets().
*/
--
1.7.5.2
2
2