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 Remove last vsystem caller and vsystem(...



details:   https://anonhg.NetBSD.org/src/rev/c82a666be7f6
branches:  trunk
changeset: 552313:c82a666be7f6
user:      wiz <wiz%NetBSD.org@localhost>
date:      Tue Sep 23 14:23:53 2003 +0000

description:
Remove last vsystem caller and vsystem() itself.

diffstat:

 usr.sbin/pkg_install/delete/perform.c |   6 +-
 usr.sbin/pkg_install/lib/Makefile     |   4 +-
 usr.sbin/pkg_install/lib/exec.c       |  68 -----------------------------------
 usr.sbin/pkg_install/lib/file.c       |  39 +++++++++++++++++++-
 usr.sbin/pkg_install/lib/lib.h        |   4 +-
 5 files changed, 43 insertions(+), 78 deletions(-)

diffs (200 lines):

diff -r fee227892ed2 -r c82a666be7f6 usr.sbin/pkg_install/delete/perform.c
--- a/usr.sbin/pkg_install/delete/perform.c     Tue Sep 23 14:18:01 2003 +0000
+++ b/usr.sbin/pkg_install/delete/perform.c     Tue Sep 23 14:23:53 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.48 2003/09/23 09:36:05 wiz Exp $ */
+/*     $NetBSD: perform.c,v 1.49 2003/09/23 14:23:53 wiz Exp $ */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.48 2003/09/23 09:36:05 wiz Exp $");
+__RCSID("$NetBSD: perform.c,v 1.49 2003/09/23 14:23:53 wiz Exp $");
 #endif
 #endif
 
@@ -826,7 +826,7 @@
        if (!Fake) {
                /* Finally nuke the +-files and the pkgdb-dir (/var/db/pkg/foo) */
                if (is_depoted_pkg) {
-                       (void) vsystem("%s %s/+*", REMOVE_CMD, LogDir);
+                       (void) remove_files(LogDir, "+*");
                        if (isemptydir(LogDir))
                                (void) fexec(RMDIR_CMD, LogDir, NULL);
                        else
diff -r fee227892ed2 -r c82a666be7f6 usr.sbin/pkg_install/lib/Makefile
--- a/usr.sbin/pkg_install/lib/Makefile Tue Sep 23 14:18:01 2003 +0000
+++ b/usr.sbin/pkg_install/lib/Makefile Tue Sep 23 14:23:53 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.21 2003/09/02 07:34:59 jlam Exp $
+# $NetBSD: Makefile,v 1.22 2003/09/23 14:23:53 wiz Exp $
 # Original from FreeBSD, no rcs id.
 
 NOLINT=                # defined
@@ -7,7 +7,7 @@
 NOPROFILE=     # defined
 
 LIB+=          install
-SRCS+=         exec.c file.c ftpio.c global.c lpkg.c pen.c pkgdb.c \
+SRCS+=         file.c ftpio.c global.c lpkg.c pen.c pkgdb.c \
                plist.c str.c version.c path.c fexec.c
 
 # only needed during build - prevent installation of library
diff -r fee227892ed2 -r c82a666be7f6 usr.sbin/pkg_install/lib/exec.c
--- a/usr.sbin/pkg_install/lib/exec.c   Tue Sep 23 14:18:01 2003 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*     $NetBSD: exec.c,v 1.10 2003/09/23 09:47:21 wiz Exp $    */
-
-#include <sys/cdefs.h>
-#ifndef lint
-#if 0
-static const char *rcsid = "from FreeBSD Id: exec.c,v 1.6 1997/10/08 07:47:50 charnier Exp";
-#else
-__RCSID("$NetBSD: exec.c,v 1.10 2003/09/23 09:47:21 wiz Exp $");
-#endif
-#endif
-
-/*
- * FreeBSD install - a package for the installation and maintainance
- * of non-core utilities.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Miscellaneous system routines.
- *
- */
-
-#include <err.h>
-#include "lib.h"
-
-/*
- * Unusual system() substitute.  Accepts format string and args,
- * builds and executes command.  Returns exit code.
- */
-int
-vsystem(const char *fmt,...)
-{
-       va_list args;
-       char   *cmd;
-       size_t  maxargs;
-       int     ret;
-
-       maxargs = (size_t) sysconf(_SC_ARG_MAX);
-       maxargs -= 32;          /* some slop for the sh -c */
-       if ((cmd = (char *) malloc(maxargs)) == (char *) NULL) {
-               warnx("vsystem can't alloc arg space");
-               return 1;
-       }
-
-       va_start(args, fmt);
-       if (vsnprintf(cmd, maxargs, fmt, args) >= maxargs) {
-               warnx("vsystem args are too long");
-               va_end(args);
-               free(cmd);
-               return 1;
-       }
-#ifdef VSYSTEM_DEBUG
-       printf("vsystem(\"%s\")\n", cmd);
-#endif
-       ret = system(cmd);
-       va_end(args);
-       free(cmd);
-       return ret;
-}
diff -r fee227892ed2 -r c82a666be7f6 usr.sbin/pkg_install/lib/file.c
--- a/usr.sbin/pkg_install/lib/file.c   Tue Sep 23 14:18:01 2003 +0000
+++ b/usr.sbin/pkg_install/lib/file.c   Tue Sep 23 14:23:53 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: file.c,v 1.65 2003/09/23 14:18:01 agc Exp $    */
+/*     $NetBSD: file.c,v 1.66 2003/09/23 14:23:54 wiz 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.65 2003/09/23 14:18:01 agc Exp $");
+__RCSID("$NetBSD: file.c,v 1.66 2003/09/23 14:23:54 wiz Exp $");
 #endif
 #endif
 
@@ -35,6 +35,7 @@
 
 #include <assert.h>
 #include <err.h>
+#include <glob.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <time.h>
@@ -519,6 +520,40 @@
        }
 }
 
+void
+remove_files(char *path, char *pattern)
+{
+       char    fpath[FILENAME_MAX];
+       glob_t  globbed;
+       int     err, i;
+
+       (void) snprintf(fpath, sizeof(fpath), "%s/%s", path, pattern);
+       if ((err=glob(fpath, GLOB_NOSORT, NULL, &globbed)) != 0) {
+               switch(err) {
+               case GLOB_NOMATCH:
+                       warn("no files matching ``%s'' found", fpath);
+                       break;
+               case GLOB_ABORTED:
+                       warn("globbing aborted");
+                       break;
+               case GLOB_NOSPACE:
+                       warn("out-of-memory during globbing");
+                       break;
+               default:
+                       warn("unknown error during globbing");
+                       break;
+               }
+               return;
+       }
+
+       /* deleting globbed files */
+       for (i=0; i<globbed.gl_pathc; i++)
+               if (unlink(globbed.gl_pathv[i]) < 0)
+                       warn("can't delete ``%s''", globbed.gl_pathv[i]);
+
+       return;
+}
+
 /*
  * Unpack a tar file
  */
diff -r fee227892ed2 -r c82a666be7f6 usr.sbin/pkg_install/lib/lib.h
--- a/usr.sbin/pkg_install/lib/lib.h    Tue Sep 23 14:18:01 2003 +0000
+++ b/usr.sbin/pkg_install/lib/lib.h    Tue Sep 23 14:23:53 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.59 2003/09/23 09:36:07 wiz Exp $ */
+/* $NetBSD: lib.h,v 1.60 2003/09/23 14:23:54 wiz Exp $ */
 
 /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
 
@@ -200,8 +200,6 @@
 
 /* Prototypes */
 /* Misc */
-int     vsystem(const char *,...)
-       __attribute__((__format__(__printf__, 1, 2)));
 void    cleanup(int);
 char   *make_playpen(char *, size_t, size_t);
 char   *where_playpen(void);



Home | Main Index | Thread Index | Old Index