Add copy and guessPlatform methods

parent c7a0721b
......@@ -26,12 +26,21 @@
##############################################################################
import logging
import os
from platform import uname
import setuptools
import shutil
import subprocess
import tempfile
import zc.buildout
ARCH_MAP = {
'i386': 'x86',
'i586': 'x86',
'i686': 'x86',
'x86_64': 'x86-64'
}
def readElfAsDict(f):
"""Reads ELF information from file"""
popen = subprocess.Popen(['readelf', '-d', f],
......@@ -79,6 +88,12 @@ def guessworkdir(path):
if len(os.listdir(path)) == 1:
return os.path.join(path, os.listdir(path)[0])
return path
def guessPlatform():
arch = uname()[-2]
target = ARCH_MAP.get(arch)
assert target, 'Unknown architecture'
return target
class Script:
"""Free script building system"""
......@@ -149,6 +164,27 @@ class Script:
setuptools.archive_util.unpack_archive(path, extract_dir)
self.cleanup_dir_list.append(extract_dir)
return extract_dir
def copy(self, origin, destination, ignore_dir_list=[]):
"""Copy directory.
"""
if os.path.exists(destination):
self.logger.info('No need to re-install java part')
return False
self.logger.info("Copying unpacked contents")
java_dir = ''
if 'ignore' in shutil.copytree.func_code.co_varnames:
shutil.copytree(os.path.join(origin, java_dir),
destination,
ignore=lambda src,names:ignore_dir_list)
else:
shutil.copytree(origin,
destination)
for ignore_dir in ignore_dir_list:
ignore_dir = os.path.join(destination, ignore_dir)
if os.path.exists(ignore_dir):
shutil.rmtree(ignore_dir)
return True
script = 'raise NotImplementedError'
def __init__(self, buildout, name, options):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment