FS#29731 - pre_upgrade script miss $2 (old version)

Attached to Project: Pacman
Opened by Sébastien Luttringer (seblu) - Thursday, 03 May 2012, 19:17 GMT
Last edited by Allan McRae (Allan) - Sunday, 31 March 2013, 07:08 GMT
Task Type Bug Report
Category General
Status Closed
Assigned To Dan McGee (toofishes)
Architecture All
Severity Medium
Priority Normal
Reported Version 4.0.3
Due in Version 4.1.0
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Summary and Info:
Manual page claims there is 2 args in pre_upgrade script.

<quote>
pre_upgrade
Run right before files are extracted. Two arguments are passed in this order: new package full version
string, old package full version string.
</quote>

With the current stable version of pacman, pre_upgrade is called only with new version.
This break PKGBUILD which use old version to remove old kernel module (e.g: virtualbox-bin)

$ pacman -V

.--. Pacman v4.0.3 - libalpm v7.0.3
/ _.-' .-. .-. .-. Copyright (C) 2006-2012 Pacman Development Team
\ '-. '-' '-' '-' Copyright (C) 2002-2006 Judd Vinet
'--'
This program may be freely redistributed under
the terms of the GNU General Public License.


Steps to Reproduce:

= First install =
$ pacman -U fake-1-1-any.pkg.tar.xz
loading packages...
resolving dependencies...
looking for inter-conflicts...

Targets (1): fake-1-1


Proceed with installation? [Y/n]
(1/1) checking package integrity [########################################] 100%
(1/1) loading package files [########################################] 100%
(1/1) checking for file conflicts [########################################] 100%
+ pre_install 1-1
+ echo 1-1
1-1
(1/1) installing fake [########################################] 100%
+ post_install 1-1
+ echo 1-1
1-1

$ pacman -U fake-2-1-any.pkg.tar.xz
loading packages...
resolving dependencies...
looking for inter-conflicts...

Targets (1): fake-2-1


Proceed with installation? [Y/n]
(1/1) checking package integrity [########################################] 100%
(1/1) loading package files [########################################] 100%
(1/1) checking for file conflicts [########################################] 100%
+ pre_upgrade 2-1
+ echo 2-1
2-1
(1/1) upgrading fake [########################################] 100%
+ post_upgrade 2-1 1-1
+ echo 2-1 1-1
2-1 1-1
This task depends upon

Closed by  Allan McRae (Allan)
Sunday, 31 March 2013, 07:08 GMT
Reason for closing:  Fixed
Additional comments about closing:  Git commit 1bf05e70
Comment by Allan McRae (Allan) - Thursday, 03 May 2012, 22:13 GMT
Looks like it was broken with commit 73139ccb
Comment by Peter Wu (Lekensteyn) - Sunday, 28 October 2012, 22:42 GMT
It is still broken. Last time I checked (<1 month) in libalpm, it just passes a NULL (or empty string? sth like that) as "old version" to the pre_upgrade/post_upgrade steps.

For DKMS packages, availability of the old version before upgrading is important to clean up mess. I have implemented a workaround for DKMS packages that I maintain:
https://wiki.archlinux.org/index.php/DKMS#How_to_create_.install_.2F_dkms.conf_files.3F

pre_upgrade() {
local curver=${2%%-*}
# $2 is unset due to a bug. Query current version using pacman as fallback
[ -n "$curver" ] || curver=$(pacman -Qi PACKAGE_NAME | awk '/^Version/{print $3}')
pre_remove $curver
}

Loading...