commit:     a5f83728d12e841c67e9e264baa4d71d26aba0d4
Author:     Rolf Eike Beer <eike <AT> sf-mail <DOT> de>
AuthorDate: Sat May  2 10:32:37 2020 +0000
Commit:     Rolf Eike Beer <eike <AT> sf-mail <DOT> de>
CommitDate: Sat May  2 10:48:43 2020 +0000
URL:        https://gitweb.gentoo.org/proj/tatt.git/commit/?id=a5f83728

remove unmaskfile config option, use unmaskdir instead

Write one unmask file per job, so cleanup can simply be rm.

Signed-off-by: Rolf Eike Beer <eike <AT> sf-mail.de>

 README.md            |  5 +++--
 scripts/tatt         | 30 ++++++++++++++++++------------
 tatt.5               |  5 +++--
 tatt/dot-tatt-spec   |  2 +-
 tatt/scriptwriter.py |  4 ++--
 templates/cleanup    |  2 +-
 6 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/README.md b/README.md
index 6e6799a..46b7f7d 100644
--- a/README.md
+++ b/README.md
@@ -100,8 +100,9 @@ The specification of the configuration file can be found in 
dot-tatt-spec which
 # to change this)
 # template-dir="/usr/share/tatt/templates/"
 
-# Where do you want tatt to put unmasked packages.
-# unmaskfile="/etc/portage/package.accept_keywords/archtest"
+# Where do you want tatt to put unmasked packages. Writes one file per
+# job in this directory.
+# unmaskdir="/etc/portage/package.accept_keywords"
 
 # You can customize the maximal number of rdeps to be tested as follows:
 # rdeps=3

diff --git a/scripts/tatt b/scripts/tatt
index 3e0d56c..b08adfd 100755
--- a/scripts/tatt
+++ b/scripts/tatt
@@ -239,30 +239,36 @@ if myJob.packageList is not None and 
len(myJob.packageList) > 0:
     myJob.packageList = filteredPackages
 
     # Unmasking:
+    unmaskname=config['unmaskdir']
+    if os.path.exists(unmaskname) and not os.path.isdir(unmaskname):
+        print ("unmaskdir '", unmaskname, "' exists and is no directory")
+        sys.exit(1)
+    elif not os.path.exists(unmaskname):
+        os.mkdir(unmaskname, 0o755)
+    unmaskname=unmaskname+"/tatt_"+myJob.name
+
     try:
-        unmaskfile=open(config['unmaskfile'], 'r+')
+        unmaskfile=open(unmaskname, 'r+')
     except IOError:
-        print ("Your unmaskfile was not found, I will create it as")
-        print (config['unmaskfile'])
         try:
-            unmaskfile=open(config['unmaskfile'], 'w')
+            unmaskfile=open(unmaskname, 'w')
             unmaskfile.write(" ")
             unmaskfile.close()
         except IOError:
             # If we can't write to the file, then it should be configured 
