Permalink
Browse files

Clean-Up script implemented, small refactoring

  • Loading branch information...
tom111 committed Sep 22, 2011
1 parent 3d4a5a3 commit 72dbf79a4296aa72d1a5124e6a73c7a9d55b69e8
Showing with 37 additions and 10 deletions.
  1. +10 −10 scripts/tatt
  2. +1 −0 tatt/bugbrowser.py
  3. +20 −0 tatt/scriptwriter.py
  4. +6 −0 templates/cleanup
View
@@ -149,23 +149,23 @@ if not packs==None:
if isroot:
# If we are root, then we can write to package.keywords
try:
- keywordfile=open("/etc/portage/package.keywords/arch", 'r+')
+ unmaskfile=open(config['unmaskfile'], 'r+')
except IOError:
# create an empty file, this should be beautified
- keywordfile=open("/etc/portage/package.keywords/arch", 'w')
- keywordfile.write(" ")
- keywordfile.close()
- keywordfile=open("/etc/portage/package.keywords/arch", 'r+')
+ unmaskfile=open(config['unmaskfile'], 'w')
+ unmaskfile.write(" ")
+ unmaskfile.close()
+ unmaskfile=open(config['unmaskfile'], 'r+')
- keywordfilecontent = keywordfile.read()
+ unmaskfileContent = unmaskfile.read()
for p in packs:
- # Test if keywordfile already contains the atom
- if re.search(p.packageString(), keywordfilecontent):
+ # Test if unmaskfile already contains the atom
+ if re.search(p.packageString(), unmaskfileContent):
print (p.packageString() + " already in package.keywords.")
else:
- keywordfile.write("\n" + p.packageString() + "\n")
+ unmaskfile.write("\n" + p.packageString() + "\n")
print ("Appended " + p.packageString()+ " to /etc/portage/package.keywords/arch")
- keywordfile.close()
+ unmaskfile.close()
else:
print ("You are not root, your unmaskstring would be:")
print ("\n".join([p.packageString() for p in packs]) + "\n")
View
@@ -342,3 +342,4 @@ def launch_browser (config):
scripts.writeusecombiscript(jobname, packages, config)
scripts.writerdepscript (jobname, packages, config)
scripts.writecommitscript (jobname, str(b.id_number()), packages, config)
+ scripts.writeCleanUpScript (jobname, config)
View
@@ -147,3 +147,23 @@ def writecommitscript (job, bugnum, packlist, config):
outfile.write (commitfooterfile.read().replace("@@ARCH@@", config['arch']).replace("@@BUG@@", bugnum))
outfile.close()
print(("Commit script written to " + outfilename))
+
+
+######## Write clean-up script ##############
+def writeCleanUpScript (job, config):
+ try:
+ cleanUpTemplate=open(config['template-dir'] + "cleanup", 'r')
+ except IOError:
+ print("Clean-Up template not found in" + config['template-dir'])
+ exit(1)
+ script = cleanUpTemplate.read().replace("@@JOB@@", job)
+ script = script.replace("@@CPV@@", job)
+ script = script.replace("@@KEYWORDFILE@@", config['unmaskfile'])
+ outfilename = (job + "-cleanup.sh")
+ if os.path.isfile(outfilename):
+ print(("WARNING: Will overwrite " + outfilename))
+ outfile = open(outfilename,'w')
+ outfile.write(script)
+
+
+
View
@@ -0,0 +1,6 @@
+#!/bin/sh
+## Clean-up the keywordfile
+sed -i "/@@CPV@@/d" @@KEYWORDFILE@@
+
+# Remove all files associated to the job:
+rm -f @@JOB@@-*

0 comments on commit 72dbf79

Please sign in to comment.