mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-03-05 22:04:48 +00:00
automatically generate version info from git HEAD
This commit is contained in:
parent
275f313442
commit
5948380997
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
lfs-bootscripts-*.tar.xz
|
||||
version.ent
|
||||
|
7
Makefile
7
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
|
||||
|
||||
|
@ -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>
|
||||
|
21
general.ent
21
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 – -->
|
||||
|
||||
<!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 – -->
|
||||
|
||||
<!ENTITY lfs-root "http://www.linuxfromscratch.org/">
|
||||
<!ENTITY blfs-root "&lfs-root;blfs/">
|
||||
<!ENTITY blfs-book "&blfs-root;view/&short-version;/">
|
||||
|
45
git-version.sh
Executable file
45
git-version.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user