| from ClientForm import ParseResponse |
from ClientForm import ParseResponse |
| |
|
| debug=0 |
debug=0 |
| clean=1 |
clean=0 |
| dont_build=0 |
dont_build=1 |
| verbose=1 |
verbose=1 |
| |
|
| # parse host-specific configuration information from gkb.cfg |
# parse host-specific configuration information from gkb.cfg |
| log("calling gkb_getsource",kinfo) |
log("calling gkb_getsource",kinfo) |
| gkb_getsource(kinfo) |
gkb_getsource(kinfo) |
| |
|
| # now we'll go into the work |
# go into the work directory |
| |
chdir(workdir) |
| |
|
| |
# archive the clean source for later uploading |
| |
os.spawnlp(os.P_WAIT, "tar xjf " + kinfo["mastertree"] + ".tar.bz2 " + kinfo["mastertree"]) |
| |
|
| |
# now we'll go into the tree's work dir |
| chdir(kinfo["workdir"],kinfo) |
chdir(kinfo["workdir"],kinfo) |
| |
|
| # check for patches and apply if necessary |
# check for patches and apply if necessary |
| # of globally as it is only needed in this target |
# of globally as it is only needed in this target |
| gkb_runmake("modules_install", kinfo, premake, "INSTALL_MOD_PATH=%s %s" % (mybindir, makeopts)) |
gkb_runmake("modules_install", kinfo, premake, "INSTALL_MOD_PATH=%s %s" % (mybindir, makeopts)) |
| |
|
| |
# compress and upload source archive |
| |
chdir(kinfo["workdir"]+"/..",kinfo) |
| |
archive_name = "src-%s.tar.bz2" % kinfo["mastertree"], |
| |
|
| |
# compress and upload kernel binary |
| chdir(bindir,kinfo) |
chdir(bindir,kinfo) |
| archive_name = "linux-%s-%s.tar.bz2" % (kinfo["name"], myversion) |
archive_name = "linux-%s-%s.tar.bz2" % (kinfo["name"], myversion) |
| |
|
| log("compressing binary archive "+archive_name,kinfo) |
log("compressing binary archive "+archive_name,kinfo) |
| |
|
| if os.system("tar cjf "+archive_name+" "+os.path.basename(mybindir)): |
if os.spawnlp(os.P_WAIT, "tar cjf "+archive_name+" "+os.path.basename(mybindir)): |
| raise BuildError("failed to `tar cjf %s`" % archive_name) |
raise BuildError("failed to `tar cjf %s`" % archive_name) |
| |
|
| os.system("rm -rf %s" % mybindir) |
os.spawnlp(os.P_WAIT, "rm -rf %s" % mybindir) |
| |
|
| |
krn_upload(archive_name,"kernel",myversion,kinfo) |
| |
krn_querymgr("checkin",kinfo) |
| |
|
| |
if (os.fork() == 0): |
| |
#in child |
| |
krn_upload(workdir + "/" + kinfo["mastertree"] + ".tar.bz2", "source", myversion, kinfo) |
| |
|
| krn_upload(archive_name,myversion,kinfo) |
|
| except BuildError, e: |
except BuildError, e: |
| log(e.message, kinfo) |
log(e.message, kinfo) |
| krn_querymgr("checkin",kinfo) |
krn_querymgr("checkin",kinfo) |
| syncline=args+" "+kinfo["workdir"] |
syncline=args+" "+kinfo["workdir"] |
| |
|
| log("running rsync : %s %s" % (syncoptions, syncline),kinfo) |
log("running rsync : %s %s" % (syncoptions, syncline),kinfo) |
| if os.system("%s %s > %s/%s/rsync.log 2>&1" % (syncoptions, syncline, logdir, kinfo["name"])): |
if os.spawnlp(os.P_WAIT, "%s %s > %s/%s/rsync.log 2>&1" % (syncoptions, syncline, logdir, kinfo["name"])): |
| raise BuildError("sync failed, tried %s. See log for details." % syncline) |
raise BuildError("sync failed, tried %s. See log for details." % syncline) |
| |
|
| def get_wget(kinfo): |
def get_wget(kinfo): |
| log("fetching source archive " % args,kinfo) |
log("fetching source archive " % args,kinfo) |
| mysourcefile="%s/%s.tar.bz2" % (kinfo["workdir"],kinfo["name"]) |
mysourcefile="%s/%s.tar.bz2" % (kinfo["workdir"],kinfo["name"]) |
| |
|
| if os.system("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])): |
if os.spawnlp(os.P_WAIT, "wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])): |
| raise BuildError("unable to download configfile, aborting.") |
raise BuildError("unable to download configfile, aborting.") |
| |
|
| log("decompressing source file",kinfo) |
log("decompressing source file",kinfo) |
| if os.system("tar xjf " % (myconfigfile,msite,kinfo["name"])): |
if os.spawnlp(os.P_WAIT, "tar xjf " % (myconfigfile,msite,kinfo["name"])): |
| raise BuildError("unable to decompress source file, aborting.") |
raise BuildError("unable to decompress source file, aborting.") |
| |
|
| def get_vanilla(kinfo): |
def get_vanilla(kinfo): |
| log("fetching source archive %s" % args) |
log("fetching source archive %s" % args) |
| mysourcefile="%s/%s.tar.bz2" % (workdir,kinfo["name"]) |
mysourcefile="%s/%s.tar.bz2" % (workdir,kinfo["name"]) |
| |
|
| if os.system("wget -c --output-document=%s %s" % (mysourcefile,args)): |
if os.spawnlp(os.P_WAIT, "wget -c --output-document=%s %s" % (mysourcefile,args)): |
| raise BuildError("unable to download source file %s, aborting." % args) |
raise BuildError("unable to download source file %s, aborting." % args) |
| |
|
| log("decompressing source file %s" % mysourcefile,kinfo) |
log("decompressing source file %s" % mysourcefile,kinfo) |
| fnames=split(data) |
fnames=split(data) |
| name=fnames[0] |
name=fnames[0] |
| |
|
| os.system("rm -rf %s" % kinfo["workdir"]) |
os.spawnlp(os.P_WAIT, "rm -rf %s" % kinfo["workdir"]) |
| move(work + "/" + dirname, kinfo["workdir"]) |
move(work + "/" + dirname, kinfo["workdir"]) |
| |
|
| #restore the previous working ectory |
#restore the previous working ectory |
| mypatchfile="%s/%s/%s.patch" % (patchdir,kinfo["name"],patch) |
mypatchfile="%s/%s/%s.patch" % (patchdir,kinfo["name"],patch) |
| |
|
| # download pathfile or bail |
# download pathfile or bail |
| if os.system("wget --quiet --output-document=%s %s/patches/%s/%s" % (mypatchfile,msite,kinfo["name"],patch)): |
if os.spawnlp(os.P_WAIT, "wget --quiet --output-document=%s %s/patches/%s/%s" % (mypatchfile,msite,kinfo["name"],patch)): |
| raise BuildError("unable to download patchfile %s, aborting." % patch) |
raise BuildError("unable to download patchfile %s, aborting." % patch) |
| |
|
| # we have a patch file, apply it or bail |
# we have a patch file, apply it or bail |
| patchcommand="patch -p1 < %s > %s/%s/patch-%s.log 2>&1" % (mypatchfile,logdir,kinfo["name"],patch) |
patchcommand="patch -p1 < %s > %s/%s/patch-%s.log 2>&1" % (mypatchfile,logdir,kinfo["name"],patch) |
| log("using %s from %s" % (patchcommand,kinfo["workdir"]),kinfo) |
log("using %s from %s" % (patchcommand,kinfo["workdir"]),kinfo) |
| chdir(kinfo["workdir"],kinfo) |
chdir(kinfo["workdir"],kinfo) |
| if os.system(patchcommand): |
if os.spawnlp(os.P_WAIT, patchcommand): |
| raise BuildError("patchfile %s failed, aborting. See patch log for details." % patch) |
raise BuildError("patchfile %s failed, aborting. See patch log for details." % patch) |
| else: |
else: |
| log("no patchfiles, continuing",kinfo) |
log("no patchfiles, continuing",kinfo) |
| log("fetching config file",kinfo) |
log("fetching config file",kinfo) |
| myconfigfile="%s/%s.config" % (configdir,kinfo["name"]) |
myconfigfile="%s/%s.config" % (configdir,kinfo["name"]) |
| |
|
| if os.system("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])): |
if os.spawnlp(os.P_WAIT, "wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])): |
| raise BuildError("unable to download configfile, aborting.") |
raise BuildError("unable to download configfile, aborting.") |
| |
|
| log("copying config file to %s/.config" % kinfo["workdir"],kinfo) |
log("copying config file to %s/.config" % kinfo["workdir"],kinfo) |
| def gkb_runmake(command, kinfo, premake, makeopts): |
def gkb_runmake(command, kinfo, premake, makeopts): |
| """Supporting method for build() ... a stub to run a make target and auto log it, given make target (command) and name (kernel name)""" |
"""Supporting method for build() ... a stub to run a make target and auto log it, given make target (command) and name (kernel name)""" |
| log("running make %s" % command,kinfo) |
log("running make %s" % command,kinfo) |
| if os.system("%s make %s %s > %s/%s/make-%s.log 2>&1" % (premake, makeopts, command, logdir, kinfo["name"], command)): |
if os.spawnlp(os.P_WAIT, "%s make %s %s > %s/%s/make-%s.log 2>&1" % (premake, makeopts, command, logdir, kinfo["name"], command)): |
| raise BuildError("unable to run make %s, aborting." % command) |
raise BuildError("unable to run make %s, aborting." % command) |
| |
|
| def gkb_parsexml(name): |
def gkb_parsexml(name): |
| p.StartElementHandler = start_element |
p.StartElementHandler = start_element |
| p.ParseFile(open(name)) |
p.ParseFile(open(name)) |
| |
|
| def krn_upload(file, version, kinfo): |
def krn_upload(file, type, version, kinfo): |
| """upload the indicated file to the distribution site (kernel archives)""" |
"""upload the indicated file to the distribution site (kernel archives)""" |
| forms = ParseResponse(urlopen(msite+"/fileupload.html")) |
|
| |
if type=="kernel": |
| |
log("uploading kernel version "+version+" to "+msite,kinfo) |
| |
elif type=="source": |
| |
log("uploading source "+kinfo["mastertree"]+" to "+msite,kinfo) |
| |
else: |
| |
raise BuildException, "invalid file upload type: " + type |
| |
|
| |
forms = ParseResponse(urlopen(msite+"/upload.html")) |
| form = forms[0] |
form = forms[0] |
| |
|
| form["host"] = host |
form["host"] = host |
| form["pass"] = passwd |
form["pass"] = passwd |
| |
form["type"] = type |
| |
form["tree"] = kinfo["mastertree"] |
| form["build"] = kinfo["name"] |
form["build"] = kinfo["name"] |
| form["version"] = version |
form["version"] = version |
| |
|
| form.add_file(open(file), "application/x-bzip2", os.path.basename(file)) |
form.add_file(open(file), "application/x-bzip2", os.path.basename(file)) |
| |
|
| log("uploading kernel version "+version+" to "+msite,kinfo) |
|
| # form.click() returns a urllib2.Request object |
# form.click() returns a urllib2.Request object |
| # (see HTMLForm.click.__doc__ if you don't have urllib2) |
# (see HTMLForm.click.__doc__ if you don't have urllib2) |
| response2 = urlopen(form.click("cmd")) |
response = urlopen(form.click("cmd")) |
| |
|
| |
if debug: |
| |
print response.geturl() |
| |
print response.info() # headers |
| |
print response.read() # body |
| |
|
| #print response2.geturl() |
log("response: " + response.read(),kinfo) |
| #print response2.info() # headers |
|
| #print response2.read() # body |
|
| log("response: " + response2.read(),kinfo) |
|
| |
|
| response2.close() |
response.close() |
| |
|
| def main(): |
def main(): |
| """ main program gets executed here """ |
""" main program gets executed here """ |
| verifydir("%s/work" % buildroot) # build dir, make sure it exists |
verifydir("%s/work" % buildroot) # build dir, make sure it exists |
| |
|
| # download the build jobs from the master site |
# download the build jobs from the master site |
| if os.system("wget --quiet --output-document=gkb.xml \"%s/manager.php?cmd=getjobs&host=%s&pass=%s\"" % (msite,host,passwd)): |
if os.spawnlp(os.P_WAIT, "wget --quiet --output-document=gkb.xml \"%s/manager.php?cmd=getjobs&host=%s&pass=%s\"" % (msite,host,passwd)): |
| deathbyerror("Unable to download build config from master site %s, aborting." % msite) |
deathbyerror("Unable to download build config from master site %s, aborting." % msite) |
| |
|
| # sets up 'mastertrees' and 'builds' dicts |
# sets up 'mastertrees' and 'builds' dicts |