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 some code cleanup



details:   https://anonhg.NetBSD.org/src/rev/b05785ed8c48
branches:  trunk
changeset: 481268:b05785ed8c48
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Tue Jan 25 12:09:19 2000 +0000

description:
some code cleanup

diffstat:

 usr.sbin/pkg_install/add/perform.c |  60 +++++++++-----------------
 usr.sbin/pkg_install/lib/file.c    |  84 +-------------------------------------
 usr.sbin/pkg_install/lib/str.c     |   8 +--
 3 files changed, 25 insertions(+), 127 deletions(-)

diffs (243 lines):

diff -r 04f5190b38e3 -r b05785ed8c48 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c        Tue Jan 25 12:06:21 2000 +0000
+++ b/usr.sbin/pkg_install/add/perform.c        Tue Jan 25 12:09:19 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.44 2000/01/19 23:28:28 hubertf Exp $     */
+/*     $NetBSD: perform.c,v 1.45 2000/01/25 12:09:19 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.44 2000/01/19 23:28:28 hubertf Exp $");
+__RCSID("$NetBSD: perform.c,v 1.45 2000/01/25 12:09:19 hubertf Exp $");
 #endif
 #endif
 
@@ -129,26 +129,16 @@
                        char *tmppkg = pkg;
 
                        if (ispkgpattern(pkg)) {
-#if 0
-                               warnx("patterns not supported in URLs, "
-                                   "please install %s manually!", pkg);
-                               /* ... until we come up with a better solution :-/  - HF */
-                               
-                               goto bomb;
-#else
-                               {
-                                       /* Handle wildcard wildcard depends */
- 
-                                       char *s;
-                                       s=fileFindByPath(NULL, pkg);
-                                       if (s == NULL) {
-                                               warnx("no pkg found for '%s', sorry.", pkg);
-                                               return 1;
-                                       }
-                                       strcpy(buf, s);
-                                       tmppkg = buf;
-                               } 
-#endif
+                               /* Handle wildcard depends */
+
+                               char *s;
+                               s=fileFindByPath(NULL, pkg);
+                               if (s == NULL) {
+                                       warnx("no pkg found for '%s', sorry.", pkg);
+                                       return 1;
+                               }
+                               strcpy(buf, s);
+                               tmppkg = buf;
                        }
                        
                        if (!(Home = fileGetURL(NULL, tmppkg))) {
@@ -411,26 +401,18 @@
                                        new_name = p->name;
 
                                        if (ispkgpattern(p->name)) {
-#if 0
-                                               warnx("can't install dependent pkg '%s' via FTP, "
-                                                   "please install manually!", p->name);
-                                               /* ... until we come up with a better solution - HF */
- 
-                                               goto bomb;
-#else
-                                               {
-                                                       /* Might hack stuff for wildcard depends in here - HF */
-                                                       
-                                                       char *s;
-                                                       s=fileFindByPath(pkg, p->name);
+                                               /* Handle wildcard depends here */
+
+                                               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;
-                                                       new_name = s;
-                                               }                                               
-#endif
+                                               /* adjust new_pkg and new_name */
+                                               new_pkg = NULL;
+                                               new_name = s;
                                        }
 
                                        /* makeplaypen() and leave_playpen() clobber Current and
diff -r 04f5190b38e3 -r b05785ed8c48 usr.sbin/pkg_install/lib/file.c
--- a/usr.sbin/pkg_install/lib/file.c   Tue Jan 25 12:06:21 2000 +0000
+++ b/usr.sbin/pkg_install/lib/file.c   Tue Jan 25 12:09:19 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: file.c,v 1.36 2000/01/19 23:28:32 hubertf Exp $        */
+/*     $NetBSD: file.c,v 1.37 2000/01/25 12:09:20 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.36 2000/01/19 23:28:32 hubertf Exp $");
+__RCSID("$NetBSD: file.c,v 1.37 2000/01/25 12:09:20 hubertf Exp $");
 #endif
 #endif
 
@@ -40,54 +40,6 @@
 #include <time.h>
 #include <fcntl.h>
 
-#if 0
-/*
- * This is as ftpGetURL from FreeBSD's ftpio.c, except that it uses
- * NetBSD's ftp command to do all FTP, which will DTRT for proxies,
- * etc.
- */
-static FILE *
-ftpGetURL(char *url, int *retcode)
-{
-       FILE   *ftp;
-       pid_t   pid_ftp;
-       int     p[2];
-
-       *retcode = 0;
-
-       if (pipe(p) < 0) {
-               *retcode = 1;
-               return NULL;
-       }
-
-       pid_ftp = fork();
-       if (pid_ftp < 0) {
-               *retcode = 1;
-               return NULL;
-       }
-       if (pid_ftp == 0) {
-               /* child */
-               dup2(p[1], 1);
-               close(p[1]);
-
-               execl("/usr/bin/ftp", "ftp", "-V", "-o", "-", url, NULL);
-               exit(1);
-       } else {
-               /* parent */
-               ftp = fdopen(p[0], "r");
-
-               close(p[1]);
-
-               if (ftp == (FILE *) NULL) {
-                       *retcode = 1;
-                       return NULL;
-               }
-       }
-       return ftp;
-
-}
-#endif
-
 
 /*
  * Quick check to see if a file (or dir ...) exists
@@ -339,36 +291,6 @@
        if (Verbose)
                printf("Trying to fetch %s.\n", fname);
        
-#if 0
-       ftp = ftpGetURL(fname, &status);
-       if (ftp) {
-               pen[0] = '\0';
-               if ((rp = make_playpen(pen, sizeof(pen), 0)) != NULL) {
-                       rp = strdup(pen);       /* be safe for nested calls */
-                       if (Verbose)
-                               printf("Extracting from FTP connection into %s\n", pen);
-                       tpid = fork();
-                       if (!tpid) {
-                               dup2(fileno(ftp), 0);
-                               i = execl(TAR_FULLPATHNAME, TAR_CMD, Verbose ? "-xzvf" : "-xzf", "-", 0);
-                               err(i, TAR_FULLPATHNAME " failed");
-                       } else {
-                               int     pstat;
-
-                               fclose(ftp);
-                               tpid = waitpid(tpid, &pstat, 0);
-                               if (Verbose)
-                                       printf("%s command returns %d status\n", TAR_CMD, WEXITSTATUS(pstat));
-                       }
-               } else
-                       printf("Error: Unable to construct a new playpen for FTP!\n");
-               fclose(ftp);
-       } else
-               printf("Error: FTP Unable to get %s: %s\n",
-                   fname,
-                   status ? "Error while performing FTP" :
-                   hstrerror(h_errno));
-#else
        pen[0] = '\0';
        rp = make_playpen(pen, sizeof(pen), 0);
        if (rp == NULL) {
@@ -377,7 +299,6 @@
        }
 
        rp = strdup(pen);
