Procházet zdrojové kódy

Add a --status-pipe.

Adam Heath před 25 roky
rodič
revize
977ae18704
4 změnil soubory, kde provedl 46 přidání a 1 odebrání
  1. 4 0
      ChangeLog
  2. 17 0
      lib/dbmodify.c
  3. 4 1
      main/dpkg.8
  4. 21 0
      main/main.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+Fri Jan  5 22:36:24 CST 2001 Adam Heath <doogie@debian.org>
+
+  * main/main.c, lib/dbmodify.c, main/dpkg.8: Add a --status-pipe.
+
 Fri Jan  5 22:25:06 CST 2001 Adam Heath <doogie@debian.org>
 
   * lib/varbuf.c: varbuf(v)printf now return the number of characters

+ 17 - 0
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)

+ 4 - 1
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<n>\fP
+Send package status info to file descriptor \fI<n>\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.

+ 21 - 0
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=<octal>         Enable debugging - see -Dhelp or --debug=help\n\
+  --status-pipe <n>	     Send status change updates to file descriptor <n>\n\
   --ignore-depends=<package>,... Ignore dependencies involving <package>\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              },