Add a -n option to pkg_create(1), to inhibit duplicate work.
When run without this option, multiple runs of `pkg_create -Rb' will recreate common packages multiple times. This can take a lot of time for large packages. With the -n option `pkg_create -b' checks with stat(2) and skips packages that already exist. Note that this may *not* be safe of the existing output file is not really a package, or if it has been corrupted, modified or otherwise tinkered with between subsequent pkg_create runs. For this and POLA reasons, the default behavior is to *rebuild* the packages, and the -n option can be used when we know it is `safe' to run in no-regenerate mode. Inspired by: A post to freebsd-questions by Matthias Apitz < matthias.apitz at oclc.org > Reviewed by: marcus, flz Approved by: marcus MFC after: 2 weeks
This commit is contained in:
parent
40715dc446
commit
bea08b23d3
@ -46,6 +46,7 @@ extern char PlayPen[];
|
||||
extern int Dereference;
|
||||
extern int PlistOnly;
|
||||
extern int Recursive;
|
||||
extern int Regenerate;
|
||||
|
||||
enum zipper {NONE, GZIP, BZIP, BZIP2 };
|
||||
extern enum zipper Zipper;
|
||||
|
@ -16,7 +16,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "lib.h"
|
||||
#include "create.h"
|
||||
|
||||
static char Options[] = "EGYNORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
|
||||
static char Options[] = "EGYNnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
|
||||
|
||||
match_t MatchType = MATCH_GLOB;
|
||||
char *Prefix = NULL;
|
||||
@ -41,6 +41,7 @@ char PlayPen[FILENAME_MAX];
|
||||
int Dereference = FALSE;
|
||||
int PlistOnly = FALSE;
|
||||
int Recursive = FALSE;
|
||||
int Regenerate = TRUE;
|
||||
#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
|
||||
enum zipper Zipper = BZIP2;
|
||||
#else
|
||||
@ -192,6 +193,10 @@ main(int argc, char **argv)
|
||||
Recursive = TRUE;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
Regenerate = FALSE;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@ -228,7 +233,7 @@ static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
||||
"usage: pkg_create [-YNOhjvyz] [-C conflicts] [-P pkgs] [-p prefix]",
|
||||
"usage: pkg_create [-YNOhjnvyz] [-C conflicts] [-P pkgs] [-p prefix]",
|
||||
" [-i iscript] [-I piscript] [-k dscript] [-K pdscript]",
|
||||
" [-r rscript] [-s srcdir] [-S basedir]",
|
||||
" [-t template] [-X excludefile]",
|
||||
|
@ -28,6 +28,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <libgen.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syslimits.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
@ -336,6 +338,7 @@ pkg_perform(char **pkgs)
|
||||
static void
|
||||
make_dist(const char *homedir, const char *pkg, const char *suff, Package *plist)
|
||||
{
|
||||
struct stat sb;
|
||||
char tball[FILENAME_MAX];
|
||||
PackingList p;
|
||||
int ret;
|
||||
@ -355,6 +358,16 @@ make_dist(const char *homedir, const char *pkg, const char *suff, Package *plist
|
||||
else
|
||||
snprintf(tball, FILENAME_MAX, "%s/%s.%s", homedir, pkg, suff);
|
||||
|
||||
/*
|
||||
* If the package tarball exists already, and we are running in `no
|
||||
* clobber' mode, skip this package.
|
||||
*/
|
||||
if (stat(tball, &sb) == 0 && Regenerate == FALSE) {
|
||||
if (Verbose)
|
||||
printf("Skipping package '%s'. It already exists.\n", tball);
|
||||
return;
|
||||
}
|
||||
|
||||
args[nargs++] = "-c";
|
||||
args[nargs++] = "-f";
|
||||
args[nargs++] = tball;
|
||||
|
@ -23,7 +23,7 @@
|
||||
.\" [jkh] Took John's changes back and made some additional extensions for
|
||||
.\" better integration with FreeBSD's new ports collection.
|
||||
.\"
|
||||
.Dd November 8, 2005
|
||||
.Dd May 27, 2008
|
||||
.Dt PKG_CREATE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -31,7 +31,7 @@
|
||||
.Nd a utility for creating software package distributions
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl YNOhjvyz
|
||||
.Op Fl YNOhjnvyz
|
||||
.Op Fl C Ar conflicts
|
||||
.Op Fl P Ar pkgs
|
||||
.Op Fl p Ar prefix
|
||||
@ -52,7 +52,7 @@
|
||||
.Fl f Ar packlist
|
||||
.Ar pkg-filename
|
||||
.Nm
|
||||
.Op Fl EGYNRhvxy
|
||||
.Op Fl EGYNRhnvxy
|
||||
.Fl b Ar pkg-name
|
||||
.Op Ar pkg-filename
|
||||
.Sh DESCRIPTION
|
||||
@ -350,6 +350,24 @@ Use extended (modern) regular expressions for
|
||||
.It Fl G
|
||||
Use exact matching for
|
||||
.Ar pkg-name .
|
||||
.It Fl n
|
||||
Run in
|
||||
.Dq no clobber
|
||||
mode.
|
||||
If a package tarball exists, the
|
||||
.Nm
|
||||
utility will not overwrite it.
|
||||
This is useful, for example, when multiple packages are saved with
|
||||
several consecutive runs of
|
||||
.Nm
|
||||
with the
|
||||
.Fl Rb
|
||||
options.
|
||||
Saving common dependencies multiple times would do a lot of duplicate
|
||||
work in this case.
|
||||
The
|
||||
.Fl n
|
||||
option avoids repackaging common dependencies multiple times.
|
||||
.El
|
||||
.Sh PACKING LIST DETAILS
|
||||
The
|
||||
|
Loading…
Reference in New Issue
Block a user