From 0cc2086e27a2109e13e8925b882d1014b5bab96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Mon, 4 Apr 2011 13:19:12 +0300 Subject: [PATCH] index: support rewriting of architecture Our build infra does not yet handle properly noarch, so for the time being we will rewrite them as native packages in index. This allows the package to be fetched from the proper URL. This feature will be removed once abuild and the build infra handle noarch properly. --- src/index.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/index.c b/src/index.c index d2b4b01..442e98a 100644 --- a/src/index.c +++ b/src/index.c @@ -25,6 +25,7 @@ struct index_ctx { const char *index; const char *output; const char *description; + apk_blob_t *rewrite_arch; time_t index_mtime; int method; }; @@ -44,6 +45,9 @@ static int index_parse(void *ctx, struct apk_db_options *dbopts, case 'd': ictx->description = optarg; break; + case 0x10000: + ictx->rewrite_arch = apk_blob_atomize(APK_BLOB_STR(optarg)); + break; default: return -1; } @@ -88,6 +92,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv) struct apk_file_info fi; int total, r, i, j, found, newpkgs = 0; struct index_ctx *ictx = (struct index_ctx *) ctx; + struct apk_package *pkg; if (isatty(STDOUT_FILENO) && ictx->output == NULL && !(apk_flags & APK_FORCE)) { @@ -139,12 +144,14 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv) break; for (j = 0; j < name->pkgs->num; j++) { - struct apk_package *pkg = name->pkgs->item[j]; + pkg = name->pkgs->item[j]; if (apk_blob_compare(bver, *pkg->version) != 0) continue; if (pkg->size != fi.size) continue; pkg->filename = strdup(argv[i]); + if (ictx->rewrite_arch != NULL) + pkg->arch = ictx->rewrite_arch; found = TRUE; break; } @@ -153,8 +160,10 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv) if (!found) { struct apk_sign_ctx sctx; apk_sign_ctx_init(&sctx, ictx->method, NULL, db->keys_fd); - if (apk_pkg_read(db, argv[i], &sctx, NULL) == 0) + if (apk_pkg_read(db, argv[i], &sctx, &pkg) == 0) newpkgs++; + if (ictx->rewrite_arch != NULL) + pkg->arch = ictx->rewrite_arch; apk_sign_ctx_free(&sctx); } } @@ -214,6 +223,8 @@ static struct apk_option index_options[] = { { 'd', "description", "Embed TEXT as description and version " "information of the repository index", required_argument, "TEXT" }, + { 0x10000, "rewrite-arch", "Use ARCH as architery for all packages", + required_argument, "ARCH" }, }; static struct apk_applet apk_index = {