Fedora Linux Support Community & Resources Center
  #1  
Old 20th July 2011, 02:53 AM
Diametric Offline
Registered User
 
Join Date: Apr 2010
Location: DC
Posts: 45
linuxubuntufirefox
rpm scriptlet help

Hola,

I've been successful so far in getting my first rpm built, but it seems I am not getting something right when attempting to run a "scriptlet' in the %pre section.

Specifically, I have the following:

Code:
%pre

if [ -s /etc/myfile ] then
         mv /etc/myfile /etc/myfile.bak;
         touch /etc/myfile
fi
Now, I think my logic is clear and correct, and I have read the fedora/rpm/wiki on the scriptlets section. However my rpm installs but the above code does not appear to be processing correctly - actually, not at all. IS there a #!/bin/sh needed or some other such formatting I'm unaware of?

Thanks for your help.
Reply With Quote
  #2  
Old 20th July 2011, 08:59 AM
Seve's Avatar
Seve Offline
Retired Community Manager
 
Join Date: Oct 2004
Location: The GTA, Ontario, Canada
Age: 54
Posts: 12,376
linuxfirefox
Re: rpm scriptlet help

Try this

create 2 text files in your home directory

PHP Code:
touch myfile && touch test 
In the test file put this in it. Adjust for your directory names etc.
PHP Code:
#!/bin/bash -x

# Script to test a rpm scriplet

if [ -/home/username/myfile ]; then
         mv 
/home/username/myfile  /home/username/myfile.bak
         touch 
/home/username/myfile.itworked
fi 
Then to make it executable
PHP Code:
chmod +x test 
then run the script from your terminal with

./test

and see if it works, if so and it should, then add to the %pre section in your .spec file.

You should see the renamed file myfile.bak and myfile.itworked

If the file "myfile" is empty, nothing happens with the -s file test, only if it is not empty. If the file exists, empty or not, then the -e file test might be preferable.

If you search for common file tests you will find more assistance, this is just one.
http://www.comptechdoc.org/os/linux/...cripttest.html
__________________
Registered Linux User: #384977
.................................................. ............
See the Links below for more Help and those much wanted extras ... :)
Reply With Quote
  #3  
Old 20th July 2011, 03:59 PM
Diametric Offline
Registered User
 
Join Date: Apr 2010
Location: DC
Posts: 45
windows_xp_2003chrome
Re: rpm scriptlet help

Thank you for your reply - it helped me figure out what my issue was. If you look at my code and then look at yours, I had the semicolons in the incorrect place, and none of my code ran. I changed it, and it performed exactly as it should.

Thanks again!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
java program/jsp scriptlet to convert a .doc/odt file to .pdf or .jpg creeping death Programming & Packaging 8 18th July 2009 03:50 PM
rpm error %preun() scriptlet failed? DaleEMoore Using Fedora 6 14th February 2007 03:03 AM
rpm doesn't work - scriptlet failed, exit status 255 vsem Using Fedora 5 11th April 2006 01:15 AM
gstreamer scriptlet failed, exit status 127 oleanj Using Fedora 0 10th November 2005 11:02 AM
RPM installation - scriptlet failed, exit status 255 Entity Using Fedora 1 27th February 2005 10:43 PM


Current GMT-time: 16:48 (Saturday, 18-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat