[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

semi-automatic firefox rebuilds (was Re: Review queue/FESCo after the merge)



On 19.11.2007 17:49, Jesse Keating wrote:
> On Mon, 19 Nov 2007 17:23:05 +0100
> Thorsten Leemhuis <fedora leemhuis info> wrote:
> 
>> Firefox IMHO is the way better example -- I fail to understand why we
>> didn't create a script that rebuilds all packages that depend on it
>> once it's build and in the buildroot. Yes,
> 
> Again, it takes /somebody/ to write it.

We often say that in Fedora-land -- the result afaics often is: we scare
people away with it.

Sure, there is of course somebody needed, but sorry, especially FESCo
members instead of "Again, it takes /somebody/ to write it." should say
something like "yeah, this could be a solution; is somebody in our
friendly community willing to realize it?" or "yeah, nice idea, but
instead we should do .... to solve the problem is a even better way"

For more complicated tasks there is of course more needed. But just
requesting "do something" won't change anything most of the time --
especially for more comlicated tasks FESCo should say "yeah, we want
something like that; this is how it could look like ..." and guide
people. Then people can be sure than the solution they work out (which
could take many workhours of even days) is at least roughly what FESCo
wants.

>  FESCo can say all they want "I
> want this to happen", but until somebody sits down and cranks out a
> script, it's just not going to happen.

Come on, if our leaders are not able to do such a simple thing like this
own their own or find somebody do do it then there really is something
wrong in Fedora-land.

It's really not that hard, even I with my very limited programming
skills (aka "knurd the package monkey") I can do what's needed in just a
few minutes:

/me wanders of to create such a "script"

/me downloads
http://cvs.fedora.redhat.com/viewcvs/rebuild-scripts/bumpspecfile.py?root=fedora&view=markup

/me adjusts changelog comment

/me copy-and pastes list from
http://fedoraproject.org/wiki/WillWoods/Drafts/FirefoxUpdates
(one could create such a list with manually as well; "repoquery
--whatrequires --alldeps 'firefox = 2.0.0.9' 'gecko-libs = 1.8.1.9'" or
something like that would be a good start)

/me removes the newlines and created a quick loop in bash

Here is your "script":
---
for package in blam chmsee devhelp epiphany epiphany-extensions firefox
galeon gnome-python2-extras gnome-web-photo gtkmozembedmm kazehakase
liferea Miro openvrml ruby-gnome2 yelp; do
	pushd ${package}
	bumpspecfile.py *.spec
	make tag build
	popd
done
---

Find bumpspecfile.py attached. Run it in a full cvs checkout once the
new firefox is in the repo; if you don't have one add a "cvs co
${package}" at the right place and adjust the pushd call.

Before above works one needs to adjust some of the spec files so none
hard-code the gecko-* or firefox-* versions -- or instead use the same
format everywhere witch can be adjusted with a simple sed call. I can't
do that, something like that is unwanted in Fedora-land (see earlier in
this thread). If FESCo gives me the permission I'm of course
volunteering to do it.

Have fun.

CU
knurd
#!/usr/bin/python -t
# -*- mode: Python; indent-tabs-mode: nil; -*-

import fcntl
import os, sys
import rpmUtils
import shutil
import string
import re
import time

EXIT_ON_WARN = False

class SpecFile:
    def __init__(self,filename):
        self.filename = filename
        file=open(filename,"r")
        self.lines=file.readlines()
        file.close()

    def bumpRelease(self):
        bump_patterns=[(re.compile(r"^Release:(\s*)(\d+.*)",re.I), self.increase),
                       (re.compile(r"^%define\s+rel\s+(\d+.*)"), self.increase2),
                       (re.compile(r"^%define\s+release\s+(\d+.*)"), self.increase3),
                       (re.compile(r"^%define\s+RELEASE\s+(\d+.*)"), self.increase4),
                       (re.compile(r"^Release:\s+%release_func\s+(\d+.*)"), self.increase5)
                       ]
        skip_pattern=re.compile(r"\$Revision:")
        for i in range(len(self.lines)):
            if skip_pattern.search(self.lines[i]): continue
            for bumpit, bumpit_func in bump_patterns:
                self.lines[i]=bumpit.sub(bumpit_func,self.lines[i])

    def addChangelogEntry(self,entry,email):
        versionre=re.compile(r"^Version:\s*(\S+)")
        changematch=re.compile(r"^%changelog")
        date=time.strftime("%a %b %d %Y",   time.localtime(time.time()))
        for i in range(len(self.lines)):
            versionmatch=versionre.search(self.lines[i])
            if(versionmatch):
                version=versionmatch.group(1)
            if(changematch.match(self.lines[i])):
                newchangelogentry="%changelog\n* "+date+" "+email+" "+version+"-"+self.newrelease+"\n"+entry+"\n\n"
                self.lines[i]=newchangelogentry
                break

    def increaseMain(self,release):
        relre = re.compile(r'(?P<pre>0\.)?(?P<rel>\d+)(?P<post>.*)',re.I)
        relmatch = relre.search(release)

        pre = relmatch.group('pre')
        value = int(relmatch.group('rel'))
        self.newrelease = `value+1`
        post = relmatch.group('post')

        old = ''
        if pre != None:
            old += pre
        old += relmatch.group('rel')+post

        if pre == None:
            if post.find('rc')>=0:
                print 'CRUCIAL WARNING: Bad pre-release versioning scheme!'
                print self.filename
                if EXIT_ON_WARN:
                    sys.exit(1)
            new = `value+1`+post
            if True or post != '%{?dist}' and len(post):
                self.debugdiff(old,new)
        else:
            if value == None or value > 10000:
                print 'CRUCIAL WARNING: Bad pre-release versioning scheme!'
                print self.filename
                if EXIT_ON_WARN:
                    sys.exit(1)
            new = '0.'+`value+1`+post
            self.debugdiff(old,new)
        return new

    def increase(self,match):
        return 'Release:' + match.group(1) + self.increaseMain(match.group(2))

    def increase2(self,match):
        return '%define rel ' + self.increaseMain(match.group(1))

    def increase3(self,match):
        return '%define release ' + self.increaseMain(match.group(1))

    def increase4(self,match):
        return '%define RELEASE ' + self.increaseMain(match.group(1))

    def increase5(self,match):
        return 'Release: %release_func ' + self.increaseMain(match.group(1))

    def writeFile(self,filename):
        file=open(filename,"w")
        file.writelines(self.lines)
        file.close()

    def debugdiff(self,old,new):
        print '-%s' % old
        print '+%s\n' % new

if __name__=="__main__":
    if len(sys.argv) < 2:
        print 'SYNTAX: %s <specfile> [specfile]...' % sys.argv[0]
        sys.exit(22)

    userstring = "You <Your Address your domain>"
    for aspec in sys.argv[1:]:
        s=SpecFile(aspec)
        s.bumpRelease()
        s.addChangelogEntry(" - rebuilt for new firefox", userstring)
        s.writeFile(aspec)

sys.exit(0)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]