diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-08-06 11:36:59 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-08-06 11:36:59 +0000 |
commit | dd2128cffe618ac1e3ebf109da0df111a4988044 (patch) | |
tree | 25af2b51bf43d6c3cc21c155a84dda52c066b421 /main/apk-tools | |
parent | 2251f300c3c86a3ef7256ed088ad4c4b1dd388e1 (diff) | |
download | aports-dd2128cffe618ac1e3ebf109da0df111a4988044.tar.bz2 aports-dd2128cffe618ac1e3ebf109da0df111a4988044.tar.xz |
main/apk-tools: fixes from upstream
Diffstat (limited to 'main/apk-tools')
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 f0f918a5..a2f33ffa 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 @@ From 2cfca5b6ed658433419f9b581b3ba30f34c973c4 Mon Sep 17 00:00:00 2001 From: Timo Teras <timo.teras@iki.fi> Date: Wed, 5 Aug 2009 19:10:54 +0300 -Subject: [PATCH] info: fix a --exists to work if the name is non-existant +Subject: [PATCH 1/7] info: fix a --exists to work if the name is non-existant --- src/info.c | 3 +++ @@ -22,5 +22,5 @@ index a222b8c..073dc80 100644 pkg = name->pkgs->item[j]; if (apk_pkg_get_state(pkg) == APK_PKG_INSTALLED) -- -1.6.3.3 +1.6.4 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 00000000..4424f7f5 --- /dev/null +++ b/main/apk-tools/0002-audit-fix-backup.patch @@ -0,0 +1,35 @@ +From 7419771b02e84a91a71b12869a40208fd2e8b773 Mon Sep 17 00:00:00 2001 +From: Timo Teras <timo.teras@iki.fi> +Date: Thu, 6 Aug 2009 08:57:50 +0300 +Subject: [PATCH 2/7] audit: fix --backup + +--- + src/audit.c | 5 ++++- + 1 files changed, 4 insertions(+), 1 deletions(-) + +diff --git a/src/audit.c b/src/audit.c +index d61b321..e47f182 100644 +--- a/src/audit.c ++++ b/src/audit.c +@@ -51,6 +51,9 @@ static int audit_directory(apk_hash_item item, void *ctx) + char tmp[PATH_MAX], reason; + DIR *dir; + ++ if (!(dbd->flags & APK_DBDIRF_PROTECTED)) ++ return 0; ++ + dir = fdopendir(openat(db->root_fd, dbd->name, O_RDONLY)); + if (dir == NULL) + return 0; +@@ -97,7 +100,7 @@ static int audit_directory(apk_hash_item item, void *ctx) + + static int audit_backup(struct apk_database *db) + { +- return apk_hash_foreach(&db->installed.dirs, audit_directory, &db); ++ return apk_hash_foreach(&db->installed.dirs, audit_directory, db); + } + + static int audit_system(struct apk_database *db) +-- +1.6.4 + 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 00000000..1f1786c3 --- /dev/null +++ b/main/apk-tools/0003-db-command-line-repositories-take-preference.patch @@ -0,0 +1,194 @@ +From 6f1de8cd530f598f3f79414390d98fd8e683f2af Mon Sep 17 00:00:00 2001 +From: Timo Teras <timo.teras@iki.fi> +Date: Thu, 6 Aug 2009 10:17:28 +0300 +Subject: [PATCH 3/7] db: command line repositories take preference + +over the ones in config file. also remove the apk_root == NULL +check as this cannot happen anymore. a valid root is always +required. +--- + src/database.c | 145 +++++++++++++++++++++++++++----------------------------- + 1 files changed, 70 insertions(+), 75 deletions(-) + +diff --git a/src/database.c b/src/database.c +index 30e0431..834383b 100644 +--- a/src/database.c ++++ b/src/database.c +@@ -895,59 +895,56 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags) + db->cache_dir = apk_static_cache_dir; + db->permanent = 1; + +- if (root != NULL) { +- db->root = strdup(root); +- db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY); +- if (db->root_fd < 0 && (flags & APK_OPENF_CREATE)) { +- mkdirat(AT_FDCWD, db->root, 0755); +- db->root_fd = openat(AT_FDCWD, root, O_RDONLY); +- } +- if (db->root_fd < 0) { +- msg = "Unable to open root"; +- goto ret_errno; +- } +- if (fstat64(db->root_fd, &st) != 0 || major(st.st_dev) == 0) +- db->permanent = 0; +- +- if (fstatat64(db->root_fd, apk_linked_cache_dir, &st, 0) == 0 && +- S_ISDIR(st.st_mode)) +- db->cache_dir = apk_linked_cache_dir; +- +- if (flags & APK_OPENF_WRITE) { ++ db->root = strdup(root); ++ db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY); ++ if (db->root_fd < 0 && (flags & APK_OPENF_CREATE)) { ++ mkdirat(AT_FDCWD, db->root, 0755); ++ db->root_fd = openat(AT_FDCWD, root, O_RDONLY); ++ } ++ if (db->root_fd < 0) { ++ msg = "Unable to open root"; ++ goto ret_errno; ++ } ++ if (fstat64(db->root_fd, &st) != 0 || major(st.st_dev) == 0) ++ db->permanent = 0; ++ ++ if (fstatat64(db->root_fd, apk_linked_cache_dir, &st, 0) == 0 && ++ S_ISDIR(st.st_mode)) ++ db->cache_dir = apk_linked_cache_dir; ++ ++ if (flags & APK_OPENF_WRITE) { ++ db->lock_fd = openat(db->root_fd, "var/lib/apk/lock", ++ O_CREAT | O_RDWR, 0400); ++ if (db->lock_fd < 0 && errno == ENOENT && ++ (flags & APK_OPENF_CREATE)) { ++ r = apk_db_create(db); ++ if (r != 0) { ++ msg = "Unable to create database"; ++ goto ret_r; ++ } + db->lock_fd = openat(db->root_fd, "var/lib/apk/lock", + O_CREAT | O_RDWR, 0400); +- if (db->lock_fd < 0 && errno == ENOENT && +- (flags & APK_OPENF_CREATE)) { +- r = apk_db_create(db); +- if (r != 0) { +- msg = "Unable to create database"; +- goto ret_r; +- } +- db->lock_fd = openat(db->root_fd, +- "var/lib/apk/lock", +- O_CREAT | O_RDWR, 0400); +- } +- if (db->lock_fd < 0 || +- flock(db->lock_fd, LOCK_EX | LOCK_NB) < 0) { +- msg = "Unable to lock database"; +- if (apk_wait) { +- struct sigaction sa, old_sa; +- +- apk_message("Waiting for repository lock"); +- memset(&sa, 0, sizeof sa); +- sa.sa_handler = handle_alarm; +- sa.sa_flags = SA_ONESHOT; +- sigaction(SIGALRM, &sa, &old_sa); +- +- alarm(apk_wait); +- if (flock(db->lock_fd, LOCK_EX) < 0) +- goto ret_errno; +- +- alarm(0); +- sigaction(SIGALRM, &old_sa, NULL); +- } else ++ } ++ if (db->lock_fd < 0 || ++ flock(db->lock_fd, LOCK_EX | LOCK_NB) < 0) { ++ msg = "Unable to lock database"; ++ if (apk_wait) { ++ struct sigaction sa, old_sa; ++ ++ apk_message("Waiting for repository lock"); ++ memset(&sa, 0, sizeof sa); ++ sa.sa_handler = handle_alarm; ++ sa.sa_flags = SA_ONESHOT; ++ sigaction(SIGALRM, &sa, &old_sa); ++ ++ alarm(apk_wait); ++ if (flock(db->lock_fd, LOCK_EX) < 0) + goto ret_errno; +- } ++ ++ alarm(0); ++ sigaction(SIGALRM, &old_sa, NULL); ++ } else ++ goto ret_errno; + } + } + +@@ -959,33 +956,18 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags) + db->cachetmp_fd = openat(db->cache_fd, "tmp", O_RDONLY); + db->keys_fd = openat(db->root_fd, "etc/apk/keys", O_RDONLY); + +- if (root != NULL) { +- r = apk_db_read_state(db, flags); +- if (r == -ENOENT && (flags & APK_OPENF_CREATE)) { +- r = apk_db_create(db); +- if (r != 0) { +- msg = "Unable to create database"; +- goto ret_r; +- } +- r = apk_db_read_state(db, flags); +- } ++ r = apk_db_read_state(db, flags); ++ if (r == -ENOENT && (flags & APK_OPENF_CREATE)) { ++ r = apk_db_create(db); + if (r != 0) { +- msg = "Unable to read database state"; ++ msg = "Unable to create database"; + goto ret_r; + } +- +- if (!(flags & APK_OPENF_NO_REPOS)) { +- if (apk_repos == NULL) +- apk_repos = "etc/apk/repositories"; +- blob = apk_blob_from_file(db->root_fd, apk_repos); +- if (!APK_BLOB_IS_NULL(blob)) { +- r = apk_blob_for_each_segment( +- blob, "\n", +- apk_db_add_repository, db); +- rr = r ?: rr; +- free(blob.ptr); +- } +- } ++ r = apk_db_read_state(db, flags); ++ } ++ if (r != 0) { ++ msg = "Unable to read database state"; ++ goto ret_r; + } + + if (!(flags & APK_OPENF_NO_REPOS)) { +@@ -993,10 +975,23 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags) + r = apk_db_add_repository(db, APK_BLOB_STR(repo->url)); + rr = r ?: rr; + } +- ++ if (apk_repos == NULL) ++ apk_repos = "etc/apk/repositories"; ++ blob = apk_blob_from_file(db->root_fd, apk_repos); ++ if (!APK_BLOB_IS_NULL(blob)) { ++ r = apk_blob_for_each_segment( ++ blob, "\n", ++ apk_db_add_repository, db); ++ rr = r ?: rr; ++ free(blob.ptr); ++ } + if (apk_flags & APK_UPDATE_CACHE) + apk_db_index_write_nr_cache(db); + } ++ if (rr != 0) { ++ r = rr; ++ goto ret_r; ++ } + + return rr; + +-- +1.6.4 + 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 00000000..2b2cc471 --- /dev/null +++ b/main/apk-tools/0004-state-ignore-missing-world-dependencies-with-force-a.patch @@ -0,0 +1,25 @@ +From 0b2052ed064708767358290a73d600ed55fee5b2 Mon Sep 17 00:00:00 2001 +From: Timo Teras <timo.teras@iki.fi> +Date: Thu, 6 Aug 2009 11:47:44 +0300 +Subject: [PATCH 4/7] state: ignore missing world dependencies with --force and --quiet + +--- + src/state.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/src/state.c b/src/state.c +index 50c1ce3..d886754 100644 +--- a/src/state.c ++++ b/src/state.c +@@ -148,7 +148,7 @@ struct apk_state *apk_state_new(struct apk_database *db) + * choices */ + for (i = 0; db->world != NULL && i < db->world->num; i++) { + r = apk_state_prune_dependency(state, &db->world->item[i]); +- if (r < 0) { ++ if (r < 0 && apk_verbosity && !(apk_flags & APK_FORCE)) { + apk_error("Top level dependencies for %s are " + "conflicting or unsatisfiable.", + db->world->item[i].name->name); +-- +1.6.4 + 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 00000000..28e2766d --- /dev/null +++ b/main/apk-tools/0005-audit-do-not-load-repositories.patch @@ -0,0 +1,40 @@ +From 20b3c7c8b3653940f357729e9f7159e2f32c1021 Mon Sep 17 00:00:00 2001 +From: Timo Teras <timo.teras@iki.fi> +Date: Thu, 6 Aug 2009 13:09:38 +0300 +Subject: [PATCH 5/7] audit: do not load repositories + +they are not needed, and cause errors if signing keys are not +present. +--- + src/audit.c | 7 +++++-- + 1 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/audit.c b/src/audit.c +index e47f182..67cefac 100644 +--- a/src/audit.c ++++ b/src/audit.c +@@ -19,6 +19,7 @@ + #include "apk_database.h" + + struct audit_ctx { ++ unsigned int open_flags; + int (*audit)(struct apk_database *db); + }; + +@@ -169,9 +170,11 @@ static int audit_main(void *ctx, int argc, char **argv) + if (actx->audit == NULL) + return -EINVAL; + +- r = apk_db_open(&db, apk_root, APK_OPENF_READ); ++ r = apk_db_open(&db, apk_root, ++ APK_OPENF_READ | APK_OPENF_NO_SCRIPTS | ++ APK_OPENF_NO_REPOS); + if (r != 0) { +- apk_error("APK database not present"); ++ apk_error("Unable to open db: %s", apk_error_str(r)); + return r; + } + r = actx->audit(&db); +-- +1.6.4 + 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 00000000..cfc5dd57 --- /dev/null +++ b/main/apk-tools/0006-db-make-missing-index-non-fatal.patch @@ -0,0 +1,29 @@ +From fac43e2d60b550425481052e521d141730a303de Mon Sep 17 00:00:00 2001 +From: Timo Teras <timo.teras@iki.fi> +Date: Thu, 6 Aug 2009 13:12:26 +0300 +Subject: [PATCH 6/7] db: make missing index non-fatal + +it's a warning not an error to have non-existant repository. +bad signature means tampering; but we might want to just ignore +those. this is especially important if we have http repositories +and we are bootstrapping (without network). +--- + src/database.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/src/database.c b/src/database.c +index 834383b..f7c3ac0 100644 +--- a/src/database.c ++++ b/src/database.c +@@ -1282,7 +1282,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository) + } + if (bs == NULL) { + apk_warning("Failed to open index for %s", repo->url); +- return -1; ++ return 0; + } + + r = load_index(db, bs, targz, r); +-- +1.6.4 + diff --git a/main/apk-tools/APKBUILD b/main/apk-tools/APKBUILD index 215e7d04..ccc50595 100644 --- a/main/apk-tools/APKBUILD +++ b/main/apk-tools/APKBUILD @@ -1,13 +1,18 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=apk-tools pkgver=2.0_rc1 -pkgrel=1 +pkgrel=2 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-a-exists-to-work-if-the-name-is-non-existan.patch + 0002-audit-fix-backup.patch + 0003-db-command-line-repositories-take-preference.patch + 0004-state-ignore-missing-world-dependencies-with-force-a.patch + 0005-audit-do-not-load-repositories.patch + 0006-db-make-missing-index-non-fatal.patch " @@ -17,7 +22,10 @@ license=GPL-2 build() { cd "$srcdir/$pkgname-$pkgver" sed -i -e 's:-Werror::' Make.rules - patch -p1 -i ../0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch || return 1 + for i in ../*.patch; do + msg "Applying $i" + patch -p1 -i $i || return 1 + done make || return 1 make static || return 1 @@ -38,4 +46,9 @@ static() { } md5sums="f790182792a41841e6932ae0b6737a43 apk-tools-2.0_rc1.tar.bz2 -87dd230bf89f429db06dcad96be235c0 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch" +c0be62f4ca4153241f82a29ee0e5ac7d 0001-info-fix-a-exists-to-work-if-the-name-is-non-existan.patch +515b39f942d6ad6ee8f022869b5ed3ab 0002-audit-fix-backup.patch +c59e35ef85ebeed98fa04dbf32fee6e6 0003-db-command-line-repositories-take-preference.patch +3377a1bc507bb3f5218e2957d642c77c 0004-state-ignore-missing-world-dependencies-with-force-a.patch +ab2d76d6308215407dfd9f2f67c05b67 0005-audit-do-not-load-repositories.patch +5d2fcd1c6a7c5040fc189ffa7d12c1e5 0006-db-make-missing-index-non-fatal.patch" |