From dd60705665b916c9f67c3bbf86aa6bb620a14ecd Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 3 Apr 2004 13:53:46 -0500 Subject: Refine the build process to avoid re-running subst all the time on some generated files, by having subst update the modtime on these files even when the generated file hasn't changed. We do this with generated files that do not have any downstream dependencies. --- util/ChangeLog | 5 +++++ util/subst.c | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/ChangeLog b/util/ChangeLog index 66254035..ec2a01c0 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,8 @@ +2004-04-03 Theodore Ts'o + + * subst.c (main): Add new option to update the timestamp of the + generated file. + 2004-02-28 Theodore Ts'o * Release of E2fsprogs 1.35 diff --git a/util/subst.c b/util/subst.c index dff1848b..0c618a86 100644 --- a/util/subst.c +++ b/util/subst.c @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include #ifdef HAVE_GETOPT_H #include @@ -289,7 +292,6 @@ static int compare_file(const char *outfn, const char *newfn) return retval; } - int main(int argc, char **argv) @@ -299,8 +301,11 @@ int main(int argc, char **argv) FILE *in, *out; char *outfn = NULL, *newfn = NULL; int verbose = 0; + int adjust_timestamp = 0; + struct stat stbuf; + struct utimbuf ut; - while ((c = getopt (argc, argv, "f:v")) != EOF) { + while ((c = getopt (argc, argv, "f:tv")) != EOF) { switch (c) { case 'f': in = fopen(optarg, "r"); @@ -311,6 +316,9 @@ int main(int argc, char **argv) parse_config_file(in); fclose(in); break; + case 't': + adjust_timestamp++; + break; case 'v': verbose++; break; @@ -361,6 +369,16 @@ int main(int argc, char **argv) if (compare_file(outfn, newfn)) { if (verbose) printf("No change, keeping %s.\n", outfn); + if (adjust_timestamp) { + if (stat(outfn, &stbuf) == 0) { + if (verbose) + printf("Updating modtime for %s\n", outfn); + ut.actime = stbuf.st_atime; + ut.modtime = time(0); + if (utime(outfn, &ut) < 0) + perror("utime"); + } + } unlink(newfn); } else { if (verbose) -- cgit v1.2.3