5 # __ _____\ \ ,_\ _____ __ ___
6 # /'__`\ /\ '__`\ \ \//\ '__`\ /'__`\ /'___\
7 #/\ \L\.\\ \ \L\ \ \ \\ \ \L\ /\ \L\.\_/\ \__/
8 #\ \__/.\_\ \ ,__/\ \__\ \ ,__\ \__/.\_\ \____\
9 # \/__/\/_/\ \ \/ \/__/\ \ \/ \/__/\/_/\/____/
12 # a pacman wrapper with syntax based on debian's apt
13 # (c) 2019-2020 Fascode Network.
14 # License: Do What The Fuck You Want To Public License
15 # maintained by Yamada Hayao
17 # Enter the path to the AUR helper you want to use here.
18 # If it is empty, the corresponding AUR helper will be searched automatically.
23 APTPAC_VERSION="3.2.1"
35 DEFAULT_PACMAN_COMMAND="/usr/bin/pacman"
36 PACMAN_COMMAND="${DEFAULT_PACMAN_COMMAND}"
37 PACMAN_CONFIG="/etc/pacman.conf"
53 if [[ ! "${UID}" = 0 ]]; then
54 if [[ -z "${AURHELPER+SET}" ]]; then
55 for AURHELPER in ${HELPERS[@]}; do
56 if [[ -f "${AURHELPER}" ]]; then
57 PACMAN_COMMAND="${AURHELPER}"
59 elif hash "$(basename "${AURHELPER}")" 2> /dev/null; then
60 PACMAN_COMMAND="$(basename "${AURHELPER}")"
64 if [[ "${PACMAN_COMMAND}" == "${DEFAULT_PACMAN_COMMAND}" ]]; then
65 PACMAN_COMMAND="sudo ${DEFAULT_PACMAN_COMMAND}"
68 if [[ -f "${AURHELPER}" ]]; then
69 PACMAN_COMMAND="${AURHELPER}"
70 elif hash "$(basename "${AURHELPER}")" 2> /dev/null; then
71 PACMAN_COMMAND="$(basename "${AURHELPER}")"
73 _msg_error "${AURHELPER} is not installed"
84 echo "usage ${0} [options] [command] [packages]"
87 echo " install Install the specified package"
88 echo " remove Remove the specified package"
89 echo " purge Permanently remove the package"
90 echo " update Update package database"
91 echo " upgrade | full-upgrade Update packages"
92 echo " edit-sources Edit config file of pacman"
93 echo " search Search for a package"
94 echo " autoremove Remove unnecessary packages"
95 echo " clean Remove the package cache"
96 echo " list Displays a list of packages"
97 echo " show Displays the package records"
100 echo " -y | --yes | --assume-yes Do not check"
101 echo " -d | --download-only Only download the package"
102 echo " -c | --config-file <file> Config file for pacman"
103 echo " -h | --help Display this help"
104 echo " -v | --version Displays the version of aptpac and pacman"
105 echo " --auto-remove | --autoremove Remove unnecessary packages with other command"
106 echo " --purge Delete the entire configuration file"
108 echo " pacapt options:"
109 echo " --aur-helper <command> Specifies the command to use as the AUR helper"
110 echo " Ignored if pacapt is run as root"
111 echo " Specify AUR helper that supports common command line options with pacman"
113 echo " aptpac supports not only above options but also options of pacman"
122 aptpac ${APTPAC_VERSION} - A pacman wrapper with syntax based on debian's apt
123 License: Do What The Fuck You Want To Public License
124 (c) 2019-2020 Fascode Network. Yamada Hayao
132 PACMAN_OPTIONS="${PACMAN_OPTIONS} ${@}"
135 # Argument analysis and processing
137 PACAPT_ARGUMENTS="${@}"
138 _opt_short="ydfc:hvVDFQRSTU"
139 _opt_long="yes,assume-yes,download-only,fix-broken,purse,installed,debug,help,version,config-file:,auto-remove,autoremove,aur-helper:"
140 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}" 2> /dev/null)
142 #if [[ ${?} != 0 ]]; then
147 #echo "Argument is \"${OPT}\""
148 unset OPT _opt_short _opt_long
152 -y | --yes | --assume-yes)
153 ADD_OPTION "--noconfirm"
156 -d | --download-only)
189 --autoremove | --auto-remove)
194 if [[ ! "${UID}" = 0 ]] && [[ -f "${2}" ]]; then
195 PACMAN_COMMAND="${2}"
196 elif [[ "${UID}" = 0 ]]; then
197 _msg_warn "The specified AUR helper is not used because pacapt is running on the root."
198 elif hash "$(basename "${2}")" 2> /dev/null; then
199 PACMAN_COMMAND="$(basename "${2}")"
201 _msg_error "${2} is not installed"
206 -V | -D | -F | -Q | -R | -S | -T | -U)
208 ADD_OPTION "${PACAPT_ARGUMENTS}"
216 _msg_error "Invalid argument '${1}'"
223 if [[ "${direct_option}" = false ]]; then
224 if [[ $# -lt 1 ]]; then
225 _msg_error "No command specified"
264 if [[ -n "${EDITOR}" ]]; then
265 sudo ${EDITOR} "${PACMAN_CONFIG}"
267 sudo nano "${PACMAN_CONFIG}"
272 if [[ "$(source "/etc/locale.conf" 2> /dev/null; echo -n "${LANG}")" = "ja_JP.UTF-8" ]]; then
273 echo "(ง •ᴗ•)ว ⁾⁾ファーウェイでウェイウェイ"
276 _msg_error "Invalid command '${COMMAND}'"
287 echo "...."Have you mooed today?"..."
291 if [[ -n "$(${PACMAN_COMMAND} -Qttdq)" ]]; then
293 PACKAGE=($(${PACMAN_COMMAND} -Qttdq))
295 echo "No packages to remove"
300 if ${installed}; then
301 ADD_OPTION "-Q | grep"
307 for pkg in "${PACKAGE[@]}"; do
308 if pacman -Qq "${pkg}" 2> /dev/null 1>&2; then
309 ${PACMAN_COMMAND} ${PACMAN_OPTIONS} -Qi --config "${PACMAN_CONFIG}" "${pkg}"
311 ${PACMAN_COMMAND} ${PACMAN_OPTIONS} -Si --config "${PACMAN_CONFIG}" "${pkg}"
317 _msg_error "Invalid command '${COMMAND}'"
323 if [[ ! "${PACMAN_COMMAND}" = "pacman" ]] && [[ ! "${PACMAN_COMMAND}" = "sudo pacman" ]]; then
324 _msg_debug "Use AUR helper ${PACMAN_COMMAND}"
327 # echo "${PACMAN_COMMAND} ${PACMAN_OPTIONS} ${PACKAGE}"
328 ${PACMAN_COMMAND} ${PACMAN_OPTIONS} --config "${PACMAN_CONFIG}" "${PACKAGE[@]}"
330 if ${autoremove}; then
331 if [[ -n $(${PACMAN_COMMAND} -Qttdq) ]]; then
332 ${PACMAN_COMMAND} -Rsc --config "${PACMAN_CONFIG}" $(${PACMAN_COMMAND} -Qttdq)
334 echo "No packages to remove"