1 # -*- coding: iso-8859-1 -*-
2 # Copyright © 2013, The AROS Development Team. All rights reserved.
4 # Copy directory 'src' recursively to 'dst' while ignoring
5 # all files given by 'ignore' parameter. Only files younger
6 # than those in 'dst' are copied.
8 # The files '.cvsignore', 'mmakefile.src' and the directories
9 # 'CVS', '.svn' are ignored.
11 # This is a support script for the %copy_dir_recursive macro
12 # in make.tmpl. Main purpose is to fix problem with file names
13 # which contain space characters.
15 import sys
, os
, shutil
17 def copy_tree(src
, dst
, ignore
):
18 names
= os
.listdir(src
)
20 if not os
.path
.exists(dst
):
24 srcname
= os
.path
.join(src
, name
)
25 dstname
= os
.path
.join(dst
, name
)
27 if os
.path
.isdir(srcname
):
28 if name
not in ("CVS", ".svn"):
29 # print "Copying dir %s to %s" % (srcname, dstname)
30 copy_tree(srcname
, dstname
, ignore
)
32 if (name
not in (".cvsignore", "mmakefile.src")) and (srcname
not in ignore
):
33 if not os
.path
.exists(dstname
) or (os
.path
.getctime(srcname
) > os
.path
.getctime(dstname
)):
34 # print "Copying file %s to %s" % (srcname, dstname)
35 shutil
.copy(srcname
, dstname
)
37 ################################################################################
56 if state
== st_source
:
58 elif state
== st_dest
:
60 elif state
== st_exclude
:
63 for destdir
in destdirs
:
64 print "Copying directory '%s' to '%s', ignore '%s'" % (sourcedir
, destdir
, ignore
)
65 copy_tree(sourcedir
, destdir
, ignore
)