source: git-version.sh@ 4467b18

11.1 11.1-rc1 arm multilib trunk xry111/clfs-ng xry111/lfs-next
Last change on this file since 4467b18 was 4467b18, checked in by Pierre Labastie <pierre.labastie@…>, 9 months ago

Add a conditional entity for sysv/systemd

This removes the need for versiond, and other xxxd entities. Those
entities will be removed in the next commits.

  • Property mode set to 100755
File size: 2.3 KB
Line 
1#!/bin/sh
2
3if [ "$1" = sysv ]; then
4 SYSV="INCLUDE"
5 SYSTEMD="IGNORE "
6elif [ "$1" = systemd ]; then
7 SYSV="IGNORE "
8 SYSTEMD="INCLUDE"
9else
10 echo You must provide either \"sysv\" or \"systemd\" as argument
11 exit 1
12fi
13
14echo "<!ENTITY % sysv \"$SYSV\">" > conditional.ent
15echo "<!ENTITY % systemd \"$SYSTEMD\">" >> conditional.ent
16
17if ! git status > /dev/null; then
18 # Either it's not a git repository, or git is unavaliable.
19 # Just workaround.
20 echo "<![ %sysv; [" > version.ent
21 echo "<!ENTITY version \"unknown\">" >> version.ent
22 echo "]]>" >> version.ent
23 echo "<![ %systemd; [" >> version.ent
24 echo "<!ENTITY version \"unknown-systemd\">" >> version.ent
25 echo "]]>" >> version.ent
26 echo "<!ENTITY releasedate \"unknown\">" >> version.ent
27 echo "<!ENTITY copyrightdate \"1999-2021\">" >> version.ent
28 exit 0
29fi
30
31export LC_ALL=en_US.utf8
32export TZ=US/Pacific
33
34commit_date=$(git show -s --format=format:"%cd" --date=local)
35
36year=$(date --date "$commit_date" "+%Y")
37month=$(date --date "$commit_date" "+%B")
38month_digit=$(date --date "$commit_date" "+%m")
39day=$(date --date "$commit_date" "+%d" | sed 's/^0//')
40
41case $day in
42 "1" | "21" | "31" ) suffix="st";;
43 "2" | "22" ) suffix="nd";;
44 "3" | "23" ) suffix="rd";;
45 * ) suffix="th";;
46esac
47
48full_date="$month $day$suffix, $year"
49
50sha="$(git describe --abbrev=1)"
51if [ "$(git branch --show-current)" = "trunk" ]; then
52 sha=$(echo "$sha" | sed 's/-g[^-]*$//')
53fi
54version="$sha"
55versiond="$sha-systemd"
56
57if [ "$(git diff HEAD | wc -l)" != "0" ]; then
58 version="$version+"
59 versiond="$versiond+"
60fi
61
62echo "<![ %sysv; [" > version.ent
63echo "<!ENTITY version \"$version\">" >> version.ent
64echo "]]>" >> version.ent
65echo "<![ %systemd; [" >> version.ent
66echo "<!ENTITY version \"$versiond\">" >> version.ent
67echo "]]>" >> version.ent
68echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
69echo "<!ENTITY copyrightdate \"1999-$year\">" >> version.ent
Note: See TracBrowser for help on using the repository browser.