summaryrefslogtreecommitdiffstats
path: root/src/index.c
diff options
context:
space:
mode:
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" }
};