Use absolute PSL path to make psl_builtin_outdated() work reliable

This commit is contained in:
Tim Rühsen 2015-11-19 11:18:17 +01:00
parent 583f97f2bf
commit b53273d406
1 changed files with 10 additions and 1 deletions

View File

@ -237,6 +237,7 @@ int main(int argc, const char **argv)
struct stat st;
size_t cmdsize = 16 + strlen(argv[1]);
char *cmd = alloca(cmdsize), checksum[64] = "";
char *abs_srcfile;
const char *source_date_epoch = NULL;
#if 0
@ -256,6 +257,7 @@ int main(int argc, const char **argv)
if (stat(argv[1], &st) != 0)
st.st_mtime = 0;
fprintf(fpout, "static time_t _psl_file_time = %lu;\n", st.st_mtime);
if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")))
fprintf(fpout, "static time_t _psl_compile_time = %lu;\n", atol(source_date_epoch));
else
@ -264,6 +266,13 @@ int main(int argc, const char **argv)
fprintf(fpout, "static int _psl_nexceptions = %d;\n", psl->nexceptions);
fprintf(fpout, "static int _psl_nwildcards = %d;\n", psl->nwildcards);
fprintf(fpout, "static const char _psl_sha1_checksum[] = \"%s\";\n", checksum);
/* We need an absolute path here, else psl_builtin_outdated() won't work reliable */
/* Caveat: symbolic links are resolved by realpath() */
if ((abs_srcfile = realpath(argv[1], NULL))) {
fprintf(fpout, "static const char _psl_filename[] = \"%s\";\n", abs_srcfile);
free(abs_srcfile);
} else
fprintf(fpout, "static const char _psl_filename[] = \"%s\";\n", argv[1]);
if (fclose(fpout) != 0)