]> git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-check
Added new package: dosfstools.
[ipfire-3.x.git] / tools / make-check
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 check_common() {
23 local NAME=$1
24 if [ -n "$3" ]; then
25 local RVER=$2
26 local COMMAND=$3
27 else
28 local COMMAND=$2
29 fi
30
31 local EXTRA=$4
32
33 RANDOM=$$
34 TMPFILE=/tmp/ipfire-check-$RANDOM
35
36 echo -ne "${BOLD}Checking for $NAME${NORMAL}"
37
38 [ -n "$RVER" ] && echo -n " (Requires at least $RVER)"
39
40 bash -c "$COMMAND" >$TMPFILE 2>&1
41
42 if ! grep -q "command not found" < $TMPFILE; then
43 beautify message DONE
44 else
45 rm -f $TMPFILE 2>/dev/null
46 exiterror "$NAME not found!"
47 fi
48
49 [ -n "$EXTRA" ] && echo -n "$EXTRA"
50
51 cat $TMPFILE
52 rm -f $TMPFILE 2>/dev/null
53 echo # Empty line
54 }
55
56 check_toolchain() {
57 check_common "GNU Bash" "2.05a" "bash --version | head -n1 | cut -d\" \" -f2-4"
58 check_common "/bin/sh links bash?" "if ! which sh; then echo \"command not found\"; fi"
59 check_common "GNU Binutils" "2.12" "ld --version | head -n1 | cut -d\" \" -f3-" "Binutils: "
60 check_common "GNU Bison" "1.875" "bison --version | head -n1"
61 #check_common "/usr/bin/yacc links bison?" "if ! which yacc; then echo \"command not found\"; fi"
62 check_common "Bzip2" "1.0.2" "bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d\" \" -f1,6-"
63 check_common "Coreutils" "5.0" "chown --version | head -n1 | cut -d\")\" -f2" "Coreutils:"
64 check_common "Diffutils" "2.8" "diff --version | head -n1"
65 check_common "Findutils" "4.1.20" "find --version | head -n1"
66 check_common "GNU awk" "3.0" "gawk --version | head -n1"
67 check_common "/bin/awk links gawk?" "if ! which awk; then echo \"command not found\"; fi"
68 check_common "GNU CC" "3.0.1" "gcc --version | head -n1"
69 check_common "GNU libc" "2.2.5" "/lib/libc.so.6 | head -n1 | cut -d\" \" -f1-7"
70 check_common "GNU Grep" "2.5" "grep --version | head -n1"
71 check_common "GNU zip" "1.2.4" "gzip --version | head -n1"
72 check_common "Linux 2.6" "2.6.x" "uname -r" "Linux: "
73 check_common "GNU make" "3.79.1" "make --version | head -n1"
74 check_common "Patch" "2.5.4" "patch --version | head -n1"
75 check_common "GNU sed" "3.0.2" "sed --version | head -n1"
76 check_common "GNU tar" "1.14" "tar --version | head -n1"
77 check_common "GNU Texinfo" "4.8" "makeinfo --version | head -n1"
78 check_common "GNU m4" "1.4.8" "m4 --version | head -n1"
79 }
80
81 check_build() {
82 check_common "Python" "python -V"
83 check_common "GNU make" "3.79.1" "make --version | head -n1"
84 check_common "Git" "git --version"
85 check_common "GNU which" "which --version | head -n1"
86 }
87
88 check_code() {
89 ACTION=$1
90 ARGS="--recurse"
91
92 echo -n " Running code checks"
93
94 case "$ACTION" in
95 --fix)
96 echo -n " and fix"
97 ;;
98 "")
99 ARGS+=" --dryrun"
100 ;;
101 *)
102 exiterror "This is not a valid option: $ACTION"
103 ;;
104 esac
105
106 echo -n "..." # End the line
107
108 python $BASEDIR/tools/code-beautify $ARGS $BASEDIR/{config,doc,lfs,src,tools}
109 if [ "$?" -eq "0" ]; then
110 beautify message DONE
111 else
112 beautify message FAIL
113 exit 1
114 fi
115 }
116
117 check_sanity() {
118
119 echo "Checking sanity of working directory..."
120
121 rootfiles_check $*
122 check_code $*
123
124 }
125
126 check_user() {
127 if [ -z $IPFIRE_USER ]; then
128 echo -n "You have to setup IPFIRE_USER first. See .config for details."
129 beautify message FAIL
130 exit 1
131 fi
132 }
133
134 check_loop() {
135 for i in $(seq 0 7); do
136 if [ -e /dev/loop/$i ] || [ -e /dev/loop$i ]; then
137 return 0
138 fi
139 done
140 return 1
141 }
142
143 CPU_FLAGS=$(grep ^flags /proc/cpuinfo)
144 check_cpu() {
145 FLAG=$1;
146 grep -q $FLAG <<< $CPU_FLAGS
147 return $?
148 }
149
150 check_supported_target() {
151 local FLAGS
152 if [ "$1" = "via-c7" ]; then
153 FLAGS="sse sse2 pni"
154 elif [ "$1" = "via-c3" ]; then
155 FLAGS="3dnow"
156 elif [ "$1" = "atom330" ]; then
157 FLAGS="mmx sse sse2 pni ssse3"
158 elif [ "$1" = "core2duo" ]; then
159 FLAGS="sse2"
160 fi
161 for j in $FLAGS; do
162 if ! check_cpu $j; then
163 echo "Your system doesn't support needed cpu feature \"$j\" to build target $1." >&2
164 return 1
165 fi
166 done
167 return 0
168 }
169
170 check_supported_targets() {
171 for i in ${1-$POSSIBLE_TARGETS}; do
172 check_supported_target $i 2>/dev/null
173 [ "$?" -eq "0" ] && echo -n "$i "
174 done
175 echo # new line
176 }