diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-08-05 16:26:46 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-08-05 16:26:46 +0000 |
commit | 6185b4b44addc295026dab7128ae161146fed984 (patch) | |
tree | cdcd85f6a24acdb339b5c33a59623db9e348f486 | |
parent | af3ef82a15ac611eeea4beec92050f80839f4e5e (diff) | |
download | alpine_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
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 @@ | |||
1 | From c1fe6d08f3ba77bf13b098216fc5e5bcd4ba23f7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Timo Teras <timo.teras@iki.fi> | ||
3 | Date: Thu, 30 Jul 2009 11:55:59 +0300 | ||
4 | Subject: [PATCH] db: fix checksum storing to db | ||
5 | |||
6 | also take precautions in audit code if the db is missing the | ||
7 | checksum. | ||
8 | --- | ||
9 | src/audit.c | 7 +++---- | ||
10 | src/database.c | 8 ++++++-- | ||
11 | 2 files changed, 9 insertions(+), 6 deletions(-) | ||
12 | |||
13 | diff --git a/src/audit.c b/src/audit.c | ||
14 | index 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'; | ||
31 | diff --git a/src/database.c b/src/database.c | ||
32 | index 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 | -- | ||
72 | 1.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 @@ | |||
1 | From 2cfca5b6ed658433419f9b581b3ba30f34c973c4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Timo Teras <timo.teras@iki.fi> | ||
3 | Date: Wed, 5 Aug 2009 19:10:54 +0300 | ||
4 | Subject: [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 | |||
10 | diff --git a/src/info.c b/src/info.c | ||
11 | index 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 | -- | ||
25 | 1.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 @@ | |||
1 | From 67108bf07a67811ea91fc965f3f1592a4a70044e Mon Sep 17 00:00:00 2001 | ||
2 | From: Timo Teras <timo.teras@iki.fi> | ||
3 | Date: Fri, 31 Jul 2009 10:50:15 +0300 | ||
4 | Subject: [PATCH] io: fix corruption of big files on mmap write | ||
5 | |||
6 | remember to increment destination pointer; and munmap the proper | ||
7 | base address. | ||
8 | --- | ||
9 | src/io.c | 27 +++++++++++++-------------- | ||
10 | 1 files changed, 13 insertions(+), 14 deletions(-) | ||
11 | |||
12 | diff --git a/src/io.c b/src/io.c | ||
13 | index 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 | -- | ||
75 | 1.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> |
2 | pkgname=apk-tools | 2 | pkgname=apk-tools |
3 | pkgver=2.0_rc1 | 3 | pkgver=2.0_rc1 |
4 | pkgrel=0 | 4 | pkgrel=1 |
5 | pkgdesc="Alpine Package Keeper - package manager for alpine" | 5 | pkgdesc="Alpine Package Keeper - package manager for alpine" |
6 | subpackages="$pkgname-static" | 6 | subpackages="$pkgname-static" |
7 | depends= | 7 | depends= |
8 | makedepends="zlib-dev openssl-dev pkgconfig" | 8 | makedepends="zlib-dev openssl-dev pkgconfig" |
9 | source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2 | 9 | source="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 | |||
16 | build() { | 17 | build() { |
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 | ||
38 | md5sums="f790182792a41841e6932ae0b6737a43 apk-tools-2.0_rc1.tar.bz2" | 40 | md5sums="f790182792a41841e6932ae0b6737a43 apk-tools-2.0_rc1.tar.bz2 |
41 | 87dd230bf89f429db06dcad96be235c0 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch" | ||