LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-27-2008, 05:47 AM   #1
shaybery
Member
 
Registered: Jan 2008
Posts: 30

Rep: Reputation: 15
So why "rpm -U" do NOT use --nopostun --nopreun by default ???


The command rpm -U is actually running rpm -i <rpm-v2> and then rpm -e <rpm-v1>.
This upgrade process can be a problematic, and this is the scenario:
there is rpm-v1 with post-uninstall script that "userdel testuser" if exist. BUT
there is rpm-v2 with post-install script that "useradd testuser" !!!

In this case if you run "rpm -i rpm-v1" and then do "rpm -U rpm-v2"
First it will run "useradd testuser" during the "rpm -i rpm-v1", and then
it will run "userdel testuser" during the "rpm -e rpm-v1".
So the testuser will not be defined on the system after upgrade. but this what we wanted to do in rpm-v2.

So why the rpm -U don't use by default the flag --nopostun and --nopreun?
because those flag disable the post\pre uninstall of the old rpm.
 
Old 12-27-2008, 10:59 PM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Why is this a problem?
Where are you getting this from?
 
Old 12-28-2008, 02:11 AM   #3
shaybery
Member
 
Registered: Jan 2008
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Simon Bridge View Post
Why is this a problem?
Where are you getting this from?
The problem is when u have rpm that execute postuninstall script,
and when u upgrade this rpm to a newer, then the postuninstall script (which execute during the rpm -U <newer-rpm>) can damage your system!
This is happand because the "rpm -U" is actually run
first "rpm -i <newer-rpm>"
second "rpm -i <older-rpm>"

I think that "rpm -U" should use by default the --nopostun and --nopreun
in order to disable those pre\post uninstall scripts of the older-rpm.
 
Old 12-28-2008, 06:15 AM   #4
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by shaybery View Post
The problem is when u have rpm that execute postuninstall script,
and when u upgrade this rpm to a newer, then the postuninstall script (which execute during the rpm -U <newer-rpm>) can damage your system!
This is happand because the "rpm -U" is actually run
first "rpm -i <newer-rpm>"
second "rpm -i <older-rpm>"

I think that "rpm -U" should use by default the --nopostun and --nopreun
in order to disable those pre\post uninstall scripts of the older-rpm.
all rpm's pre/post/install/uninstall scripts get as first argument ($1) a number of package instances after operation is finished,
i.e same postuninstall script when do 'rpm -e ' will get '0' in $1, and in 'rpm -U' - $1 will be '1'.
Postinstall script should check $1 and do correct thing for erase and for update.

There is no reason to disable scripts by default
 
Old 12-28-2008, 05:25 PM   #5
shaybery
Member
 
Registered: Jan 2008
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Valery Reznic View Post
all rpm's pre/post/install/uninstall scripts get as first argument ($1) a number of package instances after operation is finished,
i.e same postuninstall script when do 'rpm -e ' will get '0' in $1, and in 'rpm -U' - $1 will be '1'.
Postinstall script should check $1 and do correct thing for erase and for update.

There is no reason to disable scripts by default
So what you say that I need to right my pre\post unsiatll "right" with the use of the $1 parameter. $1=0 indicates that the rpm has been removed because rpm -e, $1=1 indicates that the rpm has been removed because rpm -U.

can you show me any rpm that use this $1 parameter?
 
Old 12-29-2008, 01:02 AM   #6
shaybery
Member
 
Registered: Jan 2008
Posts: 30

Original Poster
Rep: Reputation: 15
thanks for the help

Quote:
Originally Posted by Valery Reznic View Post
all rpm's pre/post/install/uninstall scripts get as first argument ($1) a number of package instances after operation is finished,
i.e same postuninstall script when do 'rpm -e ' will get '0' in $1, and in 'rpm -U' - $1 will be '1'.
Postinstall script should check $1 and do correct thing for erase and for update.

There is no reason to disable scripts by default
You are right!

This is exactly how people need to write rpms.
By using $1 parameter inside the pre\post uninstall it can be distinguished between pre\post uninstall scripts for uninstall that caused by upgrade and for uninstall that caused by a regular uninstall.

But the problem that most of the people that write rpm do not use this parameter, so in those cases I must run the upgrade by this command : "rpm -U --nopreun --nopostun <rpm-name>"

Thank you very much for your answer.
 
Old 12-29-2008, 01:20 AM   #7
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by shaybery View Post
So what you say that I need to right my pre\post unsiatll "right" with the use of the $1 parameter. $1=0 indicates that the rpm has been removed because rpm -e, $1=1 indicates that the rpm has been removed because rpm -U.

can you show me any rpm that use this $1 parameter?
Sure. for example bash.
It's post-uninstall looks like following:
Code:
%postun -p /bin/sh
if [ "$1" = 0 ]; then
    /bin/grep -v '^/bin/bash$' < /etc/shells | \
      /bin/grep -v '^/bin/sh$' > /etc/shells.new
    /bin/mv /etc/shells.new /etc/shells
fi
You can by yourself looks for the different spec files either in the sources or using
rpmrebuild (http://rpmrebuild.sf.net)

rpmrebuild -e <package> will do the trick

Valery
 
Old 12-30-2008, 03:41 AM   #8
shaybery
Member
 
Registered: Jan 2008
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks u very much.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Failed Dependency error" while installing RPM for "DateTime" perl modules giridhargopal.cj Linux - Newbie 7 11-19-2008 12:05 AM
Where to download rpm packages of "gocr" and "kooka" satimis Linux - Software 6 02-23-2006 11:35 PM
why is the default to fsck's "ignore error" "yes"? leftPeg Linux - Software 3 02-20-2006 02:02 AM
Difference Between "Source RPM" "Static RPM" Mic Q SUSE / openSUSE 2 03-30-2005 06:51 PM
Getting error: "ALSA device "default" is already in use by another program." brynjarh Debian 7 02-04-2005 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration