OSDN Git Service

[update] : Supported --config-file
[alterlinux/aptpac.git] / aptpac
diff --git a/aptpac b/aptpac
index 55b5259..493e9b3 100755 (executable)
--- a/aptpac
+++ b/aptpac
 #            \/_/         \/_/
 # a pacman wrapper with syntax based on debian's apt
 # (c) 2019-2020 Fascode Network.
+# License: Do What The Fuck You Want To Public License
 # maintained by Yamada Hayao
 
-APTPAC_VERSION="3.0.0"
+# Enter the path to the AUR helper you want to use here. 
+# If it is empty, the corresponding AUR helper will be searched automatically.
+AURHELPER=
 
-set -e
 
+
+set -e
+APTPAC_VERSION="3.0.1"
 PACMAN_OPTIONS=
-AURHELPER=
 HELPERS=(
     "/usr/bin/yay"
     "/usr/bin/yaourt"
@@ -26,12 +30,10 @@ HELPERS=(
     "/usr/bin/pikaur"
     "/usr/bin/pacaur"
 )
-
-DEFAULT_PACMAN_COMMAND="pacman"
-
+DEFAULT_PACMAN_COMMAND="/usr/bin/pacman"
 debug=false
 PACMAN_COMMAND="${DEFAULT_PACMAN_COMMAND}"
-
+PACMAN_CONFIG="/etc/pacman.conf"
 
 _msg_error () {
     echo -e "${@}" >&2
@@ -63,7 +65,7 @@ if [[ ! "${UID}" = 0 ]]; then
         elif hash "$(basename "${AURHELPER}")" 2> /dev/null; then
             PACMAN_COMMAND="$(basename "${AURHELPER}")"
         else
-            _msg_error "${AURHELPER} is not installed."
+            _msg_error "${AURHELPER} is not installed"
             exit 1
         fi
     fi
@@ -76,23 +78,25 @@ installed=false
 _usage () {
     echo "usage ${0} [options] [command] [packages]"
     echo " commands:              "
-    echo "    install                       Install the specified package."
-    echo "    remove                        Remove the specified package."
-    echo "    purge                         Permanently remove the package."
-    echo "    update                        Update the package database."
-    echo "    upgrade                       Update the package."
-    echo "    search                        Search for a package."
-    echo "    autoremove                    Remove unnecessary packages."
-    echo "    clean                         Remove the package cache."
-    echo "    list                          Displays a list of packages."
+    echo "    install                       Install the specified package"
+    echo "    remove                        Remove the specified package"
+    echo "    purge                         Permanently remove the package"
+    echo "    update                        Update the package database"
+    echo "    upgrade                       Update the package"
+    echo "    full-upgrade                  Update packages and remove unnecessary packages"
+    echo "    edit-sources                  Edit /etc/pacman.conf"
+    echo "    search                        Search for a package"
+    echo "    autoremove                    Remove unnecessary packages"
+    echo "    clean                         Remove the package cache"
+    echo "    list                          Displays a list of packages"
     echo
     echo " general options:       "
-    echo "    -y | --yes  | --assume-yes    Do not check."
-    echo "    -d | --download-only          Only download the package."
-    echo "    -c <file>                     Config file for pacman."
-    echo "    -h | --help                   Display this help."
-    echo "    -v | --version                Displays the version of aptpac and pacman."
-    echo "    --purge                       Delete the entire configuration file."
+    echo "    -y | --yes  | --assume-yes    Do not check"
+    echo "    -d | --download-only          Only download the package"
+    echo "    -c | --config-file <file>     Config file for pacman"
+    echo "    -h | --help                   Display this help"
+    echo "    -v | --version                Displays the version of aptpac and pacman"
+    echo "         --purge                  Delete the entire configuration file"
 }
 
 _exit () {
@@ -102,6 +106,7 @@ _exit () {
 _version () {
 cat << EOF
 aptpac ${APTPAC_VERSION} - A pacman wrapper with syntax based on debian's apt
+License: Do What The Fuck You Want To Public License
 (c) 2019-2020 Fascode Network. Yamada Hayao
 EOF
 echo
@@ -115,7 +120,7 @@ ADD_OPTION () {
 
 # Argument analysis and processing
 _opt_short="ydfc:hv"
-_opt_long="yes,assume-yes,download-only,fix-broken,purse,installed,debug,help,version"
+_opt_long="yes,assume-yes,download-only,fix-broken,purse,installed,debug,help,version,config-file:"
 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
 if [[ ${?} != 0 ]]; then
     exit 1
@@ -138,8 +143,8 @@ while true; do
         -f | --fix-broken)
             shift 1
             ;;
-        -c)
-            ADD_OPTION "--config ${2}"
+        -c | --config-file)
+            PACMAN_CONFIG="${2}"
             shift 2
             ;;
         --purge)
@@ -198,11 +203,12 @@ case "${COMMAND}" in
     edit-sources) sudo nano /etc/pacman.conf; _exit 0 ;;
     dist-upgrade) ADD_OPTION "-Syu" ;;
     huawei) 
+        source "/etc/locale.conf"
         if [[ "${LANG}" = "ja_JP.UTF-8" ]]; then
             echo "(ง •ᴗ•)ว ⁾⁾ファーウェイでウェイウェイ"
             _exit 0
         else
-            _msg_error "Invalid comman '${COMMAND}'"
+            _msg_error "Invalid command '${COMMAND}'"
             _exit 1
         fi
         ;;
@@ -225,7 +231,7 @@ EOF
                     ADD_OPTION "=Rsc"
                     PACKAGE="$(${PACMAN_COMMAND} -Qttdq)"
                 else
-                    echo "No packages to remove."
+                    echo "No packages to remove"
                     exit 0
                 fi
                 ;;
@@ -237,14 +243,14 @@ EOF
         fi
         ;;
     *)
-        _msg_error "Invalid comman '${COMMAND}'"
+        _msg_error "Invalid command '${COMMAND}'"
         _exit 1
         ;;
 esac
 
 if [[ ! "${PACMAN_COMMAND}" = "pacman" ]] && [[ ! "${PACMAN_COMMAND}" = "sudo pacman" ]]; then
-    _msg_debug "Use AUR helper ${PACMAN_COMMAND}."
+    _msg_debug "Use AUR helper ${PACMAN_COMMAND}"
 fi
 
 # echo "${PACMAN_COMMAND} ${PACMAN_OPTIONS} ${PACKAGE}"
-${PACMAN_COMMAND} ${PACMAN_OPTIONS} ${PACKAGE}
+${PACMAN_COMMAND} ${PACMAN_OPTIONS} --config "${PACMAN_CONFIG}" ${PACKAGE}