Skip to content

Commit

Permalink
Clean-Up script implemented, small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tom111 committed Sep 22, 2011
1 parent 3d4a5a3 commit 72dbf79
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scripts/tatt
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions tatt/bugbrowser.py
Expand Up @@ -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)
20 changes: 20 additions & 0 deletions tatt/scriptwriter.py
Expand Up @@ -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)



6 changes: 6 additions & 0 deletions templates/cleanup
@@ -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.