version 1.7, 2003/03/29 18:41:56 |
version 1.8, 2003/09/01 16:27:13 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
#if 0 |
#include <nbcompat.h> |
|
#if HAVE_CONFIG_H |
|
#include "config.h" |
|
#endif |
|
#if HAVE_SYS_CDEFS_H |
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
|
#endif |
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp"; |
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp"; |
Line 9 static const char *rcsid = "from FreeBSD |
|
Line 14 static const char *rcsid = "from FreeBSD |
|
__RCSID("$NetBSD$"); |
__RCSID("$NetBSD$"); |
#endif |
#endif |
#endif |
#endif |
#endif |
|
|
|
/* |
/* |
* FreeBSD install - a package for the installation and maintainance |
* FreeBSD install - a package for the installation and maintainance |
Line 30 __RCSID("$NetBSD$"); |
|
Line 34 __RCSID("$NetBSD$"); |
|
* This is the main body of the info module. |
* This is the main body of the info module. |
* |
* |
*/ |
*/ |
#ifdef HAVE_CONFIG_H |
|
#include "config.h" |
|
#endif |
|
|
|
#include "lib.h" |
#include "lib.h" |
#include "info.h" |
#include "info.h" |
|
|
|
#if HAVE_SYS_TYPES_H |
#include <sys/types.h> |
#include <sys/types.h> |
|
#endif |
#ifdef HAVE_SYS_STAT_H |
#if HAVE_SYS_STAT_H |
#include <sys/stat.h> |
#include <sys/stat.h> |
#endif |
#endif |
|
|
#ifdef HAVE_ERR_H |
#if HAVE_ERR_H |
#include <err.h> |
#include <err.h> |
#endif |
#endif |
|
#if HAVE_SIGNAL_H |
#include <signal.h> |
#include <signal.h> |
|
#endif |
#ifdef HAVE_DIRENT_H |
#if HAVE_DIRENT_H |
#include <dirent.h> |
#include <dirent.h> |
#endif |
#endif |
|
#if HAVE_CTYPE_H |
#include <ctype.h> |
#include <ctype.h> |
|
#endif |
|
|
static char *Home; |
static char *Home; |
|
|
Line 69 pkg_do(char *pkg) |
|
Line 72 pkg_do(char *pkg) |
|
|
|
if (IS_URL(pkg)) { |
if (IS_URL(pkg)) { |
if ((cp = fileGetURL(pkg)) != NULL) { |
if ((cp = fileGetURL(pkg)) != NULL) { |
strcpy(fname, cp); |
strlcpy(fname, cp, sizeof(fname)); |
isTMP = TRUE; |
isTMP = TRUE; |
} |
} |
} else if (fexists(pkg) && isfile(pkg)) { |
} else if (fexists(pkg) && isfile(pkg)) { |
Line 83 pkg_do(char *pkg) |
|
Line 86 pkg_do(char *pkg) |
|
len = strlen(fname); |
len = strlen(fname); |
(void) snprintf(&fname[len], sizeof(fname) - len, "/%s", pkg); |
(void) snprintf(&fname[len], sizeof(fname) - len, "/%s", pkg); |
} else { |
} else { |
strcpy(fname, pkg); |
strlcpy(fname, pkg, sizeof(fname)); |
} |
} |
cp = fname; |
cp = fname; |
} else { |
} else { |
Line 104 pkg_do(char *pkg) |
|
Line 107 pkg_do(char *pkg) |
|
char *cp2; |
char *cp2; |
|
|
if ((cp2 = fileGetURL(cp)) != NULL) { |
if ((cp2 = fileGetURL(cp)) != NULL) { |
strcpy(fname, cp2); |
strlcpy(fname, cp2, sizeof(fname)); |
isTMP = TRUE; |
isTMP = TRUE; |
} |
} |
strcpy(PlayPen, cp2); |
strcpy(PlayPen, cp2); |
Line 133 pkg_do(char *pkg) |
|
Line 136 pkg_do(char *pkg) |
|
* It's not an uninstalled package, try and find it among the |
* It's not an uninstalled package, try and find it among the |
* installed |
* installed |
*/ |
*/ |
char *tmp; |
|
|
|
(void) snprintf(log_dir, sizeof(log_dir), "%s/%s", |
(void) snprintf(log_dir, sizeof(log_dir), "%s/%s", |
(tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, |
_pkgdb_getPKGDB_DIR(), pkg); |
pkg); |
|
if (!fexists(log_dir) || !isdir(log_dir)) { |
if (!fexists(log_dir) || !isdir(log_dir)) { |
{ |
{ |
/* Check if the given package name matches |
/* Check if the given package name matches |
Line 192 pkg_do(char *pkg) |
|
Line 192 pkg_do(char *pkg) |
|
printf("%sInformation for %s:\n\n", InfoPrefix, pkg); |
printf("%sInformation for %s:\n\n", InfoPrefix, pkg); |
if (fexists(PRESERVE_FNAME)) { |
if (fexists(PRESERVE_FNAME)) { |
printf("*** PACKAGE MAY NOT BE DELETED ***\n"); |
printf("*** PACKAGE MAY NOT BE DELETED ***\n"); |
} |
} |
} |
} |
if (Flags & SHOW_COMMENT) { |
if (Flags & SHOW_COMMENT) { |
show_file("Comment:\n", COMMENT_FNAME); |
show_file("Comment:\n", COMMENT_FNAME); |
Line 200 pkg_do(char *pkg) |
|
Line 200 pkg_do(char *pkg) |
|
if (Flags & SHOW_DEPENDS) { |
if (Flags & SHOW_DEPENDS) { |
show_depends("Requires:\n", &plist); |
show_depends("Requires:\n", &plist); |
} |
} |
|
if (Flags & SHOW_BLD_DEPENDS) { |
|
show_bld_depends("Built using:\n", &plist); |
|
} |
if ((Flags & SHOW_REQBY) && !isemptyfile(REQUIRED_BY_FNAME)) { |
if ((Flags & SHOW_REQBY) && !isemptyfile(REQUIRED_BY_FNAME)) { |
show_file("Required by:\n", REQUIRED_BY_FNAME); |
show_file("Required by:\n", REQUIRED_BY_FNAME); |
} |
} |
|
|
pkg_perform(lpkg_head_t *pkghead) |
pkg_perform(lpkg_head_t *pkghead) |
{ |
{ |
struct dirent *dp; |
struct dirent *dp; |
char *tmp; |
char *dbdir; |
DIR *dirp; |
DIR *dirp; |
int err_cnt = 0; |
int err_cnt = 0; |
|
|
signal(SIGINT, cleanup); |
signal(SIGINT, cleanup); |
|
|
tmp = _pkgdb_getPKGDB_DIR(); |
dbdir = _pkgdb_getPKGDB_DIR(); |
|
|
/* Overriding action? */ |
/* Overriding action? */ |
if (CheckPkg) { |
if (CheckPkg) { |
err_cnt += CheckForPkg(CheckPkg, tmp); |
err_cnt += CheckForPkg(CheckPkg, dbdir); |
} else if (AllInstalled) { |
} else if (AllInstalled) { |
if (!(isdir(tmp) || islinktodir(tmp))) |
if (!(isdir(dbdir) || islinktodir(dbdir))) |
return 1; |
return 1; |
|
|
if (File2Pkg) { |
if (File2Pkg) { |
Line 350 pkg_perform(lpkg_head_t *pkghead) |
|
Line 353 pkg_perform(lpkg_head_t *pkghead) |
|
|
|
} else { |
} else { |
/* Show all packges with description */ |
/* Show all packges with description */ |
if ((dirp = opendir(tmp)) != (DIR *) NULL) { |
if ((dirp = opendir(dbdir)) != (DIR *) NULL) { |
while ((dp = readdir(dirp)) != (struct dirent *) NULL) { |
while ((dp = readdir(dirp)) != (struct dirent *) NULL) { |
char tmp2[FILENAME_MAX]; |
char tmp2[FILENAME_MAX]; |
|
|
Line 359 pkg_perform(lpkg_head_t *pkghead) |
|
Line 362 pkg_perform(lpkg_head_t *pkghead) |
|
continue; |
continue; |
|
|
(void) snprintf(tmp2, sizeof(tmp2), "%s/%s", |
(void) snprintf(tmp2, sizeof(tmp2), "%s/%s", |
tmp, dp->d_name); |
dbdir, dp->d_name); |
if (isfile(tmp2)) |
if (isfile(tmp2)) |
continue; |
continue; |
|
|