Currently, the src dir may be removed when the test version has changed.
Just to check to make and copy the src if it has been removed.

After check the src dir , patch files need to be copied to the parent
of src dir

Signed-off-by: Mike Qiu <[email protected]>
---
 client/shared/base_utils.py |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/client/shared/base_utils.py b/client/shared/base_utils.py
index 9f3489c..0921c8d 100644
--- a/client/shared/base_utils.py
+++ b/client/shared/base_utils.py
@@ -1,7 +1,7 @@
 #
 # Copyright 2008 Google Inc. Released under the GPL v2
 
-import os, pickle, random, re, resource, select, shutil, signal, StringIO
+import os, pickle, random, re, resource, select, shutil, signal, StringIO, glob
 import socket, struct, subprocess, sys, time, textwrap, traceback, urlparse
 import warnings, smtplib, logging, urllib2, string
 from threading import Thread, Event, Lock
@@ -767,9 +767,20 @@ def update_version(srcdir, preserve_srcdir, new_version, 
install,
     if install_needed:
         if not preserve_srcdir and os.path.exists(srcdir):
             shutil.rmtree(srcdir)
+        source_code_dir = srcdir.replace('/client/tmp/','/client/tests/')
+        if not os.path.isdir(srcdir):
+            if os.path.isdir(source_code_dir):
+                shutil.copytree(source_code_dir, srcdir)
+            else:
+                os.makedirs(srcdir)
+        patch_file_list = 
glob.glob(os.path.join((os.path.dirname(source_code_dir)), "*.patch"))
+        for patch_src in patch_file_list:
+            patch_dst = os.path.join(os.path.dirname(srcdir),
+                                     os.path.basename(patch_src))
+            shutil.copyfile(patch_src, patch_dst)
+
         install(*args, **dargs)
-        if os.path.exists(srcdir):
-            pickle.dump(new_version, open(versionfile, 'w'))
+        pickle.dump(new_version, open(versionfile, 'w'))
 
 
 def get_stderr_level(stderr_is_expected):
-- 
1.7.7.6

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to