Merge pull request #308138 from rhelmot/freebsd-minimal2/multiple-package-sets

freebsd: Separate package set contents from construction
This commit is contained in:
John Ericson 2024-05-04 15:10:38 -04:00 committed by GitHub
commit 469e40974a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 222 additions and 112 deletions

View file

@ -1,72 +1,64 @@
{ stdenv, lib, stdenvNoCC
, makeScopeWithSplicing', generateSplicesForMkScope
, buildPackages
, fetchgit, fetchzip
{
lib,
makeScopeWithSplicing',
generateSplicesForMkScope,
callPackage,
crossLibcStdenv,
attributePathToSplice ? [ "freebsd" ],
branch ? "release/13.1.0",
}:
let
inherit (buildPackages.buildPackages) rsync;
versions = builtins.fromJSON (builtins.readFile ./versions.json);
version = "13.1.0";
branch = "release/${version}";
badBranchError =
branch:
throw ''
Unknown FreeBSD branch ${branch}!
FreeBSD branches normally look like one of:
* `release/<major>.<minor>.0` for tagged releases without security updates
* `releng/<major>.<minor>` for release update branches with security updates
* `stable/<major>` for stable versions working towards the next minor release
* `main` for the latest development version
in makeScopeWithSplicing' {
otherSplices = generateSplicesForMkScope "freebsd";
f = (self: lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
} // {
sourceData = versions.${branch};
Branches can be selected by overriding the `branch` attribute on the freebsd package set.
'';
ports = fetchzip {
url = "https://cgit.freebsd.org/ports/snapshot/ports-dde3b2b456c3a4bdd217d0bf3684231cc3724a0a.tar.gz";
sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
# `./package-set.nix` should never know the name of the package set we
# are constructing; just this function is allowed to know that. This
# is why we:
#
# - do the splicing for cross compilation here
#
# - construct the *anonymized* `buildFreebsd` attribute to be passed
# to `./package-set.nix`.
callFreeBSDWithAttrs =
extraArgs:
let
# we do not include the branch in the splice here because the branch
# parameter to this file will only ever take on one value - more values
# are provided through overrides.
otherSplices = generateSplicesForMkScope attributePathToSplice;
in
makeScopeWithSplicing' {
inherit otherSplices;
f =
self:
{
inherit branch;
}
// callPackage ./package-set.nix (
{
sourceData = versions.${self.branch} or (throw (badBranchError self.branch));
versionData = self.sourceData.version;
buildFreebsd = otherSplices.selfBuildHost;
patchesRoot = ./patches/${self.versionData.revision};
}
// extraArgs
) self;
};
compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat;
freebsd-lib = import ./lib { inherit version; };
# The manual callPackages below should in principle be unnecessary, but are
# necessary. See note in ../netbsd/default.nix
compat = self.callPackage ./pkgs/compat/package.nix {
inherit stdenv;
inherit (buildPackages.freebsd) makeMinimal boot-install;
};
csu = self.callPackage ./pkgs/csu.nix {
inherit (buildPackages.freebsd) makeMinimal install gencat;
inherit (self) include;
};
include = self.callPackage ./pkgs/include/package.nix {
inherit (buildPackages.freebsd) makeMinimal install rpcgen;
};
install = self.callPackage ./pkgs/install.nix {
inherit (buildPackages.freebsd) makeMinimal;
inherit (self) mtree libnetbsd;
};
libc = self.callPackage ./pkgs/libc/package.nix {
inherit (buildPackages.freebsd) makeMinimal install gencat rpcgen;
inherit (self) csu include;
};
libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix {
inherit (buildPackages.freebsd) makeMinimal;
};
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv;
inherit (buildPackages.freebsd) makeMinimal install tsort;
};
makeMinimal = self.callPackage ./pkgs/makeMinimal.nix {
inherit (self) make;
};
});
in
{
freebsd = callFreeBSDWithAttrs { };
freebsdCross = callFreeBSDWithAttrs { stdenv = crossLibcStdenv; };
}

View file

@ -0,0 +1,71 @@
{ stdenv, lib, stdenvNoCC
, fetchzip
, sourceData, versionData, buildFreebsd, patchesRoot
}:
self:
lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
} // {
inherit sourceData patchesRoot versionData;
# Keep the crawled portion of Nixpkgs finite.
buildFreebsd = lib.dontRecurseIntoAttrs buildFreebsd;
ports = fetchzip {
url = "https://cgit.freebsd.org/ports/snapshot/ports-dde3b2b456c3a4bdd217d0bf3684231cc3724a0a.tar.gz";
sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
};
compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat;
freebsd-lib = import ./lib {
version = lib.concatStringsSep "." (map toString (lib.filter (x: x != null) [
self.versionData.major
self.versionData.minor
self.versionData.patch or null
]));
};
# The manual callPackages below should in principle be unnecessary, but are
# necessary. See note in ../netbsd/default.nix
compat = self.callPackage ./pkgs/compat/package.nix {
inherit stdenv;
inherit (buildFreebsd) makeMinimal boot-install;
};
csu = self.callPackage ./pkgs/csu.nix {
inherit (buildFreebsd) makeMinimal install gencat;
inherit (self) include;
};
include = self.callPackage ./pkgs/include/package.nix {
inherit (buildFreebsd) makeMinimal install rpcgen;
};
install = self.callPackage ./pkgs/install.nix {
inherit (buildFreebsd) makeMinimal;
inherit (self) mtree libnetbsd;
};
libc = self.callPackage ./pkgs/libc/package.nix {
inherit (buildFreebsd) makeMinimal install gencat rpcgen;
inherit (self) csu include;
};
libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix {
inherit (buildFreebsd) makeMinimal;
};
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv;
inherit (buildFreebsd) makeMinimal install tsort;
};
makeMinimal = self.callPackage ./pkgs/makeMinimal.nix {
inherit (self) make;
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, mkDerivation
{ lib, stdenv, mkDerivation, patchesRoot
, bsdSetupHook, freebsdSetupHook
, makeMinimal, boot-install
, which
@ -85,8 +85,8 @@ mkDerivation rec {
];
patches = [
./compat-install-dirs.patch
./compat-fix-typedefs-locations.patch
/${patchesRoot}/compat-install-dirs.patch
/${patchesRoot}/compat-fix-typedefs-locations.patch
];
preBuild = ''

View file

@ -1,4 +1,4 @@
{ lib, mkDerivation
{ lib, mkDerivation, patchesRoot
, buildPackages
, bsdSetupHook, freebsdSetupHook
, makeMinimal
@ -26,7 +26,7 @@ mkDerivation {
];
patches = [
./no-perms-BSD.include.dist.patch
/${patchesRoot}/no-perms-BSD.include.dist.patch
];
# The makefiles define INCSDIR per subdirectory, so we have to set

View file

@ -1,4 +1,5 @@
{ lib, stdenv, mkDerivation
, patchesRoot
, bsdSetupHook, freebsdSetupHook
, makeMinimal
@ -48,13 +49,13 @@ mkDerivation rec {
patches = [
# Hack around broken propogating MAKEFLAGS to submake, just inline logic
./libc-msun-arch-subdir.patch
/${patchesRoot}/libc-msun-arch-subdir.patch
# Don't force -lcompiler-rt, we don't actually call it that
./libc-no-force--lcompiler-rt.patch
/${patchesRoot}/libc-no-force--lcompiler-rt.patch
# Fix extra include dir to get rpcsvc headers.
./librpcsvc-include-subdir.patch
/${patchesRoot}/librpcsvc-include-subdir.patch
];
postPatch = ''

View file

@ -1,5 +1,5 @@
{ lib, stdenv
, mkDerivation
, mkDerivation, patchesRoot
, bsdSetupHook, freebsdSetupHook, makeMinimal, mandoc, groff
, boot-install, install
, compatIfNeeded
@ -15,8 +15,8 @@ mkDerivation {
else install)
];
patches = lib.optionals (!stdenv.hostPlatform.isFreeBSD) [
./libnetbsd-do-install.patch
#./libnetbsd-define-__va_list.patch
/${patchesRoot}/libnetbsd-do-install.patch
#/${patchesRoot}/libnetbsd-define-__va_list.patch
];
makeFlags = [
"STRIP=-s" # flag to install, not command

View file

@ -1,4 +1,4 @@
{ lib, mkDerivation, stdenv }:
{ lib, mkDerivation, stdenv, patchesRoot }:
mkDerivation rec {
path = "usr.bin/rpcgen";
@ -12,11 +12,11 @@ mkDerivation rec {
# those headers ends up included other headers...which ends up
# including the other one, this means by the first time we reach
# `#include `<bits/waitflags.h>`, both `_SYS_WAIT_H` and
# `_STDLIB_H` are already defined! Thus, we never ned up including
# `_STDLIB_H` are already defined! Thus, we never end up including
# `<bits/waitflags.h>` and defining `WUNTRACED`.
#
# This hacks around this by manually including `WUNTRACED` until
# the problem is fixed properly in glibc.
./rpcgen-glibc-hack.patch
/${patchesRoot}/rpcgen-glibc-hack.patch
];
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, mkDerivation, freebsd-lib
{ stdenv, mkDerivation, freebsd-lib, patchesRoot
, buildPackages
, bsdSetupHook, freebsdSetupHook
, makeMinimal, install, mandoc, groff
@ -19,8 +19,8 @@ in rec {
];
patches = [
./sys-gnu-date.patch
./sys-no-explicit-intrinsics-dep.patch
/${patchesRoot}/sys-gnu-date.patch
/${patchesRoot}/sys-no-explicit-intrinsics-dep.patch
];
# --dynamic-linker /red/herring is used when building the kernel.

View file

@ -16,6 +16,7 @@ import typing
import urllib.request
_QUERY_VERSION_PATTERN = re.compile('^([A-Z]+)="(.+)"$')
_RELEASE_PATCH_PATTERN = re.compile('^RELEASE-p([0-9]+)$')
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
MIN_VERSION = packaging.version.Version("13.0.0")
MAIN_BRANCH = "main"
@ -60,7 +61,16 @@ def query_version(repo: git.Repo) -> dict[str, typing.Any]:
continue
fields[m[1].lower()] = m[2]
fields["major"] = packaging.version.parse(fields["revision"]).major
parsed = packaging.version.parse(fields["revision"])
fields["major"] = parsed.major
fields["minor"] = parsed.minor
# Extract the patch number from `RELAESE-p<patch>`, which is used
# e.g. in the "releng" branches.
m = _RELEASE_PATCH_PATTERN.match(fields["branch"])
if m is not None:
fields["patch"] = m[1]
return fields
@ -95,7 +105,7 @@ def handle_commit(
"ref": ref_name,
"refType": ref_type,
"supported": ref_name in supported_refs,
"version": query_version(repo),
"version": version,
}
@ -151,6 +161,14 @@ def main() -> None:
result = handle_commit(
repo, tag.commit, tag.name, "tag", supported_refs, old_versions
)
# Hack in the patch version from parsing the tag, if we didn't
# get one from the "branch" field (from newvers). This is
# probably 0.
versionObj = result["version"]
if "patch" not in versionObj:
versionObj["patch"] = version.micro
versions[tag.name] = result
for branch in repo.remote("origin").refs:

View file

@ -1,14 +1,15 @@
{
"main": {
"hash": "sha256-C5ucT9BK/eK8a9HNSDDi8S1uhpPmiqV22XEooxAqbPw=",
"hash": "sha256-3aUsD2yRqVvb12z2XPmhE5/u4d9bqyD2ZHH3xNmwYwU=",
"ref": "main",
"refType": "branch",
"rev": "125c4560bc70971b950d035cfcd2255b89984011",
"rev": "aa34b1d20e44141749ffdecf16908fc1e5db4db6",
"supported": false,
"version": {
"branch": "CURRENT",
"major": 15,
"reldate": "1500017",
"minor": 0,
"reldate": "1500018",
"release": "15.0-CURRENT",
"revision": "15.0",
"type": "FreeBSD",
@ -24,6 +25,8 @@
"version": {
"branch": "RELEASE",
"major": 13,
"minor": 0,
"patch": 0,
"reldate": "1300139",
"release": "13.0-RELEASE",
"revision": "13.0",
@ -40,6 +43,8 @@
"version": {
"branch": "RELEASE",
"major": 13,
"minor": 1,
"patch": 0,
"reldate": "1301000",
"release": "13.1-RELEASE",
"revision": "13.1",
@ -56,6 +61,8 @@
"version": {
"branch": "RELEASE",
"major": 13,
"minor": 2,
"patch": 0,
"reldate": "1302001",
"release": "13.2-RELEASE",
"revision": "13.2",
@ -72,6 +79,8 @@
"version": {
"branch": "RELEASE",
"major": 13,
"minor": 3,
"patch": 0,
"reldate": "1303001",
"release": "13.3-RELEASE",
"revision": "13.3",
@ -88,6 +97,8 @@
"version": {
"branch": "RELEASE",
"major": 14,
"minor": 0,
"patch": 0,
"reldate": "1400097",
"release": "14.0-RELEASE",
"revision": "14.0",
@ -104,6 +115,8 @@
"version": {
"branch": "RELEASE-p13",
"major": 13,
"minor": 0,
"patch": "13",
"reldate": "1300139",
"release": "13.0-RELEASE-p13",
"revision": "13.0",
@ -120,6 +133,8 @@
"version": {
"branch": "RELEASE-p9",
"major": 13,
"minor": 1,
"patch": "9",
"reldate": "1301000",
"release": "13.1-RELEASE-p9",
"revision": "13.1",
@ -136,6 +151,8 @@
"version": {
"branch": "RELEASE-p11",
"major": 13,
"minor": 2,
"patch": "11",
"reldate": "1302001",
"release": "13.2-RELEASE-p11",
"revision": "13.2",
@ -144,19 +161,21 @@
}
},
"releng/13.3": {
"hash": "sha256-huzUiMZHfyK/mgLD3hW+DaSGgAaTUIuM51xDp+IE3qE=",
"hash": "sha256-g3i9q9XihesdfQxGy3oC7IMGtbWaLNwFlNzbdvS/4ng=",
"ref": "releng/13.3",
"refType": "branch",
"rev": "7a0d63c9093222938f26cd63ff742e555168de77",
"rev": "be4f1894ef399f421bab451e8cf8557e27e5a948",
"supported": true,
"version": {
"branch": "RELEASE-p1",
"branch": "RELEASE-p2",
"major": 13,
"minor": 3,
"patch": "2",
"reldate": "1303001",
"release": "13.3-RELEASE-p1",
"release": "13.3-RELEASE-p2",
"revision": "13.3",
"type": "FreeBSD",
"version": "FreeBSD 13.3-RELEASE-p1"
"version": "FreeBSD 13.3-RELEASE-p2"
}
},
"releng/14.0": {
@ -168,6 +187,8 @@
"version": {
"branch": "RELEASE-p6",
"major": 14,
"minor": 0,
"patch": "6",
"reldate": "1400097",
"release": "14.0-RELEASE-p6",
"revision": "14.0",
@ -176,15 +197,16 @@
}
},
"stable/13": {
"hash": "sha256-XateLKKs2A/HCP9Lx/nBm1cybB3otrbeXQvyCL40S0M=",
"hash": "sha256-ItC8haDdxMSZt1thpCrn8p0xxvs7Uqh/uNo1OwMalj8=",
"ref": "stable/13",
"refType": "branch",
"rev": "e0a58ef24a3baf5ed4cc09a798b9fe2d85408052",
"rev": "825cb4c850f2b97cfd1b24ed421d7938bf37eee7",
"supported": true,
"version": {
"branch": "STABLE",
"major": 13,
"reldate": "1303502",
"minor": 3,
"reldate": "1303503",
"release": "13.3-STABLE",
"revision": "13.3",
"type": "FreeBSD",
@ -192,19 +214,20 @@
}
},
"stable/14": {
"hash": "sha256-tIKnK/SYBDk9UnE5AfhjeDpqHnzspYbor0678ye/mrs=",
"hash": "sha256-iAj75IXJi4Oium6BqFvsyQipDP2crBZIGg0Dac8Zf1g=",
"ref": "stable/14",
"refType": "branch",
"rev": "ab872ab0bf195e872ed8d955aab3b2a537a230cd",
"rev": "a3b8266f5420601e231bc08c5402d9a4929fbdc0",
"supported": true,
"version": {
"branch": "STABLE",
"branch": "PRERELEASE",
"major": 14,
"reldate": "1400510",
"release": "14.0-STABLE",
"revision": "14.0",
"minor": 1,
"reldate": "1400511",
"release": "14.1-PRERELEASE",
"revision": "14.1",
"type": "FreeBSD",
"version": "FreeBSD 14.0-STABLE"
"version": "FreeBSD 14.1-PRERELEASE"
}
}
}

View file

@ -40885,10 +40885,8 @@ with pkgs;
name = "bsd-setup-hook";
} ../os-specific/bsd/setup-hook.sh;
freebsd = callPackage ../os-specific/bsd/freebsd { };
freebsdCross = callPackage ../os-specific/bsd/freebsd {
stdenv = crossLibcStdenv;
};
inherit (callPackage ../os-specific/bsd/freebsd { })
freebsd freebsdCross;
netbsd = callPackage ../os-specific/bsd/netbsd { };
netbsdCross = callPackage ../os-specific/bsd/netbsd {

View file

@ -76,6 +76,7 @@ let
buildHaskellPackages = true;
buildPackages = true;
buildFreebsd = true;
generateOptparseApplicativeCompletions = true;
callPackage = true;

View file

@ -148,17 +148,23 @@ in
makeScopeWithSplicing' = lib.makeScopeWithSplicing' { inherit splicePackages; inherit (pkgs) newScope; };
# generate 'otherSplices' for 'makeScopeWithSplicing'
generateSplicesForMkScope = attr:
generateSplicesForMkScope = attrs:
let
split = X: lib.splitString "." "${X}.${attr}";
split = X: [ X ] ++ (
if builtins.isList attrs
then attrs
else if builtins.isString attrs
then lib.splitString "." attrs
else throw "generateSplicesForMkScope must be passed a list of string or string"
);
bad = throw "attribute should be found";
in
{
# nulls should never be reached
selfBuildBuild = lib.attrByPath (split "pkgsBuildBuild") null pkgs;
selfBuildHost = lib.attrByPath (split "pkgsBuildHost") null pkgs;
selfBuildTarget = lib.attrByPath (split "pkgsBuildTarget") null pkgs;
selfHostHost = lib.attrByPath (split "pkgsHostHost") null pkgs;
selfHostTarget = lib.attrByPath (split "pkgsHostTarget") null pkgs;
selfBuildBuild = lib.attrByPath (split "pkgsBuildBuild") bad pkgs;
selfBuildHost = lib.attrByPath (split "pkgsBuildHost") bad pkgs;
selfBuildTarget = lib.attrByPath (split "pkgsBuildTarget") bad pkgs;
selfHostHost = lib.attrByPath (split "pkgsHostHost") bad pkgs;
selfHostTarget = lib.attrByPath (split "pkgsHostTarget") bad pkgs;
selfTargetTarget = lib.attrByPath (split "pkgsTargetTarget") { } pkgs;
};