Solved

Set package.spec %attr with environment variable

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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.

687 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