updated on Mon Jan 23 12:00:23 UTC 2012
[aur-mirror.git] / pacman-panis-git / pacman.install
blob294222ef457fcbea74c1b51abab9995060f5ba4e
1 #!/bin/sh
2 # arg 1: the new package version
3 # arg 2: the old package version
4 post_upgrade() {
5 # one time stuff for md5sum issue with older pacman versions
6 if [ "$(vercmp $2 3.0.2)" -lt 0 ]; then
7 _resetbackups
8 fi
11 _resetbackups() {
12 echo ">>> Performing one-time reset of NoUpgrade md5sums. After this reset"
13 echo ">>> you are able to remove all NoUpgrade lines of already protected"
14 echo ">>> files from pacman.conf."
15 echo ">>>"
17 # path variables
18 pacconf="/etc/pacman.conf"
19 dbpath="/var/lib/pacman/local"
21 # get a list of NoUpgrade files from the user's pacman.conf
22 echo ">>> Retrieving pacman.conf NoUpgrade list..."
23 config=$(grep "^NoUpgrade" $pacconf | cut -d'=' -f2)
24 # add the standard list of files, even if they are already above
25 config="$config \
26 etc/passwd etc/group etc/shadow etc/sudoers \
27 etc/fstab etc/raidtab etc/ld.so.conf \
28 etc/rc.conf etc/rc.local \
29 etc/modprobe.conf etc/modules.conf \
30 etc/lilo.conf boot/grub/menu.lst"
32 # blank md5sum for use in sed expression
33 zeroes='00000000000000000000000000000000'
35 for file in $config; do
36 echo ">>> -> finding owner of /$file..."
37 line=$(LC_ALL=C LANG=C pacman -Qo /$file 2>/dev/null)
38 # if file is owned by a package, go find its incorrectly stored sum
39 if [ ! -z "$line" ]; then
40 # get the name and version of the package owning file
41 name=$(echo $line | awk '{print $5}')
42 version=$(echo $line | awk '{print $6}')
43 # set the path to the backup array holding the md5sum
44 path="$dbpath/$name-$version/files"
45 # run a sed on the path to reset the line containing $file
46 # NOTE: literal tab characters in sed expression after $file
47 echo ">>> -> resetting sum of /$file..."
48 sed -i "s#$file [0-9a-fA-F]*#$file $zeroes#" $path
49 else
50 echo ">>> -> $file is unowned."
52 done