@@ -34,6 +34,7 @@ DEFAULT_PACMAN_COMMAND="/usr/bin/pacman"
3434debug=false
3535PACMAN_COMMAND=" ${DEFAULT_PACMAN_COMMAND} "
3636PACMAN_CONFIG=" /etc/pacman.conf"
37+ autoremove=false
3738
3839_msg_error () {
3940 echo -e " ${@ } " >&2
@@ -78,25 +79,25 @@ installed=false
7879_usage () {
7980 echo " usage ${0} [options] [command] [packages]"
8081 echo " commands: "
81- echo " install Install the specified package"
82- echo " remove Remove the specified package"
83- echo " purge Permanently remove the package"
84- echo " update Update the package database"
85- echo " upgrade Update the package"
86- echo " full-upgrade Update packages and remove unnecessary packages"
87- echo " edit-sources Edit /etc/pacman.conf"
88- echo " search Search for a package"
89- echo " autoremove Remove unnecessary packages"
90- echo " clean Remove the package cache"
91- echo " list Displays a list of packages"
82+ echo " install Install the specified package"
83+ echo " remove Remove the specified package"
84+ echo " purge Permanently remove the package"
85+ echo " update Update package database"
86+ echo " upgrade | full-upgrade Update packages"
87+ echo " edit-sources Edit config file of pacman"
88+ echo " search Search for a package"
89+ echo " autoremove Remove unnecessary packages"
90+ echo " clean Remove the package cache"
91+ echo " list Displays a list of packages"
9292 echo
9393 echo " general options: "
94- echo " -y | --yes | --assume-yes Do not check"
95- echo " -d | --download-only Only download the package"
96- echo " -c | --config-file <file> Config file for pacman"
97- echo " -h | --help Display this help"
98- echo " -v | --version Displays the version of aptpac and pacman"
99- echo " --purge Delete the entire configuration file"
94+ echo " -y | --yes | --assume-yes Do not check"
95+ echo " -d | --download-only Only download the package"
96+ echo " -c | --config-file <file> Config file for pacman"
97+ echo " -h | --help Display this help"
98+ echo " -v | --version Displays the version of aptpac and pacman"
99+ echo " --auto-remove | --autoremove Remove unnecessary packages with other command"
100+ echo " --purge Delete the entire configuration file"
100101}
101102
102103_exit () {
@@ -120,7 +121,7 @@ ADD_OPTION () {
120121
121122# Argument analysis and processing
122123_opt_short=" ydfc:hv"
123- _opt_long=" yes,assume-yes,download-only,fix-broken,purse,installed,debug,help,version,config-file:"
124+ _opt_long=" yes,assume-yes,download-only,fix-broken,purse,installed,debug,help,version,config-file:,auto-remove,autoremove "
124125OPT=$( getopt -o ${_opt_short} -l ${_opt_long} -- " ${@ } " )
125126if [[ ${?} != 0 ]]; then
126127 exit 1
@@ -169,6 +170,10 @@ while true; do
169170 shift 1
170171 exit 0
171172 ;;
173+ --autoremove | --auto-remove)
174+ autoremove=true
175+ shift 1
176+ ;;
172177 --)
173178 shift 1
174179 break
@@ -231,9 +236,9 @@ case "${COMMAND}" in
231236 PACKAGE=" $( ${PACMAN_COMMAND} -Qttdq) "
232237 else
233238 echo " No packages to remove"
234- exit 0
235- fi
236- ;;
239+ exit 0
240+ fi
241+ ;;
237242 list)
238243 if ${installed} ; then
239244 ADD_OPTION " -Q | grep"
253258
254259# echo "${PACMAN_COMMAND} ${PACMAN_OPTIONS} ${PACKAGE}"
255260${PACMAN_COMMAND} ${PACMAN_OPTIONS} --config " ${PACMAN_CONFIG} " ${PACKAGE}
261+
262+ if ${autoremove} ; then
263+ if [[ -n $( ${PACMAN_COMMAND} -Qttdq) ]]; then
264+ ${PACMAN_COMMAND} -Rsc --config " ${PACMAN_CONFIG} " $( ${PACMAN_COMMAND} -Qttdq)
265+ else
266+ echo " No packages to remove"
267+ exit 0
268+ fi
269+ fi
0 commit comments