Solved

Set package.spec %attr with environment variable

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now