mirror of
https://github.com/Zeckmathederg/glfs.git
synced 2025-01-23 14:32:13 +08:00
generate version info from git
This commit is contained in:
parent
1adab6831d
commit
17c9da822a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
version.ent
|
21
Makefile
21
Makefile
@ -55,7 +55,7 @@ all: blfs nochunks
|
||||
world: all blfs-patch-list dump-commands test-links
|
||||
|
||||
html: $(BASEDIR)/index.html
|
||||
$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML)
|
||||
$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
|
||||
@echo "Generating chunked XHTML files..."
|
||||
$(Q)xsltproc --nonet \
|
||||
--stringparam chunk.quietly $(CHUNK_QUIET) \
|
||||
@ -88,7 +88,7 @@ $(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML)
|
||||
done;
|
||||
|
||||
nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
||||
$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML)
|
||||
$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
|
||||
@echo "Generating non-chunked XHTML file..."
|
||||
$(Q)xsltproc --nonet \
|
||||
--stringparam rootid "$(ROOT_ID)" \
|
||||
@ -111,7 +111,7 @@ clean:
|
||||
$(Q)rm -f $(RENDERTMP)/blfs*
|
||||
|
||||
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)
|
||||
|
||||
@echo "Adjusting for revision $(REV)..."
|
||||
@ -130,7 +130,7 @@ $(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL)
|
||||
$(RENDERTMP)/$(BLFSHTML2)
|
||||
|
||||
profile-html: $(RENDERTMP)/$(BLFSHTML)
|
||||
$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL)
|
||||
$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
|
||||
@echo "Generating profiled XML for XHTML..."
|
||||
$(Q)xsltproc --nonet \
|
||||
--stringparam profile.condition html \
|
||||
@ -143,7 +143,7 @@ blfs-patch-list: blfs-patches.sh
|
||||
$(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
||||
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 \
|
||||
--output blfs-patches.sh \
|
||||
@ -151,7 +151,7 @@ blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL)
|
||||
$(RENDERTMP)/$(BLFSFULL)
|
||||
|
||||
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)
|
||||
$(Q)xsltproc --nonet \
|
||||
@ -160,7 +160,7 @@ $(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL)
|
||||
$(RENDERTMP)/$(BLFSFULL)
|
||||
|
||||
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)
|
||||
$(Q)xsltproc --nonet \
|
||||
@ -212,7 +212,7 @@ systemd-units:
|
||||
fi
|
||||
|
||||
dump-commands: $(DUMPDIR)
|
||||
$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL)
|
||||
$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
|
||||
@echo "Dumping book commands..."
|
||||
$(Q)xsltproc --output $(DUMPDIR)/ \
|
||||
stylesheets/dump-commands.xsl \
|
||||
@ -221,6 +221,7 @@ $(DUMPDIR): $(RENDERTMP)/$(BLFSFULL)
|
||||
|
||||
.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
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
<revhistory>
|
||||
<revision>
|
||||
<revnumber>&version;</revnumber>
|
||||
<revnumber>&short-version;</revnumber>
|
||||
<date>&pubdate;</date>
|
||||
<revremark>Ongoing Release</revremark>
|
||||
</revision>
|
||||
|
26
general.ent
26
general.ent
@ -1,17 +1,25 @@
|
||||
<!-- $LastChangedBy$ $Date$ -->
|
||||
<!-- version info generated from git commit,
|
||||
comment out the following two lines for release. -->
|
||||
<!ENTITY % version-entities SYSTEM "version.ent">
|
||||
%version-entities;
|
||||
|
||||
<!-- 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 day "15"> <!-- Always 2 digits -->
|
||||
<!ENTITY month "04"> <!-- Always 2 digits -->
|
||||
<!ENTITY year "2021">
|
||||
<!ENTITY copyrightdate "2001-&year;">
|
||||
<!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">
|
||||
|
||||
<!ENTITY maintainer-fullname "The BLFS Team">
|
||||
|
48
git-version.sh
Executable file
48
git-version.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user