On Thu, May 02, 2013 at 05:22:20PM +0200, Farkas Levente wrote: > hi, > after we carefully examine this wiki: > https://fedoraproject.org/wiki/Packaging:ScriptletSnippets?rd=Packaging/ScriptletSnippets#Scriptlet_Ordering > still don't understand how rpm works (or the wiki is wrong). > suppose we've got a package pkg with this in the spec: > > %pre > . /usr/share/pkg/foo > pkg_pre > > %post > . /usr/share/pkg/foo > pkg_post > > where pkg_pre and pkg_post are shell functions in the /usr/share/pkg/foo > shell script file. pkg-1.0 has this function: > pkg_pre { echo "pre-1.0"; } > pkg_post { echo "post-1.0"; } > while pkg-2.0: > pkg_pre { echo "pre-2.0"; } > pkg_post { echo "post-2.0"; } > note: I had to modify your function definitions to look like this: function pkg_pre() { echo "pre-2.0"; } function pkg_post() { echo "post-2.0"; } > questions 1: > if i install pkg-1.0 will it echo pre-1.0? if yes how can it be possible > since the file /usr/share/pkg/foo only installed in step 3 which is > after step 2 (%pre of new package)? > Assuming that there's no version of pkg installed already and no other package providing the file it will error out because there's no /usr/share/pkg/foo at that time. > questions 2: > when i upgrade from 1.0 to 2.0 according to the above wiki step 2. it > should have to echo pre-2.0 or pre-1.0? since the already installed > /usr/share/pkg/foo is 1.0? but (after we test it) we got pre-2.0. why? > It will echo pre-1.0. $ sudo rpm -ivh pkg-1.0-1.fc17.x86_64.rpm Preparing... ########################################### [100%] /var/tmp/rpm-tmp.j2A9KT: line 1: /usr/share/pkg/foo: No such file or directory error: %pre(pkg-1.0-1.fc17.x86_64) scriptlet failed, exit status 1 error: pkg-1.0-1.fc17.x86_64: install failed $ sudo rpm -ivh pkg-1.0-1.fc17.x86_64.rpm --noscripts Preparing... ########################################### [100%] 1:pkg ########################################### [100%] $ sudo rpm -Uvh pkg-2.0-1.fc17.x86_64.rpm Preparing... ########################################### [100%] pre-1.0 1:pkg ########################################### [100%] post-2.0 I'm not sure why your testing is showing something different. > so what is the truth here and how can i run any kind of script or file > installed by 1.0 during the update process to 2.0? the only way seems to > %pre of the new package since step 3 install the new file (ie. overwrite > all old file), so all rpm scripts of the old packages runs after the new > files have been already installed. > Depends on what you want to do. For instance, other alternatives are: * Include the whole script in the scriptlet of the old package. This is probably best for short scripts: %pre echo "pre-%{version}" %post echo "post-%{version}" * Version the filename of the scripts on the filesystem: %install mkdir -p %{buildroot}/%{_datadir}/pkg cp -pr %{SOURCE0} %{buildroot}%{_datadir}/pkg/foo-%{version} %pre if [ $1 -gt 2 ] ; then . %{_datadir}/pkg/foo-%{version} pkg_pre fi %post . %{_datadir}/pkg/foo-%{version} pkg_post This works if you only need the %pre script to run on upgrade, not on initial install (and similar concerns for *any* usage within %postun ;-). -Toshio
Attachment:
pgpNxx8VQhFCK.pgp
Description: PGP signature
-- packaging mailing list packaging@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/packaging