forked from mirrors/pacman
Compare commits
9 Commits
v6.0.2
...
morganamil
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
689223f40d | ||
|
|
39c3cbdf56 | ||
|
|
165e492485 | ||
|
|
be76f8bf06 | ||
|
|
625f3d645b | ||
|
|
e187aa9b48 | ||
|
|
c5c6633dd1 | ||
|
|
2109de613a | ||
|
|
fbb29b5047 |
@@ -70,6 +70,8 @@ repo-add Options
|
||||
Remove old package files from the disk when updating their entry in the
|
||||
database.
|
||||
|
||||
*\--include-sigs*::
|
||||
Include package PGP signatures in the repository database (if available)
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
@@ -78,7 +78,7 @@ extern "C" {
|
||||
* This struct represents an instance of libalpm.
|
||||
* @ingroup libalpm_handle
|
||||
*/
|
||||
typedef struct __alpm_handle_t alpm_handle_t;
|
||||
typedef struct _alpm_handle_t alpm_handle_t;
|
||||
|
||||
/** A database.
|
||||
*
|
||||
@@ -98,7 +98,7 @@ typedef struct __alpm_handle_t alpm_handle_t;
|
||||
* Databases are automatically unregistered when the \link alpm_handle_t \endlink is released.
|
||||
* @ingroup libalpm_databases
|
||||
*/
|
||||
typedef struct __alpm_db_t alpm_db_t;
|
||||
typedef struct _alpm_db_t alpm_db_t;
|
||||
|
||||
|
||||
/** A package.
|
||||
@@ -111,13 +111,7 @@ typedef struct __alpm_db_t alpm_db_t;
|
||||
* to be added or removed from the system.
|
||||
* @ingroup libalpm_packages
|
||||
*/
|
||||
typedef struct __alpm_pkg_t alpm_pkg_t;
|
||||
|
||||
/** Transaction structure used internally by libalpm
|
||||
* @ingroup libalpm_trans
|
||||
* */
|
||||
typedef struct __alpm_trans_t alpm_trans_t;
|
||||
|
||||
typedef struct _alpm_pkg_t alpm_pkg_t;
|
||||
|
||||
/** The time type used by libalpm. Represents a unix time stamp
|
||||
* @ingroup libalpm_misc */
|
||||
@@ -1080,8 +1074,10 @@ typedef struct _alpm_question_import_key_t {
|
||||
alpm_question_type_t type;
|
||||
/** Answer: whether or not to import key */
|
||||
int import;
|
||||
/** The key to import */
|
||||
alpm_pgpkey_t *key;
|
||||
/** UID of the key to import */
|
||||
const char *uid;
|
||||
/** Fingerprint the key to import */
|
||||
const char *fingerprint;
|
||||
} alpm_question_import_key_t;
|
||||
|
||||
/**
|
||||
@@ -2719,7 +2715,8 @@ typedef enum _alpm_transflag_t {
|
||||
ALPM_TRANS_FLAG_RECURSE = (1 << 5),
|
||||
/** Modify database but do not commit changes to the filesystem. */
|
||||
ALPM_TRANS_FLAG_DBONLY = (1 << 6),
|
||||
/* (1 << 7) flag can go here */
|
||||
/** Do not run hooks during a transaction */
|
||||
ALPM_TRANS_FLAG_NOHOOKS = (1 << 7),
|
||||
/** Use ALPM_PKG_REASON_DEPEND when installing packages. */
|
||||
ALPM_TRANS_FLAG_ALLDEPS = (1 << 8),
|
||||
/** Only download packages and do not actually install. */
|
||||
|
||||
@@ -48,13 +48,13 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/** A doubly linked list */
|
||||
typedef struct __alpm_list_t {
|
||||
typedef struct _alpm_list_t {
|
||||
/** data held by the list node */
|
||||
void *data;
|
||||
/** pointer to the previous node */
|
||||
struct __alpm_list_t *prev;
|
||||
struct _alpm_list_t *prev;
|
||||
/** pointer to the next node */
|
||||
struct __alpm_list_t *next;
|
||||
struct _alpm_list_t *next;
|
||||
} alpm_list_t;
|
||||
|
||||
/** Frees a list and its contents */
|
||||
|
||||
@@ -62,7 +62,7 @@ struct db_operations {
|
||||
};
|
||||
|
||||
/* Database */
|
||||
struct __alpm_db_t {
|
||||
struct _alpm_db_t {
|
||||
alpm_handle_t *handle;
|
||||
char *treename;
|
||||
/* do not access directly, use _alpm_db_path(db) for lazy access */
|
||||
|
||||
@@ -43,7 +43,7 @@ enum mount_fsinfo {
|
||||
MOUNT_FSINFO_FAIL,
|
||||
};
|
||||
|
||||
typedef struct __alpm_mountpoint_t {
|
||||
typedef struct _alpm_mountpoint_t {
|
||||
/* mount point information */
|
||||
char *mount_dir;
|
||||
size_t mount_dir_len;
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
|
||||
#include "alpm_list.h"
|
||||
|
||||
enum __alpm_graph_vertex_state {
|
||||
enum _alpm_graph_vertex_state {
|
||||
ALPM_GRAPH_STATE_UNPROCESSED,
|
||||
ALPM_GRAPH_STATE_PROCESSING,
|
||||
ALPM_GRAPH_STATE_PROCESSED
|
||||
};
|
||||
|
||||
typedef struct __alpm_graph_t {
|
||||
typedef struct _alpm_graph_t {
|
||||
void *data;
|
||||
struct __alpm_graph_t *parent; /* where did we come from? */
|
||||
struct _alpm_graph_t *parent; /* where did we come from? */
|
||||
alpm_list_t *children;
|
||||
alpm_list_t *iterator; /* used for DFS without recursion */
|
||||
off_t weight; /* weight of the node */
|
||||
enum __alpm_graph_vertex_state state;
|
||||
enum _alpm_graph_vertex_state state;
|
||||
} alpm_graph_t;
|
||||
|
||||
alpm_graph_t *_alpm_graph_new(void);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "alpm_list.h"
|
||||
#include "alpm.h"
|
||||
#include "trans.h"
|
||||
|
||||
#ifdef HAVE_LIBCURL
|
||||
#include <curl/curl.h>
|
||||
@@ -50,7 +51,7 @@ do { \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
struct __alpm_handle_t {
|
||||
struct _alpm_handle_t {
|
||||
/* internal usage */
|
||||
alpm_db_t *db_local; /* local db pointer */
|
||||
alpm_list_t *dbs_sync; /* List of (alpm_db_t *) */
|
||||
|
||||
@@ -57,7 +57,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
|
||||
ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
|
||||
RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
|
||||
|
||||
fpath = _alpm_filecache_find(pkg->handle, pkg->filename);
|
||||
fpath = _alpm_cache_find_pkg(pkg, 0);
|
||||
|
||||
retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM);
|
||||
|
||||
@@ -283,7 +283,7 @@ int SYMEXPORT alpm_pkg_get_sig(alpm_pkg_t *pkg, unsigned char **sig, size_t *sig
|
||||
alpm_errno_t err;
|
||||
int ret = -1;
|
||||
|
||||
pkgpath = _alpm_filecache_find(pkg->handle, pkg->filename);
|
||||
pkgpath = _alpm_cache_find_pkg(pkg, 0);
|
||||
if(!pkgpath) {
|
||||
GOTO_ERR(pkg->handle, ALPM_ERR_PKG_NOT_FOUND, cleanup);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ struct pkg_operations {
|
||||
*/
|
||||
extern const struct pkg_operations default_pkg_ops;
|
||||
|
||||
struct __alpm_pkg_t {
|
||||
struct _alpm_pkg_t {
|
||||
unsigned long name_hash;
|
||||
char *filename;
|
||||
char *base;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
* A combination of a hash table and a list, allowing for fast look-up
|
||||
* by package name but also iteration over the packages.
|
||||
*/
|
||||
struct __alpm_pkghash_t {
|
||||
struct _alpm_pkghash_t {
|
||||
/** data held by the hash table */
|
||||
alpm_list_t **hash_table;
|
||||
/** head node of the hash table data in normal list format */
|
||||
@@ -45,7 +45,7 @@ struct __alpm_pkghash_t {
|
||||
unsigned int limit;
|
||||
};
|
||||
|
||||
typedef struct __alpm_pkghash_t alpm_pkghash_t;
|
||||
typedef struct _alpm_pkghash_t alpm_pkghash_t;
|
||||
|
||||
alpm_pkghash_t *_alpm_pkghash_create(unsigned int size);
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ static int key_search_keyserver(alpm_handle_t *handle, const char *fpr,
|
||||
pgpkey->data = key;
|
||||
if(key->subkeys->fpr) {
|
||||
pgpkey->fingerprint = key->subkeys->fpr;
|
||||
} else if(key->subkeys->keyid) {
|
||||
} else {
|
||||
pgpkey->fingerprint = key->subkeys->keyid;
|
||||
}
|
||||
pgpkey->uid = key->uids->uid;
|
||||
@@ -504,19 +504,15 @@ int _alpm_key_import(alpm_handle_t *handle, const char *uid, const char *fpr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
STRDUP(fetch_key.uid, uid, return -1);
|
||||
STRDUP(fetch_key.fingerprint, fpr, free(fetch_key.uid); return -1);
|
||||
|
||||
alpm_question_import_key_t question = {
|
||||
.type = ALPM_QUESTION_IMPORT_KEY,
|
||||
.import = 0,
|
||||
.key = &fetch_key
|
||||
.uid = uid,
|
||||
.fingerprint = fpr
|
||||
};
|
||||
QUESTION(handle, &question);
|
||||
|
||||
free(fetch_key.uid);
|
||||
free(fetch_key.fingerprint);
|
||||
|
||||
if(question.import) {
|
||||
/* Try to import the key from a WKD first */
|
||||
if(email_from_uid(uid, &email) == 0) {
|
||||
|
||||
@@ -323,7 +323,7 @@ static int compute_download_size(alpm_pkg_t *newpkg)
|
||||
|
||||
ASSERT(newpkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
|
||||
fname = newpkg->filename;
|
||||
fpath = _alpm_filecache_find(handle, fname);
|
||||
fpath = _alpm_cache_find_pkg(newpkg, 0);
|
||||
|
||||
/* downloaded file exists, so there's nothing to grab */
|
||||
if(fpath) {
|
||||
@@ -333,7 +333,7 @@ static int compute_download_size(alpm_pkg_t *newpkg)
|
||||
|
||||
CALLOC(fnamepart, strlen(fname) + 6, sizeof(char), return -1);
|
||||
sprintf(fnamepart, "%s.part", fname);
|
||||
fpath = _alpm_filecache_find(handle, fnamepart);
|
||||
fpath = _alpm_cache_find_pkg(newpkg, 1);
|
||||
if(fpath) {
|
||||
struct stat st;
|
||||
if(stat(fpath, &st) == 0) {
|
||||
@@ -737,21 +737,13 @@ static int find_dl_candidates(alpm_handle_t *handle, alpm_list_t **files)
|
||||
|
||||
ASSERT(spkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
|
||||
|
||||
need_download = spkg->download_size != 0 || !_alpm_filecache_exists(handle, spkg->filename);
|
||||
need_download = spkg->download_size != 0 || !_alpm_cache_pkg_exists(spkg, 0);
|
||||
/* even if the package file in the cache we need to check for
|
||||
* accompanion *.sig file as well.
|
||||
* If *.sig is not cached then force download the package + its signature file.
|
||||
*/
|
||||
if(!need_download && (siglevel & ALPM_SIG_PACKAGE)) {
|
||||
char *sig_filename = NULL;
|
||||
int len = strlen(spkg->filename) + 5;
|
||||
|
||||
MALLOC(sig_filename, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
|
||||
snprintf(sig_filename, len, "%s.sig", spkg->filename);
|
||||
|
||||
need_download = !_alpm_filecache_exists(handle, sig_filename);
|
||||
|
||||
FREE(sig_filename);
|
||||
need_download = !_alpm_cache_pkg_exists(spkg, 1);
|
||||
}
|
||||
|
||||
if(need_download) {
|
||||
@@ -990,7 +982,7 @@ static int check_validity(alpm_handle_t *handle,
|
||||
}
|
||||
|
||||
current_bytes += v.pkg->size;
|
||||
v.path = _alpm_filecache_find(handle, v.pkg->filename);
|
||||
v.path = _alpm_cache_find_pkg(v.pkg, 0);
|
||||
v.siglevel = alpm_db_get_siglevel(alpm_pkg_get_db(v.pkg));
|
||||
|
||||
if(_alpm_pkg_validate_internal(handle, v.path, v.pkg,
|
||||
@@ -1080,7 +1072,8 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
|
||||
}
|
||||
|
||||
current_bytes += spkg->size;
|
||||
filepath = _alpm_filecache_find(handle, spkg->filename);
|
||||
|
||||
filepath = _alpm_cache_find_pkg(spkg, 0);
|
||||
|
||||
/* 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 */
|
||||
|
||||
@@ -198,7 +198,8 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||
}
|
||||
}
|
||||
|
||||
if(_alpm_hook_run(handle, ALPM_HOOK_PRE_TRANSACTION) != 0) {
|
||||
if(!(trans->flags & ALPM_TRANS_FLAG_NOHOOKS) &&
|
||||
_alpm_hook_run(handle, ALPM_HOOK_PRE_TRANSACTION) != 0) {
|
||||
RET_ERR(handle, ALPM_ERR_TRANS_HOOK_FAILED, -1);
|
||||
}
|
||||
|
||||
@@ -232,7 +233,10 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||
event.type = ALPM_EVENT_TRANSACTION_DONE;
|
||||
EVENT(handle, (void *)&event);
|
||||
alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction completed\n");
|
||||
_alpm_hook_run(handle, ALPM_HOOK_POST_TRANSACTION);
|
||||
|
||||
if(!(trans->flags & ALPM_TRANS_FLAG_NOHOOKS)) {
|
||||
_alpm_hook_run(handle, ALPM_HOOK_POST_TRANSACTION);
|
||||
}
|
||||
}
|
||||
|
||||
trans->state = STATE_COMMITED;
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef enum _alpm_transstate_t {
|
||||
} alpm_transstate_t;
|
||||
|
||||
/* Transaction */
|
||||
struct __alpm_trans_t {
|
||||
typedef struct _alpm_trans_t {
|
||||
/* bitfield of alpm_transflag_t flags */
|
||||
int flags;
|
||||
alpm_transstate_t state;
|
||||
@@ -44,7 +44,7 @@ struct __alpm_trans_t {
|
||||
alpm_list_t *add; /* list of (alpm_pkg_t *) */
|
||||
alpm_list_t *remove; /* list of (alpm_pkg_t *) */
|
||||
alpm_list_t *skip_remove; /* list of (char *) */
|
||||
};
|
||||
} alpm_trans_t;
|
||||
|
||||
void _alpm_trans_free(alpm_trans_t *trans);
|
||||
/* flags is a bitfield of alpm_transflag_t flags */
|
||||
|
||||
@@ -815,6 +815,37 @@ int _alpm_str_cmp(const void *s1, const void *s2)
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
|
||||
char *_alpm_cache_find_pkg(alpm_pkg_t *pkg, int sig) {
|
||||
alpm_handle_t *handle = pkg->handle;
|
||||
struct stat buf;
|
||||
alpm_list_t *servers = pkg->origin_data.db->servers;
|
||||
char *retpath;
|
||||
char filepath[PATH_MAX];
|
||||
|
||||
for(alpm_list_t *j = servers; j; j = j->next) {
|
||||
char *server = j->data;
|
||||
|
||||
if(strncmp("file://", server, strlen("file://")) == 0) {
|
||||
int len = strlen(server) - strlen("file://") + 1 + strlen(pkg->filename) + 1;
|
||||
|
||||
if(sig) {
|
||||
len += strlen(".sig");
|
||||
snprintf(filepath, len, "%s/%s", server + strlen("file://"), pkg->filename);
|
||||
} else {
|
||||
snprintf(filepath, len, "%s/%s.sig", server + strlen("file://"), pkg->filename);
|
||||
}
|
||||
|
||||
if(stat(filepath, &buf) == 0 && S_ISREG(buf.st_mode)) {
|
||||
STRDUP(retpath, filepath, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
|
||||
_alpm_log(handle, ALPM_LOG_DEBUG, "found pkg in repo cache: %s\n", retpath);
|
||||
return retpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _alpm_filecache_find(handle, pkg->filename);
|
||||
}
|
||||
|
||||
/** Find a filename in a registered alpm cachedir.
|
||||
* @param handle the context handle
|
||||
* @param filename name of file to find
|
||||
@@ -846,10 +877,10 @@ char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename)
|
||||
* @param filename name of file to find
|
||||
* @return 0 if the filename was not found, 1 otherwise
|
||||
*/
|
||||
int _alpm_filecache_exists(alpm_handle_t *handle, const char *filename)
|
||||
int _alpm_cache_pkg_exists(alpm_pkg_t *pkg, int sig)
|
||||
{
|
||||
int res;
|
||||
char *fpath = _alpm_filecache_find(handle, filename);
|
||||
char *fpath = _alpm_cache_find_pkg(pkg, sig);
|
||||
res = (fpath != NULL);
|
||||
FREE(fpath);
|
||||
return res;
|
||||
|
||||
@@ -133,9 +133,10 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
|
||||
_alpm_cb_io in_cb, void *in_ctx);
|
||||
int _alpm_ldconfig(alpm_handle_t *handle);
|
||||
int _alpm_str_cmp(const void *s1, const void *s2);
|
||||
char *_alpm_cache_find_pkg(alpm_pkg_t *pkg, int sig);
|
||||
char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
|
||||
/* Checks whether a file exists in cache */
|
||||
int _alpm_filecache_exists(alpm_handle_t *handle, const char *filename);
|
||||
int _alpm_cache_pkg_exists(alpm_pkg_t *pkg, int sig);
|
||||
const char *_alpm_filecache_setup(alpm_handle_t *handle);
|
||||
/* Unlike many uses of alpm_pkgvalidation_t, _alpm_test_checksum expects
|
||||
* an enum value rather than a bitfield. */
|
||||
|
||||
@@ -42,6 +42,7 @@ LOCKFILE=
|
||||
CLEAN_LOCK=0
|
||||
USE_COLOR='y'
|
||||
PREVENT_DOWNGRADE=0
|
||||
INCLUDE_SIGS=0
|
||||
|
||||
# Import libmakepkg
|
||||
source "$LIBRARY"/util/compress.sh
|
||||
@@ -260,7 +261,7 @@ db_write_entry() {
|
||||
fi
|
||||
|
||||
# compute base64'd PGP signature
|
||||
if [[ -f "$pkgfile.sig" ]]; then
|
||||
if (( INCLUDE_SIGS )) && [[ -f "$pkgfile.sig" ]]; then
|
||||
if grep -q 'BEGIN PGP SIGNATURE' "$pkgfile.sig"; then
|
||||
error "$(gettext "Cannot use armored signatures for packages: %s")" "$pkgfile.sig"
|
||||
return 1
|
||||
@@ -622,6 +623,9 @@ while (( $# )); do
|
||||
-p|--prevent-downgrade)
|
||||
PREVENT_DOWNGRADE=1
|
||||
;;
|
||||
--include-sigs)
|
||||
INCLUDE_SIGS=1
|
||||
;;
|
||||
*)
|
||||
args+=("$1")
|
||||
;;
|
||||
|
||||
@@ -541,12 +541,12 @@ void cb_question(void *ctx, alpm_question_t *question)
|
||||
{
|
||||
alpm_question_import_key_t *q = &question->import_key;
|
||||
/* the uid is unknown with db signatures */
|
||||
if (q->key->uid == NULL) {
|
||||
if (q->uid == NULL) {
|
||||
q->import = yesno(_("Import PGP key %s?"),
|
||||
q->key->fingerprint);
|
||||
q->fingerprint);
|
||||
} else {
|
||||
q->import = yesno(_("Import PGP key %s, \"%s\"?"),
|
||||
q->key->fingerprint, q->key->uid);
|
||||
q->fingerprint, q->uid);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -634,6 +634,7 @@ static int parsearg_trans(int opt)
|
||||
case OP_DBONLY:
|
||||
config->flags |= ALPM_TRANS_FLAG_DBONLY;
|
||||
config->flags |= ALPM_TRANS_FLAG_NOSCRIPTLET;
|
||||
config->flags |= ALPM_TRANS_FLAG_NOHOOKS;
|
||||
break;
|
||||
case OP_NOPROGRESSBAR:
|
||||
config->noprogressbar = 1;
|
||||
|
||||
Reference in New Issue
Block a user