2 # Copyright (C) 2014 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # basic yum/apt package manager abstraction, plus a few minor conveniences
17 if type -p yum
> /dev
/null
; then
21 [[ $EUID == 0 ]] && x
=sudo
27 [[ $EUID == 0 ]] && x
=sudo
28 $x yum
-y install "$@"
33 [[ $EUID == 0 ]] && x
=sudo
36 # package remove/uninstall
39 [[ $EUID == 0 ]] && x
=sudo
40 $x yum autoremove
"$@"
44 [[ $EUID == 0 ]] && x
=sudo
45 $x yum
-y distro-sync full
55 [[ $EUID == 0 ]] && x
=sudo
60 [[ $EUID == 0 ]] && x
=sudo
61 # update package list if its more than an hour old
62 if (( $
(( $
(date +%s
) - $
(stat
-c %Y
/var
/lib
/apt
/periodic
/update-success-stamp
) )) > 60*60 )); then
65 $x aptitude
-y install "$@"
68 # scratch a very annoying itch.
69 # package description width as wide as the screen, and package name field small
70 # aptitude manual can't figure out how wide emacs terminal is,
71 # of course it doesn't consult the $COLUMNS variable...
72 # and in a normal terminal, it makes the package name field ridiculously big
73 # also, remove that useless dash before the description
75 [[ $EUID == 0 ]] && x
=sudo
76 $x aptitude
-F "%c%a%M %p %$((COLUMNS - 30))d" -w $COLUMNS search
"$@"
80 [[ $EUID == 0 ]] && x
=sudo
81 $x aptitude
-y purge
"$@"
85 [[ $EUID == 0 ]] && x
=sudo
86 $x aptitude
-y full-upgrade
"$@"