Commit graph

147 commits

Author SHA1 Message Date
Baptiste Daroussin 1da56163f2 Remove some unneeded headers 2016-01-13 17:59:12 +00:00
Baptiste Daroussin 4c79e0d6c1 Remove extra debug that crept in 2015-09-08 22:24:20 +00:00
Baptiste Daroussin 61acb4582f Implement pubkey support for the bootstrap
Note that to not interfer with finger print it expects a signature on pkg itself
which is named pkg.txz.pubkeysign

To genrate it:
echo -n "$(sha256 -q pkg.txz)" | openssl dgst -sha256 -sign /thekey \
    -binary -out ./pkg.txz.pubkeysig

Note the "echo -n" which prevent signing the '\n' one would get otherwise

PR:		202622
MFC after:	1 week
2015-09-08 21:25:36 +00:00
Baptiste Daroussin b50756c759 Fix indentation, no functional changes 2015-09-08 19:25:15 +00:00
Xin LI f595a30ba0 Plug a possible memory leak.
MFC after:	2 weeks
2015-08-27 06:28:42 +00:00
Xin LI 48f9270689 Issue warning and refuse to proceed further if the configured
repository signature_type is unsupported by bootstrap pkg(7).

Previously, when signature_type specified an unsupported method,
the bootstrap pkg(7) would proceed like when signature_type is
"none".  MITM attackers may be able to use this vulnerability and
bypass validation and install their own versions of pkg(8).

At this time, only fingerprint and none are supported by the
bootstrap pkg(7).

FreeBSD's official pkg(8) repository uses the fingerprint method
and is therefore unaffected.

Errata candidate.

Discussed with:	bapt@
Submitted by:	Fabian Keil
Obtained from:	ElectroBSD
2015-08-19 18:24:39 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Baptiste Daroussin cc36fe4926 Allow fetching pkg(8) even if servers/proxies are not passing Content-length 2015-04-03 17:35:30 +00:00
Baptiste Daroussin 79fe80ef10 Test the return of fetchParseURL(3)
CID:		1125811
MFC after:	1 week
2015-02-04 00:18:06 +00:00
Baptiste Daroussin 92947daacf Plug resources leak
CID:		1125813
CID:		1125807
CID:		1125808
MFC after:	1 week
2015-02-04 00:10:57 +00:00
Baptiste Daroussin c6db8143ed Convert usr.sbin to LIBADD
Reduce overlinking
2014-11-25 16:57:27 +00:00
Simon J. Gerraty 488c975a1f Updated/new dependencies 2014-11-19 07:10:38 +00:00
Simon J. Gerraty 9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Nathan Whitehorn ffcaf4d24f Remove spurious libelf dependency.
Submitted by:	pluknet
2014-10-28 14:11:54 +00:00
Nathan Whitehorn 60b9a1fcf3 Use pkg-1.4-style platform identifiers based on MACHINE_ARCH (e.g.
FreeBSD:11:amd64 instead of freebsd:11:x86:64) when bootstrapping pkg.
Thanks to portmgr for providing symlinks so both styles work.

Reviewed by:	bapt
MFC after:	3 weeks
2014-10-27 23:19:51 +00:00
Simon J. Gerraty ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Baptiste Daroussin d029c3aa25 Rework privatelib/internallib
Make sure everything linking to a privatelib and/or an internallib does it directly
from the OBJDIR rather than DESTDIR.
Add src.libnames.mk so bsd.libnames.mk is not polluted by libraries not existsing
in final installation
Introduce the LD* variable which is what ld(1) is expecting (via LDADD) to link to
internal/privatelib
Directly link to the .so in case of private library to avoid having to complexify
LDFLAGS.

Phabric:	https://phabric.freebsd.org/D553
Reviewed by:	imp, emaste
2014-08-06 22:17:26 +00:00
Gavin Atkinson 4622bc4e31 When we fail to extract the pkg binaries (for example, / is read-only),
give a more helpful error message.

MFC after:	1 week
2014-07-16 00:12:57 +00:00
Marcel Moolenaar e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Baptiste Daroussin b04a7a0baf Import libucl 0.4.0
Adapt pkg(7) to the new libucl API
2014-04-22 22:02:06 +00:00
Bryan Drewery 4d3b6a7866 Add missing LIBM to DPADD from r263650
Reported by:	jilles
2014-03-24 13:13:52 +00:00
Bryan Drewery 825ab35431 Fix build with libucl 20140321 2014-03-22 22:20:43 +00:00
Bryan Drewery 197372c28d Fix ASSUME_ALWAYS_YES not being parsed properly from config after UCL conversion.
Sponsored by:	EMC / Isilon Storage Division
MFC after:	1 week
2014-03-14 17:37:38 +00:00
Bryan Drewery 97c3a76638 Fix ABI from /usr/local/etc/pkg.conf not being respected.
Regression from r259266.

Sponsored by:	EMC / Isilon Storage Division
MFC after:	1 week
2014-03-14 17:20:45 +00:00
Baptiste Daroussin d8cfb94376 Remove a useless newline, warnx already appends a newline 2014-02-23 23:49:10 +00:00
Baptiste Daroussin 0ad5dbac61 Update my copyright 2014-02-23 22:04:03 +00:00
Baptiste Daroussin 8a7d859ebf Switch pkg(7) from libyaml to libucl 2014-02-23 21:55:07 +00:00
Baptiste Daroussin a351c93d95 Implicit include of sys/queue.h instead of relying on gelf.h/libelf.h to bring it
Newer version of gelf.h and libelf.h does not include sys/queue.h anymore

Submitted by:	kaiw
MFC after:	3 days
2014-01-20 22:54:11 +00:00
Baptiste Daroussin 1efc897026 Fix yet another typo
Reported by:	kib
2013-12-23 17:47:04 +00:00
Baptiste Daroussin e9d9ee5218 Fix typos
Reported by:	bryanv
2013-12-23 17:26:56 +00:00
Baptiste Daroussin 575c4095bf Do not print a question in non-interractive mode but explain why boostrapping
has failed and how to allow it to happen

Reported by:	jmmv
2013-12-23 17:16:44 +00:00
Bryan Drewery eb31a57474 Fix multi-repository support by properly respecting 'enabled' flag.
This will read the REPOS_DIR env/config setting (default is /etc/pkg
and /usr/local/etc/pkg/repos) and use the last enabled repository.

This can be changed in the environment using a comma-separated list,
or in /usr/local/etc/pkg.conf with JSON array syntax of:
    REPOS_DIR: ["/etc/pkg", "/usr/local/etc/pkg/repos"]

Approved by:	bapt
MFC after:	1 week
2013-12-12 17:59:09 +00:00
Baptiste Daroussin d8d2111e85 Do not create pkg.conf, as it is not necessary anymore and packagesite is deprecated
Reported by:	glebius
MFC after:	3 days
2013-11-25 11:31:42 +00:00
Bryan Drewery d6ea27390b Follow-up to r258227 and document 'enabled' as a boolean instead of
a string.

Approved by:	bapt
MFC after:	2 days
X-MFC-With:	r258227
2013-11-19 15:43:27 +00:00
Baptiste Daroussin 46b67ede12 argc is now used
MFC after:	2 days
2013-11-16 15:48:49 +00:00
Bryan Drewery 0e088eec8f Remove useless checks for NULL pointer before free(3)
Reported by:		eadler
Approved by:		eadler
2013-11-11 21:42:31 +00:00
Gleb Smirnoff d2201d13a7 Do not use just freed memory.
Sponsored by:	Nginx, Inc.
2013-11-11 07:44:09 +00:00
Bryan Drewery 5494cb5f12 Remove condition which can never be true as the previous loop
is never exited while remote == NULL.

Reported by:	Coverity
Approved by:	bapt
MFC after:	2 days
2013-11-05 13:36:05 +00:00
Bryan Drewery cecc016791 Use proper capitalization for FreeBSD.org
Approved by:	bapt
MFC after:	2 days
2013-11-05 02:22:04 +00:00
Bryan Drewery 5212e8bacf Add -f support to 'pkg bootstrap' and 'pkg add' to force installation
of pkg(8) even if already installed.

This is useful if you somehow messup pkg(8) and need to reinstall from
remote with it already being registered in the pkg(8) /var/db/pkg database.

Also add some sanity checks to 'pkg add'.

Approved by:	bapt
MFC after:	2 days
2013-11-01 12:37:36 +00:00
Joel Dahl 7660932692 A few minor mdoc improvements. 2013-10-30 21:49:38 +00:00
Bryan Drewery 5eb90b9ac3 Add a pkg(7) manpage for bootstrap
Approved by:	bapt
MFC after:	2 days
2013-10-30 10:39:14 +00:00
Bryan Drewery c3e8a27aab Add a 'pkg bootstrap' command which will bootstrap pkg(8) without
forwarding any command to it after installation.

This is useful if the only goal is to install pkg(8) without any extra
output.

Requested by:	cperciva
Approved by:	bapt
MFC after:	2 days
2013-10-30 10:17:16 +00:00
Bryan Drewery c2788c07bf Fix build with GCC.
BIO_new_mem_buf takes a void* buf, but internally it never modifies the
buf. It assigns the buffer to another pointer and then marks it as
read-only. So deconsting it should be safe here.

Also fix warning about 'buf' possibly being unused in parse_cert()

Approved by:	bapt
MFC after:	2 days
X-MFC-With:	r257147
2013-10-26 19:59:42 +00:00
Bryan Drewery 029df170ca Link in libcrypto as well to fix build in some cases.
Approved by:	bapt
MFC after:	2 days
Reported by:	many
2013-10-26 13:38:49 +00:00
Bryan Drewery 52cb76fe60 Add support to check the signature of a local pkg.txz file being
added with "pkg add". If the pkg.conf is configured to check for
signature, then the pkg.txz.sig file will be expected and validated
per r257147

Approved by:	bapt
MFC after:	2 days
2013-10-26 03:47:49 +00:00
Bryan Drewery 516aaf7cf8 Tell which fingerprint pkg is being validated against.
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:44:08 +00:00
Bryan Drewery f12db248e7 Support checking signature for pkg bootstrap.
If the pkg.conf is configured with SIGNATURE_TYPE: FINGERPRINTS,
and FINGERPRINTS: /etc/keys/pkg then a pkg.sig file is fetched along
with pkg.txz. The signature contains the signature provided by the
signing server, and the public key. The .sig is the exact output
from the signing server in the following format:

  SIGNATURE
  <openssl signed>
  CERT
  <rsa public key>
  END

The signature is verified with the following logic:

 - If the .sig file is missing, it fails.
 - If the .sig doesn't validate, it fails.
 - If the public key in the .sig is not in the known trusted fingerprints,
   it fails.
 - If the public key is in the revoked key list, it fails.

Approved by:	bapt
MFC after:	2 days
Discussed by:	bapt with des, jonathan, gavin
2013-10-26 03:43:02 +00:00
Bryan Drewery 95073c2d2e Be verbose and tell where pkg(8) is being bootstrapped from.
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:32:06 +00:00
Bryan Drewery bc5e9ac08d Add support for reading configuration files from /etc/pkg.
For now only /etc/pkg/FreeBSD.conf is supported. Its style is:

Repo: {
   URL: "...",
   MIRROR_TYPE: "...",
   ...
}

The configuration will be read from /usr/local/etc/pkg.conf if exists,
otherwise /etc/pkg/FreeBSD.conf

Approved by:	bapt
MFC after: 	2 days
2013-10-26 03:31:05 +00:00
Bryan Drewery 4ff9a7ef08 Wrap long lines
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:21:08 +00:00
Bryan Drewery 62940ea951 Add support for using "pkg+http://" for the PACKAGESITE.
pkg 1.2 is adding this support as well. This should help
lessen the confusion on why the default SRV PACKAGESITE
does not load in a browser.

Adapated from:	matthew's upstream pkg change
Approved by:	bapt
MFC after:	2 days
2013-10-24 10:49:55 +00:00
Baptiste Daroussin 959bd87986 Fix build with gcc
MFC after:	3 days
2013-10-23 15:29:42 +00:00
Baptiste Daroussin b70213b5c7 Allow to bootstrap by doing pkg add ./a/path/to/a/pkg_package.txz
Requested by:	many
MFC after:	3 days
2013-10-23 14:23:48 +00:00
Baptiste Daroussin 35e07a7a52 Improve SRV records support for the pkg(8) bootstrap:
- order srv records by priorities
- for all entries of the same priority, order randomly respect the weight
- select the port where to fetch from respect the port provided in the SRV record

Obtained from:	pkg git repo
MFC after:	3 days
2013-10-23 14:06:07 +00:00
Gavin Atkinson 65008e03e7 Improve bootstrapping message
MFC after:	3 days
2013-10-19 15:36:21 +00:00
Bryan Drewery e3ededfa24 Rename libbsdyml to libyaml, make private, and bump
SHLIB_MAJOR to 1.0

Suggested by:	des
Approved by:	bapt
MFC after:	1 week
2013-10-14 18:31:15 +00:00
Simon J. Gerraty 34b33809b7 Updated dependencies 2013-10-13 00:24:00 +00:00
Simon J. Gerraty d466a5b069 Merge head 2013-09-11 18:16:18 +00:00
Baptiste Daroussin ad59bd68ad Cleanup elf macros
Only define EF_MIPS_ABI when not already supplied
Remove old now unused ARM macros

Reported by:	imp
Approved by:	re (kib)
2013-09-11 06:42:55 +00:00
Baptiste Daroussin 40274a2d65 Add support to detect arm vs armv6
There are two different versions of the ARM ABI depending on the
TARGET_ARCH. As these are sligntly different a package built for
one may not work on another. We need to detect which one we are on
by parsing the .ARM.attributes section.

This will only work on the ARM EABI as this section is part of the
ABI definition. As armv6 only supports the ARM EABI this is not a
problem for the oabi.

Older versions of libelf in FreeBSD fail to read the
.ARM.attributes section needed. As armv6 is unsupported on these
versions we can assume we are running on arm.

Submitted by:	andrew
Approved by:	re (delphij)
Obtained from:	pkgng git
2013-09-10 20:56:01 +00:00
Simon J. Gerraty d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Baptiste Daroussin 4b5ef056f1 Fix detection of arm ABIs
Submitted by:	andrew
Obtained from:	pkg git
2013-07-28 20:11:31 +00:00
Baptiste Daroussin 8ad6d9175c Fix a bad calloc(3) call
MFC after:	2 weeks
2013-06-08 23:48:13 +00:00
Simon J. Gerraty 89e0f621b2 New/updated dependencies 2013-04-14 01:22:39 +00:00
Simon J. Gerraty 69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Antoine Brodin 1f9712deb7 Fix a typo in DPADD. 2013-03-10 17:10:16 +00:00
Baptiste Daroussin 968d04c371 Fix bootstrapping pkgng by not appending "/latest/" to PACKAGESITE.
Reporter by :	Alexander Yerenkow (via irc)
2013-03-08 10:43:03 +00:00
Baptiste Daroussin d5bf8a8b57 choose in priority the allocated ABI if any to do the ${ABI} substitution in PACKAGESITE
Reviewed by:	bdrewery
2013-03-05 14:08:36 +00:00
Baptiste Daroussin 9950eceee6 Add the ability to correctly read pkg.conf is exists.
Only look for boostrap useful options:
 - PACKAGESITE
 - ABI
 - MIRROR_TYPE
 - ASSUME_ALWAYS_YES

While here makes PACKAGESITE expand the ${ABI} variable.
Allow to deactivate any SRV record look up (MIRROR_TYPE=none)
Use the same mechanism as for pkgng itself: first get configuration out of
environment variable and fallback on pkg.conf if exists.

Reviewed by:	bdrewery
2013-03-05 13:31:06 +00:00
Baptiste Daroussin ff75c36ae1 Do not use deprecated functions from libarchive 2013-02-20 22:51:42 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Baptiste Daroussin 86e220abc9 In case of failure of the pkg boostrap advice the user to either change the
PACKAGESITE they use or install from ports directly indicating where the port
is localted in the port collection

Submitted by:	kientzle
2013-02-14 12:42:09 +00:00
David E. O'Brien d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Baptiste Daroussin 8cc0ef19d2 Directly uses calloc(3) instread of malloc(3) + memset(3)
Reported by:	Jeremy Chadwick <jdc@koitsu.org>
MFC after:	3 days
2013-01-14 07:17:38 +00:00
Matthew Seaman e41b8acbd5 Remove extraneous space and new-line.
Submitted by:	pjd, gcooper
Approved by:	bapt
MFC after:	2 weeks
2012-12-23 20:39:03 +00:00
Matthew Seaman d8f9490c67 Third time's the charm. pkg -N output needs to go to stderr.
Approved by:	bapt
MFC after:	2 weeks
2012-12-23 11:22:18 +00:00
Matthew Seaman d482e1f4a6 Switch from 'pkg -n' to 'pkg -N' as the test for pkgn activation
status. '-n' is already used extensively elsewhere in pkgng (to mean
'dry-run') and this reduces the potential confusion

Submitted by:	eadler
Approved by:	bapt
MFC after:	2 weeks
2012-12-22 15:13:16 +00:00
Matthew Seaman ecfed9f2eb In preparation for making 'pkg -n' the one true method of determining
whether a system has been configured to use pkgng, cause /usr/sbin/pkg
recognise a -n option and exit with a failure code when the pkg port
is not installed.

Approved by:	bapt
MFC after:	2 weeks
2012-12-21 20:01:13 +00:00
Baptiste Daroussin 29aaa96159 if PACKAGESITE url scheme is not 'file://', always try to revolv SRV records and
use them if any. It allows the bootstrap to use directly pkg.FreeBSD.org instead
of pkgbeta.FreeBSD.org

MFC after:	1 month
2012-12-05 11:35:50 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Ed Schouten bf70becee6 More -Wmissing-variable-declarations fixes.
In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.
2012-10-19 14:49:42 +00:00
Baptiste Daroussin 204ea792b3 Fix confirmation logic when detecting a tty
Reported by:	mjg
2012-08-24 21:45:52 +00:00
Baptiste Daroussin 3a480126c4 - change ALWAYS_ASSUME_YES to ASSUME_ALWAYS_YES for consistency with pkg(8)
- if not on a tty prompt about the missing pkg(8) but default on 'no' except if
  ASSUME_ALWAYS_YES is set

MFC after:	2 days
2012-08-24 21:08:56 +00:00
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Alexander Kabaev e18ad51c15 Make pkg bootstrap program ask for confirmation before proceeding.
The previous behaviour was to silently download and install the pkg
package, without ever telling user about what it was doing and why.

Discussed with:	bapt
Reviewed by: kib
2012-07-15 04:15:27 +00:00
Baptiste Daroussin 514ead92ea Add missing \n when generating pkg.conf
Reported by:	beat
Approved by:	des (mentor)
MFC after:	1 day
2012-05-21 15:45:18 +00:00
Baptiste Daroussin 2fe3761e69 - close the open file after fetching
- create a default /usr/local/etc/pkg.conf

Approved by:	des (mentor)
2012-05-01 10:16:12 +00:00
Baptiste Daroussin a6454741a8 - Use _PATH_TMP instead of hardcoded /tmp
- more style(9) fixes
- some refactoring
- better error detection
- Add the DPADD to Makefile

Submitted by:	Garrett Cooper <yanegomi@gmail.com>
Approved by:	des (mentor)
2012-04-16 20:41:25 +00:00
Baptiste Daroussin 3b05c2a8a7 - Fix style(9) bugs + inconsistencies
Submitted by:	marius
Approved by:	des (mentor)
2012-04-15 18:32:14 +00:00
Baptiste Daroussin ce36f45d14 Do not do double initialisation
style(9) says for (;;) not while (1)

Reported by:	culot
Approved by:	des
2012-04-15 16:00:32 +00:00
Baptiste Daroussin 3aa4b42ae7 add usr.sbin/pkg which is a bootstrap tool for pkgng.
it respects PACKAGESITE, PACKAGEROOT, and a new environment variable ABI (if a user want to use a different API from the base one for its packages)
it has no man page on purpose to avoid hidding the pkg(8) man page from the pkgng package.
for now uses pkgbeta.FreeBSD.org as default mirror to find its package
it respects MK_PKGTOOLS

Approved by:	des (mentor)
2012-04-15 15:13:36 +00:00