source: git-version.sh@ 57c4c384

s6-init
Last change on this file since 57c4c384 was 193913e, checked in by Thomas Trepl (Moody) <thomas@…>, 21 months ago

First commit to add S6 as init system (like systemd)

  • Property mode set to 100755
File size: 2.9 KB
Line 
1#!/bin/sh
2
3if [ "$1" = sysv ]; then
4 SYSV="INCLUDE"
5 SYSTEMD="IGNORE "
6 S6="IGNORE "
7elif [ "$1" = systemd ]; then
8 SYSV="IGNORE "
9 SYSTEMD="INCLUDE"
10 S6="IGNORE "
11elif [ "$1" = s6 ]; then
12 SYSV="IGNORE "
13 SYSTEMD="IGNORE "
14 S6="INCLUDE "
15else
16 echo You must provide either \"sysv\" or \"systemd\" as argument
17 exit 1
18fi
19
20echo "<!ENTITY % sysv \"$SYSV\">" > conditional.ent
21echo "<!ENTITY % systemd \"$SYSTEMD\">" >> conditional.ent
22echo "<!ENTITY % s6 \"$S6\">" >> conditional.ent
23
24if ! git status > /dev/null; then
25 # Either it's not a git repository, or git is unavaliable.
26 # Just workaround.
27 echo "<![ %sysv; [" > version.ent
28 echo "<!ENTITY version \"unknown\">" >> version.ent
29 echo "]]>" >> version.ent
30 echo "<![ %systemd; [" >> version.ent
31 echo "<!ENTITY version \"unknown-systemd\">" >> version.ent
32 echo "]]>" >> version.ent
33 echo "<![ %s6; [" >> version.ent
34 echo "<!ENTITY version \"unknown-s6\">" >> version.ent
35 echo "]]>" >> version.ent
36 echo "<!ENTITY releasedate \"unknown\">" >> version.ent
37 echo "<!ENTITY copyrightdate \"1999-2022\">" >> version.ent
38 exit 0
39fi
40
41export LC_ALL=en_US.utf8
42export TZ=US/Pacific
43
44commit_date=$(git show -s --format=format:"%cd" --date=local)
45
46year=$(date --date "$commit_date" "+%Y")
47month=$(date --date "$commit_date" "+%B")
48month_digit=$(date --date "$commit_date" "+%m")
49day=$(date --date "$commit_date" "+%d" | sed 's/^0//')
50
51case $day in
52 "1" | "21" | "31" ) suffix="st";;
53 "2" | "22" ) suffix="nd";;
54 "3" | "23" ) suffix="rd";;
55 * ) suffix="th";;
56esac
57
58full_date="$month $day$suffix, $year"
59
60sha="$(git describe --abbrev=1)"
61rev=$(echo "$sha" | sed 's/-g[^-]*$//')
62version="$rev"
63versiond="$rev-systemd"
64version6="$rev-s6"
65
66if [ "$(git diff HEAD | wc -l)" != "0" ]; then
67 version="$version+"
68 versiond="$versiond+"
69 version6="$version6+"
70fi
71
72echo "<![ %sysv; [" > version.ent
73echo "<!ENTITY version \"$version\">" >> version.ent
74echo "]]>" >> version.ent
75echo "<![ %systemd; [" >> version.ent
76echo "<!ENTITY version \"$versiond\">" >> version.ent
77echo "]]>" >> version.ent
78echo "<![ %s6; [" >> version.ent
79echo "<!ENTITY version \"$version6\">" >> version.ent
80echo "]]>" >> version.ent
81echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
82echo "<!ENTITY copyrightdate \"1999-$year\">" >> version.ent
Note: See TracBrowser for help on using the repository browser.