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