source: git-version.sh@ 985d253

xry111/clfs-ng
Last change on this file since 985d253 was 985d253, checked in by Xi Ruoyao <xry111@…>, 16 months ago

Merge remote-tracking branch 'origin/trunk' into xry111/clfs-ng

  • Property mode set to 100755
File size: 2.3 KB
RevLine 
[59483809]1#!/bin/sh
2
[4467b18d]3if [ "$1" = sysv ]; then
[c37e846]4 SYSV="INCLUDE"
5 SYSTEMD="IGNORE "
[4467b18d]6elif [ "$1" = systemd ]; then
[c37e846]7 SYSV="IGNORE "
8 SYSTEMD="INCLUDE"
[4467b18d]9else
[c37e846]10 echo You must provide either \"sysv\" or \"systemd\" as argument
11 exit 1
[4467b18d]12fi
13
14echo "<!ENTITY % sysv \"$SYSV\">" > conditional.ent
15echo "<!ENTITY % systemd \"$SYSTEMD\">" >> conditional.ent
16
[8186f16]17if ! git status > /dev/null; then
[c37e846]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-2022\">" >> version.ent
28 exit 0
[59483809]29fi
30
31export LC_ALL=en_US.utf8
[45a010a]32export TZ=America/Chicago
[59483809]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")
[8186f16]39day=$(date --date "$commit_date" "+%d" | sed 's/^0//')
[59483809]40
41case $day in
[c37e846]42 "1" | "21" | "31" ) suffix="st";;
43 "2" | "22" ) suffix="nd";;
44 "3" | "23" ) suffix="rd";;
45 * ) suffix="th";;
[59483809]46esac
47
48full_date="$month $day$suffix, $year"
49
[6ca780c]50sha="$(git describe --abbrev=1)"
[7af57d2e]51rev=$(echo "$sha" | sed 's/-g[^-]*$//')
[fa7acfc]52version="cross-$rev"
53versiond="cross-$rev-systemd"
[59483809]54
55if [ "$(git diff HEAD | wc -l)" != "0" ]; then
[c37e846]56 version="$version+"
57 versiond="$versiond+"
[59483809]58fi
59
[4467b18d]60echo "<![ %sysv; [" > version.ent
61echo "<!ENTITY version \"$version\">" >> version.ent
62echo "]]>" >> version.ent
63echo "<![ %systemd; [" >> version.ent
64echo "<!ENTITY version \"$versiond\">" >> version.ent
65echo "]]>" >> version.ent
[59483809]66echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
67echo "<!ENTITY copyrightdate \"1999-$year\">" >> version.ent
Note: See TracBrowser for help on using the repository browser.