summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/info
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1993-08-26 01:19:55 +0000
committerjkh <jkh@FreeBSD.org>1993-08-26 01:19:55 +0000
commite83dde8008ab2f058dd1aa3ff1d31f1eeeaac82e (patch)
tree271e80eb2d3e22321d9c07c63334f17c43aee9a8 /usr.sbin/pkg_install/info
parentbed7953d0efa52e8dd7e4fbdddd298b715fbf72d (diff)
downloadFreeBSD-src-e83dde8008ab2f058dd1aa3ff1d31f1eeeaac82e.zip
FreeBSD-src-e83dde8008ab2f058dd1aa3ff1d31f1eeeaac82e.tar.gz
The release version of my package install suite. Please see man pages
for info.
Diffstat (limited to 'usr.sbin/pkg_install/info')
-rw-r--r--usr.sbin/pkg_install/info/Makefile8
-rw-r--r--usr.sbin/pkg_install/info/info.h41
-rw-r--r--usr.sbin/pkg_install/info/main.c138
-rw-r--r--usr.sbin/pkg_install/info/perform.c144
-rw-r--r--usr.sbin/pkg_install/info/pkg_info.178
-rw-r--r--usr.sbin/pkg_install/info/show.c110
6 files changed, 519 insertions, 0 deletions
diff --git a/usr.sbin/pkg_install/info/Makefile b/usr.sbin/pkg_install/info/Makefile
new file mode 100644
index 0000000..2b4f04e
--- /dev/null
+++ b/usr.sbin/pkg_install/info/Makefile
@@ -0,0 +1,8 @@
+PROG= pkg_info
+
+CFLAGS+= -I${.CURDIR}/../lib
+LDADD+= -L${.CURDIR}/../lib -linstall
+
+SRCS= main.c perform.c show.c
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h
new file mode 100644
index 0000000..9584afb
--- /dev/null
+++ b/usr.sbin/pkg_install/info/info.h
@@ -0,0 +1,41 @@
+/* $Id: info.h,v 1.3 1993/08/26 08:47:04 jkh Exp $ */
+
+/*
+ * 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
+ * 23 August 1993
+ *
+ * Include and define various things wanted by the info command.
+ *
+ */
+
+#ifndef _INST_INFO_H_INCLUDE
+#define _INST_INFO_H_INCLUDE
+
+#define SHOW_COMMENT 0x1
+#define SHOW_DESC 0x2
+#define SHOW_PLIST 0x4
+#define SHOW_INSTALL 0x8
+#define SHOW_DEINSTALL 0x10
+#define SHOW_REQUIRE 0x20
+#define SHOW_PREFIX 0x40
+#define SHOW_INDEX 0x80
+
+extern int Flags;
+extern Boolean AllInstalled;
+
+extern void show_file(char *, char *);
+extern void show_plist(char *, Package *, plist_t);
+
+#endif /* _INST_INFO_H_INCLUDE */
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
new file mode 100644
index 0000000..9a5e540
--- /dev/null
+++ b/usr.sbin/pkg_install/info/main.c
@@ -0,0 +1,138 @@
+#ifndef lint
+static char *rcsid = "$Header: /usr1/cvs/jkh/pkg_install/info/main.c,v 1.4 1993/08/26 08:47:05 jkh Exp $";
+#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
+ *
+ * This is the add module.
+ *
+ */
+
+#include "lib.h"
+#include "info.h"
+
+static char Options[] = "acdfikrpIvh";
+
+int Flags = 0;
+Boolean AllInstalled = FALSE;
+
+int
+main(int argc, char **argv)
+{
+ int ch;
+ char **pkgs, **start;
+ char *prog_name = argv[0];
+
+ pkgs = start = argv;
+ while ((ch = getopt(argc, argv, Options)) != EOF)
+ switch(ch) {
+ case 'a':
+ AllInstalled = TRUE;
+ break;
+
+ case 'v':
+ Verbose = TRUE;
+ /* Reasonable definition of 'everything' */
+ Flags = SHOW_COMMENT | SHOW_DESC | SHOW_PLIST | SHOW_INSTALL |
+ SHOW_DEINSTALL | SHOW_REQUIRE;
+ break;
+
+ case 'I':
+ Flags |= SHOW_INDEX;
+ break;
+
+ case 'p':
+ Flags |= SHOW_PREFIX;
+ break;
+
+ case 'c':
+ Flags |= SHOW_COMMENT;
+ break;
+
+ case 'd':
+ Flags |= SHOW_DESC;
+ break;
+
+ case 'f':
+ Flags |= SHOW_PLIST;
+ break;
+
+ case 'i':
+ Flags |= SHOW_INSTALL;
+ break;
+
+ case 'k':
+ Flags |= SHOW_DEINSTALL;
+ break;
+
+ case 'r':
+ Flags |= SHOW_REQUIRE;
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage(prog_name, NULL);
+ break;
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ /* Set some reasonable defaults */
+ if (!Flags)
+ Flags = SHOW_COMMENT | SHOW_DESC;
+
+ /* Get all the remaining package names, if any */
+ while (*argv)
+ *pkgs++ = *argv++;
+
+ /* If no packages, yelp */
+ if (pkgs == start && !AllInstalled)
+ usage(prog_name, "Missing package name(s)");
+ *pkgs = NULL;
+ return pkg_perform(start);
+}
+
+void
+usage(const char *name, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ if (fmt) {
+ fprintf(stderr, "%s: ", name);
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n\n");
+ }
+ va_end(args);
+ fprintf(stderr, "Usage: %s [args] pkg [ .. pkg ]\n", name);
+ fprintf(stderr, "Where args are one or more of:\n\n");
+ fprintf(stderr, "-a show all installed packages (if any)\n");
+ fprintf(stderr, "-I print 'index' of packages\n");
+ fprintf(stderr, "-c print `one line comment'\n");
+ fprintf(stderr, "-d print description\n");
+ fprintf(stderr, "-f show packing list\n");
+ fprintf(stderr, "-i show install script\n");
+ fprintf(stderr, "-k show deinstall script\n");
+ fprintf(stderr, "-r show requirements script\n");
+ fprintf(stderr, "-p show prefix\n");
+ fprintf(stderr, "-v show all information\n");
+ fprintf(stderr, "\n[no args = -c -d]\n");
+ exit(1);
+}
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
new file mode 100644
index 0000000..3a38421
--- /dev/null
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -0,0 +1,144 @@
+#ifndef lint
+static const char *rcsid = "$Id: perform.c,v 1.3 1993/08/26 08:47:06 jkh Exp $";
+#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
+ * 23 Aug 1993
+ *
+ * This is the main body of the info module.
+ *
+ */
+
+#include "lib.h"
+#include "info.h"
+
+#include <signal.h>
+
+static int pkg_do(char *);
+
+int
+pkg_perform(char **pkgs)
+{
+ int i, err_cnt = 0;
+
+ signal(SIGINT, cleanup);
+
+ /* Overriding action? */
+ if (AllInstalled) {
+ if (isdir(LOG_DIR)) {
+ DIR *dirp;
+ struct dirent *dp;
+
+ dirp = opendir(LOG_DIR);
+ if (dirp) {
+ for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
+ if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, ".."))
+ err_cnt += pkg_do(dp->d_name);
+ }
+ (void)closedir(dirp);
+ }
+ else
+ ++err_cnt;
+ }
+ }
+ for (i = 0; pkgs[i]; i++)
+ err_cnt += pkg_do(pkgs[i]);
+ return err_cnt;
+}
+
+static int
+pkg_do(char *pkg)
+{
+ Boolean installed = FALSE;
+ char log_dir[FILENAME_MAX];
+ char *home;
+ Package plist;
+ FILE *fp;
+
+ if (fexists(pkg)) {
+ char fname[FILENAME_MAX];
+
+ home = make_playpen();
+ if (pkg[0] == '/')
+ strcpy(fname, pkg);
+ else
+ sprintf(fname, "%s/%s", home, pkg);
+ if (unpack(fname, "+*")) {
+ whinge("Error during unpacking, no info for '%s' available.", pkg);
+ return 1;
+ }
+ }
+ else {
+ sprintf(log_dir, "%s/%s", LOG_DIR, pkg);
+ if (!fexists(log_dir)) {
+ whinge("Can't find package '%s' installed or in a file!", pkg);
+ return 1;
+ }
+ if (chdir(log_dir) == FAIL) {
+ whinge("Can't change directory to '%s'!", log_dir);
+ return 1;
+ }
+ installed = TRUE;
+ }
+
+ /* Suck in the contents list */
+ plist.head = plist.tail = NULL;
+ fp = fopen(CONTENTS_FNAME, "r");
+ if (!fp) {
+ whinge("Unable to open %s file.", CONTENTS_FNAME);
+ return 1;
+ }
+ /* If we have a prefix, add it now */
+ read_plist(&plist, fp);
+ fclose(fp);
+
+ /*
+ * Index is special info type that has to override all others to make
+ * any sense.
+ */
+ if (Flags & SHOW_INDEX) {
+ char fname[FILENAME_MAX];
+
+ sprintf(fname, "%s\t", pkg);
+ show_file(fname, COMMENT_FNAME);
+ }
+ else {
+ /* Start showing the package contents */
+ printf(" Information for %s:\n\n", pkg);
+ if (Flags & SHOW_COMMENT)
+ show_file(" Comment:\n", COMMENT_FNAME);
+ if (Flags & SHOW_DESC)
+ show_file(" Description:\n", DESC_FNAME);
+ if (Flags & SHOW_PLIST)
+ show_plist(" Packing list:\n", &plist, (plist_t)-1);
+ if ((Flags & SHOW_INSTALL) && fexists(INSTALL_FNAME))
+ show_file(" Install script:\n", INSTALL_FNAME);
+ if ((Flags & SHOW_DEINSTALL) && fexists(DEINSTALL_FNAME))
+ show_file(" De-Install script:\n", DEINSTALL_FNAME);
+ if (Flags & SHOW_PREFIX)
+ show_plist(" Prefix(s):\n", &plist, PLIST_CWD);
+ putchar('\014');
+ }
+ free_plist(&plist);
+ leave_playpen();
+ return 0;
+}
+
+void
+cleanup(int sig)
+{
+ leave_playpen();
+}
diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1
new file mode 100644
index 0000000..d74c1ff
--- /dev/null
+++ b/usr.sbin/pkg_install/info/pkg_info.1
@@ -0,0 +1,78 @@
+.\"
+.\" 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
+.\"
+.\"
+.\" @(#)pkg_info.1
+.\"
+.TH pkg_info 1 "July 18, 1993" "" "FreeBSD"
+
+.SH NAME
+pkg_info - a utility for getting information on software package distributions.
+.SH SYNOPSIS
+.na
+.B pkg_info
+.RB [options]
+.RB "pkg-file|pkg-name\ [.. pkg-file|pkg-name]"
+
+.SH DESCRIPTION
+The
+.B pkg_info
+command is used to dump out information for packages, either packed up in
+files or already installed on the system
+with the
+.B pkg_create
+command.
+
+.SH OPTIONS
+.TP
+The following command line options are supported.
+.TP
+.B \-a
+Show all currently installed packages.
+.TP
+.B \-v
+Turns on verbose output.
+.TP
+.B \-p
+Show the installation prefix for each package.
+.TP
+.B \-c
+Show the comment (one liner) field for each package.
+.TP
+.B \-d
+Show the long description field for each package.
+.TP
+.B \-i
+Show the install script (if any) for each package.
+.TP
+.B \-k
+Show the de-install script (if any) for each package.
+.TP
+.B \-r
+Show the requirements script (if any) for each package.
+.PP
+.SH "TECHNICAL DETAILS"
+Package info is either extracted from files supplied on the
+command line, or from already installed package information
+in /var/db/pkg/<pkg-name>.
+.SH BUGS
+Sure to be some.
+.SH "SEE ALSO"
+.BR pkg_add "(" 1 "),"
+.BR pkg_create "(" 1 "),"
+.BR pkg_delete "(" 1 "),"
+.SH AUTHORS
+Jordan Hubbard
+
diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c
new file mode 100644
index 0000000..8e73e88
--- /dev/null
+++ b/usr.sbin/pkg_install/info/show.c
@@ -0,0 +1,110 @@
+#ifndef lint
+static const char *rcsid = "$Id: show.c,v 1.3 1993/08/26 08:47:07 jkh Exp $";
+#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
+ * 23 Aug 1993
+ *
+ * Various display routines for the info module.
+ *
+ */
+
+#include "lib.h"
+#include "info.h"
+
+void
+show_file(char *title, char *fname)
+{
+ FILE *fp;
+ char line[1024];
+ int n;
+
+ printf(title);
+ fp = fopen(fname, "r");
+ if (!fp) {
+ whinge("show_file: Can't open '%s' for reading.", fname);
+ return;
+ }
+ while (n = fread(line, 1, 1024, fp))
+ fwrite(line, 1, n, stdout);
+ fclose(fp);
+ printf("\n"); /* just in case */
+}
+
+/* Show a packing list item type. If type is -1, show all */
+void
+show_plist(char *title, Package *plist, plist_t type)
+{
+ PackingList p;
+ Boolean ign = FALSE;
+
+ printf(title);
+ p = plist->head;
+ while (p) {
+ if (p->type != type && type != -1) {
+ p = p->next;
+ continue;
+ }
+ switch(p->type) {
+ case PLIST_FILE:
+ if (ign) {
+ printf("File: %s (ignored)\n", p->name);
+ ign = FALSE;
+ }
+ else
+ printf("File: %s\n", p->name);
+ break;
+
+ case PLIST_CWD:
+ printf("\tCWD to %s\n", p->name);
+ break;
+
+ case PLIST_CMD:
+ printf("\tEXEC '%s'\n", p->name);
+ break;
+
+ case PLIST_CHMOD:
+ printf("\tCHMOD to %s\n", p->name ? p->name : "(no default)");
+ break;
+
+ case PLIST_CHOWN:
+ printf("\tCHOWN to %s\n", p->name ? p->name : "(no default)");
+ break;
+
+ case PLIST_CHGRP:
+ printf("\tCHGRP to %s\n", p->name ? p->name : "(no default)");
+ break;
+
+ case PLIST_COMMENT:
+ printf("\tComment: %s\n", p->name);
+ break;
+
+ case PLIST_IGNORE:
+ ign = TRUE;
+ break;
+
+ case PLIST_NAME:
+ printf("\tPackage name: %s\n", p->name);
+ break;
+
+ default:
+ barf("Unknown command type %d (%s)\n", p->type, p->name);
+ break;
+ }
+ p = p->next;
+ }
+}
+
OpenPOWER on IntegriCloud