Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pkg_install * Accept ".tbz" as an alternative pkg s...



details:   https://anonhg.NetBSD.org/src/rev/a02563a393be
branches:  trunk
changeset: 500517:a02563a393be
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Wed Dec 13 03:17:53 2000 +0000

description:
* Accept ".tbz" as an alternative pkg suffix to ".tbz" for pkg_add and
   pkg_info
 * In pkg_create, compress with bzip2 if a .tbz suffix is given
 * Fix pkg_info to work via ftp, either via URL specified on command line
   or via one made up from PKG_PATH (if set)

XXX ALWAYS tacks on ".t[bg]z", NOT ".t[gb]z" !!!

diffstat:

 usr.sbin/pkg_install/add/main.c       |   6 +-
 usr.sbin/pkg_install/add/perform.c    |  31 +++++++++++--------
 usr.sbin/pkg_install/admin/main.c     |   8 ++--
 usr.sbin/pkg_install/create/perform.c |   9 +++-
 usr.sbin/pkg_install/info/perform.c   |  55 ++++++++++++++++++++++------------
 usr.sbin/pkg_install/lib/file.c       |  53 ++++++++++++++++++++++----------
 usr.sbin/pkg_install/lib/ftpio.c      |   6 +-
 usr.sbin/pkg_install/lib/str.c        |  35 +++++++++++++++------
 8 files changed, 130 insertions(+), 73 deletions(-)

diffs (truncated from 472 to 300 lines):

diff -r af4aac4c344f -r a02563a393be usr.sbin/pkg_install/add/main.c
--- a/usr.sbin/pkg_install/add/main.c   Wed Dec 13 03:16:36 2000 +0000
+++ b/usr.sbin/pkg_install/add/main.c   Wed Dec 13 03:17:53 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: main.c,v 1.16 2000/10/11 11:01:41 hubertf Exp $        */
+/*     $NetBSD: main.c,v 1.17 2000/12/13 03:17:53 hubertf Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.16 2000/10/11 11:01:41 hubertf Exp $");
+__RCSID("$NetBSD: main.c,v 1.17 2000/12/13 03:17:53 hubertf Exp $");
 #endif
 #endif
 
@@ -157,7 +157,7 @@
                                        /* Maybe just a pkg name w/o pattern was given */
                                        char tmp[FILENAME_MAX];
                                                
