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.3.0"
35 DEFAULT_PACMAN_COMMAND="/usr/bin/pacman"
36 PACMAN_COMMAND="${DEFAULT_PACMAN_COMMAND}"
37 PACMAN_CONFIG="/etc/pacman.conf"
54 if [[ ! "${UID}" = 0 ]]; then
55 if [[ -z "${AURHELPER+SET}" ]]; then
56 for AURHELPER in "${HELPERS[@]}"; do
57 if [[ -f "${AURHELPER}" ]]; then
58 PACMAN_COMMAND="${AURHELPER}"
60 elif hash "$(basename "${AURHELPER}")" 2> /dev/null; then
61 PACMAN_COMMAND="$(basename "${AURHELPER}")"
66 if [[ -f "${AURHELPER}" ]]; then
67 PACMAN_COMMAND="${AURHELPER}"
68 elif hash "$(basename "${AURHELPER}")" 2> /dev/null; then
69 PACMAN_COMMAND="$(basename "${AURHELPER}")"
71 _msg_error "${AURHELPER} is not installed"
82 echo "usage ${0} [options] [command] [packages]"
85 echo " install Install the specified package"
86 echo " remove Remove the specified package"
87 echo " purge Permanently remove the package"
88 echo " update Update package database"
89 echo " upgrade | full-upgrade Update packages"
90 echo " edit-sources Edit config file of pacman"
91 echo " search Search for a package"
92 echo " autoremove Remove unnecessary packages"
93 echo " clean Remove the package cache"
94 echo " list Display a list of packages"
95 echo " show | showpkg Display the package records"
96 echo " rdepends Display the dependencies"
99 echo " -y | --yes | --assume-yes Do not check"
100 echo " -d | --download-only Only download the package"
101 echo " -c | --config-file <file> Config file for pacman"
102 echo " -h | --help Display this help"
103 echo " -v | --version Display the version of aptpac and pacman"
104 echo " --auto-remove | --autoremove Remove unnecessary packages with other command"
105 echo " --purge Delete the entire configuration file"
107 echo " pacapt options:"
108 echo " --aur-helper <command> Specifies the command to use as the AUR helper"
109 echo " Ignored if pacapt is run as root"
110 echo " Specify AUR helper that supports common command line options with pacman"
112 echo " aptpac supports not only above options but also options of pacman"
121 aptpac ${APTPAC_VERSION} - A pacman wrapper with syntax based on debian's apt
122 License: Do What The Fuck You Want To Public License
123 (c) 2019-2020 Fascode Network. Yamada Hayao
131 PACMAN_OPTIONS+=("${@}")
134 # Argument analysis and processing
136 PACAPT_ARGUMENTS=("${@}")
137 _opt_short="ydfc:hvVDFQRSTU"
138 _opt_long="yes,assume-yes,download-only,fix-broken,purse,installed,debug,help,version,config-file:,auto-remove,autoremove,aur-helper:"
139 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}" 2> /dev/null)
141 #if [[ ${?} != 0 ]]; then
146 #echo "Argument is \"${OPT}\""
147 unset OPT _opt_short _opt_long
151 -y | --yes | --assume-yes)
152 ADD_OPTION "--noconfirm"
155 -d | --download-only)
188 --autoremove | --auto-remove)
193 if [[ ! "${UID}" = 0 ]] && [[ -f "${2}" ]]; then
194 PACMAN_COMMAND="${2}"
195 elif [[ "${UID}" = 0 ]]; then
196 _msg_warn "The specified AUR helper is not used because pacapt is running on the root."
197 elif hash "$(basename "${2}")" 2> /dev/null; then
198 PACMAN_COMMAND="$(basename "${2}")"
200 _msg_error "${2} is not installed"
205 -V | -D | -F | -Q | -R | -S | -T | -U)
207 ADD_OPTION "${PACAPT_ARGUMENTS[@]}"
215 _msg_error "Invalid argument '${1}'"
222 if [[ "${direct_option}" = false ]]; then
223 if [[ $# -lt 1 ]]; then
224 _msg_error "No command specified"
263 if [[ -n "${EDITOR}" ]]; then
264 sudo "${EDITOR}" "${PACMAN_CONFIG}"
266 sudo nano "${PACMAN_CONFIG}"
271 if [[ "$(source "/etc/locale.conf" 2> /dev/null; echo -n "${LANG}")" = "ja_JP.UTF-8" ]]; then
272 echo "(ง •ᴗ•)ว ⁾⁾ファーウェイでウェイウェイ"
275 _msg_error "Invalid command '${COMMAND}'"
286 echo "....\"Have you mooed today?\"..."
290 if [[ -n "$(${PACMAN_COMMAND} -Qttdq)" ]]; then
292 while read -r pkg; do
294 done < <(${PACMAN_COMMAND} -Qttdq)
296 echo "No packages to remove"
301 if ${installed}; then
302 ADD_OPTION "-Q | grep"
308 for pkg in "${PACKAGE[@]}"; do
309 if pacman -Qq "${pkg}" 2> /dev/null 1>&2; then
310 ${PACMAN_COMMAND} "${PACMAN_OPTIONS[@]}" -Qi --config "${PACMAN_CONFIG}" "${pkg}"
312 ${PACMAN_COMMAND} "${PACMAN_OPTIONS[@]}" -Si --config "${PACMAN_CONFIG}" "${pkg}"
326 _msg_error "Invalid command '${COMMAND}'"
332 if [[ ! "${PACMAN_COMMAND}" = "${DEFAULT_PACMAN_COMMAND}" ]] && [[ ! "$(basename "${PACMAN_COMMAND}")" = "$(basename "${DEFAULT_PACMAN_COMMAND}")" ]]; then
333 _msg_debug "Use AUR helper ${PACMAN_COMMAND}"
339 if "${RUN_WITH_SUDO}"; then
346 _sudo "${PACMAN_COMMAND}" "${PACMAN_OPTIONS[@]}" --config "${PACMAN_CONFIG}" "${PACKAGE[@]}"
348 if "${autoremove}"; then
349 if [[ -n $(${PACMAN_COMMAND} -Qttdq) ]]; then
350 "${PACMAN_COMMAND}" -Qttdq | _sudo "${PACMAN_COMMAND}" -Rsc --config "${PACMAN_CONFIG}" -
352 echo "No packages to remove"