From 9b13a9d87f9d762af930834991a0e99fefcb5150 Mon Sep 17 00:00:00 2001 From: sobomax Date: Mon, 23 Oct 2000 07:01:31 +0000 Subject: Add "-o" option to pkg_create(1) and pkg_info(1). This option intended to record a path of the port from which package has been created within FreeBSD Ports Collection and will be used to improve pkg_version(1) and similar tools. Reviewed by: ports@FreeBSD.org, jkh Approved by: jkh --- usr.sbin/pkg_install/create/create.h | 1 + usr.sbin/pkg_install/create/main.c | 11 ++++++++--- usr.sbin/pkg_install/create/perform.c | 6 +++++- usr.sbin/pkg_install/create/pkg_create.1 | 8 ++++++++ usr.sbin/pkg_install/info/info.h | 2 ++ usr.sbin/pkg_install/info/main.c | 8 ++++++-- usr.sbin/pkg_install/info/perform.c | 2 ++ usr.sbin/pkg_install/info/pkg_info.1 | 9 ++++++++- usr.sbin/pkg_install/info/show.c | 15 +++++++++++++++ 9 files changed, 55 insertions(+), 7 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h index ff3fc95..63ab997 100644 --- a/usr.sbin/pkg_install/create/create.h +++ b/usr.sbin/pkg_install/create/create.h @@ -37,6 +37,7 @@ extern char *SrcDir; extern char *ExcludeFrom; extern char *Mtree; extern char *Pkgdeps; +extern char *Origin; extern char PlayPen[]; extern int Dereference; extern int PlistOnly; diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index 403cd93e..bb6a049 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -18,7 +18,7 @@ static const char rcsid[] = #include "lib.h" #include "create.h" -static char Options[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:"; +static char Options[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:"; char *Prefix = NULL; char *Comment = NULL; @@ -34,6 +34,7 @@ char *Require = NULL; char *ExcludeFrom = NULL; char *Mtree = NULL; char *Pkgdeps = NULL; +char *Origin = NULL; char PlayPen[FILENAME_MAX]; int Dereference = 0; int PlistOnly = 0; @@ -129,6 +130,10 @@ main(int argc, char **argv) Pkgdeps = optarg; break; + case 'o': + Origin = optarg; + break; + case '?': default: usage(); @@ -165,7 +170,7 @@ usage() "usage: pkg_create [-YNOhv] [-P pkgs] [-p prefix] [-f contents] [-i iscript]", " [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ", " [-t template] [-X excludefile] [-D displayfile] ", -" [-m mtreefile] -c comment -d description -f packlist ", -" pkg-name"); +" [-m mtreefile] [-o origin] -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 e5555b1..ff38910 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -85,6 +85,10 @@ pkg_perform(char **pkgs) else suf = "tar"; + /* Add the origin if asked, at the top */ + if (Origin) + add_plist(&plist, PLIST_COMMENT, strconcat("ORIGIN:", Origin)); + /* Stick the dependencies, if any, at the top */ if (Pkgdeps) { if (Verbose && !PlistOnly) @@ -92,7 +96,7 @@ pkg_perform(char **pkgs) while (Pkgdeps) { cp = strsep(&Pkgdeps, " \t\n"); if (*cp) { - add_plist(&plist, PLIST_PKGDEP, cp); + add_plist_top(&plist, PLIST_PKGDEP, cp); if (Verbose && !PlistOnly) printf(" %s", cp); } diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1 index 4ecc921..77612a8 100644 --- a/usr.sbin/pkg_install/create/pkg_create.1 +++ b/usr.sbin/pkg_install/create/pkg_create.1 @@ -45,6 +45,7 @@ .Op Fl X Ar excludefile .Op Fl D Ar displayfile .Op Fl m Ar mtreefile +.Op Fl o Ar originpath .Fl c Ar comment .Fl d Ar description .Fl f Ar packlist @@ -243,6 +244,13 @@ where is the name of the first directory named by a .Cm @cwd directive. +.It Fl o Ar originpath +Record an +.Ar originpath , +as location of the port from which package has been created in the +.Em "FreeBSD Ports Collection" . +It should be in the form +.Pa MASTERCATEGORY/PORTDIR . .El .Pp .Sh PACKING LIST DETAILS diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 56bac9f..04d1ade 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -44,6 +44,7 @@ #define SHOW_REQBY 0x0400 #define SHOW_MTREE 0x0800 #define SHOW_SIZE 0x1000 +#define SHOW_ORIGIN 0x2000 extern int Flags; extern Boolean AllInstalled; @@ -57,5 +58,6 @@ extern void show_plist(char *, Package *, plist_t); extern void show_files(char *, Package *); extern void show_index(char *, char *); extern void show_size(char *, Package *); +extern void show_origin(char *, Package *); #endif /* _INST_INFO_H_INCLUDE */ diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c index 80b3adb..5f7329e 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -28,7 +28,7 @@ static const char rcsid[] = "$FreeBSD$"; #endif -static char Options[] = "acdDe:fhiIkl:LmpqrRst:v"; +static char Options[] = "acdDe:fhiIkl:LmopqrRst:v"; int Flags = 0; Boolean AllInstalled = FALSE; @@ -116,6 +116,10 @@ main(int argc, char **argv) Flags |= SHOW_SIZE; break; + case 'o': + Flags |= SHOW_ORIGIN; + break; + case 'l': InfoPrefix = optarg; break; @@ -175,7 +179,7 @@ static void usage() { fprintf(stderr, "%s\n%s\n%s\n", - "usage: pkg_info [-cdDfikrRpLqImv] [-e package] [-l prefix]", + "usage: pkg_info [-cdDfikorRpLqImv] [-e package] [-l prefix]", " [-t template] [pkg-name ...]", " pkg_info -a [flags]"); exit(1); diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index 81c16f1..e9fa6d5 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -205,6 +205,8 @@ pkg_do(char *pkg) show_files("Files:\n", &plist); if ((Flags & SHOW_SIZE) && installed) show_size("Package Size:\n", &plist); + if (Flags & SHOW_ORIGIN) + show_origin("Origin:\n", &plist); if (!Quiet) puts(InfoPrefix); } diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1 index 52ffc53..44f3860 100644 --- a/usr.sbin/pkg_install/info/pkg_info.1 +++ b/usr.sbin/pkg_install/info/pkg_info.1 @@ -25,7 +25,7 @@ .Nd a utility for displaying information on software packages .Sh SYNOPSIS .Nm pkg_info -.Op Fl cdDfikrRpLsqImv +.Op Fl cdDfikorRpLsqImv .Op Fl e Ar package .Op Fl l Ar prefix .Op Fl t Ar template @@ -88,6 +88,13 @@ viewing the packing list, since full pathnames for everything are generated. .It Fl s Show the total size occupied by files installed within each package. +.It Fl o +Show the +.Dq origin +path recorded on package generation. This path +intended to give an idea as to where the underlying port, from which +package was generated, is located in the +.Em "FreeBSD Ports Collection" . .It Fl e Ar pkg-name If the package identified by .Ar pkg-name diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 893e180..a0dae0a 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -256,3 +256,18 @@ show_size(char *title, Package *plist) else printf("%lu\n", size); } + +/* Show an "origin" path (usually category/portname) */ +void +show_origin(char *title, Package *plist) +{ + PackingList p; + + if (!Quiet) + printf("%s%s", InfoPrefix, title); + for (p = plist->head; p != NULL; p = p->next) + if (p->type == PLIST_COMMENT && !strncmp(p->name, "ORIGIN:", 7)) { + printf("%s\n", p->name + 7); + break; + } +} -- cgit v1.1