What’s the best practice when installing new version of software if the rpm supports installing multiple versions? Looks like the user has to use “rpm -U” command to do that. Because it’s not allowed to uninstall the software in %pre section, if the user uses “rpm -i” command to install software, there will be multiple versions installed on the system. Following is a spec example. I use it to build out 2 packages: Software-1.0-1.rpm and Software-2.0-1.rpm (change the Rev from 1.0 to 2.0) %define Package Software %define Rev 1.0 %define Rel 1 %define ViewName NightlyLinux %define UserName admin %define TempArea /tmp/%{Rev} %define __strip /bin/true Summary: Software Name: %{Package} Version: %{Rev} Release: %{Rel} License: ABC Corp. Group: Utilities/System Distribution: ABC Corp. Vendor: ABC Corp. Packager: ABC Corp. AutoReqProv: no BuildRoot: /tmp/linux/%{Rev} %description Software %prep %build %install install -m 775 -d $RPM_BUILD_ROOT/opt install -m 775 -d $RPM_BUILD_ROOT/opt/software-%{Rev} install -m 755 /emc/zhengw2/test/software.sh $RPM_BUILD_ROOT/opt/software-%{Rev}/software.sh %clean %pre echo "$1 in pre" %post echo "$1 in post" %preun echo "$1 in preun" %postun echo "$1 in postun" %files %defattr (-,root,root) %dir /opt/software-%{Rev} /opt/software-%{Rev}/software.sh Here is what I got: When installing the Software-1.0-1, it’s first time to install, $1 is 1, which is correct: **** # rpm -ivh Software-1.0-1.x86_64.rpm Preparing... ########################################### [100%] 1 in pre 1:Software ########################################### [100%] 1 in post Then I install Software-2.0-1, it’s the second time to install, $1 is 2, even though I’m using “rpm -i” command: **** # rpm -ivh Software-2.0-1.x86_64.rpm Preparing... ########################################### [100%] 2 in pre 1:Software ########################################### [100%] 2 in post Because I’ve installed 2 versions, there are 2 folders under /opt, Software-1.0 and Software-2.0. Then I uninstall 2.0 and try with “rpm -U” command, $1 is 2, same as when I’m using “rpm -i” command: **** # rpm -e Software-2.0-1 1 in preun 1 in postun **** # rpm -q Software Software-1.0-1 **** # rpm -Uvh Software-2.0-1.x86_64.rpm Preparing... ########################################### [100%] 2 in pre 1:Software ########################################### [100%] 2 in post 1 in preun 1 in postun So in my case, $1 cannot be used to distinguish which command “rpm -i” or “rpm -U” is using. Thanks, Wendy From: Greg Swift [mailto:gregswift@xxxxxxxxx] So... i think you need to step back and take a different approach. RPM shouldn't be leaving the old version the the filesystem regardless of what you are doing. Can you share your spec ? On Tue, Nov 26, 2013 at 10:43 AM, Zheng, Wendy <wendy.zheng@xxxxxxx> wrote: Hi all,
|
_______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxxxxx http://lists.rpm.org/mailman/listinfo/rpm-list