<div class="gmail_quote">On Mon, Oct 24, 2011 at 5:18 PM, Marco <span dir="ltr"><<a href="mailto:listaddr@gmail.com">listaddr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>
<br>
for reasons I won't go into here, I have a package that installs a<br>
file under /etc/package/file.instancename, then the postinst script<br>
appends the contents of that file to another (pre-existing) file on<br>
the filesystem (say, /etc/mainfile). Similarly, the preun script<br>
removes that block of data from the main file and leaves it as it was<br>
before the installation. This works nicely and allows us to install<br>
multiple instances of the package, each one contributing its own<br>
fragment to the main file, and without interfering with each other.<br>
The postinst script is carefully designed to do the right thing and<br>
not add the fragment twice (essentially, it either deletes the<br>
existing fragment in /etc/mainfile and readds the package-provided<br>
one, or doesn't touch it, depending on configuration parameters; but<br>
it does work ok).<br>
<br>
This breaks when someone uses rpm -U to upgrade, since it's equivalent<br>
to running rpm -i followed by rpm -e, which means that the postun<br>
script is ran last, so the end result is that the instance-specific<br>
fragment is missing from mainfile after the upgrade.<br>
<br>
How do people usually deal with this kind of situations?<br></blockquote><div>The precise order in update of the scriptlets is<br><ul><li>
<p>
Run %pre of new package
</p>
</li><li>
<p>
Install new files
</p>
</li><li>
<p>
Run %post of new package
</p>
</li><li>
<p>
Run %preun of old package
</p>
</li><li>
<p>
Delete any old files not overwritten by newer ones
</p>
</li><li>
<p>
Run %postun of old package
</p>
</li></ul>And postun is executed only on update (not install). The scriptlets  take an argument, the number of package that remains after the script complete: so you can know if you are in install or update for example and base your decision on this. Look at this for example <a href="http://fedoraproject.org/wiki/Packaging:ScriptletSnippets">http://fedoraproject.org/wiki/Packaging:ScriptletSnippets</a><br>
<br>hth<br><br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
_______________________________________________<br>
Rpm-list mailing list<br>
<a href="mailto:Rpm-list@lists.rpm.org">Rpm-list@lists.rpm.org</a><br>
<a href="http://lists.rpm.org/mailman/listinfo/rpm-list" target="_blank">http://lists.rpm.org/mailman/listinfo/rpm-list</a><br>
</blockquote></div><br>