From 977ae18704c8f6543a75d13a3bedc1861d01660f Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Sat, 6 Jan 2001 05:09:00 +0000 Subject: [PATCH] Add a --status-pipe. --- ChangeLog | 4 ++++ lib/dbmodify.c | 17 +++++++++++++++++ main/dpkg.8 | 5 ++++- main/main.c | 21 +++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 53f585f0..b3ae3010 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 5 22:36:24 CST 2001 Adam Heath + + * main/main.c, lib/dbmodify.c, main/dpkg.8: Add a --status-pipe. + Fri Jan 5 22:25:06 CST 2001 Adam Heath * lib/varbuf.c: varbuf(v)printf now return the number of characters diff --git a/lib/dbmodify.c b/lib/dbmodify.c index eb34c0c4..7ea2d480 100644 --- a/lib/dbmodify.c +++ b/lib/dbmodify.c @@ -219,11 +219,28 @@ void modstatdb_shutdown(void) { free(updatefnbuf); } +struct pipef *status_pipes= NULL; + void modstatdb_note(struct pkginfo *pkg) { assert(cstatus >= msdbrw_write); onerr_abort++; + if (status_pipes) { + static struct varbuf *status= NULL; + struct pipef *pipef= status_pipes; + int r; + if (status == NULL) { + status = nfmalloc(sizeof(struct varbuf)); + varbufinit(status); + } else + varbufreset(status); + r= varbufprintf(status, "status: %s: %s\n", pkg->name, statusinfos[pkg->status]); + while (pipef) { + write(pipef->fd, status->buf, r); + pipef= pipef->next; + } + } varbufreset(&uvb); varbufrecord(&uvb, pkg, &pkg->installed); if (fwrite(uvb.buf, 1, uvb.used, importanttmp) != uvb.used) diff --git a/main/dpkg.8 b/main/dpkg.8 index b17d05e0..9e136cca 100644 --- a/main/dpkg.8 +++ b/main/dpkg.8 @@ -455,7 +455,10 @@ be marked selected for installation. .BR -E " | " --skip-same-version Don't install the package if the same version of the package is already installed. - +.TP +\fB--status-pipe\fP\fI\fP +Send package status info to file descriptor \fI\fP. This can be given +multiple times. .SH FILES The files listed here are in their default directories, see option \fB--admindir\fP to see how to change locations of these files. diff --git a/main/main.c b/main/main.c index f13745dc..f39d7902 100644 --- a/main/main.c +++ b/main/main.c @@ -99,6 +99,7 @@ Options:\n\ --largemem | --smallmem Optimise for large (>4Mb) or small (<4Mb) RAM use\n\ --no-act Just say what we would do - don't do it\n\ -D|--debug= Enable debugging - see -Dhelp or --debug=help\n\ + --status-pipe Send status change updates to file descriptor \n\ --ignore-depends=,... Ignore dependencies involving \n\ --force-... Override problems - see --force-help\n\ --no-force-...|--refuse-... Stop when problems encountered\n\ @@ -258,6 +259,24 @@ static void setinteger(const struct cmdinfo *cip, const char *value) { *cip->iassignto= v; } + +static void setstatuspipe(const struct cmdinfo *cip, const char *value) { + static struct pipef *lastpipe= NULL; + unsigned long v; + char *ep; + + if (lastpipe) { + lastpipe->next= nfmalloc(sizeof(struct pipef)); + lastpipe= lastpipe->next; + } else { + lastpipe= status_pipes= nfmalloc(sizeof(struct pipef)); + } + v= strtoul(value,&ep,0); + if (*ep || v > INT_MAX) + badusage(_("invalid integer for --%s: `%.250s'"),cip->olong,value); + lastpipe->fd= v; +} + void setforce(const struct cmdinfo *cip, const char *value) { const char *comma; int l; @@ -324,6 +343,7 @@ static const char *const passlongopts[]= { static const char passshortopts[]= "bceIfxX"; static const char okpassshortopts[]= "D"; +void commandpipe(const char *const *argv); static const struct cmdinfo cmdinfos[]= { /* This table has both the action entries in it and the normal options. * The action entries are made with the ACTION macro, as they all @@ -363,6 +383,7 @@ static const struct cmdinfo cmdinfos[]= { ACTION( "predep-package", 0, act_predeppackage, predeppackage ), ACTION( "compare-versions", 0, act_cmpversions, cmpversions ), + { "status-pipe", 0, 1, 0, 0, setstatuspipe }, { "pending", 'a', 0, &f_pending, 0, 0, 1 }, { "recursive", 'R', 0, &f_recursive, 0, 0, 1 }, { "no-act", 0, 0, &f_noact, 0, 0, 1 }, -- 2.39.5