aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-08-06 11:36:59 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-08-06 11:36:59 +0000
commitdd2128cffe618ac1e3ebf109da0df111a4988044 (patch)
tree25af2b51bf43d6c3cc21c155a84dda52c066b421
parent2251f300c3c86a3ef7256ed088ad4c4b1dd388e1 (diff)
downloadalpine_aports-dd2128cffe618ac1e3ebf109da0df111a4988044.tar.bz2
alpine_aports-dd2128cffe618ac1e3ebf109da0df111a4988044.tar.xz
alpine_aports-dd2128cffe618ac1e3ebf109da0df111a4988044.zip
main/apk-tools: fixes from upstream
-rw-r--r--main/apk-tools/0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch4
-rw-r--r--main/apk-tools/0002-audit-fix-backup.patch35
-rw-r--r--main/apk-tools/0003-db-command-line-repositories-take-preference.patch194
-rw-r--r--main/apk-tools/0004-state-ignore-missing-world-dependencies-with-force-a.patch25
-rw-r--r--main/apk-tools/0005-audit-do-not-load-repositories.patch40
-rw-r--r--main/apk-tools/0006-db-make-missing-index-non-fatal.patch29
-rw-r--r--main/apk-tools/APKBUILD19
7 files changed, 341 insertions, 5 deletions
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
index f0f918a59e..a2f33ffac9 100644
--- 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
@@ -1,7 +1,7 @@
1From 2cfca5b6ed658433419f9b581b3ba30f34c973c4 Mon Sep 17 00:00:00 2001 1From 2cfca5b6ed658433419f9b581b3ba30f34c973c4 Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi> 2From: Timo Teras <timo.teras@iki.fi>
3Date: Wed, 5 Aug 2009 19:10:54 +0300 3Date: Wed, 5 Aug 2009 19:10:54 +0300
4Subject: [PATCH] info: fix a --exists to work if the name is non-existant 4Subject: [PATCH 1/7] info: fix a --exists to work if the name is non-existant
5 5
6--- 6---
7 src/info.c | 3 +++ 7 src/info.c | 3 +++
@@ -22,5 +22,5 @@ index a222b8c..073dc80 100644
22 pkg = name->pkgs->item[j]; 22 pkg = name->pkgs->item[j];
23 if (apk_pkg_get_state(pkg) == APK_PKG_INSTALLED) 23 if (apk_pkg_get_state(pkg) == APK_PKG_INSTALLED)
24-- 24--
251.6.3.3 251.6.4
26 26
diff --git a/main/apk-tools/0002-audit-fix-backup.patch b/main/apk-tools/0002-audit-fix-backup.patch
new file mode 100644
index 0000000000..4424f7f57b
--- /dev/null
+++ b/main/apk-tools/0002-audit-fix-backup.patch
@@ -0,0 +1,35 @@
1From 7419771b02e84a91a71b12869a40208fd2e8b773 Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Thu, 6 Aug 2009 08:57:50 +0300
4Subject: [PATCH 2/7] audit: fix --backup
5
6---
7 src/audit.c | 5 ++++-
8 1 files changed, 4 insertions(+), 1 deletions(-)
9
10diff --git a/src/audit.c b/src/audit.c
11index d61b321..e47f182 100644
12--- a/src/audit.c
13+++ b/src/audit.c
14@@ -51,6 +51,9 @@ static int audit_directory(apk_hash_item item, void *ctx)
15 char tmp[PATH_MAX], reason;
16 DIR *dir;
17
18+ if (!(dbd->flags & APK_DBDIRF_PROTECTED))
19+ return 0;
20+
21 dir = fdopendir(openat(db->root_fd, dbd->name, O_RDONLY));
22 if (dir == NULL)
23 return 0;
24@@ -97,7 +100,7 @@ static int audit_directory(apk_hash_item item, void *ctx)
25
26 static int audit_backup(struct apk_database *db)
27 {
28- return apk_hash_foreach(&db->installed.dirs, audit_directory, &db);
29+ return apk_hash_foreach(&db->installed.dirs, audit_directory, db);
30 }
31
32 static int audit_system(struct apk_database *db)
33--
341.6.4
35
diff --git a/main/apk-tools/0003-db-command-line-repositories-take-preference.patch b/main/apk-tools/0003-db-command-line-repositories-take-preference.patch
new file mode 100644
index 0000000000..1f1786c35a
--- /dev/null
+++ b/main/apk-tools/0003-db-command-line-repositories-take-preference.patch
@@ -0,0 +1,194 @@
1From 6f1de8cd530f598f3f79414390d98fd8e683f2af Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Thu, 6 Aug 2009 10:17:28 +0300
4Subject: [PATCH 3/7] db: command line repositories take preference
5
6over the ones in config file. also remove the apk_root == NULL
7check as this cannot happen anymore. a valid root is always
8required.
9---
10 src/database.c | 145 +++++++++++++++++++++++++++-----------------------------
11 1 files changed, 70 insertions(+), 75 deletions(-)
12
13diff --git a/src/database.c b/src/database.c
14index 30e0431..834383b 100644
15--- a/src/database.c
16+++ b/src/database.c
17@@ -895,59 +895,56 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
18 db->cache_dir = apk_static_cache_dir;
19 db->permanent = 1;
20
21- if (root != NULL) {
22- db->root = strdup(root);
23- db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY);
24- if (db->root_fd < 0 && (flags & APK_OPENF_CREATE)) {
25- mkdirat(AT_FDCWD, db->root, 0755);
26- db->root_fd = openat(AT_FDCWD, root, O_RDONLY);
27- }
28- if (db->root_fd < 0) {
29- msg = "Unable to open root";
30- goto ret_errno;
31- }
32- if (fstat64(db->root_fd, &st) != 0 || major(st.st_dev) == 0)
33- db->permanent = 0;
34-
35- if (fstatat64(db->root_fd, apk_linked_cache_dir, &st, 0) == 0 &&
36- S_ISDIR(st.st_mode))
37- db->cache_dir = apk_linked_cache_dir;
38-
39- if (flags & APK_OPENF_WRITE) {
40+ db->root = strdup(root);
41+ db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY);
42+ if (db->root_fd < 0 && (flags & APK_OPENF_CREATE)) {
43+ mkdirat(AT_FDCWD, db->root, 0755);
44+ db->root_fd = openat(AT_FDCWD, root, O_RDONLY);
45+ }
46+ if (db->root_fd < 0) {
47+ msg = "Unable to open root";
48+ goto ret_errno;
49+ }
50+ if (fstat64(db->root_fd, &st) != 0 || major(st.st_dev) == 0)
51+ db->permanent = 0;
52+
53+ if (fstatat64(db->root_fd, apk_linked_cache_dir, &st, 0) == 0 &&
54+ S_ISDIR(st.st_mode))
55+ db->cache_dir = apk_linked_cache_dir;
56+
57+ if (flags & APK_OPENF_WRITE) {
58+ db->lock_fd = openat(db->root_fd, "var/lib/apk/lock",
59+ O_CREAT | O_RDWR, 0400);
60+ if (db->lock_fd < 0 && errno == ENOENT &&
61+ (flags & APK_OPENF_CREATE)) {
62+ r = apk_db_create(db);
63+ if (r != 0) {
64+ msg = "Unable to create database";
65+ goto ret_r;
66+ }
67 db->lock_fd = openat(db->root_fd, "var/lib/apk/lock",
68 O_CREAT | O_RDWR, 0400);
69- if (db->lock_fd < 0 && errno == ENOENT &&
70- (flags & APK_OPENF_CREATE)) {
71- r = apk_db_create(db);
72- if (r != 0) {
73- msg = "Unable to create database";
74- goto ret_r;
75- }
76- db->lock_fd = openat(db->root_fd,
77- "var/lib/apk/lock",
78- O_CREAT | O_RDWR, 0400);
79- }
80- if (db->lock_fd < 0 ||
81- flock(db->lock_fd, LOCK_EX | LOCK_NB) < 0) {
82- msg = "Unable to lock database";
83- if (apk_wait) {
84- struct sigaction sa, old_sa;
85-
86- apk_message("Waiting for repository lock");
87- memset(&sa, 0, sizeof sa);
88- sa.sa_handler = handle_alarm;
89- sa.sa_flags = SA_ONESHOT;
90- sigaction(SIGALRM, &sa, &old_sa);
91-
92- alarm(apk_wait);
93- if (flock(db->lock_fd, LOCK_EX) < 0)
94- goto ret_errno;
95-
96- alarm(0);
97- sigaction(SIGALRM, &old_sa, NULL);
98- } else
99+ }
100+ if (db->lock_fd < 0 ||
101+ flock(db->lock_fd, LOCK_EX | LOCK_NB) < 0) {
102+ msg = "Unable to lock database";
103+ if (apk_wait) {
104+ struct sigaction sa, old_sa;
105+
106+ apk_message("Waiting for repository lock");
107+ memset(&sa, 0, sizeof sa);
108+ sa.sa_handler = handle_alarm;
109+ sa.sa_flags = SA_ONESHOT;
110+ sigaction(SIGALRM, &sa, &old_sa);
111+
112+ alarm(apk_wait);
113+ if (flock(db->lock_fd, LOCK_EX) < 0)
114 goto ret_errno;
115- }
116+
117+ alarm(0);
118+ sigaction(SIGALRM, &old_sa, NULL);
119+ } else
120+ goto ret_errno;
121 }
122 }
123
124@@ -959,33 +956,18 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
125 db->cachetmp_fd = openat(db->cache_fd, "tmp", O_RDONLY);
126 db->keys_fd = openat(db->root_fd, "etc/apk/keys", O_RDONLY);
127
128- if (root != NULL) {
129- r = apk_db_read_state(db, flags);
130- if (r == -ENOENT && (flags & APK_OPENF_CREATE)) {
131- r = apk_db_create(db);
132- if (r != 0) {
133- msg = "Unable to create database";
134- goto ret_r;
135- }
136- r = apk_db_read_state(db, flags);
137- }
138+ r = apk_db_read_state(db, flags);
139+ if (r == -ENOENT && (flags & APK_OPENF_CREATE)) {
140+ r = apk_db_create(db);
141 if (r != 0) {
142- msg = "Unable to read database state";
143+ msg = "Unable to create database";
144 goto ret_r;
145 }
146-
147- if (!(flags & APK_OPENF_NO_REPOS)) {
148- if (apk_repos == NULL)
149- apk_repos = "etc/apk/repositories";
150- blob = apk_blob_from_file(db->root_fd, apk_repos);
151- if (!APK_BLOB_IS_NULL(blob)) {
152- r = apk_blob_for_each_segment(
153- blob, "\n",
154- apk_db_add_repository, db);
155- rr = r ?: rr;
156- free(blob.ptr);
157- }
158- }
159+ r = apk_db_read_state(db, flags);
160+ }
161+ if (r != 0) {
162+ msg = "Unable to read database state";
163+ goto ret_r;
164 }
165
166 if (!(flags & APK_OPENF_NO_REPOS)) {
167@@ -993,10 +975,23 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
168 r = apk_db_add_repository(db, APK_BLOB_STR(repo->url));
169 rr = r ?: rr;
170 }
171-
172+ if (apk_repos == NULL)
173+ apk_repos = "etc/apk/repositories";
174+ blob = apk_blob_from_file(db->root_fd, apk_repos);
175+ if (!APK_BLOB_IS_NULL(blob)) {
176+ r = apk_blob_for_each_segment(
177+ blob, "\n",
178+ apk_db_add_repository, db);
179+ rr = r ?: rr;
180+ free(blob.ptr);
181+ }
182 if (apk_flags & APK_UPDATE_CACHE)
183 apk_db_index_write_nr_cache(db);
184 }
185+ if (rr != 0) {
186+ r = rr;
187+ goto ret_r;
188+ }
189
190 return rr;
191
192--
1931.6.4
194
diff --git a/main/apk-tools/0004-state-ignore-missing-world-dependencies-with-force-a.patch b/main/apk-tools/0004-state-ignore-missing-world-dependencies-with-force-a.patch
new file mode 100644
index 0000000000..2b2cc47155
--- /dev/null
+++ b/main/apk-tools/0004-state-ignore-missing-world-dependencies-with-force-a.patch
@@ -0,0 +1,25 @@
1From 0b2052ed064708767358290a73d600ed55fee5b2 Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Thu, 6 Aug 2009 11:47:44 +0300
4Subject: [PATCH 4/7] state: ignore missing world dependencies with --force and --quiet
5
6---
7 src/state.c | 2 +-
8 1 files changed, 1 insertions(+), 1 deletions(-)
9
10diff --git a/src/state.c b/src/state.c
11index 50c1ce3..d886754 100644
12--- a/src/state.c
13+++ b/src/state.c
14@@ -148,7 +148,7 @@ struct apk_state *apk_state_new(struct apk_database *db)
15 * choices */
16 for (i = 0; db->world != NULL && i < db->world->num; i++) {
17 r = apk_state_prune_dependency(state, &db->world->item[i]);
18- if (r < 0) {
19+ if (r < 0 && apk_verbosity && !(apk_flags & APK_FORCE)) {
20 apk_error("Top level dependencies for %s are "
21 "conflicting or unsatisfiable.",
22 db->world->item[i].name->name);
23--
241.6.4
25
diff --git a/main/apk-tools/0005-audit-do-not-load-repositories.patch b/main/apk-tools/0005-audit-do-not-load-repositories.patch
new file mode 100644
index 0000000000..28e2766d2b
--- /dev/null
+++ b/main/apk-tools/0005-audit-do-not-load-repositories.patch
@@ -0,0 +1,40 @@
1From 20b3c7c8b3653940f357729e9f7159e2f32c1021 Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Thu, 6 Aug 2009 13:09:38 +0300
4Subject: [PATCH 5/7] audit: do not load repositories
5
6they are not needed, and cause errors if signing keys are not
7present.
8---
9 src/audit.c | 7 +++++--
10 1 files changed, 5 insertions(+), 2 deletions(-)
11
12diff --git a/src/audit.c b/src/audit.c
13index e47f182..67cefac 100644
14--- a/src/audit.c
15+++ b/src/audit.c
16@@ -19,6 +19,7 @@
17 #include "apk_database.h"
18
19 struct audit_ctx {
20+ unsigned int open_flags;
21 int (*audit)(struct apk_database *db);
22 };
23
24@@ -169,9 +170,11 @@ static int audit_main(void *ctx, int argc, char **argv)
25 if (actx->audit == NULL)
26 return -EINVAL;
27
28- r = apk_db_open(&db, apk_root, APK_OPENF_READ);
29+ r = apk_db_open(&db, apk_root,
30+ APK_OPENF_READ | APK_OPENF_NO_SCRIPTS |
31+ APK_OPENF_NO_REPOS);
32 if (r != 0) {
33- apk_error("APK database not present");
34+ apk_error("Unable to open db: %s", apk_error_str(r));
35 return r;
36 }
37 r = actx->audit(&db);
38--
391.6.4
40
diff --git a/main/apk-tools/0006-db-make-missing-index-non-fatal.patch b/main/apk-tools/0006-db-make-missing-index-non-fatal.patch
new file mode 100644
index 0000000000..cfc5dd5714
--- /dev/null
+++ b/main/apk-tools/0006-db-make-missing-index-non-fatal.patch
@@ -0,0 +1,29 @@
1From fac43e2d60b550425481052e521d141730a303de Mon Sep 17 00:00:00 2001
2From: Timo Teras <timo.teras@iki.fi>
3Date: Thu, 6 Aug 2009 13:12:26 +0300
4Subject: [PATCH 6/7] db: make missing index non-fatal
5
6it's a warning not an error to have non-existant repository.
7bad signature means tampering; but we might want to just ignore
8those. this is especially important if we have http repositories
9and we are bootstrapping (without network).
10---
11 src/database.c | 2 +-
12 1 files changed, 1 insertions(+), 1 deletions(-)
13
14diff --git a/src/database.c b/src/database.c
15index 834383b..f7c3ac0 100644
16--- a/src/database.c
17+++ b/src/database.c
18@@ -1282,7 +1282,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
19 }
20 if (bs == NULL) {
21 apk_warning("Failed to open index for %s", repo->url);
22- return -1;
23+ return 0;
24 }
25
26 r = load_index(db, bs, targz, r);
27--
281.6.4
29
diff --git a/main/apk-tools/APKBUILD b/main/apk-tools/APKBUILD
index 215e7d04da..ccc505957b 100644
--- a/main/apk-tools/APKBUILD
+++ b/main/apk-tools/APKBUILD
@@ -1,13 +1,18 @@
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=1 4pkgrel=2
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 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch
11 0002-audit-fix-backup.patch
12 0003-db-command-line-repositories-take-preference.patch
13 0004-state-ignore-missing-world-dependencies-with-force-a.patch
14 0005-audit-do-not-load-repositories.patch
15 0006-db-make-missing-index-non-fatal.patch
11 " 16 "
12 17
13 18
@@ -17,7 +22,10 @@ license=GPL-2
17build() { 22build() {
18 cd "$srcdir/$pkgname-$pkgver" 23 cd "$srcdir/$pkgname-$pkgver"
19 sed -i -e 's:-Werror::' Make.rules 24 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 25 for i in ../*.patch; do
26 msg "Applying $i"
27 patch -p1 -i $i || return 1
28 done
21 29
22 make || return 1 30 make || return 1
23 make static || return 1 31 make static || return 1
@@ -38,4 +46,9 @@ static() {
38} 46}
39 47
40md5sums="f790182792a41841e6932ae0b6737a43 apk-tools-2.0_rc1.tar.bz2 48md5sums="f790182792a41841e6932ae0b6737a43 apk-tools-2.0_rc1.tar.bz2
4187dd230bf89f429db06dcad96be235c0 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch" 49c0be62f4ca4153241f82a29ee0e5ac7d 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch
50515b39f942d6ad6ee8f022869b5ed3ab 0002-audit-fix-backup.patch
51c59e35ef85ebeed98fa04dbf32fee6e6 0003-db-command-line-repositories-take-preference.patch
523377a1bc507bb3f5218e2957d642c77c 0004-state-ignore-missing-world-dependencies-with-force-a.patch
53ab2d76d6308215407dfd9f2f67c05b67 0005-audit-do-not-load-repositories.patch
545d2fcd1c6a7c5040fc189ffa7d12c1e5 0006-db-make-missing-index-non-fatal.patch"