git: e9ad2964f5de - main - pkg: Add limited --debug/-d support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Aug 2022 17:32:23 UTC
The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=e9ad2964f5de925f21f54db17da8de3796381186 commit e9ad2964f5de925f21f54db17da8de3796381186 Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2022-08-24 17:32:09 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2022-08-24 17:32:09 +0000 pkg: Add limited --debug/-d support Add an internal debug level global: - Level 1 (-d) currently does nothing. - Level 2 (-d -d) enables libfetch debugging (quite verbose) so it's possible to see what pkg is attempting to download without having to sniff traffic. Reviewed by: debdrup, bapt Differential Revision: https://reviews.freebsd.org/D35756 --- usr.sbin/pkg/pkg.7 | 18 +++++++++++++++--- usr.sbin/pkg/pkg.c | 10 +++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/usr.sbin/pkg/pkg.7 b/usr.sbin/pkg/pkg.7 index c8ebf8272092..d0b401edf1fa 100644 --- a/usr.sbin/pkg/pkg.7 +++ b/usr.sbin/pkg/pkg.7 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 30, 2022 +.Dd August 24, 2022 .Dt PKG 7 .Os .Sh NAME @@ -32,16 +32,17 @@ .Nd a utility for manipulating packages .Sh SYNOPSIS .Nm +.Op Fl d .Ar command ... .Nm .Cm add -.Op Fl fy +.Op Fl dfy .Op Fl r Ar reponame .Ar pkg.txz .Nm .Fl N .Nm -.Op Fl 46 +.Op Fl 46d .Cm bootstrap .Op Fl fy .Op Fl r Ar reponame @@ -121,6 +122,17 @@ If a .Ar reponame has been specified, then the configuration for that repository will be used. .El +.Sh OPTIONS +The following options are supported by +.Nm : +.Bl -tag -width indent +.It Fl d, Fl -debug +Show debug information. +May be specified more than once to increase the level of detail. +When specified twice, +.Xr fetch 3 +debug output is enabled. +.El .Sh CONFIGURATION Configuration varies in whether it is in a repository configuration file or the global configuration file. diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index fdc519be8492..393d1af1d69e 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -91,6 +91,8 @@ static const char *bootstrap_names [] = { STAILQ_HEAD(fingerprint_list, fingerprint); +static int debug; + static int extract_pkg_static(int fd, char *p, int sz) { @@ -1113,6 +1115,7 @@ main(int argc, char *argv[]) yes = false; struct option longopts[] = { + { "debug", no_argument, NULL, 'd' }, { "force", no_argument, NULL, 'f' }, { "only-ipv4", no_argument, NULL, '4' }, { "only-ipv6", no_argument, NULL, '6' }, @@ -1122,8 +1125,11 @@ main(int argc, char *argv[]) snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", getlocalbase()); - while ((ch = getopt_long(argc, argv, "-:fr::yN46", longopts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "-:dfr::yN46", longopts, NULL)) != -1) { switch (ch) { + case 'd': + debug++; + break; case 'f': force = true; break; @@ -1220,6 +1226,8 @@ main(int argc, char *argv[]) break; } } + if (debug > 1) + fetchDebug = 1; if ((bootstrap_only && force) || access(pkgpath, X_OK) == -1) { /*