summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2004-04-03 13:53:46 -0500
committerTheodore Ts'o <tytso@mit.edu>2004-04-03 13:53:46 -0500
commitdd60705665b916c9f67c3bbf86aa6bb620a14ecd (patch)
tree7422ed18d06e7d17f7b71c828cc05b6b9033efa2 /util
parent9dd97ae37dc664f877296db80e1d6c1ebe33e28b (diff)
downloade2fsprogs-dd60705665b916c9f67c3bbf86aa6bb620a14ecd.tar.gz
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.
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog5
-rw-r--r--util/subst.c22
2 files changed, 25 insertions, 2 deletions
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 <tytso@mit.edu>
+
+ * subst.c (main): Add new option to update the timestamp of the
+ generated file.
+
2004-02-28 Theodore Ts'o <tytso@mit.edu>
* 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 <unistd.h>
#include <string.h>
#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <utime.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
@@ -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)