script_path="$(readlink -f ${0%/*})"
arch="x86_64"
+repo="alter-stable"
debug=false
-
+force=false
+skip=false
+nocolor=false
set -e
echo
echo " General options:"
echo
- echo " -a | --arch <arch> Specify the architecture."
+ echo " -a | --arch <arch> Specify the architecture"
+ echo " -f | --force Overwrite existing directory"
+ echo " -s | --skip Skip if PKGBUILD already exists"
echo " -r | --repo <repo> Specify the repository name"
echo " -h | --help This help messageExecuted via administrator web and Yama D Saba APIs"
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
}
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
}
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
}
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
_usage 0
fi
-_opt_short="h,r:,a:"
-_opt_long="help,repo:,arch:"
+_opt_short="h,r:,a:sf"
+_opt_long="help,repo:,arch:,skip,force,nocolor"
OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
if [[ ${?} != 0 ]]; then
arch="${2}"
shift 2
;;
+ --force | -f)
+ force=true
+ shift 1
+ ;;
+ --skip | -s)
+ skip=true
+ shift 1
+ ;;
+ --nocolor)
+ nocolor=true
+ shift 1
+ ;;
--)
shift 1
break
echo ${@}
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 "${pkg} has already been added."
+ if [[ "${skip}" = true ]]; then
+ continue
+ else
+ exit 1
+ fi
+ fi
mkdir -p "${script_path}/${repo}/${arch}/${pkg}"
git clone "https://aur.archlinux.org/${pkg}.git" "${script_path}/${repo}/${arch}/${pkg}"
rm -rf "${script_path}/${repo}/${arch}/${pkg}/.git"