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