try:
# Restore original file, and also remove the backup.
# This is meant to restore the source tree to its original state.
- os.rename(os.path.join(source_tree_root, path + '.orig'),
- os.path.join(source_tree_root, path))
+ orig_file = os.path.join(source_tree_root, path + '.orig')
+ dest_file = os.path.join(source_tree_root, path)
+ stat = os.stat(orig_file)
+ os.rename(orig_file, dest_file)
+ os.utime(dest_file, (stat.st_atime, stat.st_mtime))
except OSError:
# .orig file may be not created (when we skip fetching the target
# library due to unexpected termination), so just ignore the error.
else:
try:
# Create a backup copy for --undo.
- shutil.copyfile(os.path.join(source_tree_root, path),
- os.path.join(source_tree_root, path + '.orig'))
+ base_file = os.path.join(source_tree_root, path)
+ orig_file = os.path.join(source_tree_root, path + '.orig')
+ stat = os.stat(base_file)
+ shutil.copy2(base_file, orig_file)
+ os.utime(orig_file, (stat.st_atime, stat.st_mtime))
except IOError:
# This exception may happen when the target directory does not exist,
# which is the case when we skip fetching the third_party library due to unexpected
dst = os.path.join(source_tree_root, path)
print('** use system %s library **' % lib)
print(' From %s\n To %s' % (src, dst))
- shutil.copyfile(src, dst)
+ stat = os.stat(src)
+ shutil.copy2(src, dst)
+ os.utime(dst, (stat.st_atime, stat.st_mtime))
src = os.path.join(my_dirname, '%s' % lib)
# Copy the additional configuration files from directory of this script to target path.
if os.path.isdir(src):
dst = os.path.join(source_tree_root, 'third_party')
- os.system("cp -rf " + src + " " + dst)
+ os.system("cp -rpf " + src + " " + dst)
print(' From %s\n To %s' % (src, dst))
unhandled_libraries = set(args.system_libraries) - handled_libraries
+import filecmp
import glob
import sys
import os
+import shutil
+import tempfile
from optparse import OptionParser
+from pathlib import Path
# Text file containing list of EWK APIs
filepath = 'API_LIST.txt'
basepath = os.path.dirname(os.path.realpath(__file__))
path = basepath + "/../ewk/efl_integration/public/ewk*.h"
-files = glob.glob(path)
-with open(filepath, 'w') as outfile:
- for file in files:
- if (file.find("ewk_export.h") != -1):
- continue;
- f = open(file, 'r')
- for line in f:
- outfile.write(line)
- f.close()
+with tempfile.TemporaryDirectory() as tmp_dir:
+ backup_filepath = os.path.join(Path(tmp_dir), filepath)
+ api_list_exists = os.path.isfile(filepath)
+ if api_list_exists:
+ shutil.move(filepath, backup_filepath)
+
+ files = glob.glob(path)
+ with open(filepath, 'w') as outfile:
+ for file in files:
+ if (file.find("ewk_export.h") != -1):
+ continue;
+ f = open(file, 'r')
+ for line in f:
+ outfile.write(line)
+ f.close()
+
+ api_list_is_the_same = api_list_exists and filecmp.cmp(filepath, backup_filepath)
+ if api_list_is_the_same:
+ # No action will be performed, API_LIST.txt file has not been changed.
+ sys.exit(0)
# Extract lines containing EXPORT_API
api_line = ""