1#!/bin/bash 2 3# 4# Copyright (C) 2012 The Android Open Source Project 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18 19packager="" 20retcode=0 21if [[ "$OSTYPE" == "darwin"* ]] 22then 23 packager="macports" 24 25 if ! which port >& /dev/null 26 then 27 echo "Missing port binary, please install from http://www.macports.org/" >& 2 28 fi 29elif [[ "$OSTYPE" == "linux-gnu" ]] && which apt-get >& /dev/null 30then 31 packager="apt-get" 32fi 33 34function packager_install 35{ 36 if [[ $packager == "macports" ]] 37 then 38 echo "sudo port install $1" 39 elif [[ $packager == "apt-get" ]] 40 then 41 echo "sudo apt-get install $1" 42 else 43 echo "<your package manager> install $1" 44 fi 45} 46 47function binary_check() 48{ 49 local bin=$1 50 local macports=$2 51 local aptget=$3 52 53 local pkg="" 54 55 if type -f "$bin" >& /dev/null 56 then 57 return 0 58 fi 59 60 if [[ $packager == "macports" ]] 61 then 62 pkg="$macports" 63 elif [[ $packager == "apt-get" ]] 64 then 65 pkg="$aptget" 66 fi 67 68 if [[ -n $pkg ]] 69 then 70 echo "Missing $bin binary; please install with '$(packager_install $pkg)'" 71 fi 72 73 retcode=1 74 return 1 75} 76 77function python_check() 78{ 79 local mod=$1 80 local macports=$2 81 local aptget=$3 82 83 local pkg="" 84 85 if python -c "import $mod" >& /dev/null 86 then 87 return 0 88 fi 89 90 if [[ $packager == "macports" ]] 91 then 92 pkg="$macports" 93 elif [[ $packager == "apt-get" ]] 94 then 95 pkg="$aptget" 96 fi 97 98 if [[ -n $pkg ]] 99 then 100 echo "Missing python module $mod, please install with '$(packager_install $pkg)'" 101 fi 102 103 retcode=1 104 return 1 105} 106 107binary_check xmllint libxml2 libxml2-utils 108binary_check tidy tidy tidy 109binary_check python python27 python2.7 110python_check bs4 py27-beautifulsoup4 python-bs4 111python_check mako py27-mako python-mako 112python_check markdown py27-markdown python-markdown 113 114exit $retcode 115 116