-                                       snprintf(tmp, sizeof(tmp), "%s-[0-9]*.tgz", *argv);
+                                       snprintf(tmp, sizeof(tmp), "%s-[0-9]*.t[bg]z", *argv);
                                        s=findbestmatchingname(dirname_of(tmp),
                                                               basename_of(tmp));
                                        if (s) {
diff -r af4aac4c344f -r a02563a393be usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c        Wed Dec 13 03:16:36 2000 +0000
+++ b/usr.sbin/pkg_install/add/perform.c        Wed Dec 13 03:17:53 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.55 2000/10/11 20:23:54 is Exp $  */
+/*     $NetBSD: perform.c,v 1.56 2000/12/13 03:17:53 hubertf Exp $     */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.55 2000/10/11 20:23:54 is Exp $");
+__RCSID("$NetBSD: perform.c,v 1.56 2000/12/13 03:17:53 hubertf Exp $");
 #endif
 #endif
 
@@ -151,7 +151,7 @@
                                         */
                                        return 1;
 
-                               if (strstr(pkg, ".tgz") != NULL) {
+                               if ((strstr(pkg, ".tgz") != NULL) || (strstr(pkg, ".tbz") != NULL)) {
                                        /* There already is a ".tgz" - give up 
                                         * (We don't want to pretend to be exceedingly
                                         *  clever - the user should give something sane!)
@@ -163,14 +163,14 @@
                                /* Second chance - maybe just a package name was given,
                                 * without even a wildcard as a version. Tack on
                                 * the same pattern as we do for local packages: "-[0-9]*",
-                                * plus a ".tgz" as we're talking binary pkgs here.
+                                * plus a ".t[bg]z" as we're talking binary pkgs here.
                                 * Then retry.
                                 */
                                {
                                        char *s;
                                        char buf2[FILENAME_MAX];
                                        
-                                       snprintf(buf2, sizeof(buf2), "%s-[0-9]*.tgz", tmppkg);
+                                       snprintf(buf2, sizeof(buf2), "%s-[0-9]*.t[bg]z", tmppkg);
                                        s=fileFindByPath(NULL, buf2);
                                        if (s == NULL) {
                                                warnx("no pkg found for '%s' on 2nd try, sorry.", buf2);
@@ -422,11 +422,20 @@
 
                                        char    path[FILENAME_MAX], *cp = NULL;
 
-                                       (void) snprintf(path, sizeof(path), "%s/%s.tgz", Home, p->name);
+                                       /* is there a .tbz file? */
+                                       (void) snprintf(path, sizeof(path), "%s/%s.tbz", Home, p->name);
                                        if (fexists(path))
                                                cp = path;
-                                       else
-                                               cp = fileFindByPath(pkg, p->name); /* files & wildcards */
+                                       else {
+                                               /* no, maybe .tgz? */
+                                               (void) snprintf(path, sizeof(path), "%s/%s.tgz", Home, p->name);
+                                               if (fexists(path)) {
+                                                       cp = path;
+                                               } else {
+                                                       /* neither - let's do some digging! */
+                                                       cp = fileFindByPath(pkg, p->name); /* files & wildcards */
+                                               }
+                                       }
                                        if (cp) {
                                                if (Verbose)
                                                        printf("Loading it from %s.\n", cp);
@@ -463,10 +472,6 @@
 
                                                char *s;
                                                s=fileFindByPath(pkg, p->name);
-                                               if (Verbose) {
-                                                       printf("HF: pkg='%s'\n", pkg);
-                                                       printf("HF: s='%s'\n", s);
-                                               }
 
                                                /* adjust new_pkg and new_name */
                                                new_pkg = NULL;
@@ -505,7 +510,7 @@
 
                                        } else {
                                                if (Verbose)
-                                                       warnx("HF: fileGetURL('%s', '%s') failed", new_pkg, new_name);
+                                                       warnx("fileGetURL('%s', '%s') failed", new_pkg, new_name);
                                                if (!Force)
                                                        code++;
                                        }
diff -r af4aac4c344f -r a02563a393be usr.sbin/pkg_install/admin/main.c
--- a/usr.sbin/pkg_install/admin/main.c Wed Dec 13 03:16:36 2000 +0000
+++ b/usr.sbin/pkg_install/admin/main.c Wed Dec 13 03:17:53 2000 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: main.c,v 1.16 2000/11/28 05:23:35 mycroft Exp $        */
+/*     $NetBSD: main.c,v 1.17 2000/12/13 03:17:54 hubertf Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.16 2000/11/28 05:23:35 mycroft Exp $");
+__RCSID("$NetBSD: main.c,v 1.17 2000/12/13 03:17:54 hubertf Exp $");
 #endif
 
 /*
@@ -422,7 +422,7 @@
 
                        dir = dirname_of(*argv);
                        basep = basename_of(*argv);
-                       snprintf(base, sizeof(base), "%s.tgz", basep);
+                       snprintf(base, sizeof(base), "%s.t[bg]z", basep);
 
                        fchdir(saved_wd);
                        rc = chdir(dir);
@@ -461,7 +461,7 @@
 
                        dir = dirname_of(*argv);
                        basep = basename_of(*argv);
-                       snprintf(base, sizeof(base), "%s.tgz", basep);
+                       snprintf(base, sizeof(base), "%s.t[bg]z", basep);
 
                        fchdir(saved_wd);
                        rc = chdir(dir);
diff -r af4aac4c344f -r a02563a393be usr.sbin/pkg_install/create/perform.c
--- a/usr.sbin/pkg_install/create/perform.c     Wed Dec 13 03:16:36 2000 +0000
+++ b/usr.sbin/pkg_install/create/perform.c     Wed Dec 13 03:17:53 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.23 2000/10/09 19:06:08 hubertf Exp $     */
+/*     $NetBSD: perform.c,v 1.24 2000/12/13 03:17:54 hubertf Exp $     */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.23 2000/10/09 19:06:08 hubertf Exp $");
+__RCSID("$NetBSD: perform.c,v 1.24 2000/12/13 03:17:54 hubertf Exp $");
 #endif
 #endif
 
@@ -61,7 +61,10 @@
        args[nargs++] = "-c";
        args[nargs++] = "-f";
        args[nargs++] = tball;
-       if (strchr(suffix, 'z'))/* Compress/gzip? */
+       if (strstr(suffix, "bz")) {
+               args[nargs++] = "--use-compress-program";
+               args[nargs++] = "bzip2";
+       } else if (strchr(suffix, 'z'))/* Compress/gzip? */
                args[nargs++] = "-z";
        if (Dereference)
                args[nargs++] = "-h";
diff -r af4aac4c344f -r a02563a393be usr.sbin/pkg_install/info/perform.c
--- a/usr.sbin/pkg_install/info/perform.c       Wed Dec 13 03:16:36 2000 +0000
+++ b/usr.sbin/pkg_install/info/perform.c       Wed Dec 13 03:17:53 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.33 2000/11/30 10:09:15 hubertf Exp $     */
+/*     $NetBSD: perform.c,v 1.34 2000/12/13 03:17:54 hubertf Exp $     */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.33 2000/11/30 10:09:15 hubertf Exp $");
+__RCSID("$NetBSD: perform.c,v 1.34 2000/12/13 03:17:54 hubertf Exp $");
 #endif
 #endif
 
@@ -67,12 +67,14 @@
                        }
                        len = strlen(fname);
                        (void) snprintf(&fname[len], sizeof(fname) - len, "/%s", pkg);
-               } else
+               } else {
                        strcpy(fname, pkg);
+               }
                cp = fname;
        } else {
-               if ((cp = fileFindByPath(NULL, pkg)) != NULL)
+               if ((cp = fileFindByPath(NULL, pkg)) != NULL) {
                        strncpy(fname, cp, FILENAME_MAX);
+               }
        }
 
        if (cp) {
@@ -80,22 +82,35 @@
                        /* file is already unpacked by fileGetURL() */
                        strcpy(PlayPen, cp);
                } else {
-                       /*
-                        * Apply a crude heuristic to see how much space the package will
-                        * take up once it's unpacked.  I've noticed that most packages
-                        * compress an average of 75%, but we're only unpacking the + files so
-                        * be very optimistic.
-                        */
-                       if (stat(fname, &sb) == FAIL) {
-                               warnx("can't stat package file '%s'", fname);
-                               code = 1;
-                               goto bail;
-                       }
-                       Home = make_playpen(PlayPen, PlayPenSize, sb.st_size / 2);
-                       if (unpack(fname, "+*")) {
-                               warnx("error during unpacking, no info for '%s' available", pkg);
-                               code = 1;
-                               goto bail;
+                       if (IS_URL(cp)) {
+                               /* only a package name was given, and it was expanded to a
+                                * full URL by fileFindByPath. Now extract...
+                                */
+                               char *cp2;
+
+                               if ((cp2 = fileGetURL(NULL, cp)) != NULL) {
+                                       strcpy(fname, cp2);
+                                       isTMP = TRUE;
+                               }
+                               strcpy(PlayPen, cp2);
+                       } else {
+                               /*
+                                * Apply a crude heuristic to see how much space the package will
+                                * take up once it's unpacked.  I've noticed that most packages
+                                * compress an average of 75%, but we're only unpacking the + files so
+                                * be very optimistic.
+                                */
+                               if (stat(fname, &sb) == FAIL) {
+                                       warnx("can't stat package file '%s'", fname);
+                                       code = 1;
+                                       goto bail;
+                               }
+                               Home = make_playpen(PlayPen, PlayPenSize, sb.st_size / 2);
+                               if (unpack(fname, "+*")) {
+                                       warnx("error during unpacking, no info for '%s' available", pkg);
+                                       code = 1;
+                                       goto bail;
+                               }
                        }
                }
        } else {
diff -r af4aac4c344f -r a02563a393be usr.sbin/pkg_install/lib/file.c
--- a/usr.sbin/pkg_install/lib/file.c   Wed Dec 13 03:16:36 2000 +0000
+++ b/usr.sbin/pkg_install/lib/file.c   Wed Dec 13 03:17:53 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: file.c,v 1.43 2000/10/31 23:47:05 hubertf Exp $        */
+/*     $NetBSD: file.c,v 1.44 2000/12/13 03:17:54 hubertf Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp";
 #else
-__RCSID("$NetBSD: file.c,v 1.43 2000/10/31 23:47:05 hubertf Exp $");
+__RCSID("$NetBSD: file.c,v 1.44 2000/12/13 03:17:54 hubertf Exp $");
 #endif
 #endif
 
@@ -230,11 +230,10 @@
 }
 
 /*
- * Try and fetch a file by URL, returning the directory name for where
- * it's unpacked, if successful.
+ * Wrapper routine for fileGetURL to iterate over several "sfx"s
  */
-char   *
-fileGetURL(char *base, char *spec)
+static char   *
+fileGet1URL(char *base, char *spec, char *sfx)
 {
        char    host[MAXHOSTNAMELEN], file[FILENAME_MAX];
        char   *cp, *rp;
@@ -264,14 +263,14 @@
                                *(cp + 1) = '\0';
                                strcat(cp, "All/");
                                strcat(cp, spec);
-                               strcat(cp, ".tgz");
+                               strcat(cp, sfx);
                        } else
                                return NULL;



Home | Main Index | Thread Index | Old Index