Register
It is currently Sat Sep 20, 2014 1:54 am

Spec files


All times are UTC - 6 hours


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 PostPosted: Thu Aug 25, 2005 8:23 pm   

Joined: Thu Aug 25, 2005 7:43 pm
Posts: 3
Location: Houston, Texas
I've done a few bash scripts myself, and I'm not even sure if bash would be the best way to do this, but here goes anyways.

I constantly build rpms for Mandriva and always have to edit the spec files before building them with certain criteria. I was wondering if someone has or can do a bash script to accomplish something.

I'm wanting to add 2 lines to a spec file under the %changelog section of the file now. The two lines I need/want have to be exactly as I have them below, followed by a blank line and the two lines have to start on the first line after the %changelog line in the spec file

* Thu Aug 25 2005 Cliff Wade <hawkwind@gmail.com>
- Built for the SoS Rpm Repository located at: http://seerofsouls.com

They have to be exactly like that, with the * and the - in the beginning as shown above. The day, month date and year need to be the current day, month, date, and year that the script is run and the lines added to the spec file.

When you rebuild anywhere from 10 to 80 .src.rpms per day, it gets a little old typing that once, then copy/pasting it to each and every spec file. I'd like to be able to run something like ./changelog.sh *.spec and it add that line to every spec file in the directory, keeping the name of the spec file in tact as well.

If any further info is needed, please let me know here and I will gladly provide it ASAP.

Thanks in advance!

The box said: Requires Windows 98 or better, So I installed Linux!
Registered Linux User #362532
http://seerofsouls.com
http://linuxfordummies.org
http://doomsickle.com
IRC server: irc.freenode.net in #LFD


Top
 Profile WWW  
 PostPosted: Thu Aug 25, 2005 8:34 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
hey hawkwind... nice to have you here :)
just a couple questions
1) is this file a text file (i'm assuming it is)
2) maybe you can post an example spec file... not the whole thing if it's long but atleast a section before and after where the lines need to be added
3) i see a date there on the first line... does that need to be dynamic or a static "trademark" date?

ok...maybe a few questions instead of a couple :wink:


Top
 Profile  
 PostPosted: Thu Aug 25, 2005 8:35 pm   

Joined: Thu Aug 25, 2005 7:43 pm
Posts: 3
Location: Houston, Texas
Here is a link to an actual spec file. This one has already been edited as the rpms have already been created from this file.

http://doomsickle.com/cairo.spec

The date needs to be the current date of when the script is run by myself. So if it's Mon Sep 19 2005 then it needs to put that date into the file.


Top
 Profile WWW  
 PostPosted: Thu Aug 25, 2005 9:44 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
here you go...
crude...yet affective :)
Code:
#!/bin/bash

cur_date=`date +"%a %b %d %Y"`
cur_date="* $cur_date"
info="$cur_date Cliff Wade <hawkwind@gmail.com>\n"
info2="- Built for the SoS Rpm Repository located at: http://seerofsouls.com\n"

for file in *.spec
do
        filename="$file"
        echo $filename
        until ! read buffer
        do
                if [[ "$buffer" = "%changelog" ]]
                then
                        echo -e "%changelog\n${info}${info2}"  >> newfile2.spec
                else
                        echo "$buffer"  >> newfile2.spec
                fi
        done < "${file}"

        mv newfile2.spec "$filename"
done

if that is executed in the directory of the .spec files it should do what you want


Top
 Profile  
 PostPosted: Thu Aug 25, 2005 10:21 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 667
Location: Des Moines, Iowa
I like mine better :P

Code:
#!/bin/bash
cur_date=`date +" %a %b %d %Y"`
info="Cliff Wade <hawkwind@gmail.com>"
moreinfo="- Built for the SoS Rpm Repository located at: http:\/\/seerofsouls.com"
echo "Editing .spec files" ; for i in *.spec ; do
sed -e "s/%changelog/%changelog \n *$cur_date $info \n $moreinfo \n  /" $i > newfile.spec
mv newfile.spec $i ; done ; echo "Finished"; exit


Top
 Profile WWW  
 PostPosted: Thu Aug 25, 2005 10:44 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
yea yea yea...
:P


Top
 Profile  
 PostPosted: Fri Aug 26, 2005 8:56 am   

Joined: Thu Aug 25, 2005 7:43 pm
Posts: 3
Location: Houston, Texas
All I can say is: You guys ROCK!!!!

I have tried them both, and they work flawlessly and just as I wanted. Thank you both very very much.

The box said: Requires Windows 98 or better, So I installed Linux!
Registered Linux User #362532
http://seerofsouls.com
http://linuxfordummies.org
http://doomsickle.com
IRC server: irc.freenode.net in #LFD


Top
 Profile WWW  
 PostPosted: Fri Aug 26, 2005 9:39 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 667
Location: Des Moines, Iowa
glad we could help ;)


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP