diff --git a/mk_mmc.sh b/mk_mmc.sh index a754364..01cf544 100755 --- a/mk_mmc.sh +++ b/mk_mmc.sh @@ -141,53 +141,36 @@ if parted -v | grep parted | grep 2.[1-3] >/dev/null ; then fi } -function detect_software { - -echo "This script needs:" -echo "Ubuntu/Debian: sudo apt-get install uboot-mkimage wget dosfstools parted" -echo "Fedora: as root: yum install uboot-tools wget dosfstools parted dpkg patch" -echo "Gentoo: emerge u-boot-tools wget dosfstools parted dpkg" -echo "" - -unset NEEDS_PACKAGE - -if [ ! $(which mkimage) ];then - echo "Missing uboot-mkimage" - NEEDS_PACKAGE=1 -fi - -if [ ! $(which wget) ];then - echo "Missing wget" - NEEDS_PACKAGE=1 -fi - -if [ ! $(which mkfs.vfat) ];then - echo "Missing mkfs.vfat" - NEEDS_PACKAGE=1 -fi - -if [ ! $(which parted) ];then - echo "Missing parted" - NEEDS_PACKAGE=1 -fi - -if [ ! $(which dpkg) ];then - echo "Missing dpkg" - NEEDS_PACKAGE=1 -fi - -if [ ! $(which patch) ];then - echo "Missing patch" - NEEDS_PACKAGE=1 -fi - -if [ "${NEEDS_PACKAGE}" ];then - echo "" - echo "Your System is Missing some dependencies" - echo "" - exit -fi +function check_for_command { + if ! which "$1" > /dev/null ; then + echo -n "You're missing command $1" + NEEDS_COMMAND=1 + if [ -n "$2" ] ; then + echo -n " (consider installing package $2)" + fi + echo + fi +} +function detect_software { + unset NEEDS_COMMAND + + check_for_command mkimage uboot-mkimage + check_for_command mkfs.vfat dosfstools + check_for_command wget wget + check_for_command parted parted + check_for_command dpkg dpkg + check_for_command patch patch + + if [ "${NEEDS_COMMAND}" ] ; then + echo "" + echo "Your system is missing some dependencies" + echo "Ubuntu/Debian: sudo apt-get install uboot-mkimage wget dosfstools parted" + echo "Fedora: as root: yum install uboot-tools wget dosfstools parted dpkg patch" + echo "Gentoo: emerge u-boot-tools wget dosfstools parted dpkg" + echo "" + exit + fi } function rcn-ee_down_use_mirror {