Kernel banner, boot loaders, motd, /etc/release, getty banner, boot.cfg menus, sysinst messages and the media names say Makronix (patch 0015, overlay). kern.ostype stays NetBSD on purpose. install-simple: 38 PASS. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
137 lines
5.0 KiB
Bash
Executable File
137 lines
5.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# cd3.sh -- the install CDs after the second: binary packages (Firefox,
|
|
# Thunderbird, QEMU, PulseAudio, CUPS, ...), on as many CDs as they need.
|
|
#
|
|
# usage: cd3.sh [stage]
|
|
# stage only the directory build/cd3 with all the packages (for the DVD:
|
|
# `make iso' stages it before build.sh; patch 0008 makes installdvd
|
|
# take it into CDBUILDEXTRA)
|
|
#
|
|
# Makronix installs from CDs on machines without a DVD drive: CD 1 carries the
|
|
# system, CD 2 the `makronix' set (tools/cd2.sh), CD 3 and the next ones the
|
|
# binary packages that the NetBSD project builds and Makronix does not patch
|
|
# (docs/BUILD-VM.md, "Binary first"; tools/pkg-binaries.sh fetches them).
|
|
# sysinst asks for them after the sets, when the user wants the extra programs,
|
|
# copies them all into the target and installs them with the target's own
|
|
# pkg_add (overlay/usr.sbin/sysinst/extras.c). A package on one CD can need
|
|
# one on another, which is why the CDs are copied first.
|
|
#
|
|
# The packages are put on the CDs first-fit, biggest first, each CD up to the
|
|
# size of a 700 MB CD (CDPKG_LIMIT, in bytes, to try another size); a build with
|
|
# fewer packages is one CD, a build with more is CD 3, CD 4, ... Every CD is a
|
|
# data CD, ISO 9660 with Rock Ridge, made with the build's own makefs, and has
|
|
#
|
|
# amd64/packages/All/*.tgz pkg_summary.gz its share of the packages
|
|
# amd64/packages/disc "N M": package CD N of M
|
|
# amd64/packages/top.list the names sysinst installs (packages.binary*.list,
|
|
# those that are here); the rest comes by dependency
|
|
#
|
|
# Written to RELEASEDIR/images/Makronix-<version>-amd64-cd3.iso (cd4, ...). Run
|
|
# by `make iso' after cd2.sh, when build/packages/amd64/All exists (otherwise it
|
|
# says so and does nothing). The DVD has all the packages in one directory with
|
|
# "1 1" in `disc'.
|
|
|
|
set -eu
|
|
|
|
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
|
OBJ=$TOP/build/obj
|
|
REL=$OBJ/releasedir
|
|
PKGS=$TOP/build/packages/amd64/All
|
|
STAGE=$TOP/build/cd3
|
|
# a CD holds 700 MB; the image must not be bigger than the medium
|
|
LIMIT=${CDPKG_LIMIT:-737280000}
|
|
# what the file system and the summary need on top of the packages
|
|
MARGIN=12000000
|
|
FIRSTCD=3
|
|
|
|
die()
|
|
{
|
|
echo "cd3: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
rm -rf "$STAGE" "$TOP"/build/cd3-[0-9]*
|
|
if [ ! -s "$PKGS/pkg_summary.gz" ]; then
|
|
echo "cd3: no binary packages in ${PKGS#$TOP/} (tools/pkg-binaries.sh -a amd64 fetch): no packages on the media"
|
|
exit 0
|
|
fi
|
|
|
|
# top.list: the wanted names that are on the medium
|
|
toplist()
|
|
{
|
|
: > "$1"
|
|
for l in "$TOP/packages.binary.list" "$TOP/packages.binary.amd64.list"; do
|
|
[ -f "$l" ] || continue
|
|
grep -v '^#' "$l" | grep -v '^[[:space:]]*$' | while read -r n; do
|
|
ls "$PKGS"/"$n"-[0-9]*.tgz > /dev/null 2>&1 && echo "$n" >> "$1"
|
|
done
|
|
done
|
|
[ -s "$1" ] || die "no wanted package is in ${PKGS#$TOP/}"
|
|
}
|
|
|
|
link()
|
|
{
|
|
ln "$1" "$2" 2>/dev/null || cp -p "$1" "$2"
|
|
}
|
|
|
|
# --- the directory for the DVD: all of them ---
|
|
mkdir -p "$STAGE/amd64/packages/All"
|
|
for f in "$PKGS"/*; do
|
|
link "$f" "$STAGE/amd64/packages/All/${f##*/}"
|
|
done
|
|
toplist "$STAGE/amd64/packages/top.list"
|
|
echo "1 1" > "$STAGE/amd64/packages/disc"
|
|
|
|
[ "${1:-}" = stage ] && { echo "cd3: staged ${STAGE#$TOP/}"; exit 0; }
|
|
|
|
# --- the CDs ---
|
|
MAKEFS=$(ls "$OBJ"/tooldir.*/bin/nbmakefs 2>/dev/null | head -1)
|
|
[ -x "$MAKEFS" ] || die "no nbmakefs in $OBJ/tooldir.*/bin"
|
|
# the version is in the name of the first CD
|
|
cd1=$(ls "$REL"/images/Makronix-*-amd64.iso 2>/dev/null | head -1)
|
|
[ -n "$cd1" ] || die "no first CD in $REL/images (build.sh iso-image first)"
|
|
ver=${cd1##*/Makronix-}
|
|
ver=${ver%-amd64.iso}
|
|
# ISOs of an earlier run with more CDs would be stale
|
|
rm -f "$REL"/images/Makronix-$ver-amd64-cd[3-9].iso
|
|
|
|
summary=$PKGS/pkg_summary.gz
|
|
ssize=$(wc -c < "$summary" | tr -d ' ')
|
|
cap=$((LIMIT - MARGIN - ssize))
|
|
tmp=$(mktemp "${TMPDIR:-/tmp}/cd3.XXXXXX")
|
|
trap 'rm -f "$tmp"' EXIT
|
|
|
|
# first-fit, biggest first: "CD-index file"
|
|
for f in "$PKGS"/*.tgz; do
|
|
echo "$(wc -c < "$f" | tr -d ' ') $f"
|
|
done | sort -rn | awk -v cap="$cap" '
|
|
{ sz = $1; f = $2; placed = 0
|
|
for (i = 1; i <= n; i++)
|
|
if (used[i] + sz <= cap) { used[i] += sz; print i, f; placed = 1; break }
|
|
if (!placed) { n++; used[n] = sz; print n, f }
|
|
}' > "$tmp"
|
|
ncd=$(awk '{ if ($1 > m) m = $1 } END { print m + 0 }' "$tmp")
|
|
[ "$ncd" -ge 1 ] || die "no package to put on a CD"
|
|
|
|
i=1
|
|
while [ $i -le "$ncd" ]; do
|
|
d=$TOP/build/cd3-$i
|
|
rm -rf "$d"
|
|
mkdir -p "$d/amd64/packages/All"
|
|
awk -v i="$i" '$1 == i { print $2 }' "$tmp" | while read -r f; do
|
|
link "$f" "$d/amd64/packages/All/${f##*/}"
|
|
done
|
|
link "$summary" "$d/amd64/packages/All/pkg_summary.gz"
|
|
toplist "$d/amd64/packages/top.list"
|
|
echo "$i $ncd" > "$d/amd64/packages/disc"
|
|
cdno=$((FIRSTCD + i - 1))
|
|
OUT=$REL/images/Makronix-$ver-amd64-cd$cdno.iso
|
|
rm -f "$OUT"
|
|
"$MAKEFS" -t cd9660 -o rockridge,label=MAKRONIX_CD$cdno,publisher=Makronix "$OUT" "$d"
|
|
size=$(wc -c < "$OUT" | tr -d ' ')
|
|
echo "cd3: ${OUT#$TOP/}: package CD $i of $ncd, $(du -h "$OUT" | cut -f1), $size bytes"
|
|
[ "$size" -le "$LIMIT" ] || echo "cd3: WARNING: $size bytes do not fit on the CD (limit $LIMIT)"
|
|
rm -rf "$d"
|
|
i=$((i + 1))
|
|
done
|