Initial commit: Uploaded everything from abs/core
[arch-rock.git] / base / pacman / pacman.install
blob4c6fb06bfb70dfeb912d776d9aeee657e7c94e93
1 # arg 1:  the new package version
2 post_install() {
3   _rankmirrors
6 # arg 1:  the new package version
7 # arg 2:  the old package version
8 post_upgrade() {
9         # one time stuff for md5sum issue with older pacman versions
10         if [ "$(vercmp $2 3.0.2)" -lt 0 ]; then
11                 _resetbackups
12         fi
13         if [ "$(vercmp $2 3.1.0)" -lt 0 ]; then
14                 _upgrade310
15         fi
18 _rankmirrors() {
19   echo ">>> Use of the rankmirrors script on /etc/pacman.d/mirrorfile file is"
20   echo ">>> highly recommended. Python is required, and read rankmirrors --help"
21   echo ">>> for details. In addition, mirrors are now listed by country, so"
22   echo ">>> move those that are geographically close to you to the top and"
23   echo ">>> remove the others BEFORE running rankmirrors."
26 _resetbackups() {
27         echo ">>> Performing one-time reset of NoUpgrade md5sums. After this reset"
28         echo ">>> you are able to remove all NoUpgrade lines of already protected"
29         echo ">>> files from pacman.conf."
30         echo ">>>"
32         # path variables
33     pacconf="/etc/pacman.conf"
34     dbpath="/var/lib/pacman/local"
36     # get a list of NoUpgrade files from the user's pacman.conf
37     echo ">>> Retrieving pacman.conf NoUpgrade list..."
38     config=$(grep "^NoUpgrade" $pacconf | cut -d'=' -f2)
39     # add the standard list of files, even if they are already above
40     config="$config \
41     etc/passwd etc/group etc/shadow etc/sudoers \
42     etc/fstab etc/raidtab etc/ld.so.conf \
43     etc/rc.conf etc/rc.local \
44     etc/modprobe.conf etc/modules.conf \
45     etc/lilo.conf boot/grub/menu.lst"
47     # blank md5sum for use in sed expression
48     zeroes='00000000000000000000000000000000'
50     for file in $config; do
51         echo ">>> -> finding owner of /$file..."
52         line=$(LC_ALL=C LANG=C pacman -Qo /$file 2>/dev/null)
53         # if file is owned by a package, go find its incorrectly stored sum
54         if [ ! -z "$line" ]; then
55             # get the name and version of the package owning file
56             name=$(echo $line | awk '{print $5}')
57             version=$(echo $line | awk '{print $6}')
58             # set the path to the backup array holding the md5sum
59             path="$dbpath/$name-$version/files"
60             # run a sed on the path to reset the line containing $file
61             # NOTE: literal tab characters in sed expression after $file
62             echo ">>> -> resetting sum of /$file..."
63             sed -i "s#$file [0-9a-fA-F]*#$file  $zeroes#" $path
64         else
65             echo ">>> -> $file is unowned."
66         fi
67     done
70 # TODO not used yet, we'll use it in later pacman upgrades
71 _cleanrequiredby() {
72     dbpath="/var/lib/pacman/local"
73     echo ">>> Cleaning out unnecessary requiredby entries from DB."
74     echo ">>> -> making local DB backup at /tmp/pacmanDB.tgz..."
75     bsdtar -czf /tmp/pacmanDB.tgz "$dbpath"
76     echo ">>> -> removing entries..."
77     grep -Rl REQUIREDBY /var/lib/pacman/local | xargs sed -i '/^%REQUIREDBY%/,/^$/ d'
78     echo ">>> -> done."
81 _upgrade310() {
82         # makepkg.conf syntax changed in 3.1
83         echo ">>> The makepkg.conf syntax has changed, please note the new format"
84         echo ">>> when merging the pacnew file with your old configuration."
85         echo ">>>"
86         # pacman.conf syntax changed in 3.1
87         echo ">>> The pacman.conf default file has changed. Please update your"
88         echo ">>> config to use the single mirrorlist, and any additional files"
89         echo ">>> in /etc/pacman.d/ (core, extra, etc.) can be deleted."
90         echo ">>>"
91         # sync DB location changed in 3.1
92         echo ">>> The location of sync DBs has moved from /var/lib/pacman/ to"
93         echo ">>> /var/lib/pacman/sync/ for several reasons. To delete older"
94         echo ">>> DBs, please run pacman -Sc and follow the instructions."
95         echo ">>> You will also have to run pacman -Sy to refresh the sync DBs."
96         echo ">>>"
97         # abs is no longer included
98         echo ">>> abs is no longer included; please install the 'abs' package"
99         echo ">>> to use abs. You may need to edit abs.conf to re-enable repos."
103 op=$1
104 shift
105 $op $*