aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Kahle <tomka@gentoo.org>2012-02-04 15:50:37 +0100
committerThomas Kahle <tomka@gentoo.org>2012-02-04 15:50:37 +0100
commit1a6a5103526b8eba5869ecbb3a2fc86188f29345 (patch)
tree6e3aa4fc5d27fb89b799d0adc4799f62f3c7a0b6 /scripts
parentBetter output will writing unmaskfiles (diff)
downloadtatt-1a6a5103526b8eba5869ecbb3a2fc86188f29345.tar.gz
tatt-1a6a5103526b8eba5869ecbb3a2fc86188f29345.tar.bz2
tatt-1a6a5103526b8eba5869ecbb3a2fc86188f29345.zip
Initial support for keywording bugs (also via -b)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/tatt88
1 files changed, 57 insertions, 31 deletions
diff --git a/scripts/tatt b/scripts/tatt
index c3b5520..2d5c0c6 100755
--- a/scripts/tatt
+++ b/scripts/tatt
@@ -15,6 +15,7 @@ from tatt.scriptwriter import writecommitscript as writeCommit
from tatt.scriptwriter import writeCleanUpScript as writeCleanup
from tatt.bugbrowser import launch_browser as launch_browser
from tatt.tattConfig import tattConfig as tattConfig
+from tatt.job import job as job
##### Generate a global config obj, reading from ~/.tatt #####
config = tattConfig()
@@ -77,8 +78,12 @@ parser.add_option("-o", "--overview" "--browse",
(options,args) = parser.parse_args()
-# We copy some options to the config
+## Messing with the configuration:
+# Save verbosity level
config['verbose']=options.verbose
+# Normalize the template dir:
+config['template-dir']=os.path.abspath(config['template-dir'])+os.sep
+
## Checking for root, tatt should be run as a user, I guess.
## Remove on occasion.
@@ -104,8 +109,8 @@ if options.bugbrowser:
launch_browser (config)
exit (0)
-# Will eventuall contain packages to handle:
-packs=None
+# get a job object to save things to
+myJob = job()
## If -f and a filename have been given:
if options.infile:
@@ -116,34 +121,47 @@ if options.infile:
exit(1)
packraw = packfile.read()
packfile.close()
- packs = packageFinder.findPackages(packraw, re.compile(config['atom-regexp']))
+ myJob.packageList = packageFinder.findPackages(packraw, re.compile(config['atom-regexp']))
## -b and a bugnumber was given ?
if options.bugnum:
print("Bugnumber: " + options.bugnum)
- # If packs is still empty we search in the bug-title
- if packs==None:
- p1 = Popen(['bugz', 'get', options.bugnum, '-n'], stdout=PIPE)
- bugraw = Popen(['grep', 'Title'], stdin=p1.stdout, stdout=PIPE).communicate()[0]
- if not re.search('[Ss][Tt][Aa][Bb]', bugraw):
- print("Does not look like a stable request bug !")
- print(bugraw)
- packs = packageFinder.findPackages(bugraw, re.compile(config['atom-regexp']))
+ myJob.bugnumber=options.bugnum
+ # If myJob.packageList is still empty we search in the bug-title
+ if myJob.packageList==None:
+ p1 = Popen(['bugz', 'get', myJob.bugnumber, '-n'], stdout=PIPE)
+ #This old call would just fetch the title
+ #bugraw = Popen(['grep', 'Title'], stdin=p1.stdout, stdout=PIPE).communicate()[0]
+ # Instead we now capture everything:
+ bugraw = p1.communicate()[0]
+ if re.search('KEYWORDREQ', bugraw):
+ # This is a keywording bug:
+ print ("Keywording bug detected.")
+ myJob.type="keyword"
+ elif re.search('STABLEREQ', bugraw):
+ # Stablebug
+ print ("Stabilization bug detected.")
+ myJob.type="stable"
+ else:
+ print ("Could not detect bug's type, is the 'Keywords' field set?")
+ exit(1)
+ myJob.packageList = packageFinder.findPackages(bugraw, re.compile(config['atom-regexp']))
# joint code for -f and -b
##########################
-if not packs==None:
+if not myJob.packageList==None:
## Assigning jobname
if options.jobname:
- jobname = options.jobname
+ myJob.name = options.jobname
elif options.infile:
- jobname = options.infile
+ myJob.name = options.infile
else:
- jobname = packs[0].packageName()
- print ("Jobname: " + jobname)
+ myJob.name = myJob.packageList[0].packageName()
+ print ("Jobname: " + myJob.name)
+ ## Determine jobtype
- for p in packs:
+ for p in myJob.packageList:
print("Found the following package atom : " + p.packageString())
# Unmasking:
@@ -159,25 +177,32 @@ if not packs==None:
unmaskfile=open(config['unmaskfile'], 'r+')
unmaskfileContent = unmaskfile.read()
- for p in packs:
+ for p in myJob.packageList:
# Test if unmaskfile already contains the atom
if re.search(p.packageString(), unmaskfileContent):
print (p.packageString() + " already in "+config['unmaskfile'])
else:
- unmaskfile.write("\n" + p.packageString() + "\n")
- print ("Appended " + p.packageString()+ " to "+config['unmaskfile'])
+ unmaskfile.write(p.packageString())
+ if myJob.type=="stable":
+ unmaskfile.write("\n")
+ elif myJob.type=="keyword":
+ unmaskfile.write(" ** \n")
+ else:
+ print ("Uh Oh, no job.type? Tell tomka@gentoo.org to fix this!")
+ unmaskfile.write("\n")
+ print ("Unmasked " + p.packageString()+ " in "+config['unmaskfile'])
unmaskfile.close()
else:
print ("You are not root, your unmaskstring would be:")
- print ("\n".join([p.packageString() for p in packs]) + "\n")
+ print ("\n".join([p.packageString() for p in myJob.packageList]) + "\n")
## Write the scripts
- writeUSE(jobname, packs, config)
- writeRdeps(jobname, packs, config)
- writeCleanup (jobname, config)
+ writeUSE(myJob, config)
+ writeRdeps(myJob, config)
+ writeCleanup (myJob, config)
## Config and Successscript can only be written if we have a bugnumber
- if options.bugnum:
- writeSuccess(jobname, options.bugnum, config)
- writeCommit(jobname, options.bugnum, packs, config)
+ if myJob.bugnumber:
+ writeSuccess(myJob, config)
+ writeCommit(myJob, config)
exit (0)
# Code for resolving bugs (-r and -m)
@@ -201,15 +226,16 @@ if options.resolvenum:
## If we arrive here then a package atom should be given
try:
- pack = gP(args[0])
+ myJob.packageList=gP(args[0])
+ myJob.name=myJob.packageList[0].packageName()
except IndexError:
print("Please call with package atom as argument")
exit (1)
if options.depend:
- writeRdeps(pack.packageName(), [pack])
+ writeRdeps(myJob, config)
if options.usecombi:
- writeUSE(pack.packageName(), [pack], config["ignoreprefix"])
+ writeUSE(myJob, config)
## That's all folks ##