From nobody Mon Jul 13 22:09:41 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gzc6s5mkdz6kNVQ for ; Mon, 13 Jul 2026 22:09:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gzc6s550jz3nPR for ; Mon, 13 Jul 2026 22:09:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783980581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZGCPP+OarKcYMC0NmgAA36xpx2jdD2SqJ3Ul3nWBi1M=; b=CTpGw6zfOZsjqWbk3LT0gW2D+zd2Zbu2edJ2ZZoX46Ynrgc7/iDdS4jnXp1npKiw6nLiw9 gVmLxOhk4tD3m43Ge18qo45gf0Quv7TvLZEjYgFJ4EYgA1sWhi9mSuT7+As0wOL2CMSVoe AV7eYmYb/yWtpAKDYKo+ZepEZ/vsjl59Z9j/y/BlgRMfyWVq7FnpFLRuB0K6ip+FGa/Lm4 kwwnAfVl/tGbHkYT6Xq4niLGZL4Gnn4w9Fp/As4GATTThNOb4fuWUksLJnvVlxlvyidd5j izpq5Fwh9tP9xSctEmRuQqBiSK02wYHyZa7tMra/pecWmhtUS3U2OkLf9DzfTA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783980581; a=rsa-sha256; cv=none; b=TuQFFR9CSRjc/FYYX9GdX8Fkd0FDnsgd2aUOjqkVQhYJAIkVRhK70b5df8V7QK7PmdDGSK J/R5/SZ0ObznnNw/+geqJxOSqIAQEKr/GMgMoqTc21kapWdu4Q5Aoyv8Y6uC3s0+XFfBov tnO2G7Xv2OF8LT2cIpVOFL5c3LjmuHo5KImtZA7vsqQQCdsnnKdn99eEjZcCyAZkV2eg2y 2uzB39GVI5rhOPsnY8f/Ruy2XFxFtY1LJVhXOd8YBa48N4Oz+KoMj0YAZhfS5w6s8DJJQm CvRzcZr5/WQU/wdqLaiM4wIQtrdY5qgAfF6GHgZEitE1w6iN8cCC1x6/CN3V8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783980581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZGCPP+OarKcYMC0NmgAA36xpx2jdD2SqJ3Ul3nWBi1M=; b=iml/GzSTCg4HWTKXXbtFgbdcGIl2qzwlC+0FvCGFf3gXIJNRG+OHmL/6F0j2AEwL/Wqa8p 6kyDiY8Srbtw14ubtjSXl8z0MChv80dccNQQZY9EYOvpTHiwdDd46pm5lYdOu2tQiorqwH CjNE/oG9GyXrhwO6WlWpqq7Gf7Fpkuezld8lyEl8Ndx2VHiVrkr7bqgTR1RwU0kJg2mD+y KqmB9KsuGK7VfWqgMETghuK3bA1vHLQKCAr7pJmC5IHtV79cG0UUBUX2FAjtJsGQsV8q1X WIilYvGqU3GiigerFASkZM1DXLXrgI3kUOmGd46U03UoaYYv2eECVFVR7IoeGg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gzc6s3lzGz270 for ; Mon, 13 Jul 2026 22:09:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 414b0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 13 Jul 2026 22:09:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 9dfaf1cb37f8 - main - Revert "pkg: Add -j and -r options" List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9dfaf1cb37f8ac89cf6dbfd1d6905c8d03722391 Auto-Submitted: auto-generated Date: Mon, 13 Jul 2026 22:09:41 +0000 Message-Id: <6a556225.414b0.4b104934@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=9dfaf1cb37f8ac89cf6dbfd1d6905c8d03722391 commit 9dfaf1cb37f8ac89cf6dbfd1d6905c8d03722391 Author: Kyle Evans AuthorDate: 2026-07-13 22:08:58 +0000 Commit: Kyle Evans CommitDate: 2026-07-13 22:08:58 +0000 Revert "pkg: Add -j and -r options" This reverts commit d94e034d504682be56fc2e9d20ac2c0fe15b70ec at the request of des@, as it seems to have broken the pass-through case. --- usr.sbin/pkg/Makefile | 2 +- usr.sbin/pkg/pkg.7 | 28 +++--------- usr.sbin/pkg/pkg.c | 116 +++++++++++--------------------------------------- 3 files changed, 31 insertions(+), 115 deletions(-) diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile index 3b3249c538dd..68b862826992 100644 --- a/usr.sbin/pkg/Makefile +++ b/usr.sbin/pkg/Makefile @@ -27,7 +27,7 @@ MAN= pkg.7 CFLAGS+=-I${SRCTOP}/contrib/libucl/include .PATH: ${SRCTOP}/contrib/libucl/include -LIBADD= archive der fetch jail pkgecc ucl crypto ssl util md +LIBADD= archive der fetch pkgecc ucl crypto ssl util md CFLAGS+=-I${SRCTOP}/contrib/libder/libder CFLAGS+=-I${SRCTOP}/crypto/libecc/include diff --git a/usr.sbin/pkg/pkg.7 b/usr.sbin/pkg/pkg.7 index 9d6dc21c8472..d2246f74a3fc 100644 --- a/usr.sbin/pkg/pkg.7 +++ b/usr.sbin/pkg/pkg.7 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 13, 2026 +.Dd April 29, 2025 .Dt PKG 7 .Os .Sh NAME @@ -31,25 +31,17 @@ .Sh SYNOPSIS .Nm .Op Fl d -.Op Fl j Ar jail -.Op Fl r Ar rootdir .Ar command ... .Nm .Op Fl d -.Op Fl j Ar jail -.Op Fl r Ar rootdir .Cm add .Op Fl fy .Op Fl r Ar reponame .Ar pkg.pkg .Nm -.Op Fl j Ar jail -.Op Fl r Ar rootdir .Fl N .Nm .Op Fl 46d -.Op Fl j Ar jail -.Op Fl r Ar rootdir .Cm bootstrap .Op Fl fy .Op Fl r Ar reponame @@ -69,14 +61,14 @@ will bootstrap the real .Xr pkg 8 from a remote repository. .Bl -tag -.It Nm Oo Fl j Ar jail Oc Oo Fl r Ar rootdir Oc Ar command ... +.It Nm Ar command ... If .Xr pkg 8 is not installed yet, it will be fetched, have its signature verified, installed, and then have the original command forwarded to it. If already installed, the command requested will be forwarded to the real .Xr pkg 8 . -.It Nm Oo Fl j Ar jail Oc Oo Fl r Ar rootdir Oc Cm add Oo Fl fy Oc Oo Fl r Ar reponame Oc Ar pkg.pkg +.It Nm Cm add Oo Fl fy Oc Oo Fl r Ar reponame Oc Ar pkg.pkg Install .Xr pkg 8 from a local package instead of fetching from remote. @@ -96,13 +88,13 @@ If a .Ar reponame has been specified, then the signature configuration for that repository will be used. -.It Nm Oo Fl j Ar jail Oc Oo Fl r Ar rootdir Oc Fl N +.It Nm Fl N Do not bootstrap, just determine if .Xr pkg 8 is actually installed or not. Returns 0 and the number of packages installed if it is, otherwise 1. -.It Nm Oo Fl 46d Oc Oo Fl j Ar jail Oc Oo Fl r Ar rootdir Oc Cm bootstrap Oo Fl fy Oc \ +.It Nm Oo Fl 46 Oc Cm bootstrap Oo Fl fy Oc \ Oo Fl r Ar reponame Oc Attempt to bootstrap and do not forward anything to .Xr pkg 8 @@ -139,16 +131,6 @@ May be specified more than once to increase the level of detail. When specified twice, .Xr fetch 3 debug output is enabled. -.It Fl j Ar jail , Fl -jail Ar jail -Attach to the jail designated by the name or numerical identifier -.Ar jail . -Note that -.Nm -will attach to the jail immediately upon encountering this option, so -any paths should be relative to the root of the jail. -.It Fl r Ar rootdir , Fl -rootdir Ar rootdir -Operate on the system rooted at -.Ar rootdir . .El .Sh CONFIGURATION Configuration varies in whether it is in a repository configuration file diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 3621081504cc..33a404474cf2 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -28,7 +28,8 @@ */ #include -#include +#include +#include #include #include @@ -40,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -92,8 +92,6 @@ struct fingerprint { }; static const char *bootstrap_name = "pkg.pkg"; -static const char *rootdir = NULL; -static int rootd = -1; STAILQ_HEAD(fingerprint_list, fingerprint); @@ -170,8 +168,7 @@ extract_pkg_static(int fd, char *p, int sz) { struct archive *a; struct archive_entry *ae; - const char *name, *end; - char *rname; + char *end; int ret, r; ret = -1; @@ -195,22 +192,11 @@ extract_pkg_static(int fd, char *p, int sz) ae = NULL; while ((r = archive_read_next_header(a, &ae)) == ARCHIVE_OK) { - name = archive_entry_pathname(ae); - end = strrchr(name, '/'); + end = strrchr(archive_entry_pathname(ae), '/'); if (end == NULL) continue; if (strcmp(end, "/pkg-static") == 0) { - if (rootdir) { - if (asprintf(&rname, "%s%s", rootdir, name) < 0) - err(1, NULL); - archive_entry_copy_pathname(ae, rname); - free(rname); - } - if (debug) { - fprintf(stderr, "extracting %s...\n", - archive_entry_pathname(ae)); - } r = archive_read_extract(a, ae, ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_ACL | @@ -235,56 +221,28 @@ cleanup: static int install_pkg_static(const char *path, const char *pkgpath, bool force) { - const char *argv[16]; - int argc = 0; int pstat; pid_t pid; - /* assemble the command line */ - argv[argc++] = "pkg-static"; - if (rootdir) { - argv[argc++] = "-r"; - argv[argc++] = rootdir; - } - argv[argc++] = "add"; - if (rootdir) { - /* - * Installing into an empty directory will normally fail - * because none of the shared libraries required by pkg - * are present, but pkg-static will still work and can be - * used to install a packaged base, so tell pkg-static to - * ignore missing dependencies. - */ - argv[argc++] = "-M"; - } - if (force) - argv[argc++] = "-f"; - argv[argc++] = pkgpath; - argv[argc] = NULL; - assert((size_t)argc < sizeof(argv) / sizeof(*argv)); - - if (debug) { - fprintf(stderr, "%s", path); - for (int i = 1; i < argc; i++) - fprintf(stderr, " %s", argv[i]); - fprintf(stderr, "\n"); - } - - /* fork and exec */ - if ((pid = fork()) < 0) + switch ((pid = fork())) { + case -1: return (-1); - if (pid == 0) { - /* child */ - execv(path, __DECONST(char **, argv)); + case 0: + if (force) + execl(path, "pkg-static", "add", "-f", pkgpath, + (char *)NULL); + else + execl(path, "pkg-static", "add", pkgpath, + (char *)NULL); _exit(1); + default: + break; } - /* wait for pkg-static to complete */ while (waitpid(pid, &pstat, 0) == -1) if (errno != EINTR) return (-1); - /* check the result */ if (WEXITSTATUS(pstat)) return (WEXITSTATUS(pstat)); else if (WIFSIGNALED(pstat)) @@ -988,7 +946,7 @@ static const char non_interactive_message[] = static const char args_bootstrap_message[] = "Too many arguments\n" -"Usage: pkg [-46d] [-r rootdir] bootstrap [-f] [-y]\n"; +"Usage: pkg [-4|-6] bootstrap [-f] [-y]\n"; static int pkg_query_yes_no(void) @@ -1020,7 +978,7 @@ bootstrap_pkg_local(const char *pkgpath, bool force) fd_sig = -1; ret = -1; - fd_pkg = open(pkgpath, O_RDONLY | O_CLOEXEC); + fd_pkg = open(pkgpath, O_RDONLY); if (fd_pkg == -1) err(EXIT_FAILURE, "Unable to open %s", pkgpath); @@ -1034,8 +992,7 @@ bootstrap_pkg_local(const char *pkgpath, bool force) snprintf(path, sizeof(path), "%s.sig", pkgpath); - fd_sig = open(path, O_RDONLY | O_CLOEXEC); - if (fd_sig == -1) { + if ((fd_sig = open(path, O_RDONLY)) == -1) { fprintf(stderr, "Signature for pkg not " "available.\n"); goto cleanup; @@ -1048,8 +1005,7 @@ bootstrap_pkg_local(const char *pkgpath, bool force) snprintf(path, sizeof(path), "%s.pubkeysig", pkgpath); - fd_sig = open(path, O_RDONLY | O_CLOEXEC); - if (fd_sig == -1) { + if ((fd_sig = open(path, O_RDONLY)) == -1) { fprintf(stderr, "Signature for pkg not " "available.\n"); goto cleanup; @@ -1119,9 +1075,9 @@ main(int argc, char *argv[]) { char pkgpath[MAXPATHLEN]; char **original_argv; - const char *localbase, *pkgarg, *repo_name; + const char *pkgarg, *repo_name; bool activation_test, add_pkg, bootstrap_only, force, yes; - int ch, jid; + signed char ch; const char *fetchOpts; struct repositories *repositories; @@ -1137,35 +1093,21 @@ main(int argc, char *argv[]) struct option longopts[] = { { "debug", no_argument, NULL, 'd' }, - { "jail", required_argument, NULL, 'j' }, { "only-ipv4", no_argument, NULL, '4' }, { "only-ipv6", no_argument, NULL, '6' }, - { "rootdir", required_argument, NULL, 'r' }, { NULL, 0, NULL, 0 }, }; - localbase = getlocalbase(); - while (localbase[0] == '/' && localbase[1] == '/') - localbase++; - snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", localbase); + snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", getlocalbase()); - while ((ch = getopt_long(argc, argv, "+:djNr:46", longopts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "+:dN46", longopts, NULL)) != -1) { switch (ch) { case 'd': debug++; break; - case 'j': - if ((jid = jail_getid(optarg)) == -1) - err(1, "%s", jail_errmsg); - if (jail_attach(jid) != 0) - err(1, "jail_attach(%s)", optarg); - break; case 'N': activation_test = true; break; - case 'r': - rootdir = optarg; - break; case '4': fetchOpts = "4"; break; @@ -1265,14 +1207,7 @@ main(int argc, char *argv[]) } } - if (rootdir) { - rootd = open(rootdir, O_DIRECTORY | O_SEARCH | O_CLOEXEC); - if (rootd < 0) - err(1, "%s", rootdir); - } - - if ((bootstrap_only && force) || - faccessat(rootd, pkgpath + 1, X_OK, 0) == -1) { + if ((bootstrap_only && force) || access(pkgpath, X_OK) == -1) { struct repository *repo; int ret = 0; /* @@ -1324,8 +1259,7 @@ main(int argc, char *argv[]) if (bootstrap_only) exit(EXIT_SUCCESS); } else if (bootstrap_only) { - printf("pkg already bootstrapped at %s%s\n", - rootdir ? rootdir : "", pkgpath); + printf("pkg already bootstrapped at %s\n", pkgpath); exit(EXIT_SUCCESS); }