aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/create
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-10-08 07:48:21 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-10-08 07:48:21 +0000
commit6fed414929a595c4f33ab6c19535307ff4b9b787 (patch)
tree7bcf1819b90d1844ff07ddc14881ba7e2f0d94cb /usr.sbin/pkg_install/create
parent4586e1abc5b800ef9a7c314189e3f5abea90d12d (diff)
Notes
Diffstat (limited to 'usr.sbin/pkg_install/create')
-rw-r--r--usr.sbin/pkg_install/create/create.h3
-rw-r--r--usr.sbin/pkg_install/create/main.c55
-rw-r--r--usr.sbin/pkg_install/create/perform.c32
-rw-r--r--usr.sbin/pkg_install/create/pkg_create.155
-rw-r--r--usr.sbin/pkg_install/create/pl.c12
5 files changed, 66 insertions, 91 deletions
diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h
index b9348d95a1f2..eab822a371e9 100644
--- a/usr.sbin/pkg_install/create/create.h
+++ b/usr.sbin/pkg_install/create/create.h
@@ -1,4 +1,4 @@
-/* $Id: create.h,v 1.11 1997/02/22 16:09:24 peter Exp $ */
+/* $Id: create.h,v 1.12 1997/06/06 12:19:11 jkh Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -40,7 +40,6 @@ extern int Dereference;
extern int PlistOnly;
void check_list(char *, Package *);
-void usage(const char *, const char *, ...);
int pkg_perform(char **);
void copy_plist(char *, Package *);
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index d8cef07113fa..38fff8a66b0f 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -1,5 +1,6 @@
#ifndef lint
-static const char *rcsid = "$Id: main.c,v 1.15 1997/03/31 05:10:47 imp Exp $";
+static const char rcsid[] =
+ "$Id: main.c,v 1.16 1997/06/06 12:19:11 jkh Exp $";
#endif
/*
@@ -13,6 +14,7 @@ static const char *rcsid = "$Id: main.c,v 1.15 1997/03/31 05:10:47 imp Exp $";
*
*/
+#include <err.h>
#include "lib.h"
#include "create.h"
@@ -34,12 +36,13 @@ char PlayPen[FILENAME_MAX];
int Dereference = 0;
int PlistOnly = 0;
+static void usage __P((void));
+
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)) != -1)
@@ -118,7 +121,7 @@ main(int argc, char **argv)
case '?':
default:
- usage(prog_name, NULL);
+ usage();
break;
}
@@ -131,51 +134,27 @@ main(int argc, char **argv)
/* If no packages, yelp */
if (pkgs == start)
- usage(prog_name, "Missing package name");
+ warnx("missing package name"), usage();
*pkgs = NULL;
if (start[1])
- usage(prog_name, "Only one package name allowed\n\t('%s' extraneous)",
- start[1]);
+ warnx("only one package name allowed ('%s' extraneous)", start[1]),
+ usage();
if (!pkg_perform(start)) {
if (Verbose)
- fprintf(stderr, "Package creation failed.\n");
+ warnx("package creation failed");
return 1;
}
else
return 0;
}
-void
-usage(const char *name, const char *fmt, ...)
+static void
+usage()
{
- 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\n\n", name);
- fprintf(stderr, "Where args are one or more of:\n\n");
-
- fprintf(stderr, "-c [-]file Get one-line comment from file (-or arg)\n");
- fprintf(stderr, "-d [-]file Get description from file (-or arg)\n");
- fprintf(stderr, "-f file get list of files from file (- for stdin)\n");
- fprintf(stderr, "-h follow symbolic links\n");
- fprintf(stderr, "-i script install script\n");
- fprintf(stderr, "-k script de-install script\n");
- fprintf(stderr, "-D file install notice\n");
- fprintf(stderr, "-m file mtree spec for directories\n");
- fprintf(stderr, "-P pkgs set package dependency list to pkgs\n");
- fprintf(stderr, "-p prefix install prefix will be arg\n");
- fprintf(stderr, "-r script pre/post requirements script\n");
- fprintf(stderr, "-t temp use temp as template for mktemp()\n");
- fprintf(stderr, "-X file exclude files listed in file\n");
- fprintf(stderr, "-v verbose\n");
- fprintf(stderr, "-Y assume `yes' answer to all questions\n");
- fprintf(stderr, "-N assume `no' answer to all questions\n");
- fprintf(stderr, "-O print a revised packing list and exit\n");
+ fprintf(stderr, "%s\n%s\n%s\n%s\n",
+"usage: pkg_create [-YNOhv] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
+" [-k dscript] [-r rscript] [-t template] [-X excludefile]",
+" [-D displayfile] [-m mtreefile] -c comment -d description",
+" -f packlist pkg-name");
exit(1);
}
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 49bd28de5a44..2394d8cf6904 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -1,5 +1,6 @@
#ifndef lint
-static const char *rcsid = "$Id: perform.c,v 1.35 1997/06/06 12:19:11 jkh Exp $";
+static const char rcsid[] =
+ "$Id: perform.c,v 1.36 1997/07/04 04:48:02 jkh Exp $";
#endif
/*
@@ -25,7 +26,7 @@ static const char *rcsid = "$Id: perform.c,v 1.35 1997/06/06 12:19:11 jkh Exp $"
#include "lib.h"
#include "create.h"
-#include <errno.h>
+#include <err.h>
#include <signal.h>
#include <sys/syslimits.h>
#include <sys/wait.h>
@@ -56,7 +57,8 @@ pkg_perform(char **pkgs)
else {
pkg_in = fopen(Contents, "r");
if (!pkg_in)
- barf("Unable to open contents file '%s' for input.", Contents);
+ cleanup(0), errx(2, "unable to open contents file '%s' for input",
+ Contents);
}
plist.head = plist.tail = NULL;
@@ -168,10 +170,10 @@ pkg_perform(char **pkgs)
/* Finally, write out the packing list */
fp = fopen(CONTENTS_FNAME, "w");
if (!fp)
- barf("Can't open file %s for writing.", CONTENTS_FNAME);
+ cleanup(0), errx(2, "can't open file %s for writing", CONTENTS_FNAME);
write_plist(&plist, fp);
if (fclose(fp))
- barf("Error while closing %s.", CONTENTS_FNAME);
+ cleanup(0), errx(2, "error while closing %s", CONTENTS_FNAME);
/* And stick it into a tar ball */
make_dist(home, pkg, suffix, &plist);
@@ -223,21 +225,22 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist)
/* Set up a pipe for passing the filenames, and fork off a tar process. */
if (pipe(pipefds) == -1)
- barf("Cannot create pipe: %s", strerror(errno));
+ cleanup(0), errx(2, "cannot create pipe");
if ((pid = fork()) == -1)
- barf("Cannot fork process for tar: %s", strerror(errno));
+ cleanup(0), errx(2, "cannot fork process for tar");
if (pid == 0) { /* The child */
dup2(pipefds[0], 0);
close(pipefds[0]);
close(pipefds[1]);
execv("/usr/bin/tar", args);
- barf("Failed to execute tar command: %s", strerror(errno));
+ cleanup(0);
+ errx(2, "failed to execute tar command");
}
/* Meanwhile, back in the parent process ... */
close(pipefds[0]);
if ((totar = fdopen(pipefds[1], "w")) == NULL)
- barf("fdopen failed: %s", strerror(errno));
+ cleanup(0), errx(2, "fdopen failed");
fprintf(totar, "%s\n", CONTENTS_FNAME);
fprintf(totar, "%s\n", COMMENT_FNAME);
@@ -267,18 +270,21 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist)
wait(&ret);
/* assume either signal or bad exit is enough for us */
if (ret)
- barf("tar command failed with code %d", ret);
+ cleanup(0), errx(2, "tar command failed with code %d", ret);
}
static void
sanity_check()
{
if (!Comment)
- barf("Required package comment string is missing (-c comment).");
+ cleanup(0), errx(2,
+ "required package comment string is missing (-c comment)");
if (!Desc)
- barf("Required package description string is missing (-d desc).");
+ cleanup(0), errx(2,
+ "required package description string is missing (-d desc)");
if (!Contents)
- barf("Required package contents list is missing (-f [-]file).");
+ cleanup(0), errx(2,
+ "required package contents list is missing (-f [-]file)");
}
diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1
index 231132a9ba5a..8d6a068ea8d9 100644
--- a/usr.sbin/pkg_install/create/pkg_create.1
+++ b/usr.sbin/pkg_install/create/pkg_create.1
@@ -15,7 +15,7 @@
.\"
.\"
.\" @(#)pkg_create.1
-.\" $Id: pkg_create.1,v 1.21 1997/07/01 06:13:44 jkh Exp $
+.\" $Id: pkg_create.1,v 1.22 1997/09/27 13:41:33 hoek Exp $
.\"
.\" hacked up by John Kohl for NetBSD--fixed a few bugs, extended keywords,
.\" added dependency tracking, etc.
@@ -28,7 +28,7 @@
.Os FreeBSD
.Sh NAME
.Nm pkg_create
-.Nd a utility for creating software package distributions.
+.Nd a utility for creating software package distributions
.Sh SYNOPSIS
.Nm
.Op Fl YNOhv
@@ -42,6 +42,7 @@
.Op Fl X Ar excludefile
.Op Fl D Ar displayfile
.Op Fl m Ar mtreefile
+.Fl c Ar comment
.Fl d Ar description
.Fl f Ar packlist
.Ar pkg-name
@@ -56,7 +57,7 @@ do so. It is more expected that you will use a front-end tool for
the job rather than muddling through it yourself. Nonetheless, a short
description of the input syntax is included in this document.
.Sh OPTIONS
-The following command line options are supported.
+The following command line options are supported:
.Bl -tag -width indent
.It Fl f Ar packinglist
Fetch ``packing list'' for package from the file
@@ -68,7 +69,6 @@ if
is a
.Cm -
(dash).
-.Em "Mandatory."
.It Fl c Ar [-]desc
Fetch package ``one line description'' from file
.Ar desc
@@ -77,17 +77,14 @@ or, if preceded by
the argument itself. This string should also
give some idea of which version of the product (if any) the package
represents.
-.Em "Mandatory."
.It Fl d Ar [-]desc
Fetch long description for package from file
.Ar desc
or, if preceded by
.Cm - ,
the argument itself.
-.Em "Mandatory."
.It Fl Y
Assume a default answer of `Yes' for any questions asked.
-.Em "Optional."
.It Fl N
Assume a default answer of `No' for any questions asked.
.It Fl O
@@ -96,49 +93,42 @@ Go into a `packing list Only' mode. This is a custom hack for the
and is used to do `fake pkg_add' operations when a port is installed.
In such cases, it is necessary to know what the final, adjusted packing
list will look like.
-.Em "Optional."
.It Fl v
-Turns on verbose output.
-.Em "Optional."
+Turn on verbose output.
.It Fl h
-Forces tar to follow symbolic links, so that the files they point to
+Force tar to follow symbolic links, so that the files they point to
are dumped, rather than the links themselves.
.It Fl i Ar iscript
-Sets
+Set
.Ar iscript
to be the install procedure for the package. This can be any
executable program (or shell script). It will be invoked automatically
when the package is later installed.
-.Em "Optional."
.It Fl P Ar pkgs
-Sets the initial package dependency list to
+Set the initial package dependency list to
.Ar pkgs .
This is assumed to be a whitespace separated list of package names
and is meant as a convenient shorthand for specifying multiple
.Cm @pkgdep
directives in the packing list (see PACKING LIST DETAILS section below).
-.Em "Optional."
.It Fl p Ar prefix
-Sets
+Set
.Ar prefix
as the initial directory ``base'' to start from in selecting files for
the package.
-.Em "Optional."
.It Fl k Ar dscript
-Sets
+Set
.Ar dscript
to be the de-install procedure for the package. This can be any
executable program (or shell script). It will be invoked automatically
when the package is later (if ever) de-installed.
-.Em "Optional."
.It Fl r Ar rscript
-Sets
+Set
.Ar rscript
to be the ``requirements'' procedure for the package. This can be any
executable program (or shell script). It will be invoked automatically
at installation/deinstallation time to determine whether or not
installation/deinstallation should proceed.
-.Em "Optional."
.It Fl t Ar template
Use
.Ar template
@@ -153,7 +143,6 @@ directory is limited. Be sure to leave some number of `X' characters
for
.Xr mktemp 3
to fill in with a unique ID.
-.Em "Optional."
.It Fl X Ar excludefile
Pass
.Ar excludefile
@@ -206,14 +195,14 @@ installed with. This is done by imbeding specialized command sequences
in the packing list. Briefly described, these sequences are:
.Bl -tag -width indent -compact
.It Cm @cwd Ar directory
-Sets the internal directory pointer to point to
+Set the internal directory pointer to point to
.Ar directory .
All subsequent filenames will be assumed relative to this directory.
Note:
.Cm @cd
is also an alias for this command.
.It Cm @srcdir Ar directory
-Sets the internal directory pointer for _creation only_ to
+Set the internal directory pointer for _creation only_ to
.Ar directory .
That is to say that it overrides
.Cm @cwd
@@ -235,17 +224,17 @@ and the last extracted file was
Expands to the last filename extracted (as specified), in the example case
.Pa bin/emacs
.It Cm "%D"
-Expands to the current directory prefix, as set with
+Expand to the current directory prefix, as set with
.Cm @cwd ,
in the example case
.Pa /usr/local .
.It Cm "%B"
-Expands to the ``basename'' of the fully qualified filename, that
+Expand to the ``basename'' of the fully qualified filename, that
is the current directory prefix, plus the last filespec, minus
the trailing filename. In the example case, that would be
.Pa /usr/local/bin .
.It Cm "%f"
-Expands to the ``filename'' part of the fully qualified name, or
+Expand to the ``filename'' part of the fully qualified name, or
the converse of
.Cm %B ,
being in the example case,
@@ -271,7 +260,7 @@ sequence expansion'' to get at files regardless of where they've
been potentially redirected (see
.Fl p ) .
.It Cm @mode Ar mode
-Sets default permission for all subsequently extracted files to
+Set default permission for all subsequently extracted files to
.Ar mode .
Format is the same as that used by the
.Cm chmod
@@ -279,7 +268,7 @@ command (well, considering that it's later handed off to it, that's
no surprise). Use without an arg to set back to default (extraction)
permissions.
.It Cm @option Ar option
-Sets internal package options, the only two currently supported ones
+Set internal package options, the only two currently supported ones
being
.Ar extract-in-place ,
which tells the pkg_add command not to extract the package's tarball
@@ -291,12 +280,12 @@ which tells pkg_add to move any existing files out of the way,
preserving the previous contents (which are also resurrected on
pkg_delete, so caveat emptor).
.It Cm @owner Ar user
-Sets default ownership for all subsequently extracted files to
+Set default ownership for all subsequently extracted files to
.Ar user .
Use without an arg to set back to default (extraction)
ownership.
.It Cm @group Ar group
-Sets default group ownership for all subsequently extracted files to
+Set default group ownership for all subsequently extracted files to
.Ar group .
Use without an arg to set back to default (extraction)
group ownership.
@@ -317,7 +306,7 @@ file, so you can pack a
specialized datafile in with a distribution for your install script (or
something) yet have the installer ignore it.
.It Cm @name Ar name
-Sets the name of the package. This is mandatory and is usually
+Set the name of the package. This is mandatory and is usually
put at the top. This name is potentially different than the name of
the file it came in, and is used when keeping track of the package
for later deinstallation. Note that
@@ -353,7 +342,7 @@ as the file to be displayed at install time (see
.Fl D
above).
.It Cm @pkgdep Ar pkgname
-Declares a dependency on the
+Declare a dependency on the
.Ar pkgname
package. The
.Ar pkgname
diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c
index f0a8b6de1b20..a10e38312da0 100644
--- a/usr.sbin/pkg_install/create/pl.c
+++ b/usr.sbin/pkg_install/create/pl.c
@@ -1,5 +1,6 @@
#ifndef lint
-static const char *rcsid = "$Id$";
+static const char rcsid[] =
+ "$Id: pl.c,v 1.10 1997/02/22 16:09:30 peter Exp $";
#endif
/*
@@ -25,6 +26,7 @@ static const char *rcsid = "$Id$";
#include "lib.h"
#include "create.h"
#include <errno.h>
+#include <err.h>
#include <md5.h>
/* Check a list for files that require preconversion */
@@ -84,7 +86,7 @@ trylink(const char *from, const char *to)
if (where_count > sizeof(STARTSTRING)-1) { \
strcat(where_args, "|tar xpf -"); \
if (system(where_args)) \
- barf("can't invoke tar pipeline"); \
+ cleanup(0), errx(2, "can't invoke tar pipeline"); \
memset(where_args, 0, maxargs); \
last_chdir = NULL; \
strcpy(where_args, STARTSTRING); \
@@ -111,7 +113,7 @@ copy_plist(char *home, Package *plist)
and sh -c */
where_args = malloc(maxargs);
if (!where_args)
- barf("can't get argument list space");
+ cleanup(0), errx(2, "can't get argument list space");
memset(where_args, 0, maxargs);
strcpy(where_args, STARTSTRING);
@@ -172,7 +174,7 @@ copy_plist(char *home, Package *plist)
last_chdir = home;
}
if (add_count > maxargs - where_count)
- barf("oops, miscounted strings!");
+ cleanup(0), errx(2, "oops, miscounted strings!");
where_count += add_count;
}
/*
@@ -206,7 +208,7 @@ copy_plist(char *home, Package *plist)
mythere ? mythere : where,
p->name);
if (add_count > maxargs - where_count)
- barf("oops, miscounted strings!");
+ cleanup(0), errx(2, "oops, miscounted strings!");
where_count += add_count;
last_chdir = (mythere ? mythere : where);
}