Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/release/packages/create-sets.sh
39476 views
1
#! /bin/sh
2
#
3
# SPDX-License-Identifier: ISC
4
#
5
# Copyright (c) 2025 Lexi Winter <[email protected]>
6
#
7
# Permission to use, copy, modify, and distribute this software for any
8
# purpose with or without fee is hereby granted, provided that the above
9
# copyright notice and this permission notice appear in all copies.
10
#
11
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19
# Generate metapackage sets. We do this by examining the annotations field
20
# of the packages we previously built.
21
22
set -e
23
24
if [ $# -lt 3 ]; then
25
printf >&2 'usage: %s <srcdir> <wstagedir> <repodir>\n' "$0"
26
exit 1
27
fi
28
29
srcdir="$1"; shift
30
wstagedir="$1"; shift
31
repodir="$1"; shift
32
# Everything after the first three arguments is UCL variables we pass to
33
# generate-set-ucl.lua.
34
UCL_VARS="$@"
35
36
# Nothing is explicitly added to set-base, so it wouldn't get built unless
37
# we list it here.
38
SETS="base base-dbg base-jail base-jail-dbg"
39
40
for pkg in "$repodir"/*.pkg; do
41
# If the package name doesn't containing a '-', then it's
42
# probably data.pkg or packagesite.pkg, which are not real
43
# packages.
44
{ echo "$pkg" | grep -q '-'; } || continue
45
46
set -- $(pkg query -F "$pkg" '%At %n %Av' | grep '^set ')
47
pkgname="$2"
48
sets="$(echo "$3" | tr , ' ')"
49
for set in $sets; do
50
SETS="$SETS $set"
51
setvar="$(echo "$set" | tr - _)"
52
eval PKGS_${setvar}=\"\$PKGS_${setvar} $pkgname\"
53
done
54
done
55
56
for set in $(echo $SETS | tr ' ' '\n' | sort | uniq); do
57
setvar="$(echo "$set" | tr - _)"
58
eval deps=\"\$PKGS_${setvar}\"
59
60
"${srcdir}/release/packages/generate-set-ucl.lua" \
61
"${srcdir}/release/packages/set-template.ucl" \
62
PKGNAME "$set" \
63
SET_DEPENDS "$deps" \
64
UCLFILES "${srcdir}/release/packages/sets" \
65
$UCL_VARS \
66
> "${wstagedir}/set-${set}.ucl"
67
done
68
69