#!/bin/bash function check_version() { local need_version=$1 local install_version=$2 local back='\e[0m' local red='\e[1;31m' local green='\e[1;32m' if [ "$install_version" = "$need_version" ]; then echo -e "\tinstall: $install_version$green\t[MATCH]$back" else if [[ "$install_version" > "$need_version" ]]; then echo -e "\tinstall: $install_version$green\t[OK]$back" else echo -e "\tinstall: $install_version$red\t[FAILED]$back" fi fi } function check_package() { local name=$1 echo -n "check $1..." local cmd=$2 local need_version=$(echo $name | cut -d'-' -f2) local ver_length=$(echo $need_version | tr -cd '.' | wc -c) if [ "$ver_length" = 1 ]; then check_version "$need_version" $($cmd | grep -o '[0-9]\+\.[0-9]\+') else check_version "$need_version" $($cmd | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+') fi } function check_pack(){ check_package "$1" "$2 --version" } echo "Check Host System Requirements For LFS 6.3" echo -e "\t\t----------by adie(http://www.adintr.com)" echo -e "\t\t----------script version 1.0" check_pack 'Bash-2.05a' 'bash' check_pack 'Binutils-2.12' 'ld' check_pack 'Bison-1.875' 'bison' bzip2 --version 2>&1 < /dev/null | head -n1 > bzip.version check_package 'Bzip2-1.0.2' 'cat bzip.version' rm bzip.version check_pack 'Coreutils-5.0' 'chown' check_pack 'Diffutils-2.8' 'diff' check_pack 'Findutils-4.1.20' 'find' check_pack 'Gawk-3.0' 'gawk' check_pack 'Gcc-3.0.1' 'gcc' check_package 'Glibc-2.2.5' '/lib/libc.so.6' check_pack 'Grep-2.5' 'grep' check_pack 'Gzip-1.2.4' 'gzip' check_package 'Linux Kernel-2.6' 'cat /proc/version' check_pack 'Make-3.79' 'make' check_pack 'Patch-2.5.4' 'patch' check_pack 'Sed-3.0.2' 'sed' check_pack 'Tar-1.14' 'tar'