Commit d14f5925 authored by Timo Teräs's avatar Timo Teräs Committed by Natanael Copa

main/apk-tools: upgrade to 2.0.3

(cherry picked from commit 9653fc55)
parent 6610c6a9
From 87420aaf295f58847332ba3aa89691a0259baace Mon Sep 17 00:00:00 2001
From: Timo Teras <timo.teras@iki.fi>
Date: Wed, 5 May 2010 08:56:06 +0300
Subject: [PATCH 1/5] info: fix querying of removed, but referenced packages
Check that package name has packages associated with it before
dereferencing the pointer. Fixes #345.
---
src/info.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/info.c b/src/info.c
index 7ca486c..d944fca 100644
--- a/src/info.c
+++ b/src/info.c
@@ -283,7 +283,7 @@ static int info_package(struct info_ctx *ctx, struct apk_database *db,
for (i = 0; i < argc; i++) {
name = apk_db_query_name(db, APK_BLOB_STR(argv[i]));
- if (name == NULL) {
+ if (name == NULL || name->pkgs == NULL) {
apk_error("Not found: %s", argv[i]);
return 1;
}
--
1.7.1
From 47bac8c29c9a3c3fbebfd20e907170f24f9d677c Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Tue, 11 May 2010 09:31:20 +0000
Subject: [PATCH 2/5] upgrade: reset versioned deps in world when doing upgrade -a
Doing "apk add file.apk" adds a versioned dependency to allow
downgrading, and sticky version. Most often this is to install
single packages from newer repository. So it would make sense
to reset them to non-versioned if doing:
apk upgrade -a
fixes #346
---
src/upgrade.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/upgrade.c b/src/upgrade.c
index f91e8cc..879e14c 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -41,10 +41,15 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
goto err;
for (i = 0; i < db->world->num; i++) {
- r = apk_state_lock_dependency(state, &db->world->item[i]);
+ struct apk_dependency *dep = &db->world->item[i];
+ if (dep->version && (apk_flags & APK_PREFER_AVAILABLE)) {
+ dep->result_mask = APK_VERSION_EQUAL | APK_VERSION_LESS | APK_VERSION_GREATER;
+ dep->version = NULL;
+ }
+ r = apk_state_lock_dependency(state, dep);
if (r != 0) {
apk_error("Unable to upgrade '%s'",
- db->world->item[i].name->name);
+ dep->name->name);
goto err;
}
}
--
1.7.1
From d9bf4aabff801164b4c54e51b38c5f6eab2da114 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Wed, 19 May 2010 16:48:40 +0300
Subject: [PATCH 3/5] search: add search for reverse dependencies in index
So it'll be easier to rebuild affected packages. Fixes #349.
---
src/search.c | 148 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 91 insertions(+), 57 deletions(-)
diff --git a/src/search.c b/src/search.c
index 91c2913..e5e5d55 100644
--- a/src/search.c
+++ b/src/search.c
@@ -18,18 +18,14 @@
#include "apk_state.h"
struct search_ctx {
- int (*action)(struct apk_database *db, int argc, char **argv);
+ int (*match)(struct apk_package *pkg, const char *str);
+ int (*print)(struct apk_package *pkg);
+ int argc;
+ char **argv;
};
-struct search_query_ctx {
- struct apk_database *db;
- const char *query;
-};
-
-static int search_list_print(apk_hash_item item, void *ctx)
+static int print_match(struct apk_package *pkg)
{
- struct apk_package *pkg = (struct apk_package *) item;
-
printf("%s", pkg->name->name);
if (apk_verbosity > 0)
printf("-%s", pkg->version);
@@ -41,61 +37,50 @@ static int search_list_print(apk_hash_item item, void *ctx)
return 0;
}
-static int search_query_print(apk_hash_item item, void *ctx)
+static int print_rdepends(struct apk_package *pkg)
{
- struct search_query_ctx *ictx = (struct search_query_ctx *) ctx;
- struct apk_package *pkg = (struct apk_package *) item;
+ struct apk_name *name, *name0;
+ struct apk_package *pkg0;
+ struct apk_dependency *dep;
+ int i, j, k;
- if (fnmatch(ictx->query, pkg->name->name, 0) != 0)
+ name = pkg->name;
+ if (name->rdepends == NULL)
return 0;
- search_list_print(item, ictx->db);
-
- return 0;
-}
-
-static int search_list(struct apk_database *db, int argc, char **argv)
-{
- int i;
- struct search_query_ctx ctx;
-
- ctx.db = db;
- if (argc == 0)
- apk_hash_foreach(&db->available.packages, search_list_print, db);
- else
- for (i=0; i<argc; i++) {
- ctx.query = argv[i];
- apk_hash_foreach(&db->available.packages, search_query_print, &ctx);
+ printf("%s-%s:", pkg->name->name, pkg->version);
+ for (i = 0; i < name->rdepends->num; i++) {
+ name0 = name->rdepends->item[i];
+ if (name0->pkgs == NULL)
+ continue;
+ for (j = 0; j < name0->pkgs->num; j++) {
+ pkg0 = name0->pkgs->item[j];
+ if (pkg0->depends == NULL)
+ continue;
+ for (k = 0; k < pkg0->depends->num; k++) {
+ dep = &pkg0->depends->item[k];
+ if (name == dep->name &&
+ (apk_version_compare(pkg->version, dep->version)
+ & dep->result_mask)) {
+ printf(" %s-%s", pkg0->name->name, pkg0->version);
+ }
+ }
}
+ }
+ printf("\n");
return 0;
}
-static int search_query_desc_print(apk_hash_item item, void *ctx)
+static int search_pkgname(struct apk_package *pkg, const char *str)
{
- struct search_query_ctx *ictx = (struct search_query_ctx *) ctx;
- struct apk_package *pkg = (struct apk_package *) item;
-
- if( strstr(pkg->description, ictx->query) == NULL )
- return 0;
- search_list_print(item, ictx->db);
-
- return 0;
+ return fnmatch(str, pkg->name->name, 0) == 0;
}
-static int search_desc(struct apk_database *db, int argc, char **argv)
+static int search_desc(struct apk_package *pkg, const char *str)
{
- int i;
- struct search_query_ctx ctx;
-
- ctx.db = db;
-
- for (i=0; i<argc; i++) {
- ctx.query = argv[i];
- apk_hash_foreach(&db->available.packages, search_query_desc_print, &ctx);
- }
-
- return 0;
+ return strstr(pkg->name->name, str) != NULL ||
+ strstr(pkg->description, str) != NULL;
}
static int search_parse(void *ctx, struct apk_db_options *dbopts,
@@ -105,7 +90,10 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
switch (optch) {
case 'd':
- ictx->action = search_desc;
+ ictx->match = search_desc;
+ break;
+ case 'r':
+ ictx->print = print_rdepends;
break;
default:
return -1;
@@ -113,23 +101,69 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
return 0;
}
+static int match_packages(apk_hash_item item, void *ctx)
+{
+ struct search_ctx *ictx = (struct search_ctx *) ctx;
+ struct apk_package *pkg = (struct apk_package *) item;
+ int i;
+
+ for (i = 0; i < ictx->argc; i++)
+ if (ictx->match(pkg, ictx->argv[i]))
+ break;
+ if (ictx->argc == 0 || i < ictx->argc)
+ ictx->print(pkg);
+
+ return 0;
+}
+
static int search_main(void *ctx, struct apk_database *db, int argc, char **argv)
{
struct search_ctx *ictx = (struct search_ctx *) ctx;
+ struct apk_name *name;
+ int rc = 0, i, j, slow_search;
+
+ slow_search = ictx->match != NULL || argc == 0;
+ if (!slow_search) {
+ for (i = 0; i < argc; i++)
+ if (strcspn(argv[i], "*?[") != strlen(argv[i])) {
+ slow_search = 1;
+ break;
+ }
+ }
+
+ if (ictx->match == NULL)
+ ictx->match = search_pkgname;
+ if (ictx->print == NULL)
+ ictx->print = print_match;
+ else if (argc == 0)
+ return -1;
- if (ictx->action != NULL)
- return ictx->action(db, argc, argv);
+ if (slow_search) {
+ ictx->argc = argc;
+ ictx->argv = argv;
+ rc = apk_hash_foreach(&db->available.packages,
+ match_packages, ictx);
+ } else {
+ for (i = 0; i < argc; i++) {
+ name = apk_db_query_name(db, APK_BLOB_STR(argv[i]));
+ if (name == NULL || name->pkgs == NULL)
+ continue;
+ for (j = 0; j < name->pkgs->num; j++)
+ ictx->print(name->pkgs->item[j]);
+ }
+ }
- return search_list(db, argc, argv);
+ return rc;
}
static struct apk_option search_options[] = {
- { 'd', "description", "Search also package descriptions" },
+ { 'd', "description", "Search also package descriptions" },
+ { 'r', "rdepends", "Print reverse dependencies of package" },
};
static struct apk_applet apk_search = {
.name = "search",
- .help = "Search package names (and descriptions) by wildcard PATTERN.",
+ .help = "Search package by PATTERNs or by indexed dependencies.",
.arguments = "PATTERN",
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE,
.context_size = sizeof(struct search_ctx),
--
1.7.1
From fe55da70741621f7bac2cd943b64cc13e25f9427 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Wed, 26 May 2010 14:30:08 +0300
Subject: [PATCH 4/5] package: don't leak signing key file fd
openssl BIO does not close the fd unless we explicitly tell it to
do so.
---
src/package.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/package.c b/src/package.c
index b265468..b97c412 100644
--- a/src/package.c
+++ b/src/package.c
@@ -441,7 +441,7 @@ int apk_sign_ctx_process_file(struct apk_sign_ctx *ctx,
if (fd < 0)
return 0;
- bio = BIO_new_fp(fdopen(fd, "r"), 0);
+ bio = BIO_new_fp(fdopen(fd, "r"), BIO_CLOSE);
ctx->signature.pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
if (ctx->signature.pkey != NULL) {
if (fi->name[6] == 'R')
--
1.7.1
From d21303960544b5f11b7d69d0335f0903fb93d180 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 13 May 2010 09:26:19 +0000
Subject: [PATCH 5/5] cache: display more than one error
Display all packages that are bad in world rather than only first
before exiting.
---
src/cache.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/cache.c b/src/cache.c
index 85d9777..49a71fa 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -30,7 +30,7 @@ static int cache_download(struct apk_database *db)
struct apk_package *pkg;
struct apk_repository *repo;
char item[PATH_MAX], cacheitem[PATH_MAX];
- int i, r = 0;
+ int i, r = 0, errors = 0;
if (db->world == NULL)
return 0;
@@ -41,12 +41,13 @@ static int cache_download(struct apk_database *db)
for (i = 0; i < db->world->num; i++) {
r = apk_state_lock_dependency(state, &db->world->item[i]);
- if (r != 0) {
- apk_error("Unable to select version for '%s': %d",
- db->world->item[i].name->name, r);
- goto err;
- }
+ errors += r;
+ if (r != 0)
+ apk_error("Unable to select version for '%s'",
+ db->world->item[i].name->name);
}
+ if (errors)
+ goto err;
list_for_each_entry(change, &state->change_list_head, change_list) {
pkg = change->newpkg;
@@ -67,7 +68,7 @@ static int cache_download(struct apk_database *db)
err:
if (state != NULL)
apk_state_unref(state);
- return r;
+ return errors;
}
static int cache_clean(struct apk_database *db)
--
1.7.1
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=apk-tools
pkgver=2.0.2
pkgrel=6
pkgver=2.0.3
pkgrel=0
pkgdesc="Alpine Package Keeper - package manager for alpine"
subpackages="$pkgname-static"
depends=
makedepends="zlib-dev openssl-dev pkgconfig"
source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2
0001-info-fix-querying-of-removed-but-referenced-packages.patch
0002-upgrade-reset-versioned-deps-in-world-when-doing-upg.patch
0003-search-add-search-for-reverse-dependencies-in-index.patch
0004-package-don-t-leak-signing-key-file-fd.patch
0005-cache-display-more-than-one-error.patch
"
......@@ -48,9 +43,4 @@ static() {
"$subpkgdir"/sbin/apk.static
}
md5sums="c87cb88f90eb8d7021d37e3b5386863d apk-tools-2.0.2.tar.bz2
c590e894c2580cbb092b150fca9af3cf 0001-info-fix-querying-of-removed-but-referenced-packages.patch
5c53eaa29dd9722c25b6878cde392d05 0002-upgrade-reset-versioned-deps-in-world-when-doing-upg.patch
6baca299fbf00b97f78fa8fbd0e82f5b 0003-search-add-search-for-reverse-dependencies-in-index.patch
175470e6d5b2d20fe02d6fb61f8ec6d1 0004-package-don-t-leak-signing-key-file-fd.patch
0ab64b75b09f37b4d265df3f7b5b7e83 0005-cache-display-more-than-one-error.patch"
md5sums="191938ff9433745a1e24dfab6f8f7249 apk-tools-2.0.3.tar.bz2"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment