Commit Graph

147 Commits

Author SHA1 Message Date
Warner Losh
4d65a7c695 usr.sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
John Baldwin
fd9ae9ac04 pkg: Allocate a suitably-sized string for the local ABI
Previously the local ABI string was written to an on-stack buffer and
the pointer to that buffer was saved in a global before the function
returned.  This had two issues: c[ABI].val pointed to a
no-longer-valid on-stack buffer after config_init returned, and the
string could potentially be truncated.  Fix both of those by changing
pkg_get_myabi to return a pointer to a string allocated by asprintf.

Note that the allocated string is left in the global config array
until it is implicitly freed on process exit.

Reported by:	GCC 13 -Wdangling-pointer
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42623
2023-11-15 16:53:53 -08:00
Baptiste Daroussin
d557a86c87 pkg: use https by default
Switch the repository to use https by default, base is providing a CA
root bundle suitable to validate the certificates used by the project.
This can now be activated without requiring another packages to be installed

Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D40473
2023-09-11 17:41:32 +02:00
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Baptiste Daroussin
e5dd5bfa55 pkg(7): now that we do use libmd, use it completly
Use SHA256_Fd and SHA256_Data instead of home made equivalent.
wrap those functions into hash.c to avoid header collition between
openssl and libmd

Suggested by:	kevans
2023-03-09 21:31:30 +01:00
Baptiste Daroussin
b2654064c2 pkg(7): use libmd for sha256 instead of openssl
OpenSSL 3.0 has deprecated the sha256 api, let's use libmd which has the
same API instead.

In order to avoid the collision in definitions (sha256.h cannot be
included in the same file as a file where openssl headers has been
included) let's move the sha256 related code in its own file

PR:		270023
Reported by:	ngie
2023-03-09 17:43:01 +01:00
Kyle Evans
c816aea7ab Revert "grep: remove tautological condition"
This reverts commit f6d6c66889.

Gremlins snuck into my tree and injected some WIP.
2023-03-08 23:52:23 -06:00
Kyle Evans
f6d6c66889 grep: remove tautological condition
st_size is an off_t, it cannot hold values larger than OFF_MAX.

CID:		1008931
2023-03-08 23:34:22 -06:00
Gordon Bergling
990878b07f pkg(8): Remove a double word in a source code comment
- s/that that/that/

MFC after:	3 days
2022-09-04 17:28:16 +02:00
Brooks Davis
e9ad2964f5 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
2022-08-24 18:32:09 +01:00
John Hood
60b92ba932 /usr/sbin/pkg: don't sleep on fetch failure
PR:	263458
2022-07-28 17:55:13 +02:00
Mateusz Piotrowski
3beedc3840 pkg.7: Clean up mdoc
MFC after:	1 week
2022-06-30 16:22:02 +02:00
Ed Maste
f92e0d6acd pkg-bootstrap: use latest package set on arm64 stable branches
As with i386 and amd64, "latest" packages are available on stable
branches for arm64/aarch64.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35445
2022-06-13 14:57:10 -04:00
Emmanuel Vadot
ec0ea6efa1 pkgbase: Add a FreeBSD-pkg-bootstrap package
And put pkg and its keys in it.
It's easier for small image to depend on this package rather than the
larger utilities one.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33458
2021-12-21 10:17:48 +01:00
Gleb Smirnoff
c96b4d87ba pkg: fix regression that breaks bootstrap from not a current directory.
Fixes:		40b9f924b1
Reviewed by:	kevans
2021-09-10 14:49:17 -07:00
Kyle Evans
d35164539b pkg: use specific CONFSNAME_${file} for FreeBSD.conf
Setting CONFSNAME directly is a little more complicated for downstream
consumers, as any additional CONFS that are added here will inherit the
group name by default.  This is perhaps arguably a design flaw in CONFS
because inheriting NAME will never give a good result when additional
files are added, but this is a low-effort change.

While we're here, pull FreeBSD.conf.${branch} out into a PKGCONF
variable so one can just drop a new repo config in entirely with a new
naming scheme. CONFSNAME gets set based on chopping anything off after
".conf", so that, e.g.:

- FooBSD.conf => FooBSD.conf
- FooBSD.conf.internal => FooBSD.conf

Reviewed by:	bapt, manu
Differential Revision:	https://reviews.freebsd.org/D28767
2021-08-06 14:25:45 -05:00
Kyle Evans
40b9f924b1 pkg: allow multiple add arguments again
While pkg(7) add only handles a single 'add' argument, pkg-add(8) fully
handles multiple arguments.

Stop rejecting it, just turn off local-bootstrap mode and proceed to
remote bootstrap if we need it.

While we're here, check if the first argument to pkg add is even a pkg
package. If it's not, also do remote bootstrap instead. Future work
could improve this altogether by picking out a pkg package out of many
and local bootstrap then pass the rest through to the newly installed
pkg.

Reviewed by:	bapt, manu (earlier version)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D28766
2021-08-06 14:25:07 -05:00
Baptiste Daroussin
cc9a8a116d pkg(7): replace usage of sbuf(9) with open_memstream(3)
open_memstream(3) is a standard way to obtain the same feature we do get
by using sbuf(9) (aka dynamic size buffer), switching to using it makes
pkg(7) more portable, and reduces its number of dependencies.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D30005
2021-04-29 06:41:59 +02:00
Baptiste Daroussin
f648d757b7 pkg(7): indentation fixes
Non functional changes
2021-04-29 06:41:34 +02:00
Moritz Schmitt
e869d3c601 Make pkg(7) use environment variables specified in pkg.conf
Modify /usr/sbin/pkg to use environment variables specified in pkg.conf.
This allows control over underlying libraries like fetch(3), which can
be configured by setting HTTP_PROXY.

MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D29820
2021-04-27 04:01:49 +02:00
Baptiste Daroussin
c244b1d8a3 pkg: settle the uniq extension to .pkg instead of .bsd
Requested by:	many
2021-03-16 16:19:52 +01:00
Baptiste Daroussin
a2aac2f5e5 pkg(7): when bootstrapping first search for pkg.bsd file then pkg.txz
The package extension is going to be changed to .bsd to be among other
things resilient to the change of compression format used and reduce
the impact of all third party tool of that change.

Ensure the bootstrap knows about it

Reviewed by:	manu
Differential revision:	https://reviews.freebsd.org/D29232
2021-03-15 17:52:22 +01:00
Kyle Evans
b2c4ca8d28 pkg(7): address minor nits (mostly clang-analyze complaints)
- One (1) spurious whitespace.
- One (1) occurrence of "random(3) bad, arc4random(3)" good.
- Three (3) writes that will never be seen.

The latter two points are complaints from clang-analyze. Switching to
arc4random(3) is decidedly a good idea because we weren't doing any kind
of PRNG seeding anyways. The discarded assignments are arguably good
for future-proofing, but it's better to improve the S/N ratio from
clang-analyze.

Reviewed by:	bapt, manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28525
2021-02-11 18:58:27 -06:00
Kyle Evans
18418e1936 pkg(7): add an -r reponame option for bootstrap and add
This is limited to bootstrap/add because some real pkg(8) commands
have -r flags with an incompatible meaning/usage, e.g., pkg-audit.
pkg(7) will still commence the search as it has, but it will ignore any
repo objects without the given name so that overrides and whatnot still
work as expected.

The use of it for add is noted in the manpage; notably, that the
signature config for that repository will be used over global config if
it's specified. i.e., pkg(7) should assume that the given pkg did come
from that repository and treat it appropriately.

Reviewed by:	bapt, manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28524
2021-02-11 18:58:26 -06:00
Alex Richardson
9a0a48b12d usr.sbin/pkg: Don't re-define roundup2
The file already includes sys/param.h and should use that definition.
I found this while testing D28332.

Reviewed By:	bapt
Differential Revision: https://reviews.freebsd.org/D28331
2021-01-28 17:25:53 +00:00
Baptiste Daroussin
ae994fdc5b pkg(7): rework the arguments handling
Rework the arguments handling around using getopt_long:
* add long option support
* add -4 and -6 support to enforce ipv4 or ipv6

While here fix a regression which occured between FreeBSD 12.1 and
FreeBSD 12.2 where pkg bootstrap -y stopped working

PR:		252270
MFC after:	2 weeks
Submitted by:	evilham <contact@evilham.com>
Differential Revision:	https://reviews.freebsd.org/D27860
2021-01-06 11:47:34 +01:00
Stefan Eßer
56d11d4a37 Make use of the getlocalbase() function for run-time adjustment of the
local software base directory, as committed in SVN rev. 367813.

The pkg and mailwrapper programs used the LOCALBASE environment variable
for this purpose and this functionality is preserved by getlocalbase().

After this change, the value of the user.localbase sysctl variable is used
if present (and not overridden in the environment).

The nvmecontrol program gains support of a dynamic path to its plugin
directory with this update.

Differential Revision:	https://reviews.freebsd.org/D27237
2020-11-18 20:00:55 +00:00
Scott Long
8e1031086d Revert the whole getlocalbase() set of changes while a different design is
hashed out.
2020-11-15 20:24:59 +00:00
Scott Long
1b249101df Fix the previous revision, it suffered from an incomplete change to the
getlocalbase API.  Also don't erroneously subtract the lenth from the
buffer a second time.
2020-11-15 07:50:29 +00:00
Scott Long
7ca0d5403e Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3
Reviewed by:	imp, se
2020-11-14 18:01:14 +00:00
John-Mark Gurney
e771d59074 fix up docs, if signature checking is enabled, the file MUST exist... 2020-11-06 22:11:05 +00:00
Stefan Eßer
1f474190fc Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE
Literal references to /usr/local exist in a large number of files in
the FreeBSD base system. Many are in contributed software, in configuration
files, or in the documentation, but 19 uses have been identified in C
source files or headers outside the contrib and sys/contrib directories.

