X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/runlisp/blobdiff_plain/1dff83f1891c628ec7dab32bc4958f91fc6e9464..51c47adaf77e7e99b49f52dac6a9efd0f3508d14:/dump-runlisp-image.c diff --git a/dump-runlisp-image.c b/dump-runlisp-image.c index 97f854d..dfae56f 100644 --- a/dump-runlisp-image.c +++ b/dump-runlisp-image.c @@ -447,7 +447,7 @@ static void hash_input(struct linebuf *buf, size_t n, struct sha256_state *h) /* Collect output lines from JOB's process and write them to the log. * * Read data from BUF's file descriptor. Output complete (or overlong) lines - * usng `write_line'. On end-of-file, output any final incomplete line in + * using `write_line'. On end-of-file, output any final incomplete line in * the same way, close the descriptor, and set it to -1. * * As a rather unpleasant quirk, if the hash-state pointer H is not null, @@ -547,6 +547,7 @@ static void notice_filename(const char *p, size_t sz) if (!node) { node = xmalloc(sizeof(*node)); treap_insert(&good, &path, node, p, sz); + if (verbose >= 3) moan("noticed non-junk file `%.*s'", (int)sz, p); } } @@ -702,7 +703,10 @@ static void add_job(unsigned f, struct config_section *sect) config_subst_split_var(&config, sect, runvar, &av_version); if (!av_version.n) lose("empty `run-script' command for Lisp implementation `%s'", name); - argv_append(&av_version, xstrdup("?(lisp-implementation-version)")); + argv_append(&av_version, + config_subst_string_alloc + (&config, sect, "", + "?${lisp-version?(lisp-implementation-version)}")); config_subst_split_var(&config, sect, dumpvar, &av_dump); if (!av_dump.n) lose("empty `dump-image' command for Lisp implementation `%s'", name); @@ -915,7 +919,7 @@ static void finish_job(struct job *job) job->exit); /* What happens next depends on the state of the job. This is the main - * place which advanced the job state machine. + * place which advances the job state machine. */ if (ok) switch (job->st) { @@ -982,6 +986,9 @@ static void finish_job(struct job *job) * job, because the chances are good that it failed to produce the * image properly. */ + if (verbose >= 3) + moan("rename completed Lisp `%s' image `%s' to `%s'", + JOB_NAME(job), job->imgnew, job->imghash); if (rename(job->imgnew, job->imghash)) { fprintf(job->log, "%-13s > failed to rename Lisp `%s' " "output image `%s' to `%s': %s", @@ -990,6 +997,12 @@ static void finish_job(struct job *job) ok = 0; break; } + /* Notice the image so that it doesn't get junked. */ + if (flags&AF_JUNK) { + p = strrchr(job->imghash, '/'); if (p) p++; else p = job->imghash; + notice_filename(p, strlen(p)); + } + /* Determine the basename of the final image. */ p = strrchr(job->imghash, '/'); if (p) p++; else p = job->imghash; @@ -1001,6 +1014,9 @@ static void finish_job(struct job *job) JOB_NAME(job), job->imgnewlink, strerror(errno)); break; } + if (verbose >= 3) + moan("establish Lisp `%s' image link `%s' referring to `%s'", + JOB_NAME(job), job->imglink, job->imghash); if (symlink(p, job->imgnewlink)) { bad("failed to create Lisp `%s' image link `%s': %s", JOB_NAME(job), job->imgnewlink, strerror(errno)); @@ -1011,11 +1027,15 @@ static void finish_job(struct job *job) JOB_NAME(job), job->imgnewlink, job->imglink, strerror(errno)); break; } - if (job->oldimg && STRCMP(job->oldimg, !=, job->imghash) && - unlink(job->oldimg) && errno != ENOENT) { - if (verbose >= 1) - moan("failed to delete old Lisp `%s' image `%s': %s", - JOB_NAME(job), job->oldimg, strerror(errno)); + if (job->oldimg && STRCMP(job->oldimg, !=, job->imghash)) { + if (verbose >= 3) + moan("remove old Lisp `%s' image `%s'", + JOB_NAME(job), job->oldimg); + if (unlink(job->oldimg) && errno != ENOENT) { + if (verbose >= 1) + moan("failed to delete old Lisp `%s' image `%s': %s", + JOB_NAME(job), job->oldimg, strerror(errno)); + } } /* I think we're all done. */ @@ -1318,7 +1338,7 @@ static void version(FILE *fp) static void usage(FILE *fp) { fprintf(fp, "\ -usage: %s [-RUadfinqrv] [+RUdfinr] [-c CONF] [-o [SECT:]VAR=VAL]\n\ +usage: %s [-RUafinqrv] [+RUfinr] [-c CONF] [-o [SECT:]VAR=VAL]\n\ [-O FILE|DIR] [-j NJOBS] [LISP ...]\n", progname); } @@ -1327,25 +1347,24 @@ static void help(FILE *fp) { version(fp); fputc('\n', fp); usage(fp); fputs("\n\ -Help options:\n\ +Help options\n\ -h, --help Show this help text and exit successfully.\n\ -V, --version Show version number and exit successfully.\n\ \n\ -Diagnostics:\n\ +Diagnostics\n\ -n, --dry-run Don't run run anything (useful with `-v').\n\ -q, --quiet Don't print warning messages.\n\ -v, --verbose Print informational messages (repeatable).\n\ \n\ -Configuration:\n\ +Configuration\n\ -c, --config-file=CONF Read configuration from CONF (repeatable).\n\ -o, --set-option=[SECT:]VAR=VAL Set configuration variable (repeatable).\n\ \n\ -Image dumping:\n\ +Image dumping\n\ -O, --output=FILE|DIR Store image(s) in FILE or DIR.\n\ -R, --remove-other Delete image files for other Lisp systems.\n\ -U, --remove-unknown Delete unrecognized files in image dir.\n\ -a, --all-configured Select all configured implementations.\n\ - -d, --cleanup Delete images which are no longer wanted.\n\ -f, --force Dump images even if they already exist.\n\ -i, --check-installed Check Lisp systems exist before dumping.\n\ -j, --jobs=NJOBS Run up to NJOBS jobs in parallel.\n\ @@ -1422,7 +1441,7 @@ int main(int argc, char *argv[]) break for (;;) { - i = mdwopt(argc - 1, argv + 1, "hVO:R+U+ac:d+f+i+j:n+o:qr+v", opts, 0, 0, + i = mdwopt(argc - 1, argv + 1, "hVO:R+U+ac:f+i+j:n+o:qr+v", opts, 0, 0, OPTF_NEGATION | OPTF_NOPROGNAME); if (i < 0) break; switch (i) { @@ -1447,7 +1466,7 @@ int main(int argc, char *argv[]) #undef FLAGOPT - /* CHeck that everything worked. */ + /* Check that everything worked. */ optind++; if ((flags&AF_ALL) ? optind < argc : optind >= argc) flags |= AF_BOGUS; if (flags&AF_BOGUS) { usage(stderr); exit(127); } @@ -1649,7 +1668,7 @@ int main(int argc, char *argv[]) JOB_NAME(job), job->oldimg); } else { if (verbose >= 2) - moan("deleting `%s' image `%s' (dry run)", + moan("deleting `%s' image `%s'", JOB_NAME(job), job->imglink); if (unlink(job->imglink) && errno != ENOENT) bad("failed to delete `%s' image link `%s': %s",