From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/rsync-generation/
Date: Wed, 29 Nov 2017 16:46:11 +0000 (UTC) [thread overview]
Message-ID: <1511973774.191df7d69bc652b5e7899d44934fea0de05aa53d.grobian@gentoo> (raw)
commit: 191df7d69bc652b5e7899d44934fea0de05aa53d
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 29 16:42:54 2017 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Nov 29 16:42:54 2017 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=191df7d6
hashgen: generate GLEP 74 top level Manifest
scripts/rsync-generation/hashgen.c | 56 ++++++++++++++++++++++++++++++++++----
1 file changed, 50 insertions(+), 6 deletions(-)
diff --git a/scripts/rsync-generation/hashgen.c b/scripts/rsync-generation/hashgen.c
index 034ea7f170..4180665e0f 100644
--- a/scripts/rsync-generation/hashgen.c
+++ b/scripts/rsync-generation/hashgen.c
@@ -4,6 +4,7 @@
#include <strings.h>
#include <ctype.h>
#include <dirent.h>
+#include <time.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -95,7 +96,7 @@ write_hashes(
#pragma omp section
{
if (hashes & HASH_BLAKE2B)
- blake2b_update(&bl2b, data, len);
+ blake2b_update(&bl2b, (unsigned char *)data, len);
}
}
}
@@ -152,7 +153,7 @@ write_hashes(
len += snprintf(data + len, sizeof(data) - len, "\n");
if (m != NULL)
- fwrite(data, 1, len, m);
+ fwrite(data, len, 1, m);
if (gm != NULL)
gzwrite(gm, data, len);
}
@@ -202,7 +203,7 @@ parse_layout_conf(const char *path)
/* read file, examine lines after encountering a newline, that is,
* if the file doesn't end with a newline, the final bit is ignored */
- while (sz = fread(buf + len, 1, sizeof(buf) - len, f) > 0) {
+ while ((sz = fread(buf + len, 1, sizeof(buf) - len, f)) > 0) {
len += sz;
last_nl = NULL;
for (p = buf; p - buf < len; p++) {
@@ -256,6 +257,7 @@ parse_layout_conf(const char *path)
static char *str_manifest = "Manifest";
static char *str_manifest_gz = "Manifest.gz";
+static char *str_manifest_files_gz = "Manifest.files.gz";
static char *
process_dir(const char *dir)
{
@@ -296,10 +298,12 @@ process_dir(const char *dir)
/* recurse into subdirs */
if ((d = opendir(dir)) != NULL) {
struct stat s;
+ char *my_manifest =
+ global_manifest ? str_manifest_files_gz : str_manifest_gz;
/* open up a gzipped Manifest to keep the hashes of the
* Manifests in the subdirs */
- snprintf(manifest, sizeof(manifest), "%s/%s", dir, str_manifest_gz);
+ snprintf(manifest, sizeof(manifest), "%s/%s", dir, my_manifest);
if ((mf = gzopen(manifest, "wb9")) == NULL) {
fprintf(stderr, "failed to open file '%s' for writing: %s\n",
manifest, strerror(errno));
@@ -309,7 +313,7 @@ process_dir(const char *dir)
while ((e = readdir(d)) != NULL) {
if (e->d_name[0] == '.')
continue;
- if (strcmp(e->d_name, str_manifest_gz) == 0)
+ if (strcmp(e->d_name, my_manifest) == 0)
continue;
snprintf(path, sizeof(path), "%s/%s", dir, e->d_name);
if (!stat(path, &s)) {
@@ -328,7 +332,47 @@ process_dir(const char *dir)
}
closedir(d);
- gzclose(mf);
+ if (global_manifest) {
+ char globmanifest[8192];
+ char buf[2048];
+ size_t len;
+ FILE *m;
+ time_t rtime;
+
+ len = snprintf(buf, sizeof(buf),
+ "IGNORE distfiles\n"
+ "IGNORE local\n"
+ "IGNORE lost+found\n"
+ "IGNORE packages\n");
+ gzwrite(mf, buf, len);
+ gzclose(mf);
+
+ /* create global Manifest */
+ snprintf(globmanifest, sizeof(globmanifest),
+ "%s/%s", dir, str_manifest);
+ if ((m = fopen(globmanifest, "w")) == NULL) {
+ fprintf(stderr, "failed to open file '%s' "
+ "for writing: %s\n",
+ globmanifest, strerror(errno));
+ return NULL;
+ }
+
+ write_hashes(dir, my_manifest, "MANIFEST", m, NULL);
+ time(&rtime);
+ len = strftime(buf, sizeof(buf),
+ "TIMESTAMP %Y-%m-%dT%H:%M:%SZ\n", gmtime(&rtime));
+ fwrite(buf, len, 1, m);
+ fflush(m);
+ fclose(m);
+
+ if (tv[0].tv_sec != 0) {
+ /* restore dir mtime, and set Manifest mtime to match it */
+ utimes(globmanifest, tv);
+ }
+ } else {
+ gzclose(mf);
+ }
+
if (tv[0].tv_sec != 0) {
/* restore dir mtime, and set Manifest mtime to match it */
utimes(manifest, tv);
next reply other threads:[~2017-11-29 16:46 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 16:46 Fabian Groffen [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-07-10 18:24 [gentoo-commits] repo/proj/prefix:master commit in: scripts/rsync-generation/ Fabian Groffen
2024-06-14 20:13 Fabian Groffen
2024-03-31 10:26 Fabian Groffen
2024-03-31 10:09 Fabian Groffen
2024-03-31 8:53 Fabian Groffen
2024-03-31 8:46 Fabian Groffen
2024-03-31 8:27 Fabian Groffen
2024-03-30 18:44 Fabian Groffen
2024-03-30 11:46 Fabian Groffen
2024-03-29 10:31 Fabian Groffen
2024-03-29 10:31 Fabian Groffen
2024-03-28 16:12 Fabian Groffen
2024-03-28 16:12 Fabian Groffen
2024-03-28 16:12 Fabian Groffen
2024-03-28 16:12 Fabian Groffen
2023-09-11 10:39 Fabian Groffen
2023-08-01 2:40 Benda XU
2023-04-09 16:06 Fabian Groffen
2022-08-17 19:27 Fabian Groffen
2022-07-24 20:11 Fabian Groffen
2019-06-07 5:44 Fabian Groffen
2019-06-07 5:44 Fabian Groffen
2018-05-14 15:54 Fabian Groffen
2018-03-29 5:55 Fabian Groffen
2018-03-27 14:03 Fabian Groffen
2018-03-17 20:59 Fabian Groffen
2018-03-17 20:59 Fabian Groffen
2018-03-12 10:06 Fabian Groffen
2018-03-10 15:04 Fabian Groffen
2018-03-07 18:04 Fabian Groffen
2018-03-03 21:42 Fabian Groffen
2018-03-01 16:36 Fabian Groffen
2018-03-01 14:03 Fabian Groffen
2018-03-01 13:00 Fabian Groffen
2018-03-01 10:55 Fabian Groffen
2018-03-01 6:42 Fabian Groffen
2018-02-28 19:09 Fabian Groffen
2018-02-28 18:44 Fabian Groffen
2018-02-28 18:44 Fabian Groffen
2018-02-28 18:44 Fabian Groffen
2018-02-28 14:44 Fabian Groffen
2018-02-28 14:44 Fabian Groffen
2018-02-22 19:45 Fabian Groffen
2018-02-22 7:29 Fabian Groffen
2018-02-21 8:53 Fabian Groffen
2018-02-17 17:19 Fabian Groffen
2018-02-17 8:13 Fabian Groffen
2017-12-01 13:45 Fabian Groffen
2017-11-29 21:36 Fabian Groffen
2017-11-29 21:36 Fabian Groffen
2017-11-29 19:30 Fabian Groffen
2017-11-29 19:30 Fabian Groffen
2017-11-29 19:30 Fabian Groffen
2017-11-29 16:46 Fabian Groffen
2017-11-29 14:38 Fabian Groffen
2017-11-27 14:10 Fabian Groffen
2017-11-27 13:07 Fabian Groffen
2017-11-27 13:07 Fabian Groffen
2017-09-09 18:39 Fabian Groffen
2016-10-12 7:24 Fabian Groffen
2016-09-09 13:38 Fabian Groffen
2016-09-07 11:02 Fabian Groffen
2016-08-17 4:26 Fabian Groffen
2016-08-16 7:57 Fabian Groffen
2016-07-29 9:01 Fabian Groffen
2016-07-29 8:08 Fabian Groffen
2016-05-03 18:35 Fabian Groffen
2016-05-03 16:08 Fabian Groffen
2016-04-14 15:38 Fabian Groffen
2016-04-14 13:39 Fabian Groffen
2016-04-06 12:32 Fabian Groffen
2016-04-06 11:28 Fabian Groffen
2016-04-06 11:28 Fabian Groffen
2016-04-06 10:50 Fabian Groffen
2016-04-06 10:49 Fabian Groffen
2016-01-05 19:08 Fabian Groffen
2015-08-31 18:53 Fabian Groffen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511973774.191df7d69bc652b5e7899d44934fea0de05aa53d.grobian@gentoo \
--to=grobian@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox