[sysadmin/ci-tooling] helpers: Copy all the files to the install directory instead.

Ben Cooksley null at kde.org
Fri Aug 24 10:52:27 BST 2018


Git commit 5f53aafed393ca2efe92a81ed389023870891d6b by Ben Cooksley.
Committed on 24/08/2018 at 09:52.
Pushed by bcooksley into branch 'master'.

Copy all the files to the install directory instead.
This is some-what convoluted as Python doesn't have any methods for recursively copying into directories that already exist.

One unfortunate side affect of this is that if our Craft installation has a file it will always mask the one from the currently installed project.
Depending on how things go we may also need to copy over the contents of the dependency install prefix as well.

CCMAIL: kde-frameworks-devel at kde.org

M  +21   -0    helpers/helperslib/CommonUtils.py
M  +0    -11   helpers/prepare-dependencies.py
M  +11   -0    helpers/run-tests.py

https://commits.kde.org/sysadmin/ci-tooling/5f53aafed393ca2efe92a81ed389023870891d6b

diff --git a/helpers/helperslib/CommonUtils.py b/helpers/helperslib/CommonUtils.py
index 387eac4..266b8b5 100644
--- a/helpers/helperslib/CommonUtils.py
+++ b/helpers/helperslib/CommonUtils.py
@@ -1,5 +1,6 @@
 import os
 import sys
+import shutil
 import hashlib
 import paramiko
 
@@ -90,3 +91,23 @@ def establishSSHConnection( hostname, username, keyFile ):
 	client.connect( hostname, username=username, pkey = serverAccessKey )
 	# All done
 	return client
+
+def recursiveDirectoryCopy(sourceDirectory, destinationDirectory):
+    # Copy a directory structure overwriting existing files
+	for root, dirs, files in os.walk(sourceDirectory):
+		# Ensure we have a relative path for root as we'll need it quite a bit shortly
+		currentDirectory = os.path.relpath( root, sourceDirectory )
+
+		# Make sure the directory exists in our destination
+		currentDestination = os.path.join( destinationDirectory, currentDirectory )
+		if not os.path.isdir(currentDestination):
+			os.makedirs(currentDestination)
+
+		# Now we can copy the various files within in turn
+		for fileToCopy in files:
+			# Determine the full path to the source file
+			fileSource = os.path.join(root, fileToCopy)
+			# Determine where to copy the file to
+			fileDestination = os.path.join(currentDestination, fileToCopy)
+			# Copy it!
+			shutil.copyfile( fileSource, fileDestination )
diff --git a/helpers/prepare-dependencies.py b/helpers/prepare-dependencies.py
index 101aa05..9e5a6fa 100755
--- a/helpers/prepare-dependencies.py
+++ b/helpers/prepare-dependencies.py
@@ -49,17 +49,6 @@ dependenciesFile = os.path.join( CommonUtils.scriptsBaseDirectory(), 'local-meta
 if os.path.exists( dependenciesFile ):
 	resolver.loadDependenciesFromFile( dependenciesFile )
 
-# On Windows, we need to pull bin\data\ over from the Craft prefix to ensure resources in it can be found by QStandardPaths
-# This has to be done first, as copytree requires the directory to not exist already
-if sys.platform == 'win32' and 'CRAFT_ROOT' in os.environ:
-	# Determine where Craft is...
-	craftRoot = os.path.realpath(os.environ['CRAFT_ROOT'])
-	sourceDirectory = os.path.join( craftRoot, 'bin\data' )
-	# Determine where we want to deploy these files to
-	destinationDirectory = os.path.join( arguments.installTo, 'bin\data' )
-	# Do the copy!
-	shutil.copytree( sourceDirectory, destinationDirectory )
-
 # Now that we are all initialised, we can ask the resolver for the project we represent, then resolve it's dependencies
 resolverProject = resolver.retrieveProject( arguments.project )
 projectDependencies = resolver.forProject( resolverProject, arguments.platform )
diff --git a/helpers/run-tests.py b/helpers/run-tests.py
index fe50d00..ab58e3d 100755
--- a/helpers/run-tests.py
+++ b/helpers/run-tests.py
@@ -38,6 +38,17 @@ if sys.platform == 'freebsd11':
 	# Then don't continue any further
 	sys.exit(0)
 
+# On Windows, we need to pull bin\data\ over from the Craft prefix to ensure resources in it can be found by QStandardPaths
+# This is a bit of a hack, but there isn't much we can do here as Qt doesn't give us any means of telling it to look elsewhere
+if sys.platform == 'win32' and 'CRAFT_ROOT' in os.environ:
+	# Determine where Craft is...
+	craftRoot = os.path.realpath( os.environ['CRAFT_ROOT'] )
+	sourceDirectory = os.path.join( craftRoot, 'bin\data' )
+	# Determine where we want to deploy these files to
+	destinationDirectory = os.path.join( buildLocation, 'bin\data' )
+	# Do the copy!
+	CommonUtils.recursiveDirectoryCopy( sourceDirectory, destinationDirectory )
+
 # Get a count of the number of available tests
 # This relies on the command "ctest -N" producing at least one line that matches "Total Tests: x" where x is the number of tests
 process = subprocess.Popen( "ctest -N", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=buildEnvironment, cwd=buildLocation)


More information about the Kde-frameworks-devel mailing list