aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Kahle <tomka@gentoo.org>2012-10-14 17:23:24 -0700
committerThomas Kahle <tomka@gentoo.org>2012-10-14 17:23:24 -0700
commitb84540b73521decc07dfb395f1fdf3dc1d53267d (patch)
tree6f0420c41c8a283ecf30ead648bbeb3cc88b9ce2 /scripts
parentExit if unmaskfile can not be created (diff)
downloadtatt-b84540b73521decc07dfb395f1fdf3dc1d53267d.tar.gz
tatt-b84540b73521decc07dfb395f1fdf3dc1d53267d.tar.bz2
tatt-b84540b73521decc07dfb395f1fdf3dc1d53267d.zip
Don't need to run as root
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/tatt66
1 files changed, 32 insertions, 34 deletions
diff --git a/scripts/tatt b/scripts/tatt
index a828109..b92aef5 100755
--- a/scripts/tatt
+++ b/scripts/tatt
@@ -174,43 +174,41 @@ if not myJob.packageList==None:
print("Found the following package atom : " + p.packageString())
# Unmasking:
- if isroot:
- # If we are root, then we can write to package.keywords
+ try:
+ unmaskfile=open(config['unmaskfile'], 'r+')
+ except IOError:
+ print "Your unmaskfile was not found, I will create it as"
+ print config['unmaskfile']
try:
- unmaskfile=open(config['unmaskfile'], 'r+')
+ unmaskfile=open(config['unmaskfile'], 'w')
+ unmaskfile.write(" ")
+ unmaskfile.close()
except IOError:
- print "Your unmaskfile was not found, I will create it as"
- print config['unmaskfile']
- try:
- unmaskfile=open(config['unmaskfile'], 'w')
- unmaskfile.write(" ")
- unmaskfile.close()
- except IOError:
- print " ".join(["Can not create unmaskfile",config['unmaskfile']])
- print "Probably you want to configure a different file in your ~/.tatt"
- print "Exiting"
- exit(1)
- unmaskfile=open(config['unmaskfile'], 'r+')
-
- unmaskfileContent = unmaskfile.read()
- 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'])
+ # If we can't write to the file, then it should be configured differently
+ print " ".join(["Can not write to ",config['unmaskfile']])
+ print "Maybe you don't have permission or the location is invalid."
+ print " ".join(["Is",os.path.split(config['unmaskfile'])[0],"a writeable directory?"])
+ print "Probably you want to configure a different unmaskfile"
+ print "in your ~/.tatt. Exiting"
+ exit(1)
+ unmaskfile=open(config['unmaskfile'], 'r+')
+
+ unmaskfileContent = unmaskfile.read()
+ 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(p.packageString())
+ if myJob.type=="stable":
+ unmaskfile.write("\n")
+ elif myJob.type=="keyword":
+ unmaskfile.write(" ** \n")
else:
- 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 myJob.packageList]) + "\n")
+ 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()
## Write the scripts
writeUSE(myJob, config)
writeRdeps(myJob, config)