Solved

Set package.spec %attr with environment variable

Posted on 2011-09-10
3
691 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 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now