summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-05-26 14:32:07 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-05-26 14:32:07 +0000
commit08be4cd7d8531bae1eb7574d8b2d7d0c4db5cda2 (patch)
treedeb64b4446c75d2908c4fc61d53c5e08945c8e3a /core
parent3feee61202f83526a8a637bd95af5586fa867dd3 (diff)
downloadaports-08be4cd7d8531bae1eb7574d8b2d7d0c4db5cda2.tar.bz2
aports-08be4cd7d8531bae1eb7574d8b2d7d0c4db5cda2.tar.xz
core/apk-tools: fix fd leak
and cleanup old unused patches
Diffstat (limited to 'core')
-rw-r--r--core/apk-tools/APKBUILD9
-rw-r--r--core/apk-tools/delay-state-init.patch63
-rw-r--r--core/apk-tools/fd-leak.patch24
-rw-r--r--core/apk-tools/index-delete.patch132
-rw-r--r--core/apk-tools/version.patch13
5 files changed, 30 insertions, 211 deletions
diff --git a/core/apk-tools/APKBUILD b/core/apk-tools/APKBUILD
index 71219d7bf..d1c5c0c63 100644
--- a/core/apk-tools/APKBUILD
+++ b/core/apk-tools/APKBUILD
@@ -1,16 +1,18 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=apk-tools
pkgver=2.0_pre12
-pkgrel=0
+pkgrel=1
pkgdesc="Alpine Package Keeper - package manager for alpine"
depends="uclibc"
makedepends="zlib-dev"
-source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2
+ fd-leak.patch"
url="http://git.alpinelinux.org/cgit/apk-tools/"
license=GPL-2
build() {
cd "$srcdir/$pkgname-$pkgver"
+ patch -p1 < ../fd-leak.patch || return 1
sed -i -e 's:-Werror::' Make.rules
make
make DESTDIR="$pkgdir" install
@@ -23,4 +25,5 @@ build() {
ln -s apk apk_version
}
-md5sums="042d28b5cb8ddafe6add63766bc6c17a apk-tools-2.0_pre12.tar.bz2"
+md5sums="042d28b5cb8ddafe6add63766bc6c17a apk-tools-2.0_pre12.tar.bz2
+66e915fb667e5ac382ecb801decf2c1c fd-leak.patch"
diff --git a/core/apk-tools/delay-state-init.patch b/core/apk-tools/delay-state-init.patch
deleted file mode 100644
index 397d2d4c2..000000000
--- a/core/apk-tools/delay-state-init.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-commit 110611c53c8e1b09c27c8c516c7f7c0baf47f68b
-Author: Natanael Copa <ncopa@alpinelinux.org>
-Date: Mon May 11 12:02:00 2009 +0000
-
- add: delay state initialization til we have all pkgs in db
-
- The state size is taken from name_id and cannot be extended. So we
- must wait with initializing the state til we have all packages added
- to the db.
-
- We must also always allocate the package name, incase its not in the
- repository. This is done with apk_db_get_name().
-
-diff --git a/src/add.c b/src/add.c
-index 77abc3b..9efab15 100644
---- a/src/add.c
-+++ b/src/add.c
-@@ -41,13 +41,13 @@ static int add_main(void *ctx, int argc, char **argv)
- struct add_ctx *actx = (struct add_ctx *) ctx;
- struct apk_database db;
- struct apk_state *state;
-+ struct apk_dependency_array *pkgs; /* list of pkgs to install */
- int i, r;
-
- r = apk_db_open(&db, apk_root, actx->open_flags | APK_OPENF_WRITE);
- if (r != 0)
- return r;
-
-- state = apk_state_new(&db);
- for (i = 0; i < argc; i++) {
- struct apk_dependency dep;
-
-@@ -61,7 +61,7 @@ static int add_main(void *ctx, int argc, char **argv)
- }
-
- dep = (struct apk_dependency) {
-- .name = pkg->name,
-+ .name = apk_db_get_name(&db, APK_BLOB_STR(pkg->name->name)),
- .version = pkg->version,
- .result_mask = APK_VERSION_EQUAL,
- };
-@@ -71,14 +71,18 @@ static int add_main(void *ctx, int argc, char **argv)
- .result_mask = APK_DEPMASK_REQUIRE,
- };
- }
-- apk_deps_add(&db.world, &dep);
- dep.name->flags |= APK_NAME_TOPLEVEL;
-+ apk_deps_add(&pkgs, &dep);
-+ }
-
-- r = apk_state_lock_dependency(state, &dep);
-+ state = apk_state_new(&db);
-+ for (i = 0; i < pkgs->num; i++) {
-+ r = apk_state_lock_dependency(state, &pkgs->item[i]);
- if (r != 0) {
-- apk_error("Unable to install '%s'", dep.name->name);
-+ apk_error("Unable to install '%s'", pkgs->item[i].name->name);
- goto err;
- }
-+ apk_deps_add(&db.world, &pkgs->item[i]);
- }
- r = apk_state_commit(state, &db);
- err:
diff --git a/core/apk-tools/fd-leak.patch b/core/apk-tools/fd-leak.patch
new file mode 100644
index 000000000..5f6a55ff8
--- /dev/null
+++ b/core/apk-tools/fd-leak.patch
@@ -0,0 +1,24 @@
+commit bd6278fb28d1d87a58a591244fe1069aa4216a6f
+Author: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue May 26 14:12:02 2009 +0000
+
+ fetch: fix fd leak
+
+ we should always close the in-stream, not only on failure.
+
+diff --git a/src/fetch.c b/src/fetch.c
+index 9e0d930..f3c651b 100644
+--- a/src/fetch.c
++++ b/src/fetch.c
+@@ -95,10 +95,10 @@ static int fetch_package(struct fetch_ctx *fctx,
+ }
+
+ r = apk_istream_splice(is, fd, pkg->size, NULL, NULL);
++ is->close(is);
+ if (fd != STDOUT_FILENO)
+ close(fd);
+ if (r != pkg->size) {
+- is->close(is);
+ apk_error("Unable to download '%s'", file);
+ unlink(file);
+ return -1;
diff --git a/core/apk-tools/index-delete.patch b/core/apk-tools/index-delete.patch
deleted file mode 100644
index 4985e3574..000000000
--- a/core/apk-tools/index-delete.patch
+++ /dev/null
@@ -1,132 +0,0 @@
-commit 2b6e5d6e40a0b8a7ef650ef66996148cfdca1f2c
-Author: Natanael Copa <ncopa@alpinelinux.org>
-Date: Tue May 12 06:27:25 2009 +0000
-
- index: support for -d to delete packages from given index
-
- The syntax is: apk index -d /path/to/APK_INDEX.gz pkg...
-
- It does not seem like its possible to remove packages in the db so we
- trick apk_db_index_write() by setting the repo to on-zero.
-
- It's still not perfect since it does not recalculate the dependencies.
-
-diff --git a/src/apk_database.h b/src/apk_database.h
-index e7bfac9..0a0e52d 100644
---- a/src/apk_database.h
-+++ b/src/apk_database.h
-@@ -123,6 +123,7 @@ struct apk_package *apk_db_pkg_add_file(struct apk_database *db, const char *fil
- struct apk_package *apk_db_get_pkg(struct apk_database *db, csum_t sum);
- struct apk_package *apk_db_get_file_owner(struct apk_database *db, apk_blob_t filename);
-
-+int apk_db_index_read(struct apk_database *db, struct apk_istream *is, int repo);
- int apk_db_index_write(struct apk_database *db, struct apk_ostream *os);
-
- int apk_db_add_repository(apk_database_t db, apk_blob_t repository);
-diff --git a/src/database.c b/src/database.c
-index 4da547d..e91c64a 100644
---- a/src/database.c
-+++ b/src/database.c
-@@ -370,7 +370,7 @@ static struct apk_package *apk_db_pkg_add(struct apk_database *db, struct apk_pa
- return idb;
- }
-
--static int apk_db_index_read(struct apk_database *db, struct apk_istream *is, int repo)
-+int apk_db_index_read(struct apk_database *db, struct apk_istream *is, int repo)
- {
- struct apk_package *pkg = NULL;
- struct apk_db_dir_instance *diri = NULL;
-diff --git a/src/index.c b/src/index.c
-index 08fc342..e906ab4 100644
---- a/src/index.c
-+++ b/src/index.c
-@@ -19,6 +19,40 @@ struct counts {
- int unsatisfied;
- };
-
-+struct index_ctx {
-+ const char *index_file;
-+ int delete;
-+};
-+
-+static int index_parse(void *ctx, int optch, int optindex, const char *optarg)
-+{
-+ struct index_ctx *ictx = (struct index_ctx *) ctx;
-+
-+ switch (optch) {
-+ case 'd':
-+ ictx->index_file = optarg;
-+ ictx->delete = 1;
-+ break;
-+ default:
-+ return -1;
-+ }
-+ return 0;
-+}
-+
-+static int index_read_file(struct apk_database *db, struct index_ctx *ictx)
-+{
-+ struct apk_istream *is;
-+ int r;
-+ if (ictx->index_file == NULL)
-+ return 0;
-+ is = apk_bstream_gunzip(apk_bstream_from_url(ictx->index_file), 1);
-+ if (is == NULL)
-+ return -1;
-+ r = apk_db_index_read(db, is, -1);
-+ is->close(is);
-+ return r;
-+}
-+
- static int warn_if_no_providers(apk_hash_item item, void *ctx)
- {
- struct counts *counts = (struct counts *) ctx;
-@@ -42,11 +76,26 @@ static int index_main(void *ctx, int argc, char **argv)
- struct apk_database db;
- struct counts counts = {0};
- struct apk_ostream *os;
-- int total, i;
-+ int total, i, j;
-+ struct index_ctx *ictx = (struct index_ctx *) ctx;
-
- apk_db_open(&db, NULL, APK_OPENF_READ);
-- for (i = 0; i < argc; i++)
-- apk_db_pkg_add_file(&db, argv[i]);
-+ index_read_file(&db, ictx);
-+
-+ for (i = 0; i < argc; i++) {
-+ if (ictx->delete) {
-+ struct apk_name *name;
-+ name = apk_db_query_name(&db, APK_BLOB_STR(argv[i]));
-+ if (name == NULL)
-+ continue;
-+ /* apk_db_index_write() will only print the pkgs
-+ where repos == 0. We prevent to write the given
-+ packages by setting repos to non-zero */
-+ for (j = 0; j < name->pkgs->num; j++)
-+ name->pkgs->item[j]->repos = -1;
-+ } else
-+ apk_db_pkg_add_file(&db, argv[i]);
-+ }
-
- os = apk_ostream_to_fd(STDOUT_FILENO);
- total = apk_db_index_write(&db, os);
-@@ -64,9 +113,17 @@ static int index_main(void *ctx, int argc, char **argv)
- return 0;
- }
-
-+static struct option index_options[] = {
-+ { "delete", required_argument, NULL, 'd' },
-+};
-+
- static struct apk_applet apk_index = {
- .name = "index",
-- .usage = "apkname...",
-+ .usage = "[-d indexfile] apkname...",
-+ .context_size = sizeof(struct index_ctx),
-+ .num_options = ARRAY_SIZE(index_options),
-+ .options = index_options,
-+ .parse = index_parse,
- .main = index_main,
- };
-
diff --git a/core/apk-tools/version.patch b/core/apk-tools/version.patch
deleted file mode 100644
index f1bec3b32..000000000
--- a/core/apk-tools/version.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/Make.rules b/Make.rules
-index c864064..81881a7 100644
---- a/Make.rules
-+++ b/Make.rules
-@@ -47,7 +47,7 @@ export srctree objtree
- ##
- # Consult SCM for better version string.
-
--GIT_REV := $(shell git describe || echo exported)
-+GIT_REV := $(shell test -d .git && git describe || echo exported)
- ifneq ($(GIT_REV), exported)
- FULL_VERSION := $(patsubst $(PACKAGE)-%,%,$(GIT_REV))
- FULL_VERSION := $(patsubst v%,%,$(FULL_VERSION))