michael@0: #!/usr/bin/env python michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: # michael@0: # Execute as: /import.py michael@0: # must have 'IMPORT_FILES' in it michael@0: michael@0: import sys michael@0: import re michael@0: import os michael@0: import shutil michael@0: michael@0: def die(msg): michael@0: sys.stderr.write('ERROR:' + msg + '\n') michael@0: sys.exit(1) michael@0: michael@0: DISTRO = sys.argv[1] michael@0: IMPORT_DIR = sys.argv[2] michael@0: FILES = [] michael@0: michael@0: f = open("%s/IMPORT_FILES" % IMPORT_DIR) michael@0: for l in f: michael@0: l = l.strip() michael@0: l = l.strip("'") michael@0: if l.startswith("#"): michael@0: continue michael@0: if not l: michael@0: continue michael@0: FILES.append(l) michael@0: michael@0: for f in FILES: michael@0: print f michael@0: SOURCE_PATH = "%s/%s"%(DISTRO,f) michael@0: DEST_PATH = "%s/%s"%(IMPORT_DIR,f) michael@0: if not os.path.exists(SOURCE_PATH): michael@0: die("%s does not exist"%SOURCE_PATH) michael@0: if not os.path.exists(os.path.dirname(DEST_PATH)): michael@0: os.makedirs(os.path.dirname(DEST_PATH)) michael@0: shutil.copyfile(SOURCE_PATH, DEST_PATH)