Modify pkg_create to recognise Build Information and Version files, when

creating packages, and modify pkg_add to copy the files when a binary
package is added. This preserves the fine-grained version information in
a binary package, and also the options with which the binary package was
built.
This commit is contained in:
agc 1998-10-26 17:39:20 +00:00
parent ede30e2813
commit 3fdf3a6fae
5 changed files with 168 additions and 116 deletions

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.26 1998/10/12 12:03:25 agc Exp $ */
/* $NetBSD: perform.c,v 1.27 1998/10/26 17:39:20 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.26 1998/10/12 12:03:25 agc Exp $");
__RCSID("$NetBSD: perform.c,v 1.27 1998/10/26 17:39:20 agc Exp $");
#endif
#endif
@ -488,6 +488,8 @@ pkg_do(char *pkg)
fclose(cfile);
move_file(".", DESC_FNAME, LogDir);
move_file(".", COMMENT_FNAME, LogDir);
move_file(".", BUILD_VERSION_FNAME, LogDir);
move_file(".", BUILD_INFO_FNAME, LogDir);
if (fexists(DISPLAY_FNAME))
move_file(".", DISPLAY_FNAME, LogDir);

View File

@ -1,4 +1,4 @@
/* $NetBSD: create.h,v 1.8 1998/10/12 12:03:25 agc Exp $ */
/* $NetBSD: create.h,v 1.9 1998/10/26 17:39:22 agc Exp $ */
/* from FreeBSD Id: create.h,v 1.13 1997/10/08 07:46:19 charnier Exp */
@ -38,6 +38,8 @@ extern char *ExcludeFrom;
extern char *Mtree;
extern char *Pkgdeps;
extern char *Pkgcfl;
extern char *BuildVersion;
extern char *BuildInfo;
extern char PlayPen[];
extern size_t PlayPenSize;
extern int Dereference;

View File

@ -1,11 +1,11 @@
/* $NetBSD: main.c,v 1.10 1998/10/13 10:05:38 agc Exp $ */
/* $NetBSD: main.c,v 1.11 1998/10/26 17:39:22 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: main.c,v 1.17 1997/10/08 07:46:23 charnier Exp";
#else
__RCSID("$NetBSD: main.c,v 1.10 1998/10/13 10:05:38 agc Exp $");
__RCSID("$NetBSD: main.c,v 1.11 1998/10/26 17:39:22 agc Exp $");
#endif
#endif
@ -24,7 +24,7 @@ __RCSID("$NetBSD: main.c,v 1.10 1998/10/13 10:05:38 agc Exp $");
#include "lib.h"
#include "create.h"
static char Options[] = "ORhlvf:p:P:C:c:d:i:k:r:t:X:D:m:s:";
static char Options[] = "ORhlvf:p:P:C:c:d:i:k:r:t:X:D:m:s:b:B:";
char *Prefix = NULL;
char *Comment = NULL;
@ -39,6 +39,8 @@ char *ExcludeFrom = NULL;
char *Mtree = NULL;
char *Pkgdeps = NULL;
char *Pkgcfl = NULL;
char *BuildVersion = NULL;
char *BuildInfo = NULL;
char PlayPen[FILENAME_MAX];
size_t PlayPenSize = sizeof(PlayPen);
int Dereference = 0;
@ -49,10 +51,11 @@ int ReorderDirs = 0;
static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n",
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
"usage: pkg_create [-ORhlv] [-P dpkgs] [-C cpkgs] [-p prefix] [-f contents]",
" [-i iscript] [-k dscript] [-r rscript] [-t template]",
" [-X excludefile] [-D displayfile] [-m mtreefile]",
" [-b build-version-file] [-B build-info-file]",
" -c comment -d description -f packlist pkg-name");
exit(1);
}
@ -142,6 +145,14 @@ main(int argc, char **argv)
Pkgcfl = optarg;
break;
case 'b':
BuildVersion = optarg;
break;
case 'B':
BuildInfo = optarg;
break;
case '?':
default:
usage();

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.13 1998/10/12 12:03:25 agc Exp $ */
/* $NetBSD: perform.c,v 1.14 1998/10/26 17:39:23 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.13 1998/10/12 12:03:25 agc Exp $");
__RCSID("$NetBSD: perform.c,v 1.14 1998/10/26 17:39:23 agc Exp $");
#endif
#endif
@ -106,16 +106,27 @@ make_dist(char *home, char *pkg, char *suffix, package_t *plist)
fprintf(totar, "%s\n", COMMENT_FNAME);
fprintf(totar, "%s\n", DESC_FNAME);
if (Install)
if (Install) {
fprintf(totar, "%s\n", INSTALL_FNAME);
if (DeInstall)
}
if (DeInstall) {
fprintf(totar, "%s\n", DEINSTALL_FNAME);
if (Require)
}
if (Require) {
fprintf(totar, "%s\n", REQUIRE_FNAME);
if (Display)
}
if (Display) {
fprintf(totar, "%s\n", DISPLAY_FNAME);
if (Mtree)
}
if (Mtree) {
fprintf(totar, "%s\n", MTREE_FNAME);
}
if (BuildVersion) {
(void) fprintf(totar, "%s\n", BUILD_VERSION_FNAME);
}
if (BuildInfo) {
(void) fprintf(totar, "%s\n", BUILD_INFO_FNAME);
}
for (p = plist->head; p; p = p->next) {
if (p->type == PLIST_FILE)
@ -260,8 +271,9 @@ pkg_perform(char **pkgs)
* Run down the list and see if we've named it, if not stick in a name
* at the top.
*/
if (find_plist(&plist, PLIST_NAME) == NULL)
if (find_plist(&plist, PLIST_NAME) == NULL) {
add_plist_top(&plist, PLIST_NAME, basename_of(pkg));
}
/*
* We're just here for to dump out a revised plist for the FreeBSD ports
@ -321,6 +333,16 @@ pkg_perform(char **pkgs)
add_plist(&plist, PLIST_FILE, MTREE_FNAME);
add_plist(&plist, PLIST_MTREE, MTREE_FNAME);
}
if (BuildVersion) {
copy_file(home, BuildVersion, BUILD_VERSION_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, BUILD_VERSION_FNAME);
}
if (BuildInfo) {
copy_file(home, BuildInfo, BUILD_INFO_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, BUILD_INFO_FNAME);
}
/* Finally, write out the packing list */
fp = fopen(CONTENTS_FNAME, "w");

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_create.1,v 1.11 1998/10/12 12:03:25 agc Exp $
.\" $NetBSD: pkg_create.1,v 1.12 1998/10/26 17:39:23 agc Exp $
.\"
.\" FreeBSD install - a package for the installation and maintainance
.\" of non-core utilities.
@ -33,17 +33,19 @@
.Sh SYNOPSIS
.Nm
.Op Fl ORhvl
.Op Fl P Ar dpkgs
.Op Fl B Ar build-info-file
.Op Fl C Ar cpkgs
.Op Fl p Ar prefix
.Op Fl D Ar displayfile
.Op Fl P Ar dpkgs
.Op Fl X Ar excludefile
.Op Fl b Ar build-version-file
.Op Fl f Ar contents
.Op Fl i Ar iscript
.Op Fl k Ar dscript
.Op Fl m Ar mtreefile
.Op Fl p Ar prefix
.Op Fl r Ar rscript
.Op Fl t Ar template
.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
@ -61,16 +63,68 @@ description of the input syntax is included in this document.
.Sh OPTIONS
The following command line options are supported:
.Bl -tag -width indent
.It Fl f Ar packinglist
Fetch ``packing list'' for package from the file
.Ar packinglist
or
.Cm stdin
if
.Ar packinglist
is a
.Cm -
(dash).
.It Fl B Ar build-info-file
Install the file
.Ar build-info-file
so that users of binary packages can see what
.Xr make 1
definitions
were used to control the build when creating the
binary package. This allows various build definitions
to be retained in a binary package and viewed wherever it is installed,
using
.Xr pkginfo 1 .
.It Fl C Ar cpkgs
Set the initial package conflict list to
.Ar cpkgs .
This is assumed to be a whitespace separated list of package names
and is meant as a convenient shorthand for specifying multiple
.Cm @pkgcfl
directives in the packing list (see PACKING LIST DETAILS section below).
.It Fl D Ar displayfile
Display the file (using
.Xr more 1 )
after installing the package. Useful for things like
legal notices on almost-free software, etc.
.It Fl O
Go into a `packing list Only' mode.
This is used to do `fake pkg_add' operations when a package is installed.
In such cases, it is necessary to know what the final, adjusted packing
list will look like.
.It Fl P Ar dpkgs
Set the initial package dependency list to
.Ar dpkgs .
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).
.It Fl R
Re-order any directories in the pkg/PLIST file into reverse alphabetic
order, so that child directories will automatically be removed before
parent directories.
.It Fl X Ar excludefile
Pass
.Ar excludefile
as a
.Fl exclude-from
argument to
.Cm tar
when creating final package. See
.Cm tar
man page (or run
.Cm tar
with
.Fl -help
flag) for further information on using this flag.
.It Fl b Ar build-version-file
Install the file
.Ar build-version-file
so that users of binary packages can see what versions of
the files used to control the build were used when creating the
binary package. This allows some fine-grained version control information
to be retained in a binary package and viewed wherever it is installed,
using
.Xr pkg_info 1 .
.It Fl c Ar [-]desc
Fetch package ``one line description'' from file
.Ar desc
@ -85,20 +139,31 @@ Fetch long description for package from file
or, if preceded by
.Cm - ,
the argument itself.
.It Fl O
Go into a `packing list Only' mode.
This is used to do `fake pkg_add' operations when a package is installed.
In such cases, it is necessary to know what the final, adjusted packing
list will look like.
.It Fl R
Re-order any directories in the pkg/PLIST file into reverse alphabetic
order, so that child directories will automatically be removed before
parent directories.
.It Fl v
Turn on verbose output.
.It Fl f Ar packinglist
Fetch ``packing list'' for package from the file
.Ar packinglist
or
.Cm stdin
if
.Ar packinglist
is a
.Cm -
(dash).
.It Fl h
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
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.
.It Fl k Ar dscript
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.
.It Fl l
Check that any symbolic links which are to be placed in the package are
relative to the current prefix. This means using
@ -107,37 +172,29 @@ and
.Xr symlink 2
to remove and re-link
any symbolic links which are targetted at full path names.
.It Fl i Ar iscript
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.
.It Fl P Ar dpkgs
Set the initial package dependency list to
.Ar dpkgs .
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).
.It Fl C Ar cpkgs
Set the initial package conflict list to
.Ar cpkgs .
This is assumed to be a whitespace separated list of package names
and is meant as a convenient shorthand for specifying multiple
.Cm @pkgcfl
directives in the packing list (see PACKING LIST DETAILS section below).
.It Fl m Ar mtreefile
Run
.Xr mtree 8
with input from mtreefile before the package is installed.
Mtree is invoked as
.Cm mtree
.Fl u
.Fl f
.Ar mtreefile
.Fl d
.Fl e
.Fl p
.Pa prefix ,
where
.Pa prefix
is the name of the first directory named by a
.Cm @cwd
directive.
.It Fl p Ar prefix
Set
.Ar prefix
as the initial directory ``base'' to start from in selecting files for
the package.
.It Fl k Ar dscript
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.
.It Fl r Ar rscript
Set
.Ar rscript
@ -159,43 +216,8 @@ directory is limited. Be sure to leave some number of `X' characters
for
.Xr mktemp 3
to fill in with a unique ID.
.It Fl X Ar excludefile
Pass
.Ar excludefile
as a
.Fl exclude-from
argument to
.Cm tar
when creating final package. See
.Cm tar
man page (or run
.Cm tar
with
.Fl -help
flag) for further information on using this flag.
.It Fl D Ar displayfile
Display the file (using
.Xr more 1 )
after installing the package. Useful for things like
legal notices on almost-free software, etc.
.It Fl m Ar mtreefile
Run
.Xr mtree 8
with input from mtreefile before the package is installed.
Mtree is invoked as
.Cm mtree
.Fl u
.Fl f
.Ar mtreefile
.Fl d
.Fl e
.Fl p
.Pa prefix ,
where
.Pa prefix
is the name of the first directory named by a
.Cm @cwd
directive.
.It Fl v
Turn on verbose output.
.El
.Pp
.Sh PACKING LIST DETAILS
@ -369,15 +391,10 @@ package is deinstalled. Multiple
.Cm @pkgdep
directives may be used if the package depends on multiple other packages.
.It Cm @pkgcfl Ar pkgcflname
Declare a conflict to the
Declare a conflict with the
.Ar pkgcflname
package. The
.Ar pkgcflname
package must
.Cm not
be installed if
.Ar pkgname
package gets installed cause they install the same files and thus conflict.
package, as the two packages contain references to the same files,
and so cannot co-exist on the same system.
.El
.Sh SEE ALSO
.Xr pkg_add 1 ,
@ -406,5 +423,3 @@ extracted. They additionally must not end up being split between
invocations due to exec argument-space limitations (this depends on the
value returned by
.Fn sysconf _SC_ARG_MAX ) .
.Pp
Sure to be others.