OSDN Git Service

[update] : Added --clean
[alterlinux/wfa.git] / wfa
diff --git a/wfa b/wfa
index 25558a3..e9c6ce3 100755 (executable)
--- a/wfa
+++ b/wfa
@@ -71,6 +71,7 @@ wfa_command="wfa"
 
 #-- options (int) --#
 option_y_count=0
+sync_clean_count=0
 
 #-- options (str) --#
 aururl="https://aur.archlinux.org/"
@@ -729,6 +730,7 @@ check_installed_package() {
     fi
 }
 
+# ~/.cacheに相当するディレクトリを返します
 get_cache_dir() {
     local _user_config_dir _cache_dir
     if [[ -v XDG_CONFIG_HOME ]]; then
@@ -840,9 +842,9 @@ install_aur_package() {
     local _makedepends="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".makedepends[]?")"
     local _depends="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".depends[]?")"
     local _conflicts="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".conflicts[]?")"
-    msg_info "makedepends: %s" "${_makedepends}"
-    msg_info "depends: %s" "${_depends}"
-    msg_info "conflicts: %s " "${_conflicts}"
+    msg_debug "makedepends: %s" "${_makedepends}"
+    msg_debug "depends: %s" "${_depends}"
+    msg_debug "conflicts: %s " "${_conflicts}"
 
 
     # 衝突を確認
@@ -1025,6 +1027,17 @@ upgrade_aur_package() {
 
 operation_sync(){
     local _package
+    if (( "${sync_clean_count}" >= 1 )); then
+        remove "$(get_cache_dir)/wfa"
+        run_pacman ${pacman_args} $(
+            local _count
+            for _count in $(seq 1 ${sync_clean_count}); do
+                echo -n "-c "
+            done
+        )
+    fi
+
+
     if [[ "${sync_search}" = true ]]; then
         for _package in ${specified_packages[@]}; do
             search_aur_package "${_package}"
@@ -1052,8 +1065,8 @@ operation_sync(){
 
 # Parse options
 ARGUMENT="${@}"
-_opt_short="QRShVdb:aysu"
-_opt_long="query,remove,sync,help,version,debug,dbpath:,aururl,aur,noconfirm,config:,makepkg:,mflags:,pacman:,git:,gitflags:,gpg:,gpgflags:,makepkgconf:,nomakepkgconf,nodeps,refresh,bash-debug,msg-debug,sysupgrade"
+_opt_short="QRShVdb:aysuc"
+_opt_long="query,remove,sync,help,version,debug,dbpath:,aururl,aur,noconfirm,config:,makepkg:,mflags:,pacman:,git:,gitflags:,gpg:,gpgflags:,makepkgconf:,nomakepkgconf,nodeps,refresh,bash-debug,msg-debug,sysupgrade,color:,nocolor.clean"
 
 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
 [[ ${?} != 0 ]] && exit 1
@@ -1126,6 +1139,10 @@ while :; do
             sync_upgrade=true
             shift 1
             ;;
+        -c | --clean)
+            sync_clean_count=$(( sync_clean_count + 1 ))
+            shift 1
+            ;;
         --aururl)
             aururl="${2}"
             shift 2
@@ -1137,7 +1154,7 @@ while :; do
             ;;
         --config)
             pacman_config="${2}"
-            add_args pacman "--config \"${2}\""
+            add_args pacman "--config ${2}"
             shift 2
             ;;
         --makepkg)
@@ -1182,6 +1199,27 @@ while :; do
             msgdebug=true
             shift 1
             ;;
+        --color)
+            case "${2}" in
+                "never")
+                    nocolor=true
+                    add_args pacman "--color never"
+                    ;;
+                "always")
+                    nocolor=false
+                    add_args pacman "--color always"
+                    ;;
+                "auto")
+                    msg_error "auto is not currently supported."
+                    add_args pacman "--color auto"
+                    ;;
+            esac
+            ;;
+        --nocolor)
+            nocolor=true
+            add_args pacman "--color never"
+            shift 1
+            ;;
         -h | --help)
             usage
             shift 1