summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorflz <flz@FreeBSD.org>2008-05-30 14:26:09 +0000
committerflz <flz@FreeBSD.org>2008-05-30 14:26:09 +0000
commit9a2047ba483ae2319d063ec4bd72a70e706bd7c1 (patch)
tree879a8bde309ee78659bbc86a35be8b5b8cb6071b /usr.sbin/pkg_install
parentabbda8507b5aecb2e8c4a237e56eb32f4b2d1308 (diff)
downloadFreeBSD-src-9a2047ba483ae2319d063ec4bd72a70e706bd7c1.zip
FreeBSD-src-9a2047ba483ae2319d063ec4bd72a70e706bd7c1.tar.gz
- Add long options to pkg_install.
- Remove check for '-?' as it's not listed in authorized options. - Bump PKG_INSTALL_VERSION to 20080530.
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/add/main.c29
-rw-r--r--usr.sbin/pkg_install/add/pkg_add.128
-rw-r--r--usr.sbin/pkg_install/create/main.c33
-rw-r--r--usr.sbin/pkg_install/create/pkg_create.126
-rw-r--r--usr.sbin/pkg_install/delete/main.c26
-rw-r--r--usr.sbin/pkg_install/delete/pkg_delete.126
-rw-r--r--usr.sbin/pkg_install/info/main.c28
-rw-r--r--usr.sbin/pkg_install/info/pkg_info.132
-rw-r--r--usr.sbin/pkg_install/lib/lib.h2
-rw-r--r--usr.sbin/pkg_install/updating/main.c15
-rw-r--r--usr.sbin/pkg_install/updating/pkg_updating.116
-rw-r--r--usr.sbin/pkg_install/version/main.c25
-rw-r--r--usr.sbin/pkg_install/version/pkg_version.120
13 files changed, 206 insertions, 100 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index 7a94f19..1556897 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -21,14 +21,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <err.h>
#include <sys/param.h>
#include <sys/utsname.h>
+#include <err.h>
+#include <getopt.h>
+
#include "lib.h"
#include "add.h"
-static char Options[] = "hviIRfFnrp:P:SMt:C:K";
-
char *Prefix = NULL;
Boolean PrefixRecursive = FALSE;
char *Chroot = NULL;
@@ -95,6 +95,25 @@ int getosreldate(void);
static void usage(void);
+static char opts[] = "hviIRfFnrp:P:SMt:C:K";
+static struct option longopts[] = {
+ { "chroot", required_argument, NULL, 'C' },
+ { "dry-run", no_argument, NULL, 'n' },
+ { "force", no_argument, NULL, 'f' },
+ { "help", no_argument, NULL, 'h' },
+ { "keep", no_argument, NULL, 'K' },
+ { "master", no_argument, NULL, 'M' },
+ { "no-deps", no_argument, NULL, 'i' },
+ { "no-record", no_argument, NULL, 'R' },
+ { "no-script", no_argument, NULL, 'I' },
+ { "prefix", required_argument, NULL, 'p' },
+ { "remote", no_argument, NULL, 'r' },
+ { "template", required_argument, NULL, 't' },
+ { "slave", no_argument, NULL, 'S' },
+ { "verbose", no_argument, NULL, 'v' },
+ { NULL, 0, NULL, 0 }
+};
+
int
main(int argc, char **argv)
{
@@ -110,7 +129,7 @@ main(int argc, char **argv)
PkgAddCmd = argv[0];
start = argv;
- while ((ch = getopt(argc, argv, Options)) != -1) {
+ while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch(ch) {
case 'v':
Verbose++;
@@ -170,12 +189,12 @@ main(int argc, char **argv)
case 'C':
Chroot = optarg;
break;
+
case 'i':
IgnoreDeps = TRUE;
break;
case 'h':
- case '?':
default:
usage();
break;
diff --git a/usr.sbin/pkg_install/add/pkg_add.1 b/usr.sbin/pkg_install/add/pkg_add.1
index dc2f3fc..8194758 100644
--- a/usr.sbin/pkg_install/add/pkg_add.1
+++ b/usr.sbin/pkg_install/add/pkg_add.1
@@ -15,7 +15,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 29, 2007
+.Dd May 30, 2008
.Dt PKG_ADD 1
.Os
.Sh NAME
@@ -81,31 +81,31 @@ working directory,
.Nm
will search them in each directory named by
.Ev PKG_PATH .
-.It Fl v
+.It Fl v , -verbose
Turn on verbose output.
-.It Fl K
+.It Fl K , -keep
Keep any downloaded package in
.Ev PKGDIR
if it is defined or in current directory by default.
-.It Fl i
+.It Fl i , -no-deps
Install the package without fetching and installing
dependencies.
-.It Fl I
+.It Fl I , -no-scripts
If any installation scripts (pre-install or post-install) exist for a given
package, do not execute them.
-.It Fl n
+.It Fl n , -dry-run
Do not actually install a package, just report the steps that
would be taken if it was.
-.It Fl R
+.It Fl R , -no-record
Do not record the installation of a package.
This means
that you cannot deinstall it later, so only use this option if
you know what you are doing!
-.It Fl r
+.It Fl r , -remote
Use the remote fetching feature.
This will determine the appropriate
objformat and release and then fetch and install the package.
-.It Fl f
+.It Fl f , -force
Force installation to proceed even if prerequisite packages are not
installed or the requirements script fails.
Although
@@ -114,7 +114,7 @@ will still try to find and auto-install missing prerequisite packages,
a failure to find one will not be fatal.
.It Fl F
Already installed packages are not an error.
-.It Fl p Ar prefix
+.It Fl p , -prefix Ar prefix
Set
.Ar prefix
as the directory in which to extract files from a package.
@@ -162,7 +162,7 @@ flag on the command line, it overrides its effect, causing
to use the given
.Ar prefix
recursively.
-.It Fl t Ar template
+.It Fl t , -template Ar template
Use
.Ar template
as the input to
@@ -185,7 +185,7 @@ You can get a performance boost by setting the staging area
to reside on the same disk partition as target directories for package
file installation; often this is
.Pa /usr .
-.It Fl M
+.It Fl M , -master
Run in
.Cm MASTER
mode.
@@ -207,7 +207,7 @@ When used in conjunction with
.Cm SLAVE
mode, it allows you to make radical changes to the package structure
before acting on its contents.
-.It Fl S
+.It Fl S , -slave
Run in
.Cm SLAVE
mode.
@@ -223,7 +223,7 @@ in the staging area, the location of which is read as a string
from stdin.
The complete packing list is also read from stdin,
and the contents then acted on as normal.
-.It Fl C Ar chrootdir
+.It Fl C , -chroot Ar chrootdir
Before doing any operations,
.Xr chroot 2
to the
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index 14142ae..eb8fa15 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -12,12 +12,12 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <getopt.h>
#include <err.h>
+
#include "lib.h"
#include "create.h"
-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;
char *Comment = NULL;
@@ -42,6 +42,7 @@ int Dereference = FALSE;
int PlistOnly = FALSE;
int Recursive = FALSE;
int Regenerate = TRUE;
+int Help = FALSE;
#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
enum zipper Zipper = BZIP2;
#else
@@ -51,6 +52,24 @@ enum zipper Zipper = GZIP;
static void usage(void);
+static char opts[] = "EGYNnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
+static struct option longopts[] = {
+ { "backup", required_argument, NULL, 'b' },
+ { "extended", no_argument, NULL, 'E' },
+ { "help", no_argument, &Help, TRUE },
+ { "no", no_argument, NULL, 'N' },
+ { "no-glob", no_argument, NULL, 'G' },
+ { "origin", required_argument, NULL, 'o' },
+ { "plist-only", no_argument, NULL, 'O' },
+ { "prefix", required_argument, NULL, 'p' },
+ { "recursive", no_argument, NULL, 'R' },
+ { "regex", no_argument, NULL, 'x' },
+ { "template", required_argument, NULL, 't' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "yes", no_argument, NULL, 'Y' },
+ { NULL, 0, NULL, 0 },
+};
+
int
main(int argc, char **argv)
{
@@ -58,7 +77,7 @@ main(int argc, char **argv)
char **pkgs, **start, *tmp;
pkgs = start = argv;
- while ((ch = getopt(argc, argv, Options)) != -1)
+ while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
switch(ch) {
case 'v':
Verbose++;
@@ -193,11 +212,11 @@ main(int argc, char **argv)
Recursive = TRUE;
break;
- case 'n':
- Regenerate = FALSE;
- break;
+ case 0:
+ if (Help)
+ usage();
+ break;
- case '?':
default:
usage();
break;
diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1
index a65cfaf..a567fc4 100644
--- a/usr.sbin/pkg_install/create/pkg_create.1
+++ b/usr.sbin/pkg_install/create/pkg_create.1
@@ -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 May 27, 2008
+.Dd May 30, 2008
.Dt PKG_CREATE 1
.Os
.Sh NAME
@@ -103,11 +103,11 @@ Fetch long description for package from file
or, if preceded by
.Cm - ,
the argument itself.
-.It Fl Y
+.It Fl Y , -yes
Assume a default answer of `Yes' for any questions asked.
-.It Fl N
+.It Fl N , -no
Assume a default answer of `No' for any questions asked.
-.It Fl O
+.It Fl O , -plist-only
Go into a `packing list Only' mode.
This is a custom hack for the
.Fx
@@ -115,7 +115,7 @@ This is a custom hack for the
and is used to do `fake pkg_add' operations when a port is installed.
In such cases, it is necessary to know what the final, adjusted packing
list will look like.
-.It Fl v
+.It Fl v , -verbose
Turn on verbose output.
.It Fl h
Force tar to follow symbolic links, so that the files they point to
@@ -179,7 +179,7 @@ recorded into the packing list along with the
using
.Cm @comment
directive.
-.It Fl p Ar prefix
+.It Fl p , -prefix Ar prefix
Set
.Ar prefix
as the initial directory
@@ -243,7 +243,7 @@ during package creation.
will be prefixed to all
.Cm @cwd
during package creation.
-.It Fl t Ar template
+.It Fl t , -template Ar template
Use
.Ar template
as the input to
@@ -296,7 +296,7 @@ where
is the name of the first directory named by a
.Cm @cwd
directive.
-.It Fl o Ar originpath
+.It Fl o , -origin Ar originpath
Record an
.Ar originpath ,
as location of the port from which package has been created in the
@@ -325,7 +325,7 @@ Compatibility synonym for
Use
.Xr gzip 1
utility to compress package tarball.
-.It Fl b Ar pkg-name
+.It Fl b , -backup Ar pkg-name
Create package file from a locally installed package named
.Ar pkg-name .
If the
@@ -334,20 +334,20 @@ 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
+.It Fl R , -recursive
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.
-.It Fl x
+.It Fl x , -regex
Use basic regular expressions for
.Ar pkg-name .
-.It Fl E
+.It Fl E , -extended
Use extended (modern) regular expressions for
.Ar pkg-name .
-.It Fl G
+.It Fl G , -no-glob
Use exact matching for
.Ar pkg-name .
.It Fl n
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c
index 6bf0762..6075f72 100644
--- a/usr.sbin/pkg_install/delete/main.c
+++ b/usr.sbin/pkg_install/delete/main.c
@@ -24,12 +24,12 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
+#include <getopt.h>
#include <err.h>
+
#include "lib.h"
#include "delete.h"
-static char Options[] = "adDfGhinp:rvxX";
-
char *Prefix = NULL;
Boolean CleanDirs = FALSE;
Boolean Interactive = FALSE;
@@ -39,6 +39,25 @@ match_t MatchType = MATCH_GLOB;
static void usage(void);
+static char opts[] = "adDfGhinp:rvxX";
+static struct option longopts[] = {
+ { "all", no_argument, NULL, 'a' },
+ { "clean-dirs", no_argument, NULL, 'd' },
+ { "dry-run", no_argument, NULL, 'n' },
+ { "extended", no_argument, NULL, 'X' },
+ { "force", no_argument, NULL, 'f' },
+ { "help", no_argument, NULL, 'h' },
+ { "interactive",no_argument, NULL, 'i' },
+ { "prefix", required_argument, NULL, 'p' },
+ { "recursive", no_argument, NULL, 'r' },
+ { "regex", no_argument, NULL, 'x' },
+ { "no-glob", no_argument, NULL, 'G' },
+ { "no-script", no_argument, NULL, 'D' },
+ { "no-scripts", no_argument, NULL, 'D' },
+ { "verbose", no_argument, NULL, 'v' },
+ { NULL, 0, NULL, 0 },
+};
+
int
main(int argc, char **argv)
{
@@ -49,7 +68,7 @@ main(int argc, char **argv)
struct stat stat_s;
pkgs = start = argv;
- while ((ch = getopt(argc, argv, Options)) != -1)
+ while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
switch(ch) {
case 'v':
Verbose++;
@@ -101,7 +120,6 @@ main(int argc, char **argv)
break;
case 'h':
- case '?':
default:
usage();
break;
diff --git a/usr.sbin/pkg_install/delete/pkg_delete.1 b/usr.sbin/pkg_install/delete/pkg_delete.1
index 3f10b9c..aa56a44 100644
--- a/usr.sbin/pkg_install/delete/pkg_delete.1
+++ b/usr.sbin/pkg_install/delete/pkg_delete.1
@@ -17,7 +17,7 @@
.\" @(#)pkg_delete.1
.\" $FreeBSD$
.\"
-.Dd June 29, 2004
+.Dd May 30, 2008
.Dt PKG_DELETE 1
.Os
.Sh NAME
@@ -72,20 +72,20 @@ The following command line options are supported:
.Bl -tag -width indent
.It Ar pkg-name ...
The named packages are deinstalled.
-.It Fl a
+.It Fl a , -all
Unconditionally delete all currently installed packages.
-.It Fl i
+.It Fl i , -interactive
Request confirmation before attempting to delete each package,
regardless whether or not the standard input device is a
terminal.
-.It Fl v
+.It Fl v , -verbose
Turn on verbose output.
-.It Fl D
+.It Fl D , -no-script , -no-scripts
If a deinstallation script exists for a given package, do not execute it.
-.It Fl n
+.It Fl n , -dry-run
Do not actually deinstall a package, just report the steps that
would be taken if it were.
-.It Fl p Ar prefix
+.It Fl p , -prefix Ar prefix
Set
.Ar prefix
as the directory in which to delete files from any installed packages
@@ -93,7 +93,7 @@ which do not explicitly set theirs.
For most packages, the prefix will
be set automatically to the installed location by
.Xr pkg_add 1 .
-.It Fl d
+.It Fl d , -clean-dirs
Remove empty directories created by file cleanup.
By default, only
files/directories explicitly listed in a package's contents (either as
@@ -104,17 +104,17 @@ This option tells
.Nm
to also remove any directories that were emptied as a result of removing
the package.
-.It Fl f
+.It Fl f , -force
Force removal of the package, even if a dependency is recorded or the
deinstall or require script fails.
-.It Fl G
+.It Fl G , -no-glob
Do not try to expand shell glob patterns in the
.Ar pkg-name
when selecting packages to be deleted (by default
.Nm
automatically expands shell glob patterns in the
.Ar pkg-name ) .
-.It Fl x
+.It Fl x , -regex
Treat the
.Ar pkg-name
as a regular expression and delete all packages whose names match
@@ -124,13 +124,13 @@ provided, in that case
.Nm
deletes all packages that match at least one
regular expression from the list.
-.It Fl X
+.It Fl X , -extended
Like
.Fl x ,
but treats the
.Ar pkg-name
as an extended regular expression.
-.It Fl r
+.It Fl r , -recursive
Recursive removal.
In addition to specified packages, delete all
packages that depend on those packages as well.
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
index 64c7995..aaa2a1b 100644
--- a/usr.sbin/pkg_install/info/main.c
+++ b/usr.sbin/pkg_install/info/main.c
@@ -22,11 +22,11 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "lib.h"
-#include "info.h"
+#include <getopt.h>
#include <err.h>
-static char Options[] = "abcdDe:EfgGhiIjkKl:LmoO:pPqQrRst:vVW:xX";
+#include "lib.h"
+#include "info.h"
int Flags = 0;
match_t MatchType = MATCH_GLOB;
@@ -41,6 +41,25 @@ struct which_head *whead;
static void usage(void);
+static char opts[] = "abcdDe:EfgGhiIjkKl:LmoO:pPqQrRst:vVW:xX";
+static struct option longopts[] = {
+ { "all", no_argument, NULL, 'a' },
+ { "blocksize", no_argument, NULL, 'b' },
+ { "exist", required_argument, NULL, 'X' },
+ { "exists", required_argument, NULL, 'X' },
+ { "extended", no_argument, NULL, 'e' },
+ { "help", no_argument, NULL, 'h' },
+ { "keep", no_argument, NULL, 'K' },
+ { "no-glob", no_argument, NULL, 'G' },
+ { "origin", required_argument, NULL, 'O' },
+ { "quiet", no_argument, NULL, 'q' },
+ { "regex", no_argument, NULL, 'x' },
+ { "template", required_argument, NULL, 't' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "version", no_argument, NULL, 'P' },
+ { "which", required_argument, NULL, 'W' },
+};
+
int
main(int argc, char **argv)
{
@@ -58,7 +77,7 @@ main(int argc, char **argv)
MatchType = MATCH_ALL;
Flags = SHOW_INDEX;
}
- else while ((ch = getopt(argc, argv, Options)) != -1) {
+ else while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch(ch) {
case 'a':
MatchType = MATCH_ALL;
@@ -209,7 +228,6 @@ main(int argc, char **argv)
break;
case 'h':
- case '?':
default:
usage();
break;
diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1
index 17c0bba..8b032c1 100644
--- a/usr.sbin/pkg_install/info/pkg_info.1
+++ b/usr.sbin/pkg_install/info/pkg_info.1
@@ -17,7 +17,7 @@
.\" @(#)pkg_info.1
.\" $FreeBSD$
.\"
-.Dd January 9, 2006
+.Dd May 30, 2008
.Dt PKG_INFO 1
.Os
.Sh NAME
@@ -25,7 +25,7 @@
.Nd a utility for displaying information on software packages
.Sh SYNOPSIS
.Nm
-.Op Fl bcdDEfgGiIjkKLmopPqQrRsvVxX
+.Op Fl bcdDEfghGiIjkKLmopPqQrRsvVxX
.Op Fl e Ar package
.Op Fl l Ar prefix
.Op Fl t Ar template
@@ -67,9 +67,9 @@ For example,
will match versions 20030723 and later of the
.Pa portupgrade
package.
-.It Fl a
+.It Fl a , -all
Show all currently installed packages.
-.It Fl b
+.It Fl b , -blocksize
Use the
.Ev BLOCKSIZE
environment variable for output even when the
@@ -77,11 +77,13 @@ environment variable for output even when the
or
.Fl Q
flag is present.
-.It Fl v
+.It Fl h , -help
+Print help message.
+.It Fl v , -verbose
Turn on verbose output.
.It Fl p
Show the installation prefix for each package.
-.It Fl q
+.It Fl q , -quiet
Be
.Dq quiet
in emitting report headers and such, just dump the
@@ -110,7 +112,7 @@ precedence over all other package formatting options.
Show the requirements script (if any) for each package.
.It Fl k
Show the de-install script (if any) for each package.
-.It Fl K
+.It Fl K , -keep
Keep any downloaded package in
.Ev PKGDIR
if it is defined or in current directory by default.
@@ -139,14 +141,14 @@ This path is the directory name in the
.Fx
.Em "Ports Collection"
of the underlying port from which the package was generated.
-.It Fl G
+.It Fl G , -no-glob
Do not try to expand shell glob patterns in the
.Ar pkg-name
when selecting packages to be displayed (by default
.Nm
automatically expands shell glob patterns in the
.Ar pkg-name ) .
-.It Fl W Ar filename
+.It Fl W , -which Ar filename
For the specified
.Ar filename
argument show which package it belongs to.
@@ -156,10 +158,10 @@ directories specified in the environment variable
.Ev PATH
are searched using
.Xr which 1 .
-.It Fl O Ar origin
+.It Fl O , -origin Ar origin
List all packages having the specified
.Ar origin .
-.It Fl x
+.It Fl x , -regex
Treat the
.Ar pkg-name
as a regular expression and display information only for packages
@@ -169,13 +171,13 @@ expressions could be provided, in that case
.Nm
displays information about all packages that match at least one
regular expression from the list.
-.It Fl X
+.It Fl X , -extended
Like
.Fl x ,
but treats the
.Ar pkg-name
as an extended regular expression.
-.It Fl e Ar package
+.It Fl e , -exists Ar package
If the package identified by
.Ar package
is currently installed, return 0, otherwise return 1.
@@ -198,7 +200,7 @@ necessarily want the output intermingled in such a way that they cannot
organize it.
This lets you add a special token to the start of
each field.
-.It Fl t Ar template
+.It Fl t , -template Ar template
Use
.Ar template
as the argument to
@@ -226,7 +228,7 @@ indeed to overflow it.
.Ed
.It Fl V
Show revision number of the packing list format.
-.It Fl P
+.It Fl P , -version
Show revision number of package tools.
.El
.Sh TECHNICAL DETAILS
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index e8b009b..d1477e5 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -105,7 +105,7 @@
* Version of the package tools - increase only when some
* functionality used by bsd.port.mk is changed, added or removed
*/
-#define PKG_INSTALL_VERSION 20080528
+#define PKG_INSTALL_VERSION 20080530
#define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf"
#define main(argc, argv) real_main(argc, argv)
diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c
index cb594de..238eee3 100644
--- a/usr.sbin/pkg_install/updating/main.c
+++ b/usr.sbin/pkg_install/updating/main.c
@@ -13,6 +13,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <limits.h>
#include <sysexits.h>
+#include <getopt.h>
#include "lib.h"
#include "pathnames.h"
@@ -24,6 +25,14 @@ typedef struct installedport {
int usage(void);
+static char opts[] = "d:f:h";
+static struct option longopts[] = {
+ { "date", required_argument, NULL, 'd' },
+ { "file", required_argument, NULL, 'f' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+};
+
/*
* Parse /usr/port/UPDATING for corresponding entries. If no argument is
* passed to pkg_updating all entries for all installed ports are displayed.
@@ -74,7 +83,7 @@ main(int argc, char *argv[])
DIR *dir;
FILE *fd;
- while ((ch = getopt(argc, argv, "f:d:")) != -1) {
+ while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch (ch) {
case 'd':
dflag = 1;
@@ -83,7 +92,7 @@ main(int argc, char *argv[])
case 'f':
updatingfile = optarg;
break;
- case '?':
+ case 'h':
default:
usage();
}
@@ -247,7 +256,7 @@ int
usage(void)
{
fprintf(stderr,
- "usage: pkg_updating [-d YYYYMMDD] [-f file] [portname ...]\n");
+ "usage: pkg_updating [-h] [-d YYYYMMDD] [-f file] [portname ...]\n");
exit(EX_USAGE);
}
diff --git a/usr.sbin/pkg_install/updating/pkg_updating.1 b/usr.sbin/pkg_install/updating/pkg_updating.1
index 16554b6..e3bcb54 100644
--- a/usr.sbin/pkg_install/updating/pkg_updating.1
+++ b/usr.sbin/pkg_install/updating/pkg_updating.1
@@ -10,7 +10,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 2, 2007
+.Dd May 30, 2008
.Dt PKG_UPDATING 1
.Os
.Sh NAME
@@ -18,6 +18,7 @@
.Nd a utility for displaying UPDATING entries of software packages
.Sh SYNOPSIS
.Nm
+.Op Fl h
.Op Fl d Ar date
.Op Fl f Ar file
.Op Ar pkg-name ...
@@ -32,10 +33,15 @@ The following command line options are supported:
.Bl -tag -width indent
.It Ar pkg-name ...
UPDATING entries for the named packages are displayed.
-.It Fl d Ar date
-Only entries newer than this date are shown. Use a YYYYMMDD date format.
-.It Fl f Ar UPDATING file
-Defines a alternative location of the UPDATING file.
+.It Fl d , -date Ar date
+Only entries newer than
+.Ar date
+are shown. Use a YYYYMMDD date format.
+.It Fl f , -file Ar file
+Defines a alternative location of the UPDATING
+.Ar file .
+.It Fl h , -help
+Print help message.
.El
.Sh EXAMPLES
.Bl -tag -width indent
diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c
index 6ccf7c1..f46d945 100644
--- a/usr.sbin/pkg_install/version/main.c
+++ b/usr.sbin/pkg_install/version/main.c
@@ -21,11 +21,12 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "lib.h"
-#include "version.h"
+
+#include <getopt.h>
#include <err.h>
-static char Options[] = "dIhl:L:qs:XtTO:ov";
+#include "lib.h"
+#include "version.h"
char *LimitChars = NULL;
char *PreventChars = NULL;
@@ -37,6 +38,21 @@ Boolean ShowOrigin = FALSE;
static void usage(void);
+static char opts[] = "dIhl:L:qs:XtTO:ov";
+static struct option longopts[] = {
+ { "extended", no_argument, NULL, 'X' },
+ { "help", no_argument, NULL, 'h' },
+ { "match", required_argument, NULL, 's' },
+ { "no-status", required_argument, NULL, 'L' },
+ { "origin", required_argument, NULL, 'O' },
+ { "quiet", no_argument, NULL, 'q' },
+ { "show-origin",no_argument, NULL, 'o' },
+ { "status", required_argument, NULL, 'l' },
+ { "index-only", no_argument, NULL, 'I' },
+ { "verbose", no_argument, NULL, 'v' },
+ { NULL, 0, NULL, 0 }
+};
+
int
main(int argc, char **argv)
{
@@ -51,7 +67,7 @@ main(int argc, char **argv)
cmp = version_match(argv[3], argv[2]);
exit(cmp == 1 ? 0 : 1);
}
- else while ((ch = getopt(argc, argv, Options)) != -1) {
+ else while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch(ch) {
case 'v':
Verbose++;
@@ -98,7 +114,6 @@ main(int argc, char **argv)
break;
case 'h':
- case '?':
default:
usage();
break;
diff --git a/usr.sbin/pkg_install/version/pkg_version.1 b/usr.sbin/pkg_install/version/pkg_version.1
index bef6127..db0d7af 100644
--- a/usr.sbin/pkg_install/version/pkg_version.1
+++ b/usr.sbin/pkg_install/version/pkg_version.1
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 27, 2005
+.Dd May 30, 2008
.Dt PKG_VERSION 1
.Os
.Sh NAME
@@ -118,14 +118,14 @@ The
.Nm
utility supports several command-line arguments:
.Bl -tag -width indent
-.It Fl h
+.It Fl h , -help
Print help message.
-.It Fl I
+.It Fl I , -index-only
Use only the index file for determining if a package is out of date.
This is much faster than using the version number from a port's
Makefile, at the expense of potentially giving an incorrect result if
the index file is out of date.
-.It Fl l
+.It Fl l , -status Ar limchar
Limit the output to those packages whose status flag matches the
character(s) in
.Ar limchar .
@@ -135,7 +135,7 @@ Note that because some of the status flag characters are also special
to the shell, it is best to quote
.Ar limchar
with single quotes.
-.It Fl L
+.It Fl L , -no-status Ar limchar
Limit the output to those packages whose status flag does not match
.Ar limchar .
You may specify more than one character to match in
@@ -144,13 +144,13 @@ Note that because some of the status flag characters are also special
to the shell, it is best to quote
.Ar limchar
with single quotes.
-.It Fl o
+.It Fl o , -show-origin
Show the origin recorded on package generation instead of the package
name.
-.It Fl O
+.It Fl O , -origin Ar origin
Only list packages whose registered origin is
.Ar origin .
-.It Fl q
+.It Fl q , -quiet
Enable quiet output.
Quiet output precludes printing the
.Ar limchar
@@ -160,10 +160,10 @@ or
.Fl L .
This is useful when used as the input to
.Xr portupgrade 8 .
-.It Fl s
+.It Fl s , -match Ar string
Limit the output to those packages whose names match a given
.Ar string .
-.It Fl X
+.It Fl X , -extended
Interpret
.Ar string
as a extended regular expression.
OpenPOWER on IntegriCloud