5 # Email : hayao@fascode.net
7 # (c) 2019-2020 Fascode Network.
11 script_name=$(basename ${0})
13 script_path="$(readlink -f ${0%/*})"
24 echo "usage ${0} [options] [packages] [packages] ..."
26 echo " General options:"
28 echo " -a | --arch <arch> Specify the architecture"
29 echo " -f | --force Overwrite existing directory"
30 echo " -s | --skip Skip if PKGBUILD already exists"
31 echo " -r | --repo <repo> Specify the repository name"
32 echo " -h | --help This help messageExecuted via administrator web and Yama D Saba APIs"
34 if [[ -n "${1:-}" ]]; then
41 # usage: echo_color -b <backcolor> -t <textcolor> -d <decoration> [Text]
64 # You can specify multiple decorations with ;.
65 # 0 => All attributs off (ノーマル)
67 # 4 => Underscore (下線)
69 # 7 => Reverse video on (色反転)
83 while getopts 'b:t:d:n' arg; do
85 b) backcolor="${OPTARG}" ;;
86 t) textcolor="${OPTARG}" ;;
87 d) decotypes="${OPTARG}" ;;
88 n) echo_opts="-n -e" ;;
94 echo ${echo_opts} "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v textcolor ]] && echo -n ";${textcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${*}\e[m"
98 # Show an INFO message
105 while getopts 'n' arg; do
107 n) echo_opts="${echo_opts} -n" ;;
110 shift $((OPTIND - 1))
111 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '32' 'Info') ${*}"
115 # Show an Warning message
122 while getopts 'n' arg; do
124 n) echo_opts="${echo_opts} -n" ;;
127 shift $((OPTIND - 1))
128 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '33' 'Warning') ${*}" >&2
132 # Show an debug message
139 while getopts 'n' arg; do
141 n) echo_opts="${echo_opts} -n" ;;
144 shift $((OPTIND - 1))
145 if [[ "${debug}" = true ]]; then
146 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '35' 'Debug') ${*}"
151 # Show an ERROR message then exit with status
153 # $2: exit code number (with 0 does not exit)
160 while getopts 'n' arg; do
162 n) echo_opts="${echo_opts} -n" ;;
165 shift $((OPTIND - 1))
166 echo ${echo_opts} "$( echo_color -t '36' "[${script_name}]") $( echo_color -t '31' 'Error') ${1}" >&2
167 if [[ -n "${2:-}" ]]; then
173 # Delete the file if it exists.
174 # For directories, rm -rf is used.
175 # If the file does not exist, skip it.
176 # remove <file> <file> ...
181 for _file in "${_list[@]}"; do
182 if [[ -f ${_file} ]]; then
183 _msg_debug "Removeing ${_file}"
185 elif [[ -d ${_file} ]]; then
186 _msg_debug "Removeing ${_file}"
193 if [[ -z "${@}" ]]; then
197 _opt_short="h,r:,a:sf"
198 _opt_long="help,repo:,arch:,skip,force"
200 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
201 if [[ ${?} != 0 ]]; then
237 _msg_error "Invalid argument '${1}'"
246 if [[ "${force}" = true ]]; then
247 rm -rf "${script_path}/${repo}/${arch}/${pkg}"
248 elif [[ -d "${script_path}/${repo}/${arch}/${pkg}" ]]; then
249 _msg_error "${pkg} has already been added."
250 if [[ "${skip}" = true ]]; then
256 mkdir -p "${script_path}/${repo}/${arch}/${pkg}"
257 git clone "https://aur.archlinux.org/${pkg}.git" "${script_path}/${repo}/${arch}/${pkg}"
258 rm -rf "${script_path}/${repo}/${arch}/${pkg}/.git"