Rpm-Uvh update traps
Symptom
After upgrading with rpm-Uvh, the original soft link is deleted, and the rpm package is first uninstalled by rpm-e and then installed by rpm-ivh. The soft link is still in progress. This soft link is created when the rpm package is installed and will be deleted only when the rpm package is uninstalled.
Why does Uvh delete it during upgrade?
Solution Process
The deletion of soft links is written in the % preun segment of the sepc file, and the soft link is established in the % post segment of the spec file. So when I checked the update, the execution sequence of each segment in the spec file.
Upgrade execution sequence
1. Execute % pre In the spec file of the new package. 2. Install the dependent packages of the new package. 3. Execute the % post segment in the spec file of the new package. 4. Run the % preun section in the spec file of the old package. 5. Delete unnecessary old files in the new package. 6. Run the % postun section in the spec file of the old package.
The answer is obvious. During the upgrade process, a new package is installed and the old package is uninstalled. Therefore, the soft link is deleted.
Solution
When different operations are performed, different parameters are passed to the segment. The complete parameter transfer and interpretation are as follows.
When the first parameter passed in the % pre and % post segments is 1, an rpm package is installed. When the first parameter is 2, an existing package is upgraded. When the first parameter passed in the % preun and % postun segments is 0, a package is deleted. When the first parameter is 1, it indicates updating a package.
Therefore, before deleting a link, determine whether the passed parameter is 0 or 1.