From: Adam Heath Date: Thu, 4 Jan 2001 07:35:21 +0000 (+0000) Subject: Add 'warn' parameter to waitsubproc and checksubprocerr, and also add a X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32b4a31781e921003080116d0c5365ede49ca442;p=dpkg Add 'warn' parameter to waitsubproc and checksubprocerr, and also add a return value. This fixes my last checkin, where maintainer_script_alternative would run both the old and new script. --- diff --git a/ChangeLog b/ChangeLog index fec287c4..7b50c6cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Jan 4 01:20:27 CST 2001 Adam Heath + + * dpkg-deb/build.c, dpkg-deb/extract.c, dpkg-deb/info.c, + include/dpkg.h.in, lib/mlib.c, main/archives.c, main/enquiry.c, + main/help.c main/processarc.c: Add 'warn' parameter to waitsubproc + and checksubprocerr, and also add a return value. This fixes my + last checkin, where maintainer_script_alternative would run + both the old and new script. + Thu Jan 04 05:19:37 CET 2001 peter karlsson * po/sv.po: Updated Swedish translation. diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index 8e1c41c8..713c03a7 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -391,8 +391,8 @@ void do_build(const char *const *argv) { internalGzip(0, 1, "9", _("control")); } close(p1[0]); - waitsubproc(c2,"gzip -9c",0); - waitsubproc(c1,"tar -cf",0); + waitsubproc(c2,"gzip -9c",0,0); + waitsubproc(c1,"tar -cf",0,0); if (fstat(gzfd,&controlstab)) ohshite(_("failed to fstat tmpfile (control)")); /* We have our first file for the ar-archive. Write a header for it to the * package and insert it. @@ -478,7 +478,7 @@ void do_build(const char *const *argv) { ohshite(_("failed to write filename to tar pipe (data)")); } close(p3[0]); - waitsubproc(c3,"find",0); + waitsubproc(c3,"find",0,0); for (fi= symlist;fi;fi= fi->next) if (write(p1[1], fi->fn, strlen(fi->fn)+1) == -1) @@ -486,8 +486,8 @@ void do_build(const char *const *argv) { /* All done, clean up wait for tar and gzip to finish their job */ close(p1[1]); free_filist(symlist); - waitsubproc(c2,"gzip -9c from tar -cf",0); - waitsubproc(c1,"tar -cf",0); + waitsubproc(c2,"gzip -9c from tar -cf",0,0); + waitsubproc(c1,"tar -cf",0,0); /* Okay, we have data.tar.gz as well now, add it to the ar wrapper */ if (!oldformatflag) { if (fstat(gzfd,&datastab)) ohshite("_(failed to fstat tmpfile (data))"); diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c index 1b8d41d4..f93e5509 100644 --- a/dpkg-deb/extract.c +++ b/dpkg-deb/extract.c @@ -50,7 +50,7 @@ static void movecontrolfiles(const char *thing) { if (!(c1= m_fork())) { execlp("sh","sh","-c",buf,(char*)0); ohshite(_("failed to exec sh -c mv foo/* &c")); } - waitsubproc(c1,"sh -c mv foo/* &c",0); + waitsubproc(c1,"sh -c mv foo/* &c",0,0); } static void readfail(FILE *a, const char *filename, const char *what) { @@ -302,11 +302,11 @@ void extracthalf(const char *debar, const char *directory, ohshite(_("failed to exec tar")); } close(p2[0]); - waitsubproc(c3,"tar",0); + waitsubproc(c3,"tar",0,0); } - waitsubproc(c2,"gzip -dc",1); - if (c1 != -1) waitsubproc(c1,"paste",0); + waitsubproc(c2,"gzip -dc",1,0); + if (c1 != -1) waitsubproc(c1,"paste",0,0); if (oldformat && admininfo) { if (versionnum == 0.931F) { movecontrolfiles(OLDOLDDEBDIR); diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index 7e72fc53..01e36cba 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -71,7 +71,7 @@ static void info_prepare(const char *const **argvp, if (!(c1= m_fork())) { execlp(RM,"rm","-rf",dbuf,(char*)0); ohshite(_("failed to exec rm -rf")); } - waitsubproc(c1,"rm -rf",0); + waitsubproc(c1,"rm -rf",0,0); push_cleanup(cu_info_prepare,-1, 0,0, 1, (void*)dbuf); extracthalf(*debarp, dbuf, "mx", admininfo); } diff --git a/include/dpkg.h.in b/include/dpkg.h.in index ec4920d7..e447833c 100644 --- a/include/dpkg.h.in +++ b/include/dpkg.h.in @@ -194,8 +194,8 @@ int m_fork(void); void m_dup2(int oldfd, int newfd); void m_pipe(int fds[2]); -void checksubprocerr(int status, const char *description, int sigpipeok); -void waitsubproc(pid_t pid, const char *description, int sigpipeok); +int checksubprocerr(int status, const char *description, int sigpipeok, int warn); +int waitsubproc(pid_t pid, const char *description, int sigpipeok, int warn); #define BUFFER_WRITE_BUF 0 #define BUFFER_WRITE_VBUF 1 diff --git a/lib/mlib.c b/lib/mlib.c index 4ffa3c64..e67f54d5 100644 --- a/lib/mlib.c +++ b/lib/mlib.c @@ -102,27 +102,34 @@ void m_pipe(int *fds) { ohshite(_("failed to create pipe")); } -void checksubprocerr(int status, const char *description, int sigpipeok) { +int checksubprocerr(int status, const char *description, int sigpipeok, int warn) { int n; if (WIFEXITED(status)) { - n= WEXITSTATUS(status); if (!n) return; - ohshit(_("subprocess %s returned error exit status %d"),description,n); + n= WEXITSTATUS(status); if (!n) return n; + if(warn) + fprintf(stderr, _("dpkg: warning - %s returned error exit status %d\n"),description,n); + else + ohshit(_("subprocess %s returned error exit status %d"),description,n); } else if (WIFSIGNALED(status)) { - n= WTERMSIG(status); if (!n || (sigpipeok && n==SIGPIPE)) return; - ohshit(_("subprocess %s killed by signal (%s)%s"), + n= WTERMSIG(status); if (!n || (sigpipeok && n==SIGPIPE)) return 0; + if (warn) + ohshit(_("dpkg: warning - %s killed by signal (%s)%s\n"), + description, strsignal(n), WCOREDUMP(status) ? ", core dumped" : ""); + else + ohshit(_("subprocess %s killed by signal (%s)%s"), description, strsignal(n), WCOREDUMP(status) ? ", core dumped" : ""); } else { ohshit(_("subprocess %s failed with wait status code %d"),description,status); } } -void waitsubproc(pid_t pid, const char *description, int sigpipeok) { +int waitsubproc(pid_t pid, const char *description, int sigpipeok, int warn) { pid_t r; int status; while ((r= waitpid(pid,&status,0)) == -1 && errno == EINTR); if (r != pid) { onerr_abort++; ohshite(_("wait for %s failed"),description); } - checksubprocerr(status,description,sigpipeok); + return checksubprocerr(status,description,sigpipeok, warn); } ssize_t buffer_write(buffer_data_t data, void *buf, ssize_t length, char *desc) { diff --git a/main/archives.c b/main/archives.c index 73e8a244..f1eacaac 100644 --- a/main/archives.c +++ b/main/archives.c @@ -747,7 +747,7 @@ void archivefiles(const char *const *argv) { } if (ferror(pf)) ohshite(_("error reading find's pipe")); if (fclose(pf)) ohshite(_("error closing find's pipe")); - waitsubproc(fc,"find",0); + waitsubproc(fc,"find",0,0); if (!nfiles) ohshit(_("searched, but found no packages (files matching *.deb)")); diff --git a/main/enquiry.c b/main/enquiry.c index 3035b8cb..54ff7f6f 100644 --- a/main/enquiry.c +++ b/main/enquiry.c @@ -699,7 +699,7 @@ void printarch(const char *const *argv) { } close(p1[1]); fd_vbuf_copy(fileno(ccpipe), &vb, -1, _("error reading from CC pipe")); - waitsubproc(c1,"gcc --print-libgcc-file-name",0); + waitsubproc(c1,"gcc --print-libgcc-file-name",0,0); if (!vb.used) badlgccfn(ccompiler,"",_("empty output")); varbufaddc(&vb,0); if (vb.buf[vb.used-2] != '\n') badlgccfn(ccompiler,vb.buf,_("no newline")); diff --git a/main/help.c b/main/help.c index 2762aeb3..7ac3e4e2 100644 --- a/main/help.c +++ b/main/help.c @@ -284,7 +284,7 @@ int maintainer_script_installed(struct pkginfo *pkg, const char *scriptname, ohshite(_("unable to execute %s"),buf); } script_catchsignals(); /* This does a push_cleanup() */ - waitsubproc(c1,buf,0); + waitsubproc(c1,buf,0,0); pop_cleanup(ehflag_normaltidy); ensure_diversions(); @@ -321,7 +321,7 @@ int maintainer_script_new(const char *scriptname, const char *description, ohshite(_("unable to execute new %s"),buf); } script_catchsignals(); /* This does a push_cleanup() */ - waitsubproc(c1,buf,0); + waitsubproc(c1,buf,0,0); pop_cleanup(ehflag_normaltidy); ensure_diversions(); @@ -337,7 +337,7 @@ int maintainer_script_alternative(struct pkginfo *pkg, struct stat stab; int c1, n, status; char buf[100]; - pid_t r; + int r; oldscriptpath= pkgadminfile(pkg,scriptname); arglist= buildarglist(scriptname, @@ -363,8 +363,9 @@ int maintainer_script_alternative(struct pkginfo *pkg, ohshite(_("unable to execute %s"),buf); } script_catchsignals(); /* This does a push_cleanup() */ - waitsubproc(c1,buf,0); + r= waitsubproc(c1,buf,0,1); pop_cleanup(ehflag_normaltidy); + if (!r) return 1; ensure_diversions(); } fprintf(stderr, _("dpkg - trying script from the new package instead ...\n")); @@ -392,7 +393,7 @@ int maintainer_script_alternative(struct pkginfo *pkg, ohshite(_("unable to execute %s"),buf); } script_catchsignals(); /* This does a push_cleanup() */ - waitsubproc(c1,buf,0); + waitsubproc(c1,buf,0,1); pop_cleanup(ehflag_normaltidy); fprintf(stderr, _("dpkg: ... it looks like that went OK.\n")); @@ -496,5 +497,5 @@ void ensure_pathname_nonexisting(const char *pathname) { ohshite(_("failed to exec rm for cleanup")); } debug(dbg_eachfile,"ensure_pathname_nonexisting running rm -rf"); - waitsubproc(c1,"rm cleanup",0); + waitsubproc(c1,"rm cleanup",0,0); } diff --git a/main/processarc.c b/main/processarc.c index 5a63d9d2..e73da8de 100644 --- a/main/processarc.c +++ b/main/processarc.c @@ -132,7 +132,7 @@ void process_archive(const char *filename) { /* No, it wasn't a part. */ break; default: - checksubprocerr(status,SPLITTER,0); + checksubprocerr(status,SPLITTER,0,0); } } @@ -162,7 +162,7 @@ void process_archive(const char *filename) { execlp(BACKEND, BACKEND,"--control",filename,cidir,(char*)0); ohshite(_("failed to exec dpkg-deb to extract control information")); } - waitsubproc(c1,BACKEND " --control",0); + waitsubproc(c1,BACKEND " --control",0,0); strcpy(cidirrest,CONTROLFILE); parsedb(cidir, pdb_recordavailable|pdb_rejectstatus|pdb_ignorefiles|pdb_weakclassification, @@ -527,7 +527,7 @@ void process_archive(const char *filename) { } fd_null_copy(tc.backendpipe,-1,_("dpkg-deb: zap possible trailing zeros")); close(tc.backendpipe); - waitsubproc(c1,BACKEND " --fsys-tarfile",1); + waitsubproc(c1,BACKEND " --fsys-tarfile",1,0); if (oldversionstatus == stat_halfinstalled || oldversionstatus == stat_unpacked) { /* Packages that were in `installed' and `postinstfailed' have been reduced