Index: .gitignore
===================================================================
--- .gitignore	(revision 17c9da822a12989dbfe04ee071f0f57f2ec586c8)
+++ .gitignore	(revision 17c9da822a12989dbfe04ee071f0f57f2ec586c8)
@@ -0,0 +1,1 @@
+version.ent
Index: Makefile
===================================================================
--- Makefile	(revision 1adab6831dc2e6a87de6a437b04f64ba6ffc368b)
+++ Makefile	(revision 17c9da822a12989dbfe04ee071f0f57f2ec586c8)
@@ -56,5 +56,5 @@
 
 html: $(BASEDIR)/index.html
-$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML)
+$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
 	@echo "Generating chunked XHTML files..."
 	$(Q)xsltproc --nonet                                    \
@@ -89,5 +89,5 @@
 
 nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
-$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML)
+$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
 	@echo "Generating non-chunked XHTML file..."
 	$(Q)xsltproc --nonet                                \
@@ -112,5 +112,5 @@
 
 validate: $(RENDERTMP)/$(BLFSFULL)
-$(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL)
+$(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL) version
 	$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
 
@@ -131,5 +131,5 @@
 
 profile-html: $(RENDERTMP)/$(BLFSHTML)
-$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL)
+$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
 	@echo "Generating profiled XML for XHTML..."
 	$(Q)xsltproc --nonet                              \
@@ -144,5 +144,5 @@
 	  blfs-patches.sh > blfs-patch-list
 
-blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL)
+blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL) version
 	@echo "Generating blfs patch script..."
 	$(Q)xsltproc --nonet                     \
@@ -152,5 +152,5 @@
 
 wget-list: $(BASEDIR)/wget-list
-$(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL)
+$(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL) version
 	@echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
 	$(Q)mkdir -p $(BASEDIR)
@@ -161,5 +161,5 @@
 
 test-links: $(BASEDIR)/test-links
-$(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL)
+$(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL) version
 	@echo "Generating test-links file..."
 	$(Q)mkdir -p $(BASEDIR)
@@ -213,5 +213,5 @@
 
 dump-commands: $(DUMPDIR)
-$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL)
+$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
 	@echo "Dumping book commands..."
 	$(Q)xsltproc --output $(DUMPDIR)/          \
@@ -222,5 +222,6 @@
 .PHONY: blfs all world html nochunks tmpdir clean  \
    validate profile-html blfs-patch-list wget-list test-links \
-   dump-commands  bootscripts systemd-units
-
-
+   dump-commands  bootscripts systemd-units version
+
+version:
+	$(Q)./git-version.sh
Index: book/bookinfo.xml
===================================================================
--- book/bookinfo.xml	(revision 1adab6831dc2e6a87de6a437b04f64ba6ffc368b)
+++ book/bookinfo.xml	(revision 17c9da822a12989dbfe04ee071f0f57f2ec586c8)
@@ -49,5 +49,5 @@
   <revhistory>
     <revision>
-      <revnumber>&version;</revnumber>
+      <revnumber>&short-version;</revnumber>
       <date>&pubdate;</date>
       <revremark>Ongoing Release</revremark>
Index: general.ent
===================================================================
--- general.ent	(revision 1adab6831dc2e6a87de6a437b04f64ba6ffc368b)
+++ general.ent	(revision 17c9da822a12989dbfe04ee071f0f57f2ec586c8)
@@ -1,16 +1,24 @@
-<!-- $LastChangedBy$ $Date$ -->
+<!-- version info generated from git commit,
+     comment out the following two lines for release. -->
+<!ENTITY % version-entities SYSTEM "version.ent">
+%version-entities;
 
-<!ENTITY day          "15">                   <!-- Always 2 digits -->
-<!ENTITY month        "04">                   <!-- Always 2 digits -->
-<!ENTITY year         "2021">
-<!ENTITY copyrightdate "2001-&year;">
+<!-- uncomment the following entities and modify them for release,
+     month and year should be always 2 digits. -->
+<!--
+<!ENTITY day            "01">
+<!ENTITY month          "09">
+<!ENTITY year           "2021">
+<!ENTITY copyrightdate  "2001-2021">
+<!ENTITY version        "10.2">
+<!ENTITY releasedate    "September 1st, &year;">
+<!ENTITY pubdate        "&year;-&month;-&day;">
+<!ENTITY short-version "&version;">
+-->
+
 <!ENTITY copyholder   "The BLFS Development Team">
-<!ENTITY version      "&year;-&month;-&day;">
-<!ENTITY releasedate  "April 15th, &year;">
-<!ENTITY pubdate      "&year;-&month;-&day;"> <!-- metadata req. by TLDP -->
 <!ENTITY blfs-version "svn">                  <!-- svn|[release #] -->
 <!ENTITY lfs-version  "development">          <!-- x.y|development -->
 <!ENTITY lfs-versiond "systemd">              <!-- x.y-systemd|systemd -->
-<!ENTITY last-commit  "$Date$"> <!-- Automatic update -->
 <!ENTITY lfs-domainname       "linuxfromscratch.org">
 
Index: git-version.sh
===================================================================
--- git-version.sh	(revision 17c9da822a12989dbfe04ee071f0f57f2ec586c8)
+++ git-version.sh	(revision 17c9da822a12989dbfe04ee071f0f57f2ec586c8)
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+if ! git status > /dev/null; 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_digit=$(date --date "$commit_date" "+%d")
+day=$(echo $day_digit | 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="g$(git describe --always)"
+version="$short_date-$sha"
+
+if [ "$(git diff HEAD | wc -l)" != "0" ]; then
+	version="$version-MODIFIED"
+fi
+
+echo "<!ENTITY day               \"$day_digit\">"          >  version.ent
+echo "<!ENTITY month             \"$month_digit\">"        >> version.ent
+echo "<!ENTITY year              \"$year\">"               >> version.ent
+echo "<!ENTITY copyrightdate     \"2001-$year\">"          >> version.ent
+echo "<!ENTITY version           \"$version\">"            >> version.ent
+echo "<!ENTITY short-version     \"$sha\">"                >> version.ent
+echo "<!ENTITY releasedate       \"$full_date\">"          >> version.ent
+echo "<!ENTITY pubdate           \"$short_date\">"         >> version.ent
