Source-Changes-HG archive

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

[src/netbsd-1-5]: src/usr.sbin/pkg_install/add Pull up revisions 1.21-1.22 (r...



details:   https://anonhg.NetBSD.org/src/rev/bf3611cb0006
branches:  netbsd-1-5
changeset: 491361:bf3611cb0006
user:      he <he%NetBSD.org@localhost>
date:      Tue Apr 24 23:11:45 2001 +0000

description:
Pull up revisions 1.21-1.22 (requested by dmcmahill):
  Allow PKG_PATH (or parts of it) to refer to local directories,
  and still let "pkg_add foo" work.  Required packages will be
  pulled in as usual.  If PKG_PATH contains a mixture of local
  paths and ftp:// URLs, the local paths will be searched first.

diffstat:

 usr.sbin/pkg_install/add/main.c |  66 +++++++++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 19 deletions(-)

diffs (95 lines):

diff -r be0795e61b6c -r bf3611cb0006 usr.sbin/pkg_install/add/main.c
--- a/usr.sbin/pkg_install/add/main.c   Tue Apr 24 23:05:30 2001 +0000
+++ b/usr.sbin/pkg_install/add/main.c   Tue Apr 24 23:11:45 2001 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: main.c,v 1.15.2.4 2001/03/30 22:19:58 he Exp $ */
+/*     $NetBSD: main.c,v 1.15.2.5 2001/04/24 23:11:45 he 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.15.2.4 2001/03/30 22:19:58 he Exp $");
+__RCSID("$NetBSD: main.c,v 1.15.2.5 2001/04/24 23:11:45 he Exp $");
 #endif
 #endif
 
@@ -167,32 +167,60 @@
                                        /* Maybe just a pkg name w/o pattern was given */
                                        char tmp[FILENAME_MAX];
                                                
+                                       if (*argv[0] == '/'){
+                                               /* given arg has path - ignore PKG_PATH */
                                        snprintf(tmp, sizeof(tmp), "%s-[0-9]*.t[bg]z", *argv);
-                                       s=findbestmatchingname(dirname_of(tmp),
+                                               s = findbestmatchingname(dirname_of(tmp),
+                                                                        basename_of(tmp));
+                                       } else {
+                                               /* try all elements of PKG_PATH, see also loop
+                                                * in file.c::fileFindByPath() */
+                                               /* This code prefers local pkgs over remote
+                                                * pkgs - feature? */
+                                               char *e;
+                                               
+                                               if (getenv("PKG_PATH"))
+                                                       e = strdup(getenv("PKG_PATH"));
+                                               else
+                                                       e = NULL;
+                                               s = NULL;
+                                               while(s==NULL && e && *e) {
+                                                       char *e2 = strsep(&e, ";");
+                                                       
+                                                       if (IS_URL(e2)) {
+                                                               /* Let some other code do this */
+                                                               ;
+                                                       } else {
+                                                               snprintf(tmp, sizeof(tmp), "%s/%s-[0-9]*.t[bg]z",
+                                                                        e2, *argv);
+                                                               s = findbestmatchingname(dirname_of(tmp),
                                                               basename_of(tmp));
+                                                       }
+                                               }
+                                       }
                                        if (s) {
                                                char tmp2[FILENAME_MAX];
                                                
                                                snprintf(tmp2, sizeof(tmp2), "%s/%s", dirname_of(tmp), s);
                                                
-                                       if (Verbose)
-                                               printf("Using %s for %s\n", tmp2, *argv);
+                                               if (Verbose)
+                                                       printf("Using %s for %s\n", tmp2, *argv);
 
-                                       if (!(cp = realpath(tmp2, pkgname))) {
-                                               lpp = NULL;
-                                               warn("realpath failed for '%s'", tmp2);
-                                               error++;
-                                       } else
-                                               lpp = alloc_lpkg(cp);
-                               } else {
+                                               if (!(cp = realpath(tmp2, pkgname))) {
+                                                       lpp = NULL;
+                                                       warn("realpath failed for '%s'", tmp2);
+                                                       error++;
+                                               } else
+                                                       lpp = alloc_lpkg(cp);
+                                       } else {
                                                /* No go there... */
-                                       /* look for the file(pattern) in the expected places */
-                                       if (!(cp = fileFindByPath(NULL, *argv))) {
-                                               lpp = NULL;
-                                               warnx("can't find package '%s'", *argv);
-                                               error++;
-                                       } else
-                                               lpp = alloc_lpkg(cp);
+                                               /* look for the file(pattern) in the expected places */
+                                               if (!(cp = fileFindByPath(NULL, *argv))) {
+                                                       lpp = NULL;
+                                                       warnx("can't find package '%s'", *argv);
+                                                       error++;
+                                               } else
+                                                       lpp = alloc_lpkg(cp);
                                        }
                                }
                        }



Home | Main Index | Thread Index | Old Index