~strahinja/reflow

3c15d8d67c875243fc31884dfa7385ca92bcefa6 — Страхиња Радић 6 months ago 340c953
Simplify build scripts

Signed-off-by: Страхиња Радић <contact@strahinja.org>
2 files changed, 14 insertions(+), 14 deletions(-)

M date.do
M version.do
M date.do => date.do +8 -8
@@ 1,20 1,20 @@
FALLBACKDATE=${FALLBACKDATE:-unknown}
LC_ALL=C
export LC_ALL
user=$(unalias ls >/dev/null 2>&1 || true; \
	LC_ALL=C command ls -nd . | LC_ALL=C awk '{print $3}')
e_user=$(id -u)
user_s=$(LC_ALL=C awk 'BEGIN{FS=":"}{if ($3=="'$user'") { print $1}}' \
	</etc/passwd)
	command ls -ld . | awk '{print $3}')
e_user=$(id -un)
if [ -d .git ] && command -v git >/dev/null 2>&1; then
	if [ "$e_user" = "$user" ]; then
		env LC_ALL=C git log --format=format:%cd \
		git log --format=format:%cd \
			--date=format:"%B %d, %Y" -1 @ >$3
	else
		su "${user_s}" -c 'env LC_ALL=C git log --format=format:%cd '\
'--date=format:"%B %d, %Y" -1 @' >$3
		su "${user}" -c 'env LC_ALL=C git log --format=format:%cd \
			--date=format:"%B %d, %Y" -1 @' >$3
	fi
	echo >>$3
else
	echo $FALLBACKDATE >$3
	printf "%s\n" "$FALLBACKDATE" >$3
fi
redo-always
redo-stamp <$3

M version.do => version.do +6 -6
@@ 1,17 1,17 @@
FALLBACKVER=${FALLBACKVER:-unknown}
LC_ALL=C
export LC_ALL
user=$(unalias ls >/dev/null 2>&1 || true; \
	LC_ALL=C command ls -nd . | LC_ALL=C awk '{print $3}')
e_user=$(id -u)
user_s=$(LC_ALL=C awk 'BEGIN{FS=":"}{if ($3=="'$user'") { print $1}}' \
	</etc/passwd)
	command ls -ld . | awk '{print $3}')
e_user=$(id -un)
if [ -d .git ] && command -v git >/dev/null 2>&1; then
	if [ "$e_user" = "$user" ]; then
		git describe 2>/dev/null | sed 's/^v//' >$3
	else
		su "${user_s}" -c 'git describe' 2>/dev/null | sed 's/^v//' >$3
		su "${user}" -c 'git describe' 2>/dev/null | sed 's/^v//' >$3
	fi
else
	echo $FALLBACKVER >$3
	printf "%s\n" "$FALLBACKVER" >$3
fi
redo-always
redo-stamp <$3