aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-08-05 16:26:46 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-08-05 16:26:46 +0000
commit6185b4b44addc295026dab7128ae161146fed984 (patch)
treecdcd85f6a24acdb339b5c33a59623db9e348f486
parentaf3ef82a15ac611eeea4beec92050f80839f4e5e (diff)
downloadalpine_aports-6185b4b44addc295026dab7128ae161146fed984.tar.bz2
alpine_aports-6185b4b44addc295026dab7128ae161146fed984.tar.xz
alpine_aports-6185b4b44addc295026dab7128ae161146fed984.zip
main/apk-tools: fix segfault for info --exist
and remove unused patches
-rw-r--r--main/apk-tools/0001-db-fix-checksum-storing-to-db.patch73
-rw-r--r--main/apk-tools/0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch26
-rw-r--r--main/apk-tools/0001-io-fix-corruption-of-big-files-on-mmap-write.patch76
-rw-r--r--main/apk-tools/APKBUILD7
4 files changed, 31 insertions, 151 deletions
diff --git a/main/apk-tools/0001-db-fix-checksum-storing-to-db.patch b/main/apk-tools/0001-db-fix-checksum-storing-to-db.patch
deleted file mode 100644
index c54fe73b48..0000000000
--- a/main/apk-tools/0001-db-fix-checksum-storing-to-db.patch
+++ /dev/null
@@ -1,73 +0,0 @@
1From c1fe6d08f3ba77bf13b098216fc5e5bcd4ba23f7 Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Thu, 30 Jul 2009 11:55:59 +0300
4Subject: [PATCH] db: fix checksum storing to db
5
6also take precautions in audit code if the db is missing the
7checksum.
8---
9 src/audit.c | 7 +++----
10 src/database.c | 8 ++++++--
11 2 files changed, 9 insertions(+), 6 deletions(-)
12
13diff --git a/src/audit.c b/src/audit.c
14index 31965df..76bd492 100644
15--- a/src/audit.c
16+++ b/src/audit.c
17@@ -69,10 +69,9 @@ static int audit_directory(apk_hash_item item, void *ctx)
18 } else {
19 dbf = apk_db_file_query(db, bdir, APK_BLOB_STR(de->d_name));
20 if (dbf != NULL) {
21- if (apk_file_get_info(tmp, dbf->csum.type, &fi) < 0)
22- continue;
23-
24- if (apk_checksum_compare(&fi.csum, &dbf->csum) == 0)
25+ if (dbf->csum.type != APK_CHECKSUM_NONE &&
26+ apk_file_get_info(tmp, dbf->csum.type, &fi) == 0 &&
27+ apk_checksum_compare(&fi.csum, &dbf->csum) == 0)
28 continue;
29
30 reason = 'U';
31diff --git a/src/database.c b/src/database.c
32index 968d55e..16ae94b 100644
33--- a/src/database.c
34+++ b/src/database.c
35@@ -1458,6 +1458,7 @@ static int apk_db_install_archive_entry(void *_ctx,
36 diri->dir->name, file->name);
37 r = apk_archive_entry_extract(ae, is, alt_name,
38 extract_cb, ctx);
39+ memcpy(&file->csum, &ae->csum, sizeof(file->csum));
40 } else {
41 if (apk_verbosity >= 3)
42 apk_message("%s", ae->name);
43@@ -1502,7 +1503,8 @@ static void apk_db_purge_pkg(struct apk_database *db, struct apk_package *pkg,
44 hash = apk_blob_hash_seed(key.filename, diri->dir->hash);
45 if (!(diri->dir->flags & APK_DBDIRF_PROTECTED) ||
46 (apk_flags & APK_PURGE) ||
47- (apk_file_get_info(name, file->csum.type, &fi) == 0 &&
48+ (file->csum.type != APK_CHECKSUM_NONE &&
49+ apk_file_get_info(name, file->csum.type, &fi) == 0 &&
50 apk_checksum_compare(&file->csum, &fi.csum) == 0))
51 unlink(name);
52 if (apk_verbosity >= 3)
53@@ -1565,6 +1567,7 @@ static void apk_db_migrate_files(struct apk_database *db,
54 if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
55 (r == 0) &&
56 (ofile == NULL ||
57+ ofile->csum.type == APK_CHECKSUM_NONE ||
58 apk_checksum_compare(&ofile->csum, &fi.csum) != 0)) {
59 /* Protected directory, with file without
60 * db entry, or local modifications.
61@@ -1575,7 +1578,8 @@ static void apk_db_migrate_files(struct apk_database *db,
62 ofile->csum.type != file->csum.type)
63 apk_file_get_info(name, file->csum.type, &fi);
64 if ((apk_flags & APK_CLEAN_PROTECTED) ||
65- apk_checksum_compare(&file->csum, &fi.csum) == 0)
66+ (file->csum.type != APK_CHECKSUM_NONE &&
67+ apk_checksum_compare(&file->csum, &fi.csum) == 0))
68 unlink(tmpname);
69 } else {
70 /* Overwrite the old file */
71--
721.6.3.3
73
diff --git a/main/apk-tools/0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch b/main/apk-tools/0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch
new file mode 100644
index 0000000000..f0f918a59e
--- /dev/null
+++ b/main/apk-tools/0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch
@@ -0,0 +1,26 @@
1From 2cfca5b6ed658433419f9b581b3ba30f34c973c4 Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Wed, 5 Aug 2009 19:10:54 +0300
4Subject: [PATCH] info: fix a --exists to work if the name is non-existant
5
6---
7 src/info.c | 3 +++
8 1 files changed, 3 insertions(+), 0 deletions(-)
9
10diff --git a/src/info.c b/src/info.c
11index a222b8c..073dc80 100644
12--- a/src/info.c
13+++ b/src/info.c
14@@ -94,6 +94,9 @@ static int info_exists(struct info_ctx *ctx, struct apk_database *db,
15 continue;
16
17 name = dep.name;
18+ if (name->pkgs == NULL)
19+ continue;
20+
21 for (j = 0; j < name->pkgs->num; j++) {
22 pkg = name->pkgs->item[j];
23 if (apk_pkg_get_state(pkg) == APK_PKG_INSTALLED)
24--
251.6.3.3
26
diff --git a/main/apk-tools/0001-io-fix-corruption-of-big-files-on-mmap-write.patch b/main/apk-tools/0001-io-fix-corruption-of-big-files-on-mmap-write.patch
deleted file mode 100644
index 4261ce521f..0000000000
--- a/main/apk-tools/0001-io-fix-corruption-of-big-files-on-mmap-write.patch
+++ /dev/null
@@ -1,76 +0,0 @@
1From 67108bf07a67811ea91fc965f3f1592a4a70044e Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Fri, 31 Jul 2009 10:50:15 +0300
4Subject: [PATCH] io: fix corruption of big files on mmap write
5
6remember to increment destination pointer; and munmap the proper
7base address.
8---
9 src/io.c | 27 +++++++++++++--------------
10 1 files changed, 13 insertions(+), 14 deletions(-)
11
12diff --git a/src/io.c b/src/io.c
13index 18e89d3..3929ba1 100644
14--- a/src/io.c
15+++ b/src/io.c
16@@ -114,21 +114,19 @@ size_t apk_istream_splice(void *stream, int fd, size_t size,
17 {
18 static void *splice_buffer = NULL;
19 struct apk_istream *is = (struct apk_istream *) stream;
20- unsigned char *buf = MAP_FAILED;
21- size_t bufsz, done = 0, r, togo, mmapped = 0;
22+ unsigned char *buf, *mmapbase = MAP_FAILED;
23+ size_t bufsz, done = 0, r, togo;
24
25 bufsz = size;
26 if (size > 128 * 1024) {
27 if (ftruncate(fd, size) == 0)
28- buf = mmap(NULL, size, PROT_READ | PROT_WRITE,
29- MAP_SHARED, fd, 0);
30- if (buf != MAP_FAILED) {
31- mmapped = 1;
32- if (bufsz > 2*1024*1024)
33- bufsz = 2*1024*1024;
34- }
35+ mmapbase = mmap(NULL, size, PROT_READ | PROT_WRITE,
36+ MAP_SHARED, fd, 0);
37+ if (bufsz > 2*1024*1024)
38+ bufsz = 2*1024*1024;
39+ buf = mmapbase;
40 }
41- if (!mmapped) {
42+ if (mmapbase == MAP_FAILED) {
43 if (splice_buffer == NULL)
44 splice_buffer = malloc(256*1024);
45 buf = splice_buffer;
46@@ -149,13 +147,14 @@ size_t apk_istream_splice(void *stream, int fd, size_t size,
47 if (r < 0)
48 goto err;
49
50- if (!mmapped) {
51+ if (mmapbase == MAP_FAILED) {
52 if (write(fd, buf, r) != r) {
53 if (r < 0)
54 r = -errno;
55 goto err;
56 }
57- }
58+ } else
59+ buf += r;
60
61 done += r;
62 if (r != togo)
63@@ -163,8 +162,8 @@ size_t apk_istream_splice(void *stream, int fd, size_t size,
64 }
65 r = done;
66 err:
67- if (mmapped)
68- munmap(buf, size);
69+ if (mmapbase != MAP_FAILED)
70+ munmap(mmapbase, size);
71 return r;
72 }
73
74--
751.6.3.3
76
diff --git a/main/apk-tools/APKBUILD b/main/apk-tools/APKBUILD
index 2f0b37e384..215e7d04da 100644
--- a/main/apk-tools/APKBUILD
+++ b/main/apk-tools/APKBUILD
@@ -1,12 +1,13 @@
1# Maintainer: Natanael Copa <ncopa@alpinelinux.org> 1# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
2pkgname=apk-tools 2pkgname=apk-tools
3pkgver=2.0_rc1 3pkgver=2.0_rc1
4pkgrel=0 4pkgrel=1
5pkgdesc="Alpine Package Keeper - package manager for alpine" 5pkgdesc="Alpine Package Keeper - package manager for alpine"
6subpackages="$pkgname-static" 6subpackages="$pkgname-static"
7depends= 7depends=
8makedepends="zlib-dev openssl-dev pkgconfig" 8makedepends="zlib-dev openssl-dev pkgconfig"
9source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2 9source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2
10 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch
10 " 11 "
11 12
12 13
@@ -16,6 +17,7 @@ license=GPL-2
16build() { 17build() {
17 cd "$srcdir/$pkgname-$pkgver" 18 cd "$srcdir/$pkgname-$pkgver"
18 sed -i -e 's:-Werror::' Make.rules 19 sed -i -e 's:-Werror::' Make.rules
20 patch -p1 -i ../0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch || return 1
19 21
20 make || return 1 22 make || return 1
21 make static || return 1 23 make static || return 1
@@ -35,4 +37,5 @@ static() {
35 "$subpkgdir"/sbin/apk.static 37 "$subpkgdir"/sbin/apk.static
36} 38}
37 39
38md5sums="f790182792a41841e6932ae0b6737a43 apk-tools-2.0_rc1.tar.bz2" 40md5sums="f790182792a41841e6932ae0b6737a43 apk-tools-2.0_rc1.tar.bz2
4187dd230bf89f429db06dcad96be235c0 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch"