diff --git a/config b/config new file mode 100644 index 0000000..efa4cda --- /dev/null +++ b/config @@ -0,0 +1,66 @@ +#! /usr/bin/env bash + +. scripts/versioncmp.sh +. scripts/log.sh + +function check_dep() { + local package=$1 + local hint=$2 + local version=$3 + local version_to_check=$4 + if [ $package ] + then + if hash $package 2>/dev/null; then + + if [ "$version" ] + then + + version_cmp $version $version_to_check + #python ./scripts/versioncmp.py $version $version_to_check + local cmp=$? + + if [ "$cmp" == "2" ] + then + error "$package version $version_to_check required. Yours is $version" + info "$hint" + else + info "$package version $version is fine. need ($version_to_check)" + + fi + else + info "Found $package" + + fi + else + error "Can't find '$package'." + info "$hint" + fi + else + error "first argument is empty" + fi +} + + +check_dep 'emacs' '' `emacs --version | head -n 1 | cut -d " " -f 3` '24.3' + +check_dep 'git' 'On Debian you can install git by installing "git-core" package.' +check_dep 'bzr' 'On Debian you can install bzr by installing "bzr" package.' +check_dep 'makeinfo' 'On Debian you can install makeinfo by installing "texinfo" package.' + +check_dep 'python' 'You need to install it from your package manager or from source' +check_dep 'pep8' 'Install it using "pip" or "easy_install"' +check_dep 'pyflakes' 'Install it using "pip" or "easy_install"' +check_dep 'pychecker' 'Install it using "pip" or "easy_install"' +check_dep 'pylint' 'Install it using "pip" or "easy_install"' +check_dep 'jedi' 'Install it using "pip" or "easy_install"' +check_dep 'epc' 'Install it using "pip" or "easy_install"' +check_dep 'csscapture' 'Install it using "pip cssutils" or "easy_install cssutils"' +check_dep 'csscombine' 'Install it using "pip cssutils" or "easy_install cssutils"' +check_dep 'cssparse' 'Install it using "pip cssutils" or "easy_install cssutils"' + +check_dep 'ruby' 'You need to install it from your package manager or from source' +check_dep 'rake' 'Install it using "gem install rake"' +check_dep 'bundle' 'Install it using "gem install bundler"' + +check_dep 'xmlstarlet' 'On Debian you can install xmlstarlet by installing "xmlstarlet" package.' +check_dep 'csslint' 'For installing csslint you need "nodejs". You can install "csslint" via "npm"' diff --git a/scripts/log.sh b/scripts/log.sh new file mode 100644 index 0000000..92cb05e --- /dev/null +++ b/scripts/log.sh @@ -0,0 +1,23 @@ +#! /usr/bin/env bash + +# Coloring Functions +function info() { + if [ "$1" ] + then + echo -e "[\033[01;32mINFO\033[00m]: $1" + fi +} + +function error(){ + if [ "$1" ] + then + echo -e "[\033[01;31mERR\033[00m]: $1" + fi +} + +function warn(){ + if [ "$1" ] + then + echo -e "[\033[01;33mWARN\033[00m]: $1" + fi +} diff --git a/scripts/versioncmp.py b/scripts/versioncmp.py new file mode 100755 index 0000000..5da3c9e --- /dev/null +++ b/scripts/versioncmp.py @@ -0,0 +1,14 @@ +import sys +from distutils.version import LooseVersion + + +def version_cmp(ver1, ver2): + print ">>>> ", ver1, ver2 + if LooseVersion(ver1) < LooseVersion(ver2): + print 1 + else: + print 0 + + +if __name__ == "__main__": + version_cmp(sys.argv[1], sys.argv[2]) diff --git a/scripts/versioncmp.sh b/scripts/versioncmp.sh new file mode 100644 index 0000000..f6e57e0 --- /dev/null +++ b/scripts/versioncmp.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# Copyright (c) 2012 Yu-Jie Lin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +VER_SPLIT_SED='s/\./ /g;s/\([[:digit:]]\)\([^[:digit:] ]\)/\1 \2/g;s/\([^[:digit:] ]\)\([[:digit:]]\)/\1 \2/g' + +# Compare with one element of version components +_ver_cmp_1() { + [[ "$1" = "$2" ]] && return 0 + if [[ -z "${1//[[:digit:]]/}" ]] && [[ -z "${2//[[:digit:]]/}" ]]; then + # Both $1 and $2 are numbers + # Using arithmetic comparison + (( $1 > $2 )) && return 1 + (( $1 < $2 )) && return 2 + else + # Either or both are not numbers, containing non-digit characters + # Using string comparison + [[ "$1" > "$2" ]] && return 1 + [[ "$1" < "$2" ]] && return 2 + fi + # This should not be happening + exit 1 +} + +version_cmp() { + local A B i result + A=($(sed "$VER_SPLIT_SED" <<< "$1")) + B=($(sed "$VER_SPLIT_SED" <<< "$2")) + i=0 + while (( i < ${#A[@]} )) && (( i < ${#B[@]})); do + _ver_cmp_1 "${A[i]}" "${B[i]}" + result=$? + [[ $result =~ [12] ]] && return $result + let i++ + done + # Which has more, then it is the newer version + _ver_cmp_1 "${#A[i]}" "${#B[i]}" + return $? +}