differently
-            print (" ".join(["Can not write to ",config['unmaskfile']]))
+            print (" ".join(["Can not write to ",unmaskname]))
             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 (" ".join(["Is",config['unmaskdir'],"a writeable 
directory?"]))
             print ("Probably you want to configure a different unmaskfile")
             print ("in your ~/.tatt.  Exiting")
             sys.exit(1)
-        unmaskfile=open(config['unmaskfile'], 'r+')
+        unmaskfile=open(unmaskname, 'r+')
 
     unmaskfileContent = unmaskfile.read()
     for p in myJob.packageList:
         # Test if unmaskfile already contains the atom
         if re.search(re.escape(p.packageString()), unmaskfileContent):
-            print (p.packageString() + " already in "+config['unmaskfile'])
+            print (p.packageString() + " already in "+unmaskname)
         else:
             unmaskfile.write(p.packageString())
             if myJob.type=="stable":
@@ -272,22 +278,22 @@ if myJob.packageList is not None and 
len(myJob.packageList) > 0:
             else:
                 print ("Uh Oh, no job.type? Tell [email protected] to fix 
this!")
             unmaskfile.write("  # Job " + myJob.name + "\n")
-            print ("Unmasked " + p.packageString()+ " in 
"+config['unmaskfile'])
+            print ("Unmasked " + p.packageString()+ " in "+unmaskname)
 
     # now write the remaining packages for keywording
     for p in kwPackages:
         # Test if unmaskfile already contains the atom
         if re.search(re.escape(p.packageString()), unmaskfileContent):
-            print (p.packageString() + " already in "+config['unmaskfile'])
+            print (p.packageString() + " already in "+unmaskname)
         else:
             unmaskfile.write(p.packageString() + "  # Job " + myJob.name + 
"\n")
-            print ("Unmasked " + p.packageString() + " in " + 
config['unmaskfile'])
+            print ("Unmasked " + p.packageString() + " in " + unmaskname)
 
     unmaskfile.close()
     ## Write the scripts
     writeUSE(myJob, config)
     writeRdeps(myJob, config)
-    writeCleanup (myJob, config)
+    writeCleanup (myJob, config, unmaskname)
     ## Successscript can only be written if we have a bugnumber
     if myJob.bugnumber:
         writeSuccess(myJob, config)

diff --git a/tatt.5 b/tatt.5
index 59e0273..c40d34c 100644
--- a/tatt.5
+++ b/tatt.5
@@ -31,9 +31,10 @@ which usually resides \fI 
/usr/lib/${python}/site-packages/tatt \fI
 #template-dir="/usr/share/tatt/templates/"
 
 .br
-# Where do you want tatt to put unmasked packages.
+# Where do you want tatt to put unmasked packages. Writes one file per
+# job in this directory.
 .br
-#unmaskfile="/etc/portage/package.accept_keywords/archtest"
+#unmaskdir="/etc/portage/package.accept_keywords"
 
 .br
 # You can customize the maximal number of rdeps to be tested as follows:

diff --git a/tatt/dot-tatt-spec b/tatt/dot-tatt-spec
index 76a7039..1d9fe9d 100644
--- a/tatt/dot-tatt-spec
+++ b/tatt/dot-tatt-spec
@@ -1,7 +1,7 @@
 successmessage=string(default="Archtested on @@ARCH@@: Everything fine")
 
ignoreprefix=string_list(default=list("elibc_","video_cards_","linguas_","python_targets_","python_single_target_","kdeenablefinal","test","debug"))
 template-dir=string(default="/usr/share/tatt/templates/")
-unmaskfile=string(default="/etc/portage/package.accept_keywords/archtest")
+unmaskdir=string(default="/etc/portage/package.accept_keywords")
 arch=string(default="x86")
 defaultopts=string(default="")
 emergeopts=string(default="")

diff --git a/tatt/scriptwriter.py b/tatt/scriptwriter.py
index b4bee69..c540626 100644
--- a/tatt/scriptwriter.py
+++ b/tatt/scriptwriter.py
@@ -41,7 +41,6 @@ def scriptTemplate(job, config, filename):
     snippet = snippet.replace("@@REPODIR@@", config['repodir'])
     snippet = snippet.replace("@@REPORTFILE@@", reportname)
     snippet = snippet.replace("@@BUILDLOGDIR@@", config['buildlogdir'])
-    snippet = snippet.replace("@@KEYWORDFILE@@", config['unmaskfile'])
     snippet = snippet.replace("@@NEWKEYWORD@@", newkeyword)
     snippet = snippet.replace("@@TEMPLATEDIR@@", config['template-dir'])
     return snippet
@@ -214,8 +213,9 @@ def writecommitscript (job, config):
 
 
 ######## Write clean-up script ##############
-def writeCleanUpScript (job, config):
+def writeCleanUpScript (job, config, unmaskname):
     script = scriptTemplate(job, config, "cleanup")
+    script = script.replace("@@KEYWORDFILE@@", unmaskname)
     outfilename = (job.name + "-cleanup.sh")
     if os.path.isfile(outfilename):
         print("WARNING: Will overwrite " + outfilename)

diff --git a/templates/cleanup b/templates/cleanup
index e852684..394077e 100644
--- a/templates/cleanup
+++ b/templates/cleanup
@@ -1,6 +1,6 @@
 #!/bin/bash
 ## Clean-up the keywordfile 
-sed -i "/# Job @@JOB@@$/d" @@KEYWORDFILE@@
+rm @@KEYWORDFILE@@
 
 # Remove all files associated to the job:
 rm -f @@JOB@@-*

Reply via email to