-/*     printf("fileGetURL: fname='%s', pen='%s'\n", fname, pen); *//*HF*/
        rc = unpackURL(fname, pen);
        if (rc < 0) {
                leave_playpen(rp); /* Don't leave dir hang around! */
@@ -385,7 +306,6 @@
                printf("Error on unpackURL('%s', '%s')\n", fname, pen);
                return NULL;
        }
-#endif
        return rp;
 }
 
diff -r 04f5190b38e3 -r b05785ed8c48 usr.sbin/pkg_install/lib/str.c
--- a/usr.sbin/pkg_install/lib/str.c    Tue Jan 25 12:06:21 2000 +0000
+++ b/usr.sbin/pkg_install/lib/str.c    Tue Jan 25 12:09:19 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: str.c,v 1.19 2000/01/19 23:28:34 hubertf Exp $ */
+/*     $NetBSD: str.c,v 1.20 2000/01/25 12:09:21 hubertf Exp $ */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
 #else
-__RCSID("$NetBSD: str.c,v 1.19 2000/01/19 23:28:34 hubertf Exp $");
+__RCSID("$NetBSD: str.c,v 1.20 2000/01/25 12:09:21 hubertf Exp $");
 #endif
 #endif
 
@@ -277,10 +277,6 @@
                        continue;
 
                (void) snprintf(tmp, sizeof(tmp), "%s/%s", dir, dp->d_name);
-#if 0 /* This code breaks a LOT ... */
-               if (isfile(tmp))/* pkgdb, ... */
-                       continue;
-#endif
                
                if (pmatch(pattern, dp->d_name)) {
                        if (match) {



Home | Main Index | Thread Index | Old Index