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