summaryrefslogtreecommitdiff
path: root/src/index.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-09-03 14:56:24 +0400
committerTimo Teras <timo.teras@iki.fi>2009-09-03 14:56:24 +0400
commit58e771303c95f9d97d009602516b509866c3fb5a (patch)
tree9cf8ce0d4608d4531850177549cb70670544fbb4 /src/index.c
parent7829f1191f1812f30c763a685dff1b61393f7491 (diff)
downloadapk-tools-58e771303c95f9d97d009602516b509866c3fb5a.tar.gz
apk-tools-58e771303c95f9d97d009602516b509866c3fb5a.tar.bz2
apk-tools-58e771303c95f9d97d009602516b509866c3fb5a.tar.xz
apk-tools-58e771303c95f9d97d009602516b509866c3fb5a.zip
index, version: support for repository descriptions (fixes #141)
ability embed description information to repository indexes (e.g. repository name and version) and show it via "apk version -I".
Diffstat (limited to 'src/index.c')
-rw-r--r--src/index.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/index.c b/src/index.c
index d485afd..ac6a763 100644
--- a/src/index.c
+++ b/src/index.c
@@ -25,6 +25,7 @@ struct counts {
struct index_ctx {
const char *index;
const char *output;
+ const char *description;
time_t index_mtime;
int method;
};
@@ -41,6 +42,9 @@ static int index_parse(void *ctx, struct apk_db_options *dbopts,
case 'o':
ictx->output = optarg;
break;
+ case 'd':
+ ictx->description = optarg;
+ break;
case INDEX_OLD_FORMAT:
ictx->method = APK_SIGN_GENERATE_V1;
break;
@@ -159,27 +163,35 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
}
}
- if (ictx->method == APK_SIGN_GENERATE) {
- memset(&fi, 0, sizeof(fi));
- fi.name = "APKINDEX";
- fi.mode = 0644 | S_IFREG;
- os = apk_ostream_counter(&fi.size);
- apk_db_index_write(db, os);
- os->close(os);
- }
-
if (ictx->output != NULL)
os = apk_ostream_to_file(AT_FDCWD, ictx->output, NULL, 0644);
else
os = apk_ostream_to_fd(STDOUT_FILENO);
+
if (ictx->method == APK_SIGN_GENERATE) {
+ struct apk_ostream *counter;
+
os = apk_ostream_gzip(os);
+
+ memset(&fi, 0, sizeof(fi));
+ fi.mode = 0644 | S_IFREG;
+ fi.name = "DESCRIPTION";
+ fi.size = strlen(ictx->description);
+ apk_tar_write_entry(os, &fi, ictx->description);
+
+ memset(&fi, 0, sizeof(fi));
+ fi.mode = 0644 | S_IFREG;
+ fi.name = "APKINDEX";
+ counter = apk_ostream_counter(&fi.size);
+ apk_db_index_write(db, counter);
+ counter->close(counter);
apk_tar_write_entry(os, &fi, NULL);
- }
- total = apk_db_index_write(db, os);
- if (ictx->method == APK_SIGN_GENERATE) {
+ total = apk_db_index_write(db, os);
apk_tar_write_padding(os, &fi);
+
apk_tar_write_entry(os, NULL, NULL);
+ } else {
+ total = apk_db_index_write(db, os);
}
os->close(os);
@@ -201,6 +213,9 @@ static struct apk_option index_options[] = {
{ 'x', "index", "Read INDEX to speed up new index creation by reusing "
"the information from an old index",
required_argument, "INDEX" },
+ { 'd', "description", "Embed TEXT as description and version "
+ "information of the repository index",
+ required_argument, "TEXT" },
{ INDEX_OLD_FORMAT, "old-format",
"Specify to create old style index files" }
};