source: git-version.sh@ c858ba4e

12.1 12.1-rc1 12.2 12.2-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/loongarch-12.2 xry111/mips64el xry111/multilib xry111/update-glibc
Last change on this file since c858ba4e was c858ba4e, checked in by Xi Ruoyao <xry111@…>, 13 months ago

build: Add "make dist"

For creating a tarball without .git directory easier. The tarball will
include version.ent and LFS-RELEASE files so the book rendered from it
won't show "unknown" for all dates.

  • Property mode set to 100755
File size: 2.4 KB
Line 
1#!/bin/bash
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
14echo "<!ENTITY % sysv \"$SYSV\">" > conditional.ent
15echo "<!ENTITY % systemd \"$SYSTEMD\">" >> conditional.ent
16
17if ! 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
34fi
35
36export LC_ALL=en_US.utf8
37export TZ=America/Chicago
38
39commit_date=$(git show -s --format=format:"%cd" --date=local)
40
41year=$(date --date "$commit_date" "+%Y")
42month=$(date --date "$commit_date" "+%B")
43month_digit=$(date --date "$commit_date" "+%m")
44day=$(date --date "$commit_date" "+%d" | sed 's/^0//')
45
46case $day in
47 "1" | "21" | "31" ) suffix="st";;
48 "2" | "22" ) suffix="nd";;
49 "3" | "23" ) suffix="rd";;
50 * ) suffix="th";;
51esac
52
53full_date="$month $day$suffix, $year"
54
55sha="$(git describe --abbrev=1)"
56rev=$(echo "$sha" | sed 's/-g[^-]*$//')
57version="$rev"
58versiond="$rev-systemd"
59
60if [ "$(git diff HEAD | wc -l)" != "0" ]; then
61 version="$version+"
62 versiond="$versiond+"
63fi
64
65echo "<![ %sysv; [" > version.ent
66echo "<!ENTITY version \"$version\">" >> version.ent
67echo "]]>" >> version.ent
68echo "<![ %systemd; [" >> version.ent
69echo "<!ENTITY version \"$versiond\">" >> version.ent
70echo "]]>" >> version.ent
71echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
72echo "<!ENTITY copyrightdate \"1999-$year\">" >> version.ent
73
74[ -z "$DIST" ] || echo $version > "$DIST"
Note: See TracBrowser for help on using the repository browser.