From 57e3cc774bcdfcaad3b14c6f4679a126625a61eb Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 16 Mar 2014 01:30:46 +0330 Subject: [PATCH] configuration script done. ready to rc2 --- config.sh | 41 +++++++++++++++++++++++++++++++ install.sh | 2 +- kuso | 0 scripts/check_dep.sh | 54 +++++++++++++++++++++++++++++++++++++++++ scripts/log.sh | 23 ++++++++++++++++++ scripts/pypackage.py | 13 ++++++++++ scripts/versioncmp.py | 14 +++++++++++ scripts/versioncmp.sh | 56 +++++++++++++++++++++++++++++++++++++++++++ share/Kuso.desktop | 13 ++++++++++ 9 files changed, 215 insertions(+), 1 deletion(-) create mode 100755 config.sh create mode 100755 kuso create mode 100644 scripts/check_dep.sh create mode 100644 scripts/log.sh create mode 100644 scripts/pypackage.py create mode 100755 scripts/versioncmp.py create mode 100644 scripts/versioncmp.sh create mode 100644 share/Kuso.desktop diff --git a/config.sh b/config.sh new file mode 100755 index 0000000..bf700ee --- /dev/null +++ b/config.sh @@ -0,0 +1,41 @@ +#! /usr/bin/env bash + +. ./scripts/check_dep.sh + + +echo " _ __ ___ ___ ___ "; +echo " | |/ / _ ___ ___ |_ _| \| __|"; +echo " | ' < || (_-/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 +} + +function py_check_dep() { + local package=$1 + local hint=$2 + local existance=$3 + if [ "$existance" == "1" ] + then + info "$package version $version is fine. need ($version_to_check)" + else + error "Can't find python package '$package'." + info "$hint" + fi + +} 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/pypackage.py b/scripts/pypackage.py new file mode 100644 index 0000000..6d96acc --- /dev/null +++ b/scripts/pypackage.py @@ -0,0 +1,13 @@ +import sys + + +def check_for_package(pkg): + try: + __import__(pkg, globals(), locals(), [], -1) + print "1" + except ImportError: + print "0" + + +if __name__ == "__main__": + check_for_package(sys.argv[1]) 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 $? +} diff --git a/share/Kuso.desktop b/share/Kuso.desktop new file mode 100644 index 0000000..5fedc9c --- /dev/null +++ b/share/Kuso.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Kuso +GenericName=Kuso IDE +Comment=An Emacs base IDE for emacs lovers. +MimeType=text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-java;application/x-shellscript;text/x-c;text/x-c++;text/x-ruby;text/x-python; +Type=Application +Terminal=false +Categories=Development;TextEditor; +StartupWMClass=Kuso +Exec=--PATH--/kuso %F +Icon=--PATH--/share/kuso.tiff +Version=--VERSION-- \ No newline at end of file