Browse code

Merge pull request #693 from dreur/upstream-debian-apt-history

Add apt-history function to debian plugin

Robby Russell authored on 26/12/2011 at 18:31:41
Showing 1 changed files
... ...
@@ -54,7 +54,7 @@ if [[ $use_sudo -eq 1 ]]; then
54 54
 
55 55
     # apt-get only
56 56
     alias ads="sudo $apt_pref dselect-upgrade"
57
-    
57
+
58 58
     # Install all .deb files in the current directory.
59 59
     # Warning: you will need to put the glob in single quotes if you use:
60 60
     # glob_subst
... ...
@@ -113,9 +113,6 @@ alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
113 113
 alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
114 114
 
115 115
 
116
-
117
-
118
-
119 116
 # Functions #################################################################
120 117
 # create a simple script that can be used to 'duplicate' a system
121 118
 apt-copy() {
... ...
@@ -132,11 +129,46 @@ apt-copy() {
132 132
     chmod +x apt-copy.sh
133 133
 }
134 134
 
135
+# Prints apt history
136
+# Usage:
137
+#   apt-history install
138
+#   apt-history upgrade
139
+#   apt-history remove
140
+#   apt-history rollback
141
+#   apt-history list
142
+# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
143
+apt-history () {
144
+  case "$1" in
145
+    install)
146
+      zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
147
+      ;;
148
+    upgrade|remove)
149
+      zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
150
+      ;;
151
+    rollback)
152
+      zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
153
+        grep "$2" -A10000000 | \
154
+        grep "$3" -B10000000 | \
155
+        awk '{print $4"="$5}'
156
+      ;;
157
+    list)
158
+      zcat $(ls -rt /var/log/dpkg*)
159
+      ;;
160
+    *)
161
+      echo "Parameters:"
162
+      echo " install - Lists all packages that have been installed."
163
+      echo " upgrade - Lists all packages that have been upgraded."
164
+      echo " remove - Lists all packages that have been removed."
165
+      echo " rollback - Lists rollback information."
166
+      echo " list - Lists all contains of dpkg logs."
167
+      ;;
168
+  esac
169
+}
135 170
 
136 171
 # Kernel-package building shortcut
137 172
 kerndeb () {
138 173
     # temporarily unset MAKEFLAGS ( '-j3' will fail )
139
-    MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )		
174
+    MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
140 175
     print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
141 176
 	appendage='-custom' # this shows up in $ (uname -r )
142 177
     revision=$(date +"%Y%m%d") # this shows up in the .deb file name