- move showprogress implementation out of the header file so that changes
authorpmatilai <pmatilai>
Thu, 25 May 2006 13:31:38 +0000 (13:31 +0000)
committerpmatilai <pmatilai>
Thu, 25 May 2006 13:31:38 +0000 (13:31 +0000)
  dont trigger rebuilding the whole dang thing

apt-pkg/Makefile.am
apt-pkg/Makefile.in
apt-pkg/rpm/rpmshowprogress.cc [new file with mode: 0644]
apt-pkg/rpm/rpmshowprogress.h

index e364b03..f5acf90 100644 (file)
@@ -52,6 +52,7 @@ libapt_pkg_la_SOURCES = \
        rpm/rpmpm.cc \
        rpm/rpmpm.h \
        rpm/rpmshowprogress.h \
+       rpm/rpmshowprogress.cc \
        rpm/rpmrecords.cc \
        rpm/rpmrecords.h \
        rpm/rpmsrcrecords.cc \
index bbc6ff5..663e8e0 100644 (file)
@@ -71,14 +71,14 @@ am_libapt_pkg_la_OBJECTS = contrib/cdromutl.lo contrib/cmndline.lo \
        contrib/mmap.lo contrib/progress.lo contrib/sha1.lo \
        contrib/strutl.lo rpm/repomd.lo rpm/rpmhandler.lo \
        rpm/rpmindexfile.lo rpm/rpmlistparser.lo rpm/rpmpackagedata.lo \
-       rpm/rpmpm.lo rpm/rpmrecords.lo rpm/rpmsrcrecords.lo \
-       rpm/rpmsystem.lo rpm/rpmversion.lo acquire.lo acquire-item.lo \
-       acquire-method.lo acquire-worker.lo algorithms.lo cachefile.lo \
-       clean.lo depcache.lo indexfile.lo init.lo luaiface.lo \
-       orderlist.lo packagemanager.lo pkgcache.lo pkgcachegen.lo \
-       pkgrecords.lo pkgsystem.lo policy.lo repository.lo \
-       sourcelist.lo srcrecords.lo tagfile.lo version.lo \
-       versionmatch.lo
+       rpm/rpmpm.lo rpm/rpmshowprogress.lo rpm/rpmrecords.lo \
+       rpm/rpmsrcrecords.lo rpm/rpmsystem.lo rpm/rpmversion.lo \
+       acquire.lo acquire-item.lo acquire-method.lo acquire-worker.lo \
+       algorithms.lo cachefile.lo clean.lo depcache.lo indexfile.lo \
+       init.lo luaiface.lo orderlist.lo packagemanager.lo pkgcache.lo \
+       pkgcachegen.lo pkgrecords.lo pkgsystem.lo policy.lo \
+       repository.lo sourcelist.lo srcrecords.lo tagfile.lo \
+       version.lo versionmatch.lo
 libapt_pkg_la_OBJECTS = $(am_libapt_pkg_la_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
 depcomp = $(SHELL) $(top_srcdir)/buildlib/depcomp
@@ -286,6 +286,7 @@ libapt_pkg_la_SOURCES = \
        rpm/rpmpm.cc \
        rpm/rpmpm.h \
        rpm/rpmshowprogress.h \
+       rpm/rpmshowprogress.cc \
        rpm/rpmrecords.cc \
        rpm/rpmrecords.h \
        rpm/rpmsrcrecords.cc \
@@ -472,6 +473,8 @@ rpm/rpmlistparser.lo: rpm/$(am__dirstamp) \
 rpm/rpmpackagedata.lo: rpm/$(am__dirstamp) \
        rpm/$(DEPDIR)/$(am__dirstamp)
 rpm/rpmpm.lo: rpm/$(am__dirstamp) rpm/$(DEPDIR)/$(am__dirstamp)
+rpm/rpmshowprogress.lo: rpm/$(am__dirstamp) \
+       rpm/$(DEPDIR)/$(am__dirstamp)
 rpm/rpmrecords.lo: rpm/$(am__dirstamp) rpm/$(DEPDIR)/$(am__dirstamp)
 rpm/rpmsrcrecords.lo: rpm/$(am__dirstamp) \
        rpm/$(DEPDIR)/$(am__dirstamp)
@@ -520,6 +523,8 @@ mostlyclean-compile:
        -rm -f rpm/rpmpm.lo
        -rm -f rpm/rpmrecords.$(OBJEXT)
        -rm -f rpm/rpmrecords.lo
+       -rm -f rpm/rpmshowprogress.$(OBJEXT)
+       -rm -f rpm/rpmshowprogress.lo
        -rm -f rpm/rpmsrcrecords.$(OBJEXT)
        -rm -f rpm/rpmsrcrecords.lo
        -rm -f rpm/rpmsystem.$(OBJEXT)
@@ -573,6 +578,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@rpm/$(DEPDIR)/rpmpackagedata.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@rpm/$(DEPDIR)/rpmpm.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@rpm/$(DEPDIR)/rpmrecords.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@rpm/$(DEPDIR)/rpmshowprogress.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@rpm/$(DEPDIR)/rpmsrcrecords.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@rpm/$(DEPDIR)/rpmsystem.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@rpm/$(DEPDIR)/rpmversion.Plo@am__quote@
diff --git a/apt-pkg/rpm/rpmshowprogress.cc b/apt-pkg/rpm/rpmshowprogress.cc
new file mode 100644 (file)
index 0000000..ccae011
--- /dev/null
@@ -0,0 +1,152 @@
+
+#include <stdio.h>
+#include <rpm/rpmlib.h>
+#include <apti18n.h>
+
+#include "rpmshowprogress.h"
+//
+// This code was originally from rpm 4.0.3.
+//
+static void printHash(const unsigned long amount, const unsigned long total)
+{
+    int hashesNeeded;
+    int hashesTotal = 50;
+
+    if (isatty (STDOUT_FILENO))
+       hashesTotal = 44;
+
+    if (hashesPrinted != hashesTotal) {
+       hashesNeeded = (int)(hashesTotal*(total?(((float)amount)/total):1));
+       while (hashesNeeded > hashesPrinted) {
+           if (isatty (STDOUT_FILENO)) {
+               int i;
+               for (i = 0; i < hashesPrinted; i++) (void) putchar ('#');
+               for (; i < hashesTotal; i++) (void) putchar (' ');
+               fprintf(stdout, "(%3d%%)",
+                       (int)(100 * (total ? (((float) amount) / total) : 1)));
+               for (i = 0; i < (hashesTotal + 6); i++) (void) putchar ('\b');
+           } else
+               fprintf(stdout, "#");
+
+           hashesPrinted++;
+       }
+       (void) fflush(stdout);
+       hashesPrinted = hashesNeeded;
+
+       if (hashesPrinted == hashesTotal) {
+           int i;
+           progressCurrent++;
+           if (isatty(STDOUT_FILENO)) {
+               for (i = 1; i < hashesPrinted; i++) (void) putchar ('#');
+               fprintf(stdout, " [%3d%%]", (int)(100 * (progressTotal ?
+                       (((float) progressCurrent) / progressTotal) : 1)));
+           }
+           fprintf(stdout, "\n");
+       }
+       (void) fflush(stdout);
+    }
+}
+
+#if RPM_VERSION < 0x040000
+void * rpmpmShowProgress(const Header h,
+#else
+void * rpmpmShowProgress(const void * arg, 
+#endif
+                       const rpmCallbackType what,
+                       const unsigned long amount,
+                       const unsigned long total,
+                       const void * pkgKey, void * data)
+{
+#if RPM_VERSION >= 0x040000
+    Header h = (Header) arg;
+#endif
+
+    char * s;
+    int flags = (int) ((long)data);
+    void * rc = NULL;
+    const char * filename = (const char *) pkgKey;
+    static FD_t fd = NULL;
+
+    switch (what) {
+    case RPMCALLBACK_INST_OPEN_FILE:
+       if (filename == NULL || filename[0] == '\0')
+           return NULL;
+       fd = Fopen(filename, "r.ufdio");
+       if (fd)
+           fd = fdLink(fd, "persist (showProgress)");
+       return fd;
+       /*@notreached@*/ break;
+
+    case RPMCALLBACK_INST_CLOSE_FILE:
+       fd = fdFree(fd, "persist (showProgress)");
+       if (fd) {
+           (void) Fclose(fd);
+           fd = NULL;
+       }
+       break;
+
+    case RPMCALLBACK_INST_START:
+       hashesPrinted = 0;
+       if (h == NULL || !(flags & INSTALL_LABEL))
+           break;
+       if (flags & INSTALL_HASH) {
+           s = headerSprintf(h, "%{NAME}.%{ARCH}",
+                               rpmTagTable, rpmHeaderFormats, NULL);
+           if (isatty (STDOUT_FILENO))
+               fprintf(stdout, "%4d:%-23.23s", progressCurrent + 1, s);
+           else
+               fprintf(stdout, "%-28.28s", s);
+           (void) fflush(stdout);
+           free(s);
+           s = NULL;
+       } else {
+           s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}",
+                                 rpmTagTable, rpmHeaderFormats, NULL);
+           fprintf(stdout, "%s\n", s);
+           (void) fflush(stdout);
+           free(s);
+           s = NULL;
+       }
+       break;
+
+    case RPMCALLBACK_TRANS_PROGRESS:
+    case RPMCALLBACK_INST_PROGRESS:
+       if (flags & INSTALL_PERCENT)
+           fprintf(stdout, "%%%% %f\n", (double) (total
+                               ? ((((float) amount) / total) * 100)
+                               : 100.0));
+       else if (flags & INSTALL_HASH)
+           printHash(amount, total);
+       (void) fflush(stdout);
+       break;
+
+    case RPMCALLBACK_TRANS_START:
+       hashesPrinted = 0;
+       progressTotal = 1;
+       progressCurrent = 0;
+       if (!(flags & INSTALL_LABEL))
+           break;
+       if (flags & INSTALL_HASH)
+           fprintf(stdout, "%-28s", _("Preparing..."));
+       else
+           fprintf(stdout, "%s\n", _("Preparing..."));
+       (void) fflush(stdout);
+       break;
+
+    case RPMCALLBACK_TRANS_STOP:
+       if (flags & INSTALL_HASH)
+           printHash(1, 1);    /* Fixes "preparing..." progress bar */
+       progressTotal = packagesTotal;
+       progressCurrent = 0;
+       break;
+
+    case RPMCALLBACK_UNINST_PROGRESS:
+    case RPMCALLBACK_UNINST_START:
+    case RPMCALLBACK_UNINST_STOP:
+       /* ignore */
+       break;
+    }
+
+    return rc;
+}      
+
index 41dd3fa..6ea5eee 100644 (file)
@@ -1,50 +1,10 @@
-//
-// This code was originally from rpm 4.0.3.
-//
+
 static int hashesPrinted = 0;
 static int packagesTotal = 0;
 static int progressTotal = 0;
 static int progressCurrent = 0;
 
-static void printHash(const unsigned long amount, const unsigned long total)
-{
-    int hashesNeeded;
-    int hashesTotal = 50;
-
-    if (isatty (STDOUT_FILENO))
-       hashesTotal = 44;
-
-    if (hashesPrinted != hashesTotal) {
-       hashesNeeded = (int)(hashesTotal*(total?(((float)amount)/total):1));
-       while (hashesNeeded > hashesPrinted) {
-           if (isatty (STDOUT_FILENO)) {
-               int i;
-               for (i = 0; i < hashesPrinted; i++) (void) putchar ('#');
-               for (; i < hashesTotal; i++) (void) putchar (' ');
-               fprintf(stdout, "(%3d%%)",
-                       (int)(100 * (total ? (((float) amount) / total) : 1)));
-               for (i = 0; i < (hashesTotal + 6); i++) (void) putchar ('\b');
-           } else
-               fprintf(stdout, "#");
-
-           hashesPrinted++;
-       }
-       (void) fflush(stdout);
-       hashesPrinted = hashesNeeded;
-
-       if (hashesPrinted == hashesTotal) {
-           int i;
-           progressCurrent++;
-           if (isatty(STDOUT_FILENO)) {
-               for (i = 1; i < hashesPrinted; i++) (void) putchar ('#');
-               fprintf(stdout, " [%3d%%]", (int)(100 * (progressTotal ?
-                       (((float) progressCurrent) / progressTotal) : 1)));
-           }
-           fprintf(stdout, "\n");
-       }
-       (void) fflush(stdout);
-    }
-}
+static void printHash(const unsigned long amount, const unsigned long total);
 
 #if RPM_VERSION < 0x040000
 void * rpmpmShowProgress(const Header h,
@@ -54,98 +14,4 @@ void * rpmpmShowProgress(const void * arg,
                        const rpmCallbackType what,
                        const unsigned long amount,
                        const unsigned long total,
-                       const void * pkgKey, void * data)
-{
-#if RPM_VERSION >= 0x040000
-    Header h = (Header) arg;
-#endif
-
-    char * s;
-    int flags = (int) ((long)data);
-    void * rc = NULL;
-    const char * filename = (const char *) pkgKey;
-    static FD_t fd = NULL;
-
-    switch (what) {
-    case RPMCALLBACK_INST_OPEN_FILE:
-       if (filename == NULL || filename[0] == '\0')
-           return NULL;
-       fd = Fopen(filename, "r.ufdio");
-       if (fd)
-           fd = fdLink(fd, "persist (showProgress)");
-       return fd;
-       /*@notreached@*/ break;
-
-    case RPMCALLBACK_INST_CLOSE_FILE:
-       fd = fdFree(fd, "persist (showProgress)");
-       if (fd) {
-           (void) Fclose(fd);
-           fd = NULL;
-       }
-       break;
-
-    case RPMCALLBACK_INST_START:
-       hashesPrinted = 0;
-       if (h == NULL || !(flags & INSTALL_LABEL))
-           break;
-       if (flags & INSTALL_HASH) {
-           s = headerSprintf(h, "%{NAME}.%{ARCH}",
-                               rpmTagTable, rpmHeaderFormats, NULL);
-           if (isatty (STDOUT_FILENO))
-               fprintf(stdout, "%4d:%-23.23s", progressCurrent + 1, s);
-           else
-               fprintf(stdout, "%-28.28s", s);
-           (void) fflush(stdout);
-           free(s);
-           s = NULL;
-       } else {
-           s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}",
-                                 rpmTagTable, rpmHeaderFormats, NULL);
-           fprintf(stdout, "%s\n", s);
-           (void) fflush(stdout);
-           free(s);
-           s = NULL;
-       }
-       break;
-
-    case RPMCALLBACK_TRANS_PROGRESS:
-    case RPMCALLBACK_INST_PROGRESS:
-       if (flags & INSTALL_PERCENT)
-           fprintf(stdout, "%%%% %f\n", (double) (total
-                               ? ((((float) amount) / total) * 100)
-                               : 100.0));
-       else if (flags & INSTALL_HASH)
-           printHash(amount, total);
-       (void) fflush(stdout);
-       break;
-
-    case RPMCALLBACK_TRANS_START:
-       hashesPrinted = 0;
-       progressTotal = 1;
-       progressCurrent = 0;
-       if (!(flags & INSTALL_LABEL))
-           break;
-       if (flags & INSTALL_HASH)
-           fprintf(stdout, "%-28s", _("Preparing..."));
-       else
-           fprintf(stdout, "%s\n", _("Preparing..."));
-       (void) fflush(stdout);
-       break;
-
-    case RPMCALLBACK_TRANS_STOP:
-       if (flags & INSTALL_HASH)
-           printHash(1, 1);    /* Fixes "preparing..." progress bar */
-       progressTotal = packagesTotal;
-       progressCurrent = 0;
-       break;
-
-    case RPMCALLBACK_UNINST_PROGRESS:
-    case RPMCALLBACK_UNINST_START:
-    case RPMCALLBACK_UNINST_STOP:
-       /* ignore */
-       break;
-    }
-
-    return rc;
-}      
-
+                       const void * pkgKey, void * data);