def find_java_tree(platform): java = "java/" + platform revision = execute("git rev-parse HEAD:" + java) if platform == "macosx-java3d": return [revision.replace("\n", ""), platform] tree = execute("git --git-dir=" + java + "/.git ls-tree " + revision) return [tree[12:52] + ":jre", platform + "/" + tree[53:].replace("\n", "") + "/jre"]
def find_java_tree(platform): java = 'java/' + platform revision = execute('git rev-parse HEAD:' + java) if platform == 'macosx-java3d': return [revision.replace('\n', ''), platform] tree = execute('git --git-dir=' + java + '/.git ls-tree ' + revision) return [tree[12:52] + ':jre', platform + '/' + tree[53:].replace('\n', '') + '/jre']
def find_java_tree(platform): java = 'java/' + platform revision = execute('git rev-parse HEAD:' + java) if platform == 'macosx-java3d': return [revision.replace('\n', ''), platform] tree = execute('git --git-dir=' + java + '/.git ls-tree ' + revision) return [ tree[12:52] + ':jre', platform + '/' + tree[53:].replace('\n', '') + '/jre' ]
root = 'root-x86_64-pc-linux/' cxx = root + 'bin/x86_64-pc-mingw32-g++' strip = root + 'bin/x86_64-pc-mingw32-strip' windres = root + 'bin/x86_64-pc-mingw32-windres' target = 'precompiled/fiji-win64.exe' if not os.path.exists(cxx): url = 'http://heanet.dl.sourceforge.net/sourceforge/mingw-w64/' file = 'mingw-w64-bin_x86-64-linux_20080721.tar.bz2' filename = urllib.urlretrieve(url + file)[0] if filename is None: print "You need to install the mingw64 cross compiler into", cxx sys.exit(1) os.makedirs(root) execute('tar -C ' + root + ' -xjvf ' + filename) if not os.path.exists(cxx): print "You need to install the mingw64 cross compiler into", cxx sys.exit(1) res = open('tmp.rc', 'w') res.write('101 ICON images/fiji.ico') res.close() print(windres + ' -o tmp.o -i tmp.rc') print execute(windres + ' -o tmp.o -i tmp.rc') quoted_args = ' '.join(sys.argv[2:]).replace("'", '"').replace('"', '\"') print(cxx + ' -o ' + target + ' ' + quoted_args + ' fiji.cxx tmp.o') print execute(cxx + ' -o ' + target + ' ' + quoted_args + ' fiji.cxx tmp.o') print(strip + ' ' + target) print execute(strip + ' ' + target)
def add_plugin(plugin): if plugin.endswith('.java'): target = 'plugins/' + plugin[0:len(plugin) - 5] + '.class' elif plugin in third_parties: target = 'plugins/' + plugin else: if plugin.endswith('/'): plugin = plugin[0:len(plugin) - 1] remove_class_files('src-plugins/' + plugin) target = 'plugins/' + plugin + '.jar' ignore_line = '/' + target + "\n" if not ignore_line in ignored: f = open('.gitignore', 'a') f.write(ignore_line) f.close() ignored[target] = -1 execute('git add .gitignore') plugin_line = "\t" + target + " \\\n" global last_plugin_line, last_jar_plugin_line, faked_plugins global last_3rd_party_plugin_line if not plugin_line in faked_plugins: if plugin.endswith('.java'): if last_jar_plugin_line > last_plugin_line: last_jar_plugin_line += 1 if last_3rd_party_plugin_line > last_plugin_line: last_3rd_party_plugin_line += 1 last_plugin_line += 1 fakefile.insert(last_plugin_line, plugin_line) elif plugin in third_parties: if last_plugin_line > last_3rd_party_plugin_line: last_plugin_line += 1 if last_jar_plugin_line > last_3rd_party_plugin_line: last_jar_plugin_line += 1 last_3rd_party_plugin_line += 1 fakefile.insert(last_3rd_party_plugin_line, plugin_line) else: if last_plugin_line > last_jar_plugin_line: last_plugin_line += 1 if last_3rd_party_plugin_line > last_jar_plugin_line: last_3rd_party_plugin_line += 1 last_jar_plugin_line += 1 fakefile.insert(last_jar_plugin_line, plugin_line) f = open ('Fakefile', 'w') f.write(''.join(fakefile)) f.close() execute('git add Fakefile') if plugin in third_parties: file = 'staged-plugins/' + plugin third_party = 'third-party ' else: file = 'src-plugins/' + plugin third_party = '' if execute('git ls-files ' + file) == '': action = 'Add' else: action = 'Modify' execute('git add ' + file) f = open('.msg', 'w') if plugin.endswith('.java'): plugin = plugin[0:len(plugin) - 5] elif plugin.endswith('.jar'): plugin = plugin[0:len(plugin) - 4] configfile = 'staged-plugins/' + plugin + '.config' if os.path.exists(configfile): execute('git add ' + configfile) name = plugin.replace('/', '>').replace('_', ' ') f.write(action + ' the ' + third_party + 'plugin "' + name + '"') f.close() execute('git commit -s -F .msg') os.remove('.msg')
#!/bin/sh ''''exec "$(dirname "$0")"/../fiji --jython "$0" "$@" # (call again with fiji)''' import sys from compat import execute if len(sys.argv) < 3: print 'Usage: ', sys.argv[0], ' <archive> <folder>' exit(1) archive = sys.argv[1] folder = sys.argv[2] print 'Making', archive, 'from', folder if not archive.endswith('.7z'): archive = archive + '.7z' execute('7z a -m0=lzma -mx=9 -md=64M ' + archive + ' ' + folder) execute('chmod a+r ' + archive)
def get_disk_id(dmg): match = re.match(".*/dev/([^ ]*)[^/]*Apple_HFS.*", execute("hdid " + dmg), re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None
import sys from compat import execute if len(sys.argv) < 3: print 'Usage:', sys.argv[0], '<source> <launcher>...' sys.exit(1) source = sys.argv[1] count = 0 for file in sys.argv[2:]: # Find out the edge commits (edges being the commits changing the # launcher, but having no offspring with the same property) edges = '' while True: edge = execute('git rev-list -1 HEAD ' + edges + ' -- ' + file) if edge == '': break edges = edges + ' ^' + edge if edges == '': print file, 'has not been committed yet' count += 1 continue # Now verify that that the source has not changed since any of those # edges if execute('git rev-list HEAD ' + edges + ' -- ' + source) != '': print file, 'is not up-to-date.' count += 1
space = prereq.find(' ') if space < 0: space = len(prereq) star = prereq.find('*', 0, space) if star < 0: star = space slash = prereq.rfind('/', 0, star) if slash > 0: prereq = prereq[:slash] timestamp = str(timestamp) from datetime import datetime, timedelta date = datetime.strptime(timestamp[6:8] + '.' + timestamp[4:6] + '.' + timestamp[:4] + ' ' + timestamp[8:10] + ':' + timestamp[10:12] + ':' + timestamp[12:14] + ' +0000', '%d.%m.%Y %H:%M:%S') startdate = date - timedelta(0, 2 * 60 * 60) enddate = date + timedelta(0, 2 * 60 * 60) date = date.strftime('%d.%m.%Y.%H:%M:%S') startdate = startdate.strftime('%d.%m.%Y.%H:%M:%S') enddate = enddate.strftime('%d.%m.%Y.%H:%M:%S') from compat import execute cmd = 'git log --since=' + startdate + ' --until=' + enddate + ' ' + prereq print 'Running:', cmd result = execute(cmd) if result == '': cmd = 'git log -1 --until=' + startdate + ' ' + prereq print 'Running again:', cmd result = execute(cmd) print '\nFound:' print result
else: print 'Need a target, as the submodule', submodule, \ 'was not added yet' sys.exit(1) elif len(sys.argv) == 3: if not submodule in has_rule.keys() or \ sys.argv[2] == has_rule[submodule]: target = sys.argv[2] else: print 'Submodule', submodule, 'already has target', \ has_rule[submodule], '(you gave', sys.argv[2] + ')' sys.exit(1) # push submodule url = execute('git --git-dir=' + submodule + '.git config remote.origin.url') if url.startswith('git://'): print 'The origin\'s URL of', submodule, \ 'must be a pushable (i.e. not start with git://)' sys.exit(1) print 'Making sure that the submodule is pushed:', \ execute('git --git-dir=' + submodule + '.git push origin HEAD') # add to .gitignore if not yet there ignore_line = '/' + target + "\n" if not ignore_line in ignored: f = open('.gitignore', 'a') f.write(ignore_line) f.close() ignored[target] = -1
star = prereq.find('*', 0, space) if star < 0: star = space slash = prereq.rfind('/', 0, star) if slash > 0: prereq = prereq[:slash] timestamp = str(timestamp) from datetime import datetime, timedelta date = datetime.strptime( timestamp[6:8] + '.' + timestamp[4:6] + '.' + timestamp[:4] + ' ' + timestamp[8:10] + ':' + timestamp[10:12] + ':' + timestamp[12:14] + ' +0000', '%d.%m.%Y %H:%M:%S') startdate = date - timedelta(0, 2 * 60 * 60) enddate = date + timedelta(0, 2 * 60 * 60) date = date.strftime('%d.%m.%Y.%H:%M:%S') startdate = startdate.strftime('%d.%m.%Y.%H:%M:%S') enddate = enddate.strftime('%d.%m.%Y.%H:%M:%S') from compat import execute cmd = 'git log --since=' + startdate + ' --until=' + enddate + ' ' + prereq print 'Running:', cmd result = execute(cmd) if result == '': cmd = 'git log -1 --until=' + startdate + ' ' + prereq print 'Running again:', cmd result = execute(cmd) print '\nFound:' print result
print 'Copying platform-specific files for', platform, \ '(host platform=' + host_platform + ')' if platform == 'macosx': macos='Fiji.app/Contents/MacOS/' os.makedirs(macos) shutil.copy('Contents/MacOS/ImageJ-macosx', macos + 'ImageJ-macosx') shutil.copy('Contents/MacOS/ImageJ-tiger', macos) chmod(macos + 'ImageJ-macosx', 0755) chmod(macos + 'ImageJ-tiger', 0755) shutil.copy('Contents/Info.plist', 'Fiji.app/Contents/') images='Fiji.app/Contents/Resources/' os.makedirs(images) shutil.copy('Contents/Resources/Fiji.icns', images) else: if platform.startswith('win'): exe = ".exe" else: exe = '' binary = 'ImageJ-' + platform + exe shutil.copy(binary, 'Fiji.app/' + binary) chmod('Fiji.app/' + binary, 0755) make_app() execute('bin/download-launchers.sh snapshot') if platform == 'all': for p in all_platforms: copy_platform_specific_files(p) else: copy_platform_specific_files(platform)
def find_java_tree(platform): if platform == 'linux64': platform = 'linux-amd64' java = 'origin/java/' + platform version = execute('git ls-tree --name-only ' + java).replace('\n', '') return java + ':' + version + '/jre'
else: print 'Need a target, as the submodule', submodule, \ 'was not added yet' sys.exit(1) elif len(sys.argv) == 3: if not submodule in has_rule.keys() or \ sys.argv[2] == has_rule[submodule]: target = sys.argv[2] else: print 'Submodule', submodule, 'already has target', \ has_rule[submodule], '(you gave', sys.argv[2] + ')' sys.exit(1) # push submodule url = execute('git --git-dir=' + submodule + '.git config remote.origin.url') if url.startswith('git://'): print 'The origin\'s URL of', submodule, \ 'must be a pushable (i.e. not start with git://)' sys.exit(1) print 'Making sure that the submodule has no uncommitted changes' git_base='git --git-dir=' + submodule + '.git --work-tree=' + submodule if os.system(git_base + ' update-index --refresh') != 0 or \ os.system(git_base + ' diff-files --quiet') != 0 or \ os.system(git_base + ' diff-index --cached --quiet HEAD') != 0: print 'Submodule ' + submodule + ' contains uncommitted changes' sys.exit(1) print 'Making sure that the submodule is pushed:', \ execute('git --git-dir=' + submodule + '.git push origin HEAD') # add to .gitignore if not yet there
#!/bin/sh ''''exec "$(dirname "$0")"/ImageJ.sh --jython "$0" "$@" # (call again with fiji)''' import sys from compat import execute if len(sys.argv) < 3: print 'Usage: ', sys.argv[0], ' <tarfile> <folder>' exit(1) tarfile = sys.argv[1] folder = sys.argv[2] print 'Making', tarfile, 'from', folder if tarfile.endswith('.bz2'): packer = 'bzip2 -9 -f' tarfile = tarfile[:len(tarfile) - 4] elif tarfile.endswith('.gz'): packer = 'gzip -9 -f' tarfile = tarfile[:len(tarfile) - 3] else: packer = '' execute('tar cvf ' + tarfile + ' ' + folder) if packer != '': execute(packer + ' ' + tarfile)
def get_folder(dmg): match = re.match('.*Apple_HFS\s*([^\n]*).*', execute('hdid ' + dmg), re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None def eject(dmg): disk_id = get_disk_id(dmg) print "disk_id: ", disk_id hdiutil('eject ' + disk_id) # create temporary disk image and format, ejecting when done hdiutil('create ' + dmg + ' -srcfolder ' + app \ + ' -fs HFS+ -format UDRW -volname Fiji -ov') folder = get_folder(dmg) print "folder: ", folder os.system('cp resources/install-fiji.jpg "' + folder + '"/.background.jpg') symlink('/Applications', folder + '/Applications') execute('perl bin/generate-finder-dsstore.perl') # to edit the background image/icon positions: raw_input('Press Enter...') eject(dmg) os.rename(dmg, dmg + '.tmp') hdiutil('convert ' + dmg + '.tmp -format UDZO -o ' + dmg) eject(dmg) os.remove(dmg + '.tmp')
return None def get_folder(dmg): match = re.match(".*Apple_HFS\s*([^\n]*).*", execute("hdid " + dmg), re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None def eject(dmg): disk_id = get_disk_id(dmg) print "disk_id: ", disk_id hdiutil("eject " + disk_id) # create temporary disk image and format, ejecting when done hdiutil("create " + dmg + " -srcfolder " + app + " -fs HFS+ -format UDRW -volname Fiji -ov") folder = get_folder(dmg) print "folder: ", folder os.system('cp resources/install-fiji.jpg "' + folder + '"/.background.jpg') symlink("/Applications", folder + "/Applications") execute("perl bin/generate-finder-dsstore.perl") # to edit the background image/icon positions: raw_input('Press Enter...') eject(dmg) os.rename(dmg, dmg + ".tmp") hdiutil("convert " + dmg + ".tmp -format UDZO -o " + dmg) eject(dmg) os.remove(dmg + ".tmp")
def get_disk_id(dmg): match = re.match('.*/dev/([^ ]*)[^/]*Apple_HFS.*', execute('hdid ' + dmg), re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None
def get_folder(dmg): match = re.match(".*Apple_HFS\s*([^\n]*).*", execute("hdid " + dmg), re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None
def get_folder(dmg): match = re.match('.*Apple_HFS\s*([^\n]*).*', execute('hdid ' + dmg), re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None
'(host platform=' + host_platform + ')' if platform == 'macosx': macos = 'Fiji.app/Contents/MacOS/' os.makedirs(macos) shutil.copy('Contents/MacOS/ImageJ-macosx', macos + 'ImageJ-macosx') shutil.copy('Contents/MacOS/ImageJ-tiger', macos) chmod(macos + 'ImageJ-macosx', 0755) chmod(macos + 'ImageJ-tiger', 0755) shutil.copy('Contents/Info.plist', 'Fiji.app/Contents/') images = 'Fiji.app/Contents/Resources/' os.makedirs(images) shutil.copy('Contents/Resources/Fiji.icns', images) else: if platform.startswith('win'): exe = ".exe" else: exe = '' binary = 'ImageJ-' + platform + exe shutil.copy(binary, 'Fiji.app/' + binary) chmod('Fiji.app/' + binary, 0755) make_app() execute('bin/download-launchers.sh snapshot') if platform == 'all': for p in all_platforms: copy_platform_specific_files(p) else: copy_platform_specific_files(platform)
re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None def get_folder(dmg): match=re.match('.*Apple_HFS\s*([^\n]*).*', execute('hdid ' + dmg), re.MULTILINE | re.DOTALL) if match != None: return match.group(1) return None def eject(dmg): disk_id=get_disk_id(dmg) print "disk_id: ", disk_id hdiutil('eject ' + disk_id) # create temporary disk image and format, ejecting when done hdiutil('create ' + dmg + ' -srcfolder ' + app \ + ' -fs HFS+ -format UDRW -volname Fiji -ov') folder=get_folder(dmg) print "folder: ", folder os.system('cp resources/install-fiji.jpg "' + folder + '"/.background.jpg') symlink('/Applications', folder + '/Applications') execute('perl bin/generate-finder-dsstore.perl') # to edit the background image/icon positions: raw_input('Press Enter...') eject(dmg) os.rename(dmg, dmg + '.tmp') hdiutil('convert ' + dmg + '.tmp -format UDZO -o ' + dmg) eject(dmg) os.remove(dmg + '.tmp')
verbose = False print 'Making', zipfile, 'from', folder if os.name == 'java': from java.io import FileOutputStream from java.util.zip import ZipOutputStream, ZipEntry def add_folder(zip, folder): for file in os.listdir(folder): file = folder + '/' + file if os.path.isdir(file): add_folder(zip, file) elif os.path.isfile(file): if verbose: print file entry = ZipEntry(file) zip.putNextEntry(entry) f = open(file, "rb") zip.write(f.read()) f.close() zip.closeEntry() output = FileOutputStream(zipfile) zip = ZipOutputStream(output) add_folder(zip, folder) zip.close() else: execute('zip -9r ' + zipfile + ' ' + folder)
#!/bin/sh ''''exec "$(dirname "$0")"/../ImageJ --jython "$0" "$@" # (call again with fiji)''' import sys from compat import execute if len(sys.argv) < 3: print 'Usage: ', sys.argv[0], ' <archive> <folder>' exit(1) archive = sys.argv[1] folder = sys.argv[2] print 'Making', archive, 'from', folder if not archive.endswith('.7z'): archive = archive + '.7z' execute('7z a -m0=lzma -mx=9 -md=64M ' + archive + ' ' + folder) execute('chmod a+r ' + archive)
else: print "Unsupported platform:", sys.argv[1] sys.exit(1) cc = prefix + 'gcc' strip = prefix + 'strip' windres = prefix + 'windres' target = 'precompiled/fiji-' + platform + exe source = 'fiji.c' if platform.startswith('win'): res = open('tmp.rc', 'w') res.write('101 ICON images/fiji.ico') res.close() if platform == 'win32': m32 = '--target=pe-i386' else: m32 = '' command = windres + ' ' + m32 + ' -o tmp.o -i tmp.rc' print(command) print execute(command) source += " tmp.o" quoted_args = ' '.join(cflags).replace("'", '"').replace('"', '\"') command = cc + ' -o ' + target + ' ' + quoted_args + ' ' + source print(command) print execute(command) command = strip + ' ' + target print(command) print execute(command)
#!/bin/sh ''''exec "$(dirname "$0")"/../fiji --jython "$0" "$@" # (call again with fiji)''' import sys from compat import execute if len(sys.argv) < 3: print 'Usage: ', sys.argv[0], ' <tarfile> <folder>' exit(1) tarfile = sys.argv[1] folder = sys.argv[2] print 'Making', tarfile, 'from', folder if tarfile.endswith('.bz2'): packer = 'bzip2 -9 -f' tarfile = tarfile[:len(tarfile) - 4] elif tarfile.endswith('.gz'): packer = 'gzip -9 -f' tarfile = tarfile[:len(tarfile) - 3] else: packer = '' execute('tar cvf ' + tarfile + ' ' + folder) if packer != '': execute(packer + ' ' + tarfile)
if sys.argv[1] != 'win64': print "Unsupported platform:", sys.argv[1] sys.exit(1) root = 'root-x86_64-pc-linux/' cc = root + 'bin/x86_64-w64-mingw32-gcc' strip = root + 'bin/x86_64-w64-mingw32-strip' windres = root + 'bin/x86_64-w64-mingw32-windres' target = 'precompiled/fiji-win64.exe' if not os.path.exists(cc): url = 'http://dfn.dl.sourceforge.net/project/mingw-w64/' url += 'Toolchains%20targetting%20Win64/Automated%20Builds/' file = 'mingw-w64-bin_x86_64-linux_20090920.tar.bz2' execute('curl -o ' + file + ' ' + url + file ) filename = file if filename is None: print "You need to install the mingw64 cross compiler into", cc sys.exit(1) os.makedirs(root) execute('tar -C ' + root + ' -xjvf ' + filename) if not os.path.exists(cc): print "You need to install the mingw64 cross compiler into", cc sys.exit(1) res = open('tmp.rc', 'w') res.write('101 ICON images/fiji.ico') res.close() print(windres + ' -o tmp.o -i tmp.rc') print execute(windres + ' -o tmp.o -i tmp.rc')