Add -R modifier for the mode when pkg_create(8) creates package file
from the locally installed package. When this modifier is specified pkg_create(8) will also create package files for all packages on which that locally installed package depends. MFC after: 5 days
This commit is contained in:
parent
8002a53be2
commit
23ca2a1c91
@ -44,6 +44,7 @@ extern char *InstalledPkg;
|
||||
extern char PlayPen[];
|
||||
extern int Dereference;
|
||||
extern int PlistOnly;
|
||||
extern int Recursive;
|
||||
|
||||
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[] = "YNOhjvyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
|
||||
static char Options[] = "YNORhjvyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
|
||||
|
||||
char *Prefix = NULL;
|
||||
char *Comment = NULL;
|
||||
@ -39,6 +39,7 @@ char *InstalledPkg = NULL;
|
||||
char PlayPen[FILENAME_MAX];
|
||||
int Dereference = FALSE;
|
||||
int PlistOnly = FALSE;
|
||||
int Recursive = FALSE;
|
||||
enum zipper Zipper = GZIP;
|
||||
|
||||
static void usage __P((void));
|
||||
@ -169,6 +170,10 @@ main(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
Recursive = TRUE;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@ -211,6 +216,6 @@ usage()
|
||||
" [-D displayfile] [-m mtreefile] [-o origin] ",
|
||||
" [-s srcdir] [-S basedir] ",
|
||||
" -c comment -d description -f packlist pkg-filename",
|
||||
" pkg_create [-YNhvyz] -b pkg-name [pkg-filename]");
|
||||
" pkg_create [-YNhvyzR] -b pkg-name [pkg-filename]");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
static void sanity_check(void);
|
||||
static void make_dist(const char *, const char *, const char *, Package *);
|
||||
static int create_from_installed(const char *, const char *);
|
||||
static int create_from_installed_recursive(const char *, const char *);
|
||||
static int create_from_installed(const char *, const char *, const char *);
|
||||
|
||||
static char *home;
|
||||
|
||||
@ -79,8 +80,11 @@ pkg_perform(char **pkgs)
|
||||
} else
|
||||
suf = "tar";
|
||||
|
||||
if (InstalledPkg != NULL)
|
||||
return (create_from_installed(pkg, suf));
|
||||
if (InstalledPkg != NULL) {
|
||||
if (!Recursive)
|
||||
return (create_from_installed(InstalledPkg, pkg, suf));
|
||||
return (create_from_installed_recursive(pkg, suf));
|
||||
}
|
||||
|
||||
get_dash_string(&Comment);
|
||||
get_dash_string(&Desc);
|
||||
@ -446,15 +450,55 @@ cleanup(int sig)
|
||||
}
|
||||
|
||||
static int
|
||||
create_from_installed(const char *pkg, const char *suf)
|
||||
create_from_installed_recursive(const char *pkg, const char *suf)
|
||||
{
|
||||
FILE *fp;
|
||||
Package plist;
|
||||
PackingList p;
|
||||
char tmp[PATH_MAX];
|
||||
int rval;
|
||||
|
||||
if (!create_from_installed(InstalledPkg, pkg, suf))
|
||||
return FALSE;
|
||||
snprintf(tmp, sizeof(tmp), "%s/%s/%s", LOG_DIR, InstalledPkg, CONTENTS_FNAME);
|
||||
if (!fexists(tmp)) {
|
||||
warnx("can't find package '%s' installed!", InstalledPkg);
|
||||
return FALSE;
|
||||
}
|
||||
/* Suck in the contents list */
|
||||
plist.head = plist.tail = NULL;
|
||||
fp = fopen(tmp, "r");
|
||||
if (!fp) {
|
||||
warnx("unable to open %s file", tmp);
|
||||
return FALSE;
|
||||
}
|
||||
read_plist(&plist, fp);
|
||||
fclose(fp);
|
||||
rval = TRUE;
|
||||
for (p = plist.head; p ; p = p->next) {
|
||||
if (p->type != PLIST_PKGDEP)
|
||||
continue;
|
||||
if (Verbose)
|
||||
printf("Creating package %s\n", p->name);
|
||||
if (!create_from_installed(p->name, p->name, suf)) {
|
||||
rval = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free_plist(&plist);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static int
|
||||
create_from_installed(const char *ipkg, const char *pkg, const char *suf)
|
||||
{
|
||||
FILE *fp;
|
||||
Package plist;
|
||||
char homedir[MAXPATHLEN], log_dir[FILENAME_MAX];
|
||||
|
||||
snprintf(log_dir, sizeof(log_dir), "%s/%s", LOG_DIR, InstalledPkg);
|
||||
snprintf(log_dir, sizeof(log_dir), "%s/%s", LOG_DIR, ipkg);
|
||||
if (!fexists(log_dir)) {
|
||||
warnx("can't find package '%s' installed!", InstalledPkg);
|
||||
warnx("can't find package '%s' installed!", ipkg);
|
||||
return FALSE;
|
||||
}
|
||||
getcwd(homedir, sizeof(homedir));
|
||||
@ -485,5 +529,9 @@ create_from_installed(const char *pkg, const char *suf)
|
||||
make_dist(homedir, pkg, suf, &plist);
|
||||
|
||||
free_plist(&plist);
|
||||
if (chdir(homedir) == FAIL) {
|
||||
warnx("can't change directory to '%s'!", homedir);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
.Fl f Ar packlist
|
||||
.Ar pkg-filename
|
||||
.Nm
|
||||
.Op Fl YNhvy
|
||||
.Op Fl YNRhvy
|
||||
.Fl b Ar pkg-name
|
||||
.Op Ar pkg-filename
|
||||
.Sh DESCRIPTION
|
||||
@ -335,6 +335,13 @@ is not specified, then resulting archive will be created in the
|
||||
current directory and named
|
||||
.Ar pkg-name
|
||||
with an appropriate extraction suffix applied.
|
||||
.It Fl R
|
||||
When creating package file from a locally installed package
|
||||
also create package files for all packages required by
|
||||
.Ar pkg-name .
|
||||
Resulting archive(s) will be created in the current directory
|
||||
and named using name of the respective package with appropriate
|
||||
extraction suffix applied.
|
||||
.El
|
||||
.Sh PACKING LIST DETAILS
|
||||
The
|
||||
|
Loading…
Reference in New Issue
Block a user