source: git-version.sh@ 4653242

11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 4653242 was 4653242, checked in by Xi Ruoyao <xry111@…>, 15 months ago

git-version: Don't dump revision if no "important files" are changed

If an important file is changed, we regenerate version.ent and so bump
the revision. Otherwise, version.ent may be kept. Hack git-version.sh
so we can ensure version.ent is really not changed.

Add Makefile itself and git-version.sh into the important file list as
they can definitely affect book rendering.

  • Property mode set to 100755
File size: 1.7 KB
Line 
1#!/bin/sh
2
3if [ "$1" = sysv ]; then
4 SYSV="INCLUDE"
5 SYSTEMD="IGNORE "
6elif [ "$1" = systemd ]; then
7 SYSV="IGNORE "
8 SYSTEMD="INCLUDE"
9else
10 echo You must provide either \"sysv\" or \"systemd\" as argument
11 exit 1
12fi
13
14shift 1
15
16echo "<!ENTITY % sysv \"$SYSV\">" > conditional.ent
17echo "<!ENTITY % systemd \"$SYSTEMD\">" >> conditional.ent
18
19if ! git status > /dev/null; then
20 # Either it's not a git repository, or git is unavaliable.
21 # Just workaround.
22 echo "<!ENTITY year \"????\">" > version.ent
23 echo "<!ENTITY version \"unknown\">" >> version.ent
24 echo "<!ENTITY releasedate \"unknown\">" >> version.ent
25 echo "<!ENTITY pubdate \"unknown\">" >> version.ent
26 exit 0
27fi
28
29export LC_ALL=en_US.utf8
30export TZ=America/Chicago
31
32sha=$(git log -s --format=format:"%H" --date=local -1 $*)
33commit_date=$(git log -s --format=format:"%cd" --date=local -1 $*)
34short_date=$(date --date "$commit_date" "+%Y-%m-%d")
35
36year=$(date --date "$commit_date" "+%Y")
37month=$(date --date "$commit_date" "+%B")
38day_digit=$(date --date "$commit_date" "+%d")
39day=$(echo $day_digit | sed 's/^0//')
40
41case $day in
42 "1" | "21" | "31" ) suffix="st";;
43 "2" | "22" ) suffix="nd";;
44 "3" | "23" ) suffix="rd";;
45 * ) suffix="th";;
46esac
47
48full_date="$month $day$suffix, $year"
49
50sha="$(git describe --abbrev=1 $sha)"
51version=$(echo "$sha" | sed 's/-g[^-]*$//')
52
53echo "<!ENTITY year \"$year\">" > version.ent
54echo "<!ENTITY version \"$version\">" >> version.ent
55echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
56echo "<!ENTITY pubdate \"$short_date\">" >> version.ent
Note: See TracBrowser for help on using the repository browser.