aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2022-08-24 17:32:09 +0000
committerBrooks Davis <brooks@FreeBSD.org>2022-08-24 17:32:09 +0000
commite9ad2964f5de925f21f54db17da8de3796381186 (patch)
tree25f6d0153441e68820723d52e2ba10d6baad9475
parent8036234c72c9361711e867cc1a0c6a7fe0babd84 (diff)
downloadsrc-e9ad2964f5de925f21f54db17da8de3796381186.tar.gz
src-e9ad2964f5de925f21f54db17da8de3796381186.zip
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
-rw-r--r--usr.sbin/pkg/pkg.718
-rw-r--r--usr.sbin/pkg/pkg.c10
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) {
/*