This commit makes it possible to set _PATH_LOCALBASE in paths.h to use
a different prefix for locally installed software.

In order to avoid changes to openssh source files, LOCALBASE is passed to
the build via Makefiles under src/secure. While _PATH_LOCALBASE could have
been used here, there is precedent in the construction of the path used to
a xauth program which depends on the LOCALBASE value passed on the compiler
command line to select a non-default directory.

This could be changed in a later commit to make the openssh build
consistently use _PATH_LOCALBASE. It is considered out-of-scope for this
commit.

Reviewed by:	imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D26942
2020-10-27 11:29:11 +00:00
Baptiste Daroussin
ae659caa0a Use asprintf instead of sbuf 2020-10-19 07:26:42 +00:00
Kyle Evans
ca7f7593ba pkg-bootstrap: complain on improper pkg bootstrap usage
Right now, the bootstrap will gloss over things like pkg bootstrap -x or
pkg bootstrap -f pkg. Make it more clear that this is incorrect, and hint
at the correct formatting.

Reported by:	jhb (IIRC via IRC)
Approved by:	bapt, jhb, manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24750
2020-07-22 17:33:35 +00:00
Tom Jones
a10f71c53a pkg: Provide a friendlier message when bootstrap fails due to address resolution
The current message when bootstapping pkg fails for any reason implies that pkg
is not available. We have the error code from fetch so if bootstrap failed due
to address resolution say so.

Reviewed by:    bapt, bz
Approved by:    bz (co-mentor)
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D25323
2020-06-23 15:14:54 +00:00
Glen Barber
48c8f7d454 Rework the logic for installing the pkg(8) configuration.
'quarterly' package sets do not exist for head, so explicitly
install the 'latest' configuration file there.  Otherwise,
fall back to the original conditional evaluation to determine
if the 'latest' or 'quarterly' configuration file should be
installed.

Reported by:	manu
Reviewed by:	manu
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-08 18:58:23 +00:00
Glen Barber
5f6bb72e7f Apply r346792 (cperciva) from stable/12 to head. The original commit
message:

 On non-x86 systems, use "quarterly" packages.

 x86 architectures have "latest" package builds on stable/*, so keep using
 those (they'll get switched over to "quarterly" during releases).

The original commit was a direct commit to stable/12, as at the time it
was presumed it would not be necessary for head.  However, when it is time
to create a releng branch or switch from PRERELEASE/STABLE to BETA/RC, the
pkg(7) Makefile needs further adjusting.  This commit includes those
further adjustments, evaluating the BRANCH variable from release/Makefile
to determine the pkg(7) repository to use.

MFC after:	immediate (if possible)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-09-19 16:43:12 +00:00
Colin Percival
0b18e008cc Keep two versions of the FreeBSD.conf pkg configuration file; one which
points at the "latest" branch and one which points at the "quarterly"
branch.  Install the "latest" version unless overridden via the newly
added PKGCONFBRANCH variable.

This does not change user-visible behaviour (assuming said vairable is
not set) but will make it easier to change the defaults in the future --
on stable branches we will want "latest" on x86 but "quarterly" elsewhere.

Discussed with:	gjb
MFC after:	3 days
X-MFC:		After MFCing this I'll make a direct commit to stable/* to
		switch non-x86 architectures to "quarterly".
2019-04-24 06:25:21 +00:00
Brad Davis
5836319ae6 Move pkg/FreeBSD.conf to usr.sbin/pkg/
Approved by:	bapt (mentor)
Differential Revision:	https://reviews.freebsd.org/D16491
2018-07-31 16:42:03 +00:00
Baptiste Daroussin
8e877d85dc pkg: accept -y and --yes from arguments
By popular demand, pkg now walks thought the arguments passed and
if it finds -y or --yes it does accept those as equivalent of
ASSUME_ALWAYS_YES env var.

Requested by:	many
MFC after:	1 week
2018-04-13 18:25:00 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Poul-Henning Kamp
67c9f60e86 Flush stdout before yes/no confirmations, to force question
through pipes/tee(1)/whatever
2017-05-03 20:41:26 +00:00
Enji Cooper
64a0982bee usr.sbin: normalize paths using SRCTOP-relative paths or :H when possible
This simplifies make logic/output

MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-03-04 11:38:03 +00:00
Baptiste Daroussin
7556d9b06a Remove usage of _WITH_GETLINE from usr.sbin 2016-07-30 01:10:05 +00:00