Remove last vsystem caller and vsystem() itself.
This commit is contained in:
parent
342644fea5
commit
161f3f684b
|
@ -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 @@ pkg_do(char *pkg)
|
|||
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
|
||||
|
|
|
@ -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 @@ NOPIC= # defined
|
|||
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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 @@ __RCSID("$NetBSD: file.c,v 1.65 2003/09/23 14:18:01 agc Exp $");
|
|||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <glob.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <time.h>
|
||||
|
@ -519,6 +520,40 @@ move_file(char *dir, char *fname, char *to)
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
|
|
@ -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 @@ typedef int (*matchfn) (const char *, void *);
|
|||
|
||||
/* 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);
|
||||
|
|
Loading…
Reference in New Issue