Page MenuHomeFreeBSD

Add sanity checks for chroot/jail building and stop asking kernel for OSVERSION.
ClosedPublic

Authored by bdrewery on Sep 27 2014, 9:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 7, 5:51 AM
Unknown Object (File)
Sun, Apr 7, 5:51 AM
Unknown Object (File)
Feb 19 2024, 10:48 PM
Unknown Object (File)
Feb 19 2024, 10:40 PM
Unknown Object (File)
Feb 19 2024, 10:40 PM
Unknown Object (File)
Feb 19 2024, 10:25 PM
Unknown Object (File)
Jan 13 2024, 12:32 PM
Unknown Object (File)
Dec 24 2023, 11:49 PM
Subscribers

Details

Reviewers
gjb
bapt
Group Reviewers
portmgr
Summary

If either of OSVERSION or UNAME_r is improperly set when building in a
jail/chroot, a number of unexpected errors can occur.

  1. autotools fixup may not run when needed. This could be avoided by always running it [PR 177980, 177403]
  2. Not having UNAME_r set will cause many unknown errors. Many ports use OSREL (derived from UNAME_r) to determine the name of files. This is usually also due to the port build itself using uname -r to derive filenames or 'built for' messages. [PR 192449, 191943]

Without having these sanity checks it is very easy for users to get into
situations where "everything worked" until they touch a certain port that
reads uname or OSVERSION. It has always been necessary to define all of the
UNAME_ vars and OSVERSION (or have a proper sys/param.h present), but many
users do not know this.

Remove the fallback on the kernel for kern.osreldate as it easily gets the
answer wrong.

I have added sanity checks to ensure OSVERSION==OSREL==UNAME_r as these are the
most critical vars to have set properly.

Test Plan

Built cross-release in poudriere and on host.

uname -r; make OSVERSION=1000036 OSREL="11" clean

11.0-CURRENT
make: "/root/svn/ports/Mk/bsd.port.mk" line 1206: UNAME_r (11.0-CURRENT) and OSVERSION (1000036) do not agree on major version number.

uname -r;make OSVERSION=1000036 clean

11.0-CURRENT
make: "/root/svn/ports/Mk/bsd.port.mk" line 1206: UNAME_r (11.0-CURRENT) and OSVERSION (1000036) do not agree on major version number.

make OSVERSION=1000036 OSREL="11" UNAME_r="10.0-STABLE" clean

make: "/root/svn/ports/Mk/bsd.port.mk" line 1208: OSREL (11) and OSVERSION (1000036) do not agree on major version number.

make OSVERSION=1000036 UNAME_r="10.0-STABLE" clean

> Cleaning for beadm-1.1_1

make OSVERSION=1000036 OSREL="10" UNAME_r="10.0-STABLE" clean

> Cleaning for beadm-1.1_1

  1. mv /usr/include/sys/param.h{,.old}
  2. make -V SRC_BASE -V OSVERSION

/usr/src
1100036

make -V SRC_BASE -V OSVERSION SRC_BASE=/nonexistent

make: "/root/svn/ports/Mk/bsd.port.mk" line 1201: Unable to determine os version. Either define OSVERSION or install /usr/include/sys/param.h

make -V SRC_BASE -V OSVERSION SRC_BASE=/nonexistent OSVERSION=1000036

make: "/root/svn/ports/Mk/bsd.port.mk" line 1206: UNAME_r (11.0-CURRENT) and OSVERSION (1000036) do not agree on major version number.

make -V SRC_BASE -V OSVERSION SRC_BASE=/nonexistent OSVERSION=1000036 UNAME_r="10.0-STABLE"

/nonexistent
1000036

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bdrewery retitled this revision from to Add sanity checks for chroot/jail building and stop asking kernel for OSVERSION..
bdrewery updated this object.
bdrewery edited the test plan for this revision. (Show Details)
bdrewery added reviewers: portmgr, bapt.
bdrewery added subscribers: gjb, ngie.
antoine added inline comments.
Mk/bsd.port.mk
1206

${OSVERSION:C/([0-9]*)[0-9]{5}/\1/} is simpler and does the same?

bdrewery edited edge metadata.

Fix OSREL assignment.

gjb added a reviewer: gjb.

At quick (untested) review, this looks good to me.

bapt requested changes to this revision.Sep 28 2014, 8:46 PM
bapt edited edge metadata.

At least handling case like 5.2.1 should be done

Mk/bsd.port.mk
1201

This should be IGNORE to be consistent (I know the IGNORE variable sucks)
Or .error should be a propagated usage

1208

That will fail in case of the 11.1.1 release (which already happened in the past aka 5.2.1)

This revision now requires changes to proceed.Sep 28 2014, 8:46 PM
Mk/bsd.port.mk
1201

IGNORE does not work here. What is the problem with .error?

1208

I don't think so. The intent is to only grab the first 2 numbers since we have ABI stability on those.
sys/sys/param.h: scheme is: <major><two digit minor>Rxx
Major may be 1 or 2 long, the rest are fixed-width.

bapt edited edge metadata.
bapt added inline comments.
Mk/bsd.port.mk
1201

.error is probably ok

This revision is now accepted and ready to land.Sep 30 2014, 12:35 PM