blob: d98bb0de90ce5067f95755f33b68fbfd072221ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Check if commands grep, sed, and date can be used for
# building perfbook.
#
# Copyright (C) Akira Yokosawa, 2023
export LC_TIME=C
: ${SED:=sed}
: ${DATE:=date}
: ${VERBOSE:=}
: ${WHICH:=command -v}
fatal=""
# test sed (repeat pattern \? and \+)
sed_result=""
sed_out=`echo aaabbc | $SED -e 's/[ab]\+c\?//'`
if [ "$sed_out" = "" ] ; then
sed_result="OK"
else
sed_result="NG"
fatal="sed $fatal"
fi
# test date (format conversion)
date_result=""
date_str="Tue, 10 Jan 2023 00:00:00 +0000"
if month=`$DATE -d "$date_str" +%B 2>/dev/null` ; then
date_flavor="GNU date"
else
if month=`$DATE -jR -f "%a, %d %b %Y %T %z" "$date_str" +%B 2>/dev/null` ;
then
date_flavor="BSD date"
else
date_flavor="Unknown"
fatal="date $fatal"
fi
fi
if [ "$month" = "January" ] ; then
date_result="OK"
else
date_result="NG"
fatal="date-format $fatal"
fi
if [ "$fatal" = "" -a "$VERBOSE" = "" ] ; then
exit 0
fi
# print results if any missing feature is detected
echo "==========================================="
echo " preparatory test of necessary features "
echo "==========================================="
if [ "$sed_result" != "OK" -o "$VERBOSE" != "" ] ; then
echo
echo '------------------------------------------'
echo ' testing sed (repeat patterns \? and \+) '
echo '------------------------------------------'
if [ "$sed_result" = "OK" ] ; then
echo "OK."
else
echo "$SED (at `$WHICH $SED`) failed the test!"
fi
fi
if [ "$date_result" != "OK" -o "$VERBOSE" != "" ] ; then
echo
echo "------------------------------------------"
echo " testing date (format conversion) "
echo "------------------------------------------"
echo -n "$date_flavor ... "
if [ "$date_flavor" = "Unknown" ] ; then
echo
echo "Unknown date command found at `$WHICH $DATE`."
else
if [ "$month" = "January" ] ; then
echo "OK."
else
echo "Hmm, something is wrong with format conversion"
echo "$month"
fi
fi
fi
if [ "$fatal" != "" ] ; then
echo "See #14 in FAQ-BUILD.txt for further info."
echo "fatal: $fatal"
exit 1
fi
|