1 | #!/bin/bash
|
---|
2 |
|
---|
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 |
|
---|
17 | if ! git status > /dev/null; then
|
---|
18 | # Either it's not a git repository, or git is unavaliable.
|
---|
19 | # Just workaround.
|
---|
20 |
|
---|
21 | if [ -e LFS-RELEASE ]; then
|
---|
22 | exit 0
|
---|
23 | fi
|
---|
24 |
|
---|
25 | echo "<![ %sysv; [" > version.ent
|
---|
26 | echo "<!ENTITY version \"unknown\">" >> version.ent
|
---|
27 | echo "]]>" >> version.ent
|
---|
28 | echo "<![ %systemd; [" >> version.ent
|
---|
29 | echo "<!ENTITY version \"unknown-systemd\">" >> version.ent
|
---|
30 | echo "]]>" >> version.ent
|
---|
31 | echo "<!ENTITY releasedate \"unknown\">" >> version.ent
|
---|
32 | echo "<!ENTITY copyrightdate \"1999-2023\">" >> version.ent
|
---|
33 | exit 0
|
---|
34 | fi
|
---|
35 |
|
---|
36 | export LC_ALL=en_US.utf8
|
---|
37 | export TZ=America/Chicago
|
---|
38 |
|
---|
39 | commit_date=$(git show -s --format=format:"%cd" --date=local)
|
---|
40 |
|
---|
41 | year=$(date --date "$commit_date" "+%Y")
|
---|
42 | month=$(date --date "$commit_date" "+%B")
|
---|
43 | month_digit=$(date --date "$commit_date" "+%m")
|
---|
44 | day=$(date --date "$commit_date" "+%d" | sed 's/^0//')
|
---|
45 |
|
---|
46 | case $day in
|
---|
47 | "1" | "21" | "31" ) suffix="st";;
|
---|
48 | "2" | "22" ) suffix="nd";;
|
---|
49 | "3" | "23" ) suffix="rd";;
|
---|
50 | * ) suffix="th";;
|
---|
51 | esac
|
---|
52 |
|
---|
53 | full_date="$month $day$suffix, $year"
|
---|
54 |
|
---|
55 | sha="$(git describe --abbrev=1)"
|
---|
56 | rev=$(echo "$sha" | sed 's/-g[^-]*$//')
|
---|
57 | version="$rev"
|
---|
58 | versiond="$rev-systemd"
|
---|
59 |
|
---|
60 | if [ "$(git diff HEAD | wc -l)" != "0" ]; then
|
---|
61 | version="$version+"
|
---|
62 | versiond="$versiond+"
|
---|
63 | fi
|
---|
64 |
|
---|
65 | echo "<![ %sysv; [" > version.ent
|
---|
66 | echo "<!ENTITY version \"$version\">" >> version.ent
|
---|
67 | echo "]]>" >> version.ent
|
---|
68 | echo "<![ %systemd; [" >> version.ent
|
---|
69 | echo "<!ENTITY version \"$versiond\">" >> version.ent
|
---|
70 | echo "]]>" >> version.ent
|
---|
71 | echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
|
---|
72 | echo "<!ENTITY copyrightdate \"1999-$year\">" >> version.ent
|
---|
73 |
|
---|
74 | [ -z "$DIST" ] || echo $version > "$DIST"
|
---|