?
Solved

Set package.spec %attr with environment variable

Posted on 2011-09-10
3
Medium Priority
?
746 Views
Last Modified: 2012-05-12
I have a rpm file that will be installed in different environments.  In package.spec, the filelist has %attr(755, xuser, somegroup) where xuser will vary between environments.  I'm able in preinstall to execute a script that sets environment variables.  

So I want to be able to pick up an environment variable when using %attr.  This does not work:

%attr(755, ${ENV_USER}, someGroup)

Does anyone know what might work here?
0
Comment
Question by:jkavx
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
unSpawn earned 2000 total points
ID: 36527851
I want to be able to pick up an environment variable when using %attr.
As far as I understand RPM a more accurate description of what you are trying to do would be to say that you want to programmatically change a value that is interpreted only at the %install stage and that isn't going to work. IMHO nor should it work that way because, as far as I understand package management philosophy, it is not about allowing individual environments to dictate a packages contents but the other way around: to provide standards-compliant, uniform ways of distributing, installing and verifying software.

So the question is which aspect is leading. Is it more important that, for to be disclosed reasons, a specific (and existing?) "xuser" account is used? Or is it more important to adhere to standards? If your answer leans towards the first option then why not use a "%post" scriptlet to change ownership? But then be aware of the consequences: if different users are in use on different systems then this weakens RPM as you have to resort to using "%verify(not owner) /path/to/file" in your spec file and force the user to run 'rpm -V --nouser packagename' unless you want to be confronted with verification errors for that package all of the time.

If using %post is not acceptable or if I'm misunderstanding what you try to do then could you explain in detail what you need to deliver and your reasons for having (to deal with) a between environments varying xuser?
0
 

Author Comment

by:jkavx
ID: 36529409
A post install script is an option, although it would be simpler to utilize the @attr in package.spec, if possible.

This is a corporate environment, with a package that needs to be deployed in both Uat and Prod environments.  The problem is that the functional id differs between uat and prod.

I'm new to this, so thx for the heads up about the % verify.  
0
 
LVL 7

Expert Comment

by:unSpawn
ID: 36530571
The problem is that the functional id differs between uat and prod.
If it's only about two generic environments (here the Id should not differ in the first place IMHO but) you could easily create two packages and use a %define (you drive from the 'rpmbuild' commandline) for %if-%else switching between user Ids BTW.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question