Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jul 2008 15:12:33 GMT
From:      Anders Nore <andenore@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 145284 for review
Message-ID:  <200807151512.m6FFCXKa059034@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=145284

Change 145284 by andenore@andenore_laptop on 2008/07/15 15:12:12

	Added progress bar to -r option of pkg_add

Affected files ...

.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/CHANGES#6 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/convert/perform.c#6 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/create/main.c#3 integrate
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/create/perform.c#5 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/perform.c#6 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/database.c#7 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/lib.h#8 integrate
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/url.c#3 edit

Differences ...

==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/CHANGES#6 (text+ko) ====

@@ -1,5 +1,5 @@
 Changes made to pkg_install during SoC2008 by Anders Nore (andenore@FreeBSD.org)
-Last modified: 2008 06 25
+Last modified: 2008 07 15
 
 
 Converter: 
@@ -16,6 +16,7 @@
 
 Add:
 	- Indexes information to dbcache according to the add
+	- Added percentage progress for remote fetching ( -r option )
 
 Delete:
 	- Deindexes information according to the delete

==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/convert/perform.c#6 (text+ko) ====


==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/create/main.c#3 (text+ko) ====

@@ -10,7 +10,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/pkg_install/create/main.c,v 1.45 2008/06/16 23:41:11 flz Exp $");
+__FBSDID("$FreeBSD: src/usr.sbin/pkg_install/create/main.c,v 1.46 2008/07/08 03:21:05 keramida Exp $");
 
 #include <getopt.h>
 #include <err.h>
@@ -208,6 +208,10 @@
 	    Recursive = TRUE;
 	    break;
 
+	case 'n':
+	    Regenerate = FALSE;
+	    break;
+
 	case 0:
 	    if (Help)
 		usage();

==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/create/perform.c#5 (text+ko) ====

@@ -242,11 +242,12 @@
 	 * See /usr/ports/Mk/bsd.port.mk (in the fake-pkg target)
 	 */
 	if (PlistOnly) {
-		openDatabase(O_RDWR);
+		if (openDatabase(O_CREAT | O_RDWR))
+			err("Could not open database: %s", DBCACHE_FILE);
 	
 		check_list(home, &plist);
+		write_plist(&plist, stdout);
 		int retval = cache_plist(&plist, FALSE);
-		write_plist(&plist, stdout);
 
 		closeDatabase();
 		exit(retval);

==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/perform.c#6 (text+ko) ====

@@ -377,20 +377,19 @@
 	}
 
 	/* If cache exists check database for the key (i.e., file absolute path) */
-	if(CacheExists == TRUE) {
+	if (CacheExists == TRUE) {
 // 		DEBUG("find_pkg: USES CACHE\n");
 		TAILQ_FOREACH(wp, which_list, next) {
 			if (wp->skip == TRUE)
 				continue;
 			DBT tmp;
-			if(dbKeyExists(wp->file, &tmp))
+			if (dbKeyExists(wp->file, &tmp))
 				strlcpy(wp->package, tmp.data, PATH_MAX);
 			else
 				DEBUG("find_pkg: Doesn't exist\n");
 		}
 	} else {
-		DEBUG("find_pkg: NO CACHE\n");
-
+		DEBUG("debug: not using cache; run pkg_convert\n");
 	installed = matchinstalled(MATCH_ALL, NULL, &errcode);
 	if (installed == NULL)
 		return errcode;

==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/database.c#7 (text+ko) ====

@@ -46,7 +46,7 @@
 DB *
 opendb(const char *filename, int flags)
 {
-	return dbopen(filename, flags, 0755, DB_BTREE, &btinfo);
+	return dbopen(filename, flags, 0777, DB_BTREE, &btinfo);
 }
 
 /*

==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/lib.h#8 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/usr.sbin/pkg_install/lib/lib.h,v 1.68 2008/06/12 15:21:13 flz Exp $ */
+/* $FreeBSD: src/usr.sbin/pkg_install/lib/lib.h,v 1.69 2008/07/08 03:21:05 keramida Exp $ */
 
 /*
  * FreeBSD install - a package for the installation and maintainance
@@ -113,7 +113,7 @@
  * Version of the package tools - increase only when some
  * functionality used by bsd.port.mk is changed, added or removed
  */
-#define PKG_INSTALL_VERSION	20080612
+#define PKG_INSTALL_VERSION	20080708
 
 #define PKG_WRAPCONF_FNAME	"/var/db/pkg_install.conf"
 #define main(argc, argv)	real_main(argc, argv)

==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/url.c#3 (text+ko) ====

@@ -45,6 +45,7 @@
     int pfd[2], pstat, r, w = 0;
     char *hint;
     int fd, pkgfd = 0;
+    struct url_stat ustat;
 
     rp = NULL;
     /* Special tip that sysinstall left for us */
@@ -104,6 +105,11 @@
     }
 
     fetchDebug = (Verbose > 0);
+    if ((fetchStatURL(fname, &ustat, Verbose ? "v" : NULL)) == -1) {
+	if (Verbose)
+	    warn("Error: Could not get filestat for url: %s", fname);
+    }
+
     if ((ftp = fetchGetURL(fname, Verbose ? "v" : NULL)) == NULL) {
 	printf("Error: FTP Unable to get %s: %s\n",
 	       fname, fetchLastErrString);
@@ -111,7 +117,7 @@
     }
 
     if (isatty(0) || Verbose)
-	printf("Fetching %s...", fname), fflush(stdout);
+	printf("Fetching %i bytes from %s...\n", (int)ustat.size, fname), fflush(stdout);
     pen[0] = '\0';
     if ((rp = make_playpen(pen, 0)) == NULL) {
 	printf("Error: Unable to construct a new playpen for FTP!\n");
@@ -139,6 +145,7 @@
     }
     close(pfd[0]);
     for (;;) {
+	static int count = 0;
 	if ((r = fread(buf, 1, sizeof buf, ftp)) < 1)
 	    break;
 	if ((w = write(pfd[1], buf, r)) != r)
@@ -146,7 +153,14 @@
 	if (keep_package) {
 	    if ((w = write(pkgfd, buf, r)) != r)
 		break;
-	}    
+	}
+	count += r;
+	int perc = (int)count*100/(int)ustat.size;
+	if (isatty(0) || Verbose)
+	    printf("Progress: %3i%%", perc);
+	fflush(stdout);
+	if(count != (int)ustat.size)
+	    printf("\r");
     }
     if (ferror(ftp))
 	warn("warning: error reading from server");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807151512.m6FFCXKa059034>