Files
lfs/git-version.sh
Zeckmathederg 3ea5d3b1db Replaced SysVinit with OpenRC.
This is a rough draft of LFS w/ OpenRC without SysVinit. This is nowhere
close for a merge as I need to confirm this works with LFS. Beyond that,
BLFS also must get support, and BLFS will be a battlefield. Until we get
to that point, please do not have this merged.

This branch has been created because the LSB is getting changed, where
SysVinit will not be part of it. However, OpenRC will be. OpenRC also
provides technology projects like GNOME use. SysVinit simply will not
get those technologies. I believe OpenRC will be the way to go, going
forward for an educational alternative to the Systemd version of LFS.

SysVinit can act as an init system under OpenRC, which would introduce
unneeded complexity. That's why this removes SysVinit.

This shall get rendered at
https://linuxfromscratch.org/~zeckma/. MLFS support is not planned until
merge into trunk.

Feedback is appreciated.
2025-12-08 21:51:31 -07:00

74 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
if [ "$1" = openrc ]; then
OPENRC="INCLUDE"
SYSTEMD="IGNORE "
elif [ "$1" = systemd ]; then
OPENRC="IGNORE "
SYSTEMD="INCLUDE"
else
echo You must provide either \"sysv\" or \"systemd\" as argument
exit 1
fi
echo "<!ENTITY % openrc \"$OPENRC\">" > conditional.ent
echo "<!ENTITY % systemd \"$SYSTEMD\">" >> conditional.ent
if [ -e LFS-RELEASE ]; then
exit 0
fi
if ! git status > /dev/null; then
# Either it's not a git repository or git is unavailable.
# Just workaround.
echo "<![ %openrc; [" > version.ent
echo "<!ENTITY version \"unknown\">" >> version.ent
echo "]]>" >> version.ent
echo "<![ %systemd; [" >> version.ent
echo "<!ENTITY version \"unknown-systemd\">" >> version.ent
echo "]]>" >> version.ent
echo "<!ENTITY releasedate \"unknown\">" >> version.ent
echo "<!ENTITY copyrightdate \"1999-2023\">" >> version.ent
exit 0
fi
export LC_ALL=en_US.utf8
export TZ=America/Chicago
commit_date=$(git show -s --format=format:"%cd" --date=local)
year=$(date --date "$commit_date" "+%Y")
month=$(date --date "$commit_date" "+%B")
month_digit=$(date --date "$commit_date" "+%m")
day=$(date --date "$commit_date" "+%d" | sed 's/^0//')
case $day in
"1" | "21" | "31" ) suffix="st";;
"2" | "22" ) suffix="nd";;
"3" | "23" ) suffix="rd";;
* ) suffix="th";;
esac
full_date="$month $day$suffix, $year"
sha="$(git describe --abbrev=1)"
rev=$(echo "$sha" | sed 's/-g[^-]*$//')
version="$rev"
versiond="$rev-systemd"
if [ "$(git diff HEAD | wc -l)" != "0" ]; then
version="$version-wip"
versiond="$versiond-wip"
fi
echo "<![ %openrc; [" > version.ent
echo "<!ENTITY version \"$version\">" >> version.ent
echo "]]>" >> version.ent
echo "<![ %systemd; [" >> version.ent
echo "<!ENTITY version \"$versiond\">" >> version.ent
echo "]]>" >> version.ent
echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
echo "<!ENTITY copyrightdate \"1999-$year\">" >> version.ent
[ -z "$DIST" ] || echo $version > "$DIST"