5 # Email : hayao@fascode.net
7 # (c) 2019-2020 Fascode Network.
11 script_name=$(basename ${0})
13 script_path="$(readlink -f ${0%/*})"
22 echo "usage ${0} [options] [packages] [packages] ..."
24 echo " General options:"
26 echo " -a | --arch <arch> Specify the architecture."
27 echo " -r | --repo <repo> Specify the repository name"
28 echo " -h | --help This help messageExecuted via administrator web and Yama D Saba APIs"
30 if [[ -n "${1:-}" ]]; then
37 # usage: echo_color -b <backcolor> -t <textcolor> -d <decoration> [Text]
60 # You can specify multiple decorations with ;.
61 # 0 => All attributs off (ノーマル)
63 # 4 => Underscore (下線)
65 # 7 => Reverse video on (色反転)
79 while getopts 'b:t:d:n' arg; do
81 b) backcolor="${OPTARG}" ;;
82 t) textcolor="${OPTARG}" ;;
83 d) decotypes="${OPTARG}" ;;
84 n) echo_opts="-n -e" ;;
90 echo ${echo_opts} "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v textcolor ]] && echo -n ";${textcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${*}\e[m"
94 # Show an INFO message
101 while getopts 'n' arg; do
103 n) echo_opts="${echo_opts} -n" ;;
106 shift $((OPTIND - 1))
107 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '32' 'Info') ${*}"
111 # Show an Warning message
118 while getopts 'n' arg; do
120 n) echo_opts="${echo_opts} -n" ;;
123 shift $((OPTIND - 1))
124 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '33' 'Warning') ${*}" >&2
128 # Show an debug message
135 while getopts 'n' arg; do
137 n) echo_opts="${echo_opts} -n" ;;
140 shift $((OPTIND - 1))
141 if [[ "${debug}" = true ]]; then
142 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '35' 'Debug') ${*}"
147 # Show an ERROR message then exit with status
149 # $2: exit code number (with 0 does not exit)
156 while getopts 'n' arg; do
158 n) echo_opts="${echo_opts} -n" ;;
161 shift $((OPTIND - 1))
162 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '31' 'Error') ${1}" >&2
163 if [[ -n "${2:-}" ]]; then
169 # Delete the file if it exists.
170 # For directories, rm -rf is used.
171 # If the file does not exist, skip it.
172 # remove <file> <file> ...
177 for _file in "${_list[@]}"; do
178 if [[ -f ${_file} ]]; then
179 _msg_debug "Removeing ${_file}"
181 elif [[ -d ${_file} ]]; then
182 _msg_debug "Removeing ${_file}"
189 if [[ -z "${@}" ]]; then
194 _opt_long="help,repo:,arch:"
196 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
197 if [[ ${?} != 0 ]]; then
225 _msg_error "Invalid argument '${1}'"
234 mkdir -p "${script_path}/${repo}/${arch}/${pkg}"
235 git clone "https://aur.archlinux.org/${pkg}.git" "${script_path}/${repo}/${arch}/${pkg}"
236 rm -rf "${script_path}/${repo}/${arch}/${pkg}/.git"