[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Set package.spec %attr with environment variable

Posted on 2011-09-10
3
Medium Priority
?
734 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

650 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