Discussion:
Parameter passing between %pre and %post section
Lis Maria
2007-08-08 03:58:36 UTC
Permalink
Hi

I am trying to set a variable with some value in the %pre section, and I am
trying to access the variable in the %post setion but cannot. Is there any
possible way for passing variables between %pre and %post section ?

Thanks in advance for any Help

Lis Thomas
Bob Proulx
2007-08-08 05:24:34 UTC
Permalink
Post by Lis Maria
I am trying to set a variable with some value in the %pre section, and I am
trying to access the variable in the %post setion but cannot.
As you have discovered that won't work. The %pre and %post sections
are two different scripts each executed at different stages in the
install process. Because they are different scripts any variables set
in one won't be available in the other.
Post by Lis Maria
Is there any possible way for passing variables between %pre and
%post section ?
Not directly no.

Could you say a few words about what you are trying to do?

Bob
Lis Maria
2007-08-08 07:41:37 UTC
Permalink
Hi,

Thanks for your mail.

I am basically trying to set a flag in the %pre section which is used in the
%post section to perform some activities.
Currently I have writtent the entry to a temporary file and am reading that
file in the %post section. This, I understand is not an elegant one. is
there someway through which we cans etup a macro in the pre section and
access it elsewhere/

Thanks for your help.

Regards

Lis Thomas
Post by Bob Proulx
Post by Lis Maria
I am trying to set a variable with some value in the %pre section, and I
am
Post by Lis Maria
trying to access the variable in the %post setion but cannot.
As you have discovered that won't work. The %pre and %post sections
are two different scripts each executed at different stages in the
install process. Because they are different scripts any variables set
in one won't be available in the other.
Post by Lis Maria
Is there any possible way for passing variables between %pre and
%post section ?
Not directly no.
Could you say a few words about what you are trying to do?
Bob
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
Bob Proulx
2007-08-09 03:48:00 UTC
Permalink
Post by Lis Maria
Post by Bob Proulx
Could you say a few words about what you are trying to do?
I am basically trying to set a flag in the %pre section which is used in the
%post section to perform some activities.
Hmm... That is a very vague description. It would help if you were
more specific.

What would be available to be known in the %pre section that would not
also be available to be known in the %post section in exactly the same
way? The only thing I can think of is that in the %pre section it is
possible to determine if files that are going to be installed by the
package are already existing on the filesystem. In which case they
could be moved out of the way and into a save location if there was a
desire to do that. (I would probably avoid that though. It makes a
cleanup problem.) Other than this I can't guess and any information
that would be available in %pre but not be readily in %post.
Post by Lis Maria
Currently I have writtent the entry to a temporary file and am reading that
file in the %post section. This, I understand is not an elegant one.
I would be concerned about ordering of events in all cases and picking
up possibly stale data in other cases and odd corner case problems.
In the simple case it should work but the devil is in the details and
there are a lot of use case possibilities.
Post by Lis Maria
is there someway through which we cans etup a macro in the pre
section and access it elsewhere/
None of which I am aware.

Bob
Lis Maria
2007-08-17 05:24:50 UTC
Permalink
Hi,
Thanks for your mail.

Yes you are right. I am checking for the existence of a file in the %pre
section and setting a counter which will be used in further processing in
the %post section. This file contains some sql statements which will be
executed/skipped depending on the counter value in the %post section after
additional files have been copied by the %install section.

So, what I am trying to achieve is that :
Check for existence of a file in %pre section,
do not execute the %install and break out if the file is not there,
set a counter in the %pre section if the file exists.

In %post
use this counter and do subsequent processing.

Hope I have been able to explain my problem.

Currently I am writing this counter to a temporary file in %pre and reading
it in %post and then deleting the temporary file containing the counter.

Once again, thanks for your reply.

Regards,

Lis Thomas
---------- Forwarded message ----------
Date: Aug 9, 2007 9:18 AM
Subject: Re: Parameter passing between %pre and %post section
Hmm... That is a very vague description. It would help if you were
more specific.
What would be available to be known in the %pre section that would not
also be available to be known in the %post section in exactly the same
way? The only thing I can think of is that in the %pre section it is
possible to determine if files that are going to be installed by the
package are already existing on the filesystem. In which case they
could be moved out of the way and into a save location if there was a
desire to do that. (I would probably avoid that though. It makes a
cleanup problem.) Other than this I can't guess and any information
that would be available in %pre but not be readily in %post.
Post by Lis Maria
Currently I have writtent the entry to a temporary file and am reading
that
Post by Lis Maria
file in the %post section. This, I understand is not an elegant one.
I would be concerned about ordering of events in all cases and picking
up possibly stale data in other cases and odd corner case problems.
In the simple case it should work but the devil is in the details and
there are a lot of use case possibilities.
Post by Lis Maria
is there someway through which we cans etup a macro in the pre
section and access it elsewhere/
None of which I am aware.
Bob
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
Bob Proulx
2007-08-18 18:27:03 UTC
Permalink
Post by Lis Maria
Yes you are right. I am checking for the existence of a file in the %pre
section and setting a counter which will be used in further processing in
the %post section. This file contains some sql statements which will be
executed/skipped depending on the counter value in the %post section after
additional files have been copied by the %install section.
I am sure that you mean something other than the %install section
because the rpm %install runs at package creation time and not at
package install time.
Post by Lis Maria
Currently I am writing this counter to a temporary file in %pre and reading
it in %post and then deleting the temporary file containing the counter.
I think that is probably the best that you can do. Often I have seen
packages move files to special names and later if those special named
files exist they do something with them. If you are careful with
filesystem permissions then I think you are okay with what you are
doing there.

Bob

Loading...