LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-14-2009, 03:50 PM   #1
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Rep: Reputation: 15
possibly creating an RPM


okay I've done it this time. I went and talked my boss out of buying software to help us in the creation of RPMs on the grounds that it would be cheaper to pay some poor sap to waste a week figuring it out on his own. Guess who got nominated to be the poor sap

Anyways I've read about RPM files and structure, but I'm not cretin I have the concept correct. Our program is small and doesnít need a complex make file to compile (eclipse does that automatically ever time I make a change ). However, we need a lot of environment setup, creating a new user to run the program and configuring it to run at bootup (ie without needing anyone to login) installing other RPMs and modifying lots of config files. We could include install directions for all this configuration, but we would prefer to make the install as fast and automated as we can.

after some basic studying of the RPM framework it seems as if I could skip the install phase all together and just include the pre-compiled bin directory of my program in the %files section of the .spec file (eclipse compiles it already automatically, why bother figuring out the commands to do it from command line?). From there I would include a rather large install and uninstall program in the RPM to do all the other system configuration.

Except if I do it that way I really havenít gained anything from making an rpm, rather then just handing over the byte code (it's a java program if you havenít guessed) and two scripts. in fact just giving the binaries and a script file would be better, because if the script failed somehow during an install it is easier to debug/fix if you have the script file then if you only have an RPM.

So Iím wondering if I'm somehow missing the point? Is there a better way to utilize the RPM structure to do all the system configuration I want to do rather then having it run one huge script file? Should I be arguing for using a make file over an RPM?

I'm also curious about the other RPMS we need. we need at least 3 other RPM's that I can think of installed for our program to function. I know an RPM can specify prerequisite RPM's, but I don't see where in the .spec file this is done. So how would I ensure (for instance) that JRE is installed before our RPM installs.
 
Old 09-15-2009, 01:21 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Hi,

RPM packaging is a little bit of an art form, happy to assist even though I'm not a guru -

- you cant avoid the %install phase
- the directive to specify prerequisites is 'Requires: '

For pre-compiled binaries/scripts:
-------------------------
Source0: %{name}-%{version}.tar.gz
Requires: java

%prep
%setup -q

%build

%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}
cp -a ${RPM_BUILD_DIR}/%{name}-%{version}/* ${RPM_BUILD_ROOT}

%files
%defattr(644,root,root)
%attr(755,root,root) /path/to/yourfile
%doc README LICENSE
------------------------

- the %prep section extracts the source file/s
- the %install section moves the files to RPM_BUILD_ROOT

Using the scripts (%pre, %post, %preun, %postun) within the spec file to change system config files is possible but can get messy very quickly; but then this is no different to using a makefile. Using an RPM to deploy your application provides you with version control that can be queried generically.

Having a makefile can simplify spec file creation -

eg.
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

Basically, if you control the environment that the package is being deployed into then go ahead and change the config files, otherwise - it will be difficult to cater for all the variations out there.

cheers,

kbp
 
Old 09-15-2009, 07:44 AM   #3
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Original Poster
Rep: Reputation: 15
okay thank you that's good information.

on a related note I was wondering do RPM's regularly install other RPM's, or does one usually just require them? I belive I will have to install at least one RPM from within mine, we own the lisence on it but presumably can't give the key out to others. Would there be a better way to do the install for this then just a script?

and on a related note is there a way that someone can see the script files within an rpm? if I hard code a lisence key into a script file run within the rpm will that be secure?
 
Old 09-15-2009, 09:19 AM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Hi,

No, rpm itself works out the dependencies and will prompt you to install them, if you create a custom repository with all the dependencies in it, installation will be simpler via yum.

No again, ideally your rpm would not contain a license key, possibly prompting the user to provide it ... ? .. things have a habit of "escaping". I try to keep my rpm's as generic as possible so that they can be reused, but the choice is yours.

And we have a yes ... 'rpm -qc installed_package_name' or 'rpm -qcp your.rpm' ... (q)uery (c)onfigfiles in (p)ackage


cheers
 
Old 09-16-2009, 11:29 AM   #5
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Original Poster
Rep: Reputation: 15
okay i'm trying to make the rpm now and it isn't working. I'm thinking it is due to this line

Quote:
Source0: %{name}-%{version}.tar.gz{version}.tar.gz
I actually changed that to %{name}-%{version}-%{release}.tar.gz to match the name of my tar file. but when i run rpmbuild -ba I get the error message

Fetching /%{_RsourceDir}/tarfileName failed: unknown or unexpected error(obviously tarfileName is the name of my tarfile)

everything I read states that Source should be a URL so I was assuming that giving just the name of the tar file isn't enough? Obviously there isn't anywhere online I can link to. I tried file://%(RPM_BUILD_DIR)/../SOURCES/tarfileName just to see what would happen, but that didn't work either.


I am working under the assumption that the tar file should go into SOURCES. None of the resource I have read actually specify that but I'm taking that to be implied.
 
Old 09-16-2009, 02:06 PM   #6
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Original Poster
Rep: Reputation: 15
okay i figured out my proglem. it looks like it's looking for my tar file in a differnt SOURCE folder then the one I intended for it to use. I also figured out why your Source example dosn't give a longer url, the RPM only looks at the last part to get the name of the tar file anyways.
 
Old 09-16-2009, 02:39 PM   #7
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Original Poster
Rep: Reputation: 15
okay Iíve got to stop replying to myself, it's the first sign of insanity you know.

I have a different problem now. When I run rpmbuild it gets to the install phase and runs all my commands in the install phase. however after that it tries to run /usr/lib/rpm/brp-compress which fails. The reason it fails is because brp-compress is located in /usr/lib/rpm/5.0, it's linking to the wrong directory.

I'm sure there is some configuration file or command line argument I can use to cause rpmbuild to link to the correct folder for brp-compress and the other programs it needs, but I can't figure out where. I don't suppose you know where?
 
Old 09-16-2009, 09:41 PM   #8
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Not sure what platform you're on or how your rpmbuild environemnt is set up, maybe a quick symlink would solve it ? .. otherwise you may need to start digging in the rpm macros

cheers
 
Old 09-16-2009, 09:52 PM   #9
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Had another thought, if you want to disable compress/strip you can use:
Code:
%define __os_install_post %{nil}
.. at the top of your spec file

cheers
 
Old 09-18-2009, 08:49 AM   #10
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Original Poster
Rep: Reputation: 15
okay I ended up needing both a single sym link and the %define but I got past that problem. Had a few other battles but the rpm has built now and installed the basic program.

Now the RPM is expected to modify the environment and config files of some preinstalled software, per our clients request. I got to learn the sed command and the difference between > and >>. I'm still having trouble with modifying vnc config file though, and I know its probably something painfully obvious to someone who has created RPM's before.

I added to my tared source a /etc/vnc/xstartup file with the configuraiton I want. This way if the RPM is removed so will the xstartup file and the next time vncserver is run it will generate a default startup file rather then trying to run the old xstartup file that would fail after the rpm is removed. the problem is the line

%files
/etc/vnc/xstartup

Doesnít work. Instead when I try to install the rpm I receive an error message saying the rpm requires /etc/vnc. The directory does exist and I ran the rpm as root so I know it has permission to modify it. I ran into this problem earlier and fixed it by using the %dir command to own the directory I was trying to copy files into, but I don't think I want to do that here because if I own the vnc directory then when the rpm is erased it will erase the vnc directory too. Is there a way to tell rpm that I am trying to add a file to an existing directory?
 
Old 09-19-2009, 07:01 AM   #11
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Glad to hear you're making progress, try adding:

Code:
# Turn off both find-requires and find-provides
Autoreqprov: 0
.. near the top of your spec file. rpmbuild is trying to automatically determine what your rpm 'Requires: ' and 'Provides: ', you will need to ensure you put these in manually though.

eg.

Code:
Provides: myappname
Requires: appx appy appz
cheers
 
Old 09-21-2009, 06:55 AM   #12
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Original Poster
Rep: Reputation: 15
I tried your solution but it didn't help, RPM is still saying it needs /etc/vnc. I also noticed that the list of requirements it prints out when it makes the RPM does not include /etc/vnc as a requirement. I'm guessing that the directory isn't considered a requirement checked prior to install, but causes the RPM to fail when it attempts to copy files there during the install.

I don't suppose there is a way I can use %dir to say I own the etc/vnc dir in order to copy files into the directory, and then use some other command to say I no longer own the directory afterwards? Is there an inverse %dir command?
 
Old 09-21-2009, 07:13 AM   #13
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
The %dir directive doesn't mean 'this is a directory', it mean 'process this directory and all files in it' i.e it's a shortcut method of listing files

I'm happy to take a look if you want to PM me the srpm

cheers
 
Old 09-21-2009, 09:23 AM   #14
dsollen
Member
 
Registered: Jun 2009
Posts: 56

Original Poster
Rep: Reputation: 15
I understand what %dir does, I just know that i was able to get the rpm to do what I wanted by including the directory as well as the files, but that it's not correct to own the vnc directory sense I don't want it deleted if my rpm is. I figured I could try a sloppy hack where I included the directory in my %files list until I had copied everything over then excluded the directory afterwards. It didn't work .

it's not really convenient to get copy the spec file to cd just to past it here, but the only relevant lines in my spec file are:

%install
cp -q $(RPM_BUILD_DIR/%{name}-%{version}/ $(RPM_BUILD_ROOT)

%files
%defattr(-,IIU,IIU,-)
/etc/vnc/*

And as I'm sure you guessed the tar file I installed has a /etc/vnc/xstartup file.

After some quick testing I have noticed I can copy anything I want into /home /etc /bin but not /etc/test or /test. it seems that I only get this complaint when trying to copy files into non system directories. I don't know if rpm is trying to force me to keep everything in those directories or if the script does some pre processing to make those directories accessible but not others. in fact I'm just realizing if I check the %files macro I could probably figure out what it does to let me copy into /etc and repeat that logic to copy into /etc/vnc. Now all i need is time to do that

currently my rpm includes the vnc directory. it seems that when I erase the rpm the vnc directory stays untouched due to there being files in the directory that my rpm package didn't install. However, despite the fact that this seems to work it still would be best if I could avoid including the directory when I only want the file within the directory included. Now the question is, do I take the time to figure out the correct process or stick with the bad one that currently works? And why is it when I say that I get an image of a little angle and devil on my shoulders arguing over rather I use the lazy method...and the devil is wearing a Microsoft shirt? :P
 
Old 09-21-2009, 05:26 PM   #15
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
You could try specifying the owner:

Code:
%files
%defattr(-,IIU,IIU,-)
%attr(0644,root,root) /etc/vnc/*
.. and see if it makes any difference

cheers
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an RPM that installs in a directory made by another RPM erinfin Linux - Software 4 11-15-2007 05:10 PM
Creating RPM Debugger Programming 2 11-14-2006 02:53 AM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM
Creating an RPM database Null Linux - Software 6 03-20-2003 06:09 PM
Creating RPM. jayakrishnan Linux - General 1 04-10-2002 12:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration