5 # Email : hayao@fascode.net
7 # (c) 2019-2020 Fascode Network.
11 script_name=$(basename ${0})
13 script_path="$(readlink -f ${0%/*})"
23 echo "usage ${0} [options] [packages] [packages] ..."
25 echo " General options:"
27 echo " -a | --arch <arch> Specify the architecture"
28 echo " -f | --force Overwrite existing directory"
29 echo " -s | --skip Skip if PKGBUILD already exists"
30 echo " -r | --repo <repo> Specify the repository name"
31 echo " -h | --help This help messageExecuted via administrator web and Yama D Saba APIs"
33 if [[ -n "${1:-}" ]]; then
40 # usage: echo_color -b <backcolor> -t <textcolor> -d <decoration> [Text]
63 # You can specify multiple decorations with ;.
64 # 0 => All attributs off (ノーマル)
66 # 4 => Underscore (下線)
68 # 7 => Reverse video on (色反転)
82 while getopts 'b:t:d:n' arg; do
84 b) backcolor="${OPTARG}" ;;
85 t) textcolor="${OPTARG}" ;;
86 d) decotypes="${OPTARG}" ;;
87 n) echo_opts="-n -e" ;;
93 echo ${echo_opts} "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v textcolor ]] && echo -n ";${textcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${*}\e[m"
97 # Show an INFO message
104 while getopts 'n' arg; do
106 n) echo_opts="${echo_opts} -n" ;;
109 shift $((OPTIND - 1))
110 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '32' 'Info') ${*}"
114 # Show an Warning message
121 while getopts 'n' arg; do
123 n) echo_opts="${echo_opts} -n" ;;
126 shift $((OPTIND - 1))
127 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '33' 'Warning') ${*}" >&2
131 # Show an debug message
138 while getopts 'n' arg; do
140 n) echo_opts="${echo_opts} -n" ;;
143 shift $((OPTIND - 1))
144 if [[ "${debug}" = true ]]; then
145 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '35' 'Debug') ${*}"
150 # Show an ERROR message then exit with status
152 # $2: exit code number (with 0 does not exit)
159 while getopts 'n' arg; do
161 n) echo_opts="${echo_opts} -n" ;;
164 shift $((OPTIND - 1))
165 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '31' 'Error') ${1}" >&2
166 if [[ -n "${2:-}" ]]; then
172 # Delete the file if it exists.
173 # For directories, rm -rf is used.
174 # If the file does not exist, skip it.
175 # remove <file> <file> ...
180 for _file in "${_list[@]}"; do
181 if [[ -f ${_file} ]]; then
182 _msg_debug "Removeing ${_file}"
184 elif [[ -d ${_file} ]]; then
185 _msg_debug "Removeing ${_file}"
192 if [[ -z "${@}" ]]; then
197 _opt_long="help,repo:,arch:"
199 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
200 if [[ ${?} != 0 ]]; then
236 _msg_error "Invalid argument '${1}'"
245 if [[ "${force}" = true ]]; then
246 rm -rf "${script_path}/${repo}/${arch}/${pkg}"
247 elif [[ -d "${script_path}/${repo}/${arch}/${pkg}" ]]; then
248 _msg_error "Hoge has already been added."
249 if [[ "${skip}" = true ]]; then
255 mkdir -p "${script_path}/${repo}/${arch}/${pkg}"
256 git clone "https://aur.archlinux.org/${pkg}.git" "${script_path}/${repo}/${arch}/${pkg}"
257 rm -rf "${script_path}/${repo}/${arch}/${pkg}/.git"