Merge branch 'master' of ssh://dev.alpinelinux.org/gitroot/apk-tools
commit
500778f45e
12
src/add.c
12
src/add.c
|
@ -14,7 +14,7 @@
|
||||||
#include "apk_applet.h"
|
#include "apk_applet.h"
|
||||||
#include "apk_database.h"
|
#include "apk_database.h"
|
||||||
|
|
||||||
#define FLAG_INITDB 0x001
|
#define FLAG_INITDB 0x0001
|
||||||
|
|
||||||
struct add_ctx {
|
struct add_ctx {
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
@ -28,6 +28,9 @@ static int add_parse(void *ctx, int optch, int optindex, const char *optarg)
|
||||||
case 0x10000:
|
case 0x10000:
|
||||||
actx->flags |= FLAG_INITDB;
|
actx->flags |= FLAG_INITDB;
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
apk_upgrade = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -73,8 +76,8 @@ static int add_main(void *ctx, int argc, char **argv)
|
||||||
|
|
||||||
dep = (struct apk_dependency) {
|
dep = (struct apk_dependency) {
|
||||||
.name = pkg->name,
|
.name = pkg->name,
|
||||||
.version_mask = APK_VERSION_RESULT_MASK(APK_VERSION_EQUAL),
|
.min_version = pkg->version,
|
||||||
.version = pkg->version,
|
.max_version = pkg->version,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
dep = (struct apk_dependency) {
|
dep = (struct apk_dependency) {
|
||||||
|
@ -91,11 +94,12 @@ err:
|
||||||
|
|
||||||
static struct option add_options[] = {
|
static struct option add_options[] = {
|
||||||
{ "initdb", no_argument, NULL, 0x10000 },
|
{ "initdb", no_argument, NULL, 0x10000 },
|
||||||
|
{ "upgrade", no_argument, NULL, 'u' },
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct apk_applet apk_add = {
|
static struct apk_applet apk_add = {
|
||||||
.name = "add",
|
.name = "add",
|
||||||
.usage = "[--initdb] apkname...",
|
.usage = "[--initdb] [--upgrade|-u] apkname...",
|
||||||
.context_size = sizeof(struct add_ctx),
|
.context_size = sizeof(struct add_ctx),
|
||||||
.num_options = ARRAY_SIZE(add_options),
|
.num_options = ARRAY_SIZE(add_options),
|
||||||
.options = add_options,
|
.options = add_options,
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
const char *apk_root;
|
const char *apk_root;
|
||||||
const char *apk_repository = NULL;
|
const char *apk_repository = NULL;
|
||||||
int apk_verbosity = 1, apk_progress = 0;
|
int apk_verbosity = 1, apk_progress = 0, apk_upgrade = 0;
|
||||||
int apk_cwd_fd;
|
int apk_cwd_fd;
|
||||||
|
|
||||||
void apk_log(const char *prefix, const char *format, ...)
|
void apk_log(const char *prefix, const char *format, ...)
|
||||||
|
|
|
@ -53,7 +53,6 @@ struct apk_db_dir_instance {
|
||||||
|
|
||||||
struct apk_name {
|
struct apk_name {
|
||||||
apk_hash_node hash_node;
|
apk_hash_node hash_node;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
struct apk_package_array *pkgs;
|
struct apk_package_array *pkgs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,7 +50,7 @@ extern csum_t bad_checksum;
|
||||||
#define csum_valid(buf) memcmp(buf, bad_checksum, sizeof(csum_t))
|
#define csum_valid(buf) memcmp(buf, bad_checksum, sizeof(csum_t))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int apk_cwd_fd, apk_verbosity, apk_progress;
|
extern int apk_cwd_fd, apk_verbosity, apk_progress, apk_upgrade;
|
||||||
|
|
||||||
#define apk_error(args...) apk_log("ERROR: ", args);
|
#define apk_error(args...) apk_log("ERROR: ", args);
|
||||||
#define apk_warning(args...) if (apk_verbosity > 0) { apk_log("WARNING: ", args); }
|
#define apk_warning(args...) if (apk_verbosity > 0) { apk_log("WARNING: ", args); }
|
||||||
|
|
|
@ -36,12 +36,9 @@ struct apk_script {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct apk_dependency {
|
struct apk_dependency {
|
||||||
unsigned conflict : 1;
|
|
||||||
unsigned prefer_upgrade : 1;
|
|
||||||
unsigned version_mask : 3;
|
|
||||||
|
|
||||||
struct apk_name *name;
|
struct apk_name *name;
|
||||||
char *version;
|
char *min_version;
|
||||||
|
char *max_version;
|
||||||
};
|
};
|
||||||
APK_ARRAY(apk_dependency_array, struct apk_dependency);
|
APK_ARRAY(apk_dependency_array, struct apk_dependency);
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,8 @@
|
||||||
#include "apk_database.h"
|
#include "apk_database.h"
|
||||||
|
|
||||||
#define APK_STATE_NOT_CONSIDERED 0
|
#define APK_STATE_NOT_CONSIDERED 0
|
||||||
#define APK_STATE_PREFER_UPGRADE 1
|
#define APK_STATE_INSTALL 1
|
||||||
#define APK_STATE_INSTALL 2
|
#define APK_STATE_NO_INSTALL 2
|
||||||
#define APK_STATE_NO_INSTALL 3
|
|
||||||
|
|
||||||
struct apk_change {
|
struct apk_change {
|
||||||
struct list_head change_list;
|
struct list_head change_list;
|
||||||
|
|
|
@ -638,6 +638,7 @@ int apk_db_open(struct apk_database *db, const char *root)
|
||||||
list_init(&db->installed.packages);
|
list_init(&db->installed.packages);
|
||||||
|
|
||||||
if (root != NULL) {
|
if (root != NULL) {
|
||||||
|
fchdir(apk_cwd_fd);
|
||||||
db->root = strdup(root);
|
db->root = strdup(root);
|
||||||
db->root_fd = open(root, O_RDONLY);
|
db->root_fd = open(root, O_RDONLY);
|
||||||
if (db->root_fd < 0) {
|
if (db->root_fd < 0) {
|
||||||
|
|
|
@ -112,10 +112,7 @@ static int parse_depend(void *ctx, apk_blob_t blob)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
*dep = (struct apk_dependency){
|
*dep = (struct apk_dependency){
|
||||||
.prefer_upgrade = 0,
|
|
||||||
.version_mask = 0,
|
|
||||||
.name = name,
|
.name = name,
|
||||||
.version = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -205,7 +205,7 @@ int apk_state_satisfy_name(struct apk_state *state,
|
||||||
struct apk_name *name)
|
struct apk_name *name)
|
||||||
{
|
{
|
||||||
struct apk_package *preferred = NULL, *installed = NULL;
|
struct apk_package *preferred = NULL, *installed = NULL;
|
||||||
int i, r, upgrading = 1;
|
int i, r;
|
||||||
|
|
||||||
/* Is something already installed? Or figure out the preferred
|
/* Is something already installed? Or figure out the preferred
|
||||||
* package. */
|
* package. */
|
||||||
|
@ -216,9 +216,9 @@ int apk_state_satisfy_name(struct apk_state *state,
|
||||||
|
|
||||||
if (apk_pkg_get_state(name->pkgs->item[i]) == APK_STATE_INSTALL) {
|
if (apk_pkg_get_state(name->pkgs->item[i]) == APK_STATE_INSTALL) {
|
||||||
installed = name->pkgs->item[i];
|
installed = name->pkgs->item[i];
|
||||||
if (!upgrading) {
|
if (!apk_upgrade) {
|
||||||
preferred = installed;
|
preferred = installed;
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue