OSDN Git Service

[update] : libldac
[alterlinux/alterlinux-pkgbuilds.git] / get_from_aur.sh
index df69a85..7c68346 100755 (executable)
@@ -12,9 +12,11 @@ script_name=$(basename ${0})
 
 script_path="$(readlink -f ${0%/*})"
 arch="x86_64"
+repo="alter-stable"
 debug=false
 force=false
 skip=false
+nocolor=false
 
 set -e
 
@@ -107,7 +109,11 @@ _msg_info() {
         esac
     done
     shift $((OPTIND - 1))
-    echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]")    $( echo_color -t '32' 'Info') ${*}"
+    if [[ "${nocolor}" = true ]]; then
+        echo ${echo_opts} "[${script_name}]    Info ${*}"
+    else
+        echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]")    $( echo_color -t '32' 'Info') ${*}"
+    fi
 }
 
 
@@ -124,7 +130,11 @@ _msg_warn() {
         esac
     done
     shift $((OPTIND - 1))
-    echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '33' 'Warning') ${*}" >&2
+    if [[ "${nocolor}" = true ]]; then
+        echo ${echo_opts} "[${script_name}] Warning ${*}"
+    else
+        echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '33' 'Warning') ${*}" >&2
+    fi
 }
 
 
@@ -142,7 +152,11 @@ _msg_debug() {
     done
     shift $((OPTIND - 1))
     if [[ "${debug}" = true ]]; then
-        echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]")   $( echo_color -t '35' 'Debug') ${*}"
+        if [[ "${nocolor}" = true ]]; then
+            echo ${echo_opts} "[${script_name}]   Debug ${*}"
+        else
+            echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]")   $( echo_color -t '35' 'Debug') ${*}"
+        fi
     fi
 }
 
@@ -162,7 +176,11 @@ _msg_error() {
         esac
     done
     shift $((OPTIND - 1))
-    echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]")   $( echo_color -t '31' 'Error') ${1}" >&2
+    if [[ "${nocolor}" = true ]]; then
+        echo ${echo_opts} "[${script_name}]   Error ${1}"
+    else
+        echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]")   $( echo_color -t '31' 'Error') ${1}" >&2
+    fi
     if [[ -n "${2:-}" ]]; then
         exit ${2}
     fi
@@ -194,7 +212,7 @@ if [[ -z "${@}" ]]; then
 fi
 
 _opt_short="h,r:,a:sf"
-_opt_long="help,repo:,arch:,skip,force"
+_opt_long="help,repo:,arch:,skip,force,nocolor"
 
 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
 if [[ ${?} != 0 ]]; then
@@ -228,6 +246,10 @@ while :; do
             skip=true
             shift 1
             ;;
+        --nocolor)
+            nocolor=true
+            shift 1
+            ;;
         --) 
             shift 1
             break
@@ -245,7 +267,7 @@ for pkg in ${@}; do
     if [[ "${force}" = true ]]; then
         rm -rf "${script_path}/${repo}/${arch}/${pkg}"
     elif [[ -d "${script_path}/${repo}/${arch}/${pkg}" ]]; then
-        _msg_error "Hoge has already been added."
+        _msg_error "${pkg} has already been added."
         if [[ "${skip}" = true ]]; then
             continue
         else