diff options
-rw-r--r-- | usr.sbin/pkg_install/create/create.h | 1 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/main.c | 9 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/perform.c | 60 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/pkg_create.1 | 9 |
4 files changed, 70 insertions, 9 deletions
diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h index b2a2b4a..33c3db7 100644 --- a/usr.sbin/pkg_install/create/create.h +++ b/usr.sbin/pkg_install/create/create.h @@ -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; diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index b0a9415..4869bfd5 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -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); } diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index efbac43..3f7ab47 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -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; } diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1 index cfa81f1..75b491b 100644 --- a/usr.sbin/pkg_install/create/pkg_create.1 +++ b/usr.sbin/pkg_install/create/pkg_create.1 @@ -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 |