aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile7
-rw-r--r--chapter01/changelog.xml1
-rw-r--r--general.ent21
-rwxr-xr-xgit-version.sh45
5 files changed, 67 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 4d9db122b..9f764ff0d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
lfs-bootscripts-*.tar.xz
+version.ent
diff --git a/Makefile b/Makefile
index c28733ce3..83064f376 100644
--- a/Makefile
+++ b/Makefile
@@ -119,7 +119,7 @@ tmpdir:
$(Q)rm -f $(RENDERTMP)/*md5sum*
$(Q)rm -f $(RENDERTMP)/*pdf.fo
-validate: tmpdir
+validate: tmpdir version
@echo "Processing bootscripts..."
$(Q)bash process-scripts.sh
@@ -187,6 +187,9 @@ $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
"s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.xz | cut -d' ' -f1)/" \
$(BASEDIR)/md5sums
+version:
+ $(Q)./git-version.sh
+
#dump-commands: validate
# @echo "Dumping book commands..."
# $(Q)xsltproc --nonet \
@@ -204,5 +207,5 @@ $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
all: book nochunks pdf # dump-commands
-.PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list
+.PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list version
diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml
index cd59ea662..b02437f6d 100644
--- a/chapter01/changelog.xml
+++ b/chapter01/changelog.xml
@@ -42,6 +42,7 @@
<listitem revision="sysv"> or <listitem revision="systemd"> as
appropriate for the entry or if needed the entire day's listitem.
-->
+
<listitem>
<para>2021-03-26</para>
<itemizedlist>
diff --git a/general.ent b/general.ent
index 0db8fe99b..90443c9b5 100644
--- a/general.ent
+++ b/general.ent
@@ -1,16 +1,25 @@
-<!ENTITY version "SVN-20210326">
+<!-- version info automatically generated by git
+ comment the following two lines for release -->
+<!ENTITY % version-entities SYSTEM "version.ent">
+%version-entities;
+
+<!-- uncomment and edit the following four lines
+ for releases (including -rc) -->
+<!--
+<!ENTITY version "10.2-rc1">
+<!ENTITY versiond "10.2-rc1">
+<!ENTITY releasedate "August 26th, 2021">
+<!ENTITY copyrightdate "1999-2021">
+-->
+<!-- jhalfs needs a literal dash, not &ndash; -->
+
<!ENTITY short-version "svn"> <!-- Used below in &blfs-book;
Change to x.y for release but not -rc releases -->
<!ENTITY generic-version "development"> <!-- Use "development" or "x.y[-pre{x}]" -->
-<!ENTITY versiond "20210326-systemd">
<!ENTITY short-versiond "systemd">
<!ENTITY generic-versiond "systemd">
-<!ENTITY releasedate "March 26th, 2021">
-
-<!ENTITY copyrightdate "1999-2021"><!-- jhalfs needs a literal dash, not &ndash; -->
-
<!ENTITY lfs-root "http://www.linuxfromscratch.org/">
<!ENTITY blfs-root "&lfs-root;blfs/">
<!ENTITY blfs-book "&blfs-root;view/&short-version;/">
diff --git a/git-version.sh b/git-version.sh
new file mode 100755
index 000000000..8b1f13d00
--- /dev/null
+++ b/git-version.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+if ! git status; then
+ # Either it's not a git repository, or git is unavaliable.
+ # Just workaround.
+ echo "<!ENTITY version \"unknown\">" > version.ent
+ echo "<!ENTITY versiond \"unknown-systemd\">" >> version.ent
+ echo "<!ENTITY releasedate \"unknown\">" >> version.ent
+ echo "<!ENTITY copyrightdate \"1999-2021\">" >> version.ent
+ exit 0
+fi
+
+export LC_ALL=en_US.utf8
+export TZ=US/Pacific
+
+commit_date=$(git show -s --format=format:"%cd" --date=local)
+short_date=$(date --date "$commit_date" "+%Y%m%d")
+
+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")
+
+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="g$(git describe --always)"
+version="GIT-$short_date-$sha"
+versiond="GIT-$short_date-$sha-systemd"
+
+if [ "$(git diff HEAD | wc -l)" != "0" ]; then
+ version="$version-MODIFIED"
+ versiond="$versiond-MODIFIED"
+fi
+
+echo "<!ENTITY version \"$version\">" > version.ent
+echo "<!ENTITY versiond \"$versiond\">" >> version.ent
+echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
+echo "<!ENTITY copyrightdate \"1999-$year\">" >> version.ent