diff options
Diffstat (limited to 'dtools/bin')
-rwxr-xr-x | dtools/bin/check-imports | 4 | ||||
-rwxr-xr-x | dtools/bin/check-tarball-h-files | 25 | ||||
-rwxr-xr-x | dtools/bin/fix-copyright-years | 65 | ||||
-rwxr-xr-x | dtools/bin/install-tbb | 88 | ||||
-rwxr-xr-x | dtools/bin/make-upload | 16 | ||||
-rwxr-xr-x | dtools/bin/remove-whitespace | 3 | ||||
-rwxr-xr-x | dtools/bin/update_fsf_address | 134 |
7 files changed, 335 insertions, 0 deletions
diff --git a/dtools/bin/check-imports b/dtools/bin/check-imports new file mode 100755 index 000000000..fe4bf2302 --- /dev/null +++ b/dtools/bin/check-imports @@ -0,0 +1,4 @@ +#!/bin/bash + +find . -name '*.py' | xargs grep -h -E '^(from|import)' | sort -u + diff --git a/dtools/bin/check-tarball-h-files b/dtools/bin/check-tarball-h-files new file mode 100755 index 000000000..6e3e1e776 --- /dev/null +++ b/dtools/bin/check-tarball-h-files @@ -0,0 +1,25 @@ +#!/bin/sh + +tarball=$1 +if [ "x$tarball" = "x" ] +then + echo "usage: $0 tarball" 1>&2 + exit 1 +fi + +path=${tarball%%.tar.gz} + +tar tzf $tarball \ + | grep -E '\.(h|py|v|vh)$' \ + | sed -e "s/$path/./" \ + | sort >/tmp/tarball-h-files + +find . \( -name '*.h' -o -name '*.py' -o -name '*.v' -o -name '*.vh' \) -print \ + | grep -v ./$path | sort >/tmp/build-h-files + +comm -23 /tmp/build-h-files /tmp/tarball-h-files \ + | grep -Ev '(GrAtsc|_swig_|limbo|config\.h|std_paths\.h)' + +# rm /tmp/tarball-h-files /tmp/build-h-files + + diff --git a/dtools/bin/fix-copyright-years b/dtools/bin/fix-copyright-years new file mode 100755 index 000000000..bb0f3009d --- /dev/null +++ b/dtools/bin/fix-copyright-years @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +import re +import datetime +import subprocess +import multiprocessing + +def command(*args): return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] + +def is_gnuradio_co_source(lines): + for line in lines[:20]: + if 'GNU Radio is free software' in line: return True + return False + +def get_gnuradio_co_line(lines): + for i, line in enumerate(lines[:5]): + if 'Copyright' in line and 'Free Software Foundation' in line: return line, i + return None + +def fix_co_years(files): + for file in files: + print file + lines = open(file).readlines() + if not is_gnuradio_co_source(lines): continue + + #extract the years from the git history + years = set(map( + lambda l: int(l.split()[-2]), + filter( + lambda l: l.startswith('Date'), + command('git', 'log', file).splitlines(), + ), + )) + + #extract line and line number for co line + try: line, num = get_gnuradio_co_line(lines) + except: continue + + #extract years from co string + try: + co_years_str = re.match('^.*Copyright (.*) Free Software Foundation.*$', line).groups()[0] + co_years = set(map(int, co_years_str.split(','))) + except: print ' format error on line %d: "%s"'%(num, line); continue + + #update the years if missing any + all_years = co_years.union(years) + if all_years != co_years: + print ' missing years: %s'%(', '.join(map(str, sorted(all_years - co_years)))) + all_years.add(datetime.datetime.now().year) #add the current year + all_years_str = ', '.join(map(str, sorted(all_years))) + new_text = ''.join(lines[:num] + [line.replace(co_years_str, all_years_str)] + lines[num+1:]) + open(file, 'w').write(new_text) + +if __name__ == "__main__": + #get recursive list of files in the repo + files = command('git', 'ls-tree', '--name-only', 'HEAD', '-r').splitlines() + + #start n+1 processes to handle the files + num_procs = multiprocessing.cpu_count() + procs = [multiprocessing.Process( + target=lambda *files: fix_co_years(files), + args=files[num::num_procs], + ) for num in range(num_procs)] + map(multiprocessing.Process.start, procs) + map(multiprocessing.Process.join, procs) diff --git a/dtools/bin/install-tbb b/dtools/bin/install-tbb new file mode 100755 index 000000000..8ff216da4 --- /dev/null +++ b/dtools/bin/install-tbb @@ -0,0 +1,88 @@ +#!/usr/bin/env python + +""" +Install the release and debug libs and includes under --prefix +""" + +from optparse import OptionParser +import os +import os.path +import glob + +default_prefix="/usr/local" + +pkgconfig_filename = "tbb.pc" +pkgconfig_file_contents = """\ +prefix=%s +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: tbb +Description: Intel Threading Building Blocks +Requires: +Version: 2.0 +Libs: -L${libdir} -ltbb -ltbbmalloc +Cflags: -I${includedir} +""" + +debug_pkgconfig_filename = "tbb_debug.pc" +debug_pkgconfig_file_contents = """\ +prefix=%s +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: tbb +Description: Intel Threading Building Blocks +Requires: +Version: 2.0 +Libs: -L${libdir} -ltbb_debug -ltbbmalloc_debug +Cflags: -I${includedir} +""" + +def main(): + parser = OptionParser() + parser.add_option('','--prefix', default=default_prefix, + help="install architecture-independent files in PREFIX [default=%default]") + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + raise SystemExit, 1 + + prefix = options.prefix + + # are we installing 64-bit libs? + + is_64bit = False + files = glob.glob('build/*_em64t_*_release') + # print "files: ", files + if len(files) != 0: + is_64bit = True + + # FIXME add 32 and 64-bit PPC support + + if is_64bit: + lib = 'lib64' + else: + lib = 'lib' + + os.system('install -d ' + os.path.join(prefix, 'include/tbb')) + os.system('install -d ' + os.path.join(prefix, 'include/tbb/machine')) + os.system('install -d ' + os.path.join(prefix, lib)) + os.system('install -d ' + os.path.join(prefix, lib, 'pkgconfig')) + os.system('install -t ' + os.path.join(prefix, lib) + ' build/linux*release/*.so*') + os.system('install -t ' + os.path.join(prefix, lib) + ' build/linux*debug/*.so*') + os.system('install -t ' + os.path.join(prefix, 'include/tbb') + ' include/tbb/*.h') + os.system('install -t ' + os.path.join(prefix, 'include/tbb/machine') + ' include/tbb/machine/*.h') + + f = open(os.path.join(prefix, lib, 'pkgconfig', pkgconfig_filename), 'w') + f.write(pkgconfig_file_contents % (prefix,)) + f.close() + + f = open(os.path.join(prefix, lib, 'pkgconfig', debug_pkgconfig_filename), 'w') + f.write(debug_pkgconfig_file_contents % (prefix,)) + f.close() + +if __name__ == "__main__": + main() diff --git a/dtools/bin/make-upload b/dtools/bin/make-upload new file mode 100755 index 000000000..967dcfa1e --- /dev/null +++ b/dtools/bin/make-upload @@ -0,0 +1,16 @@ +#!/bin/bash + +read -s -p "GPG Passphrase: " passphrase + +for file in "$@" +do + ( + echo "version: 1.1" + echo "directory: gnuradio" + echo "filename: $file" + )> $file.directive + echo "$passphrase" | gpg --passphrase-fd 0 --clearsign $file.directive + rm $file.directive + echo "$passphrase" | gpg --passphrase-fd 0 -b $file +done +passphrase="XYZabcdefhghakdsj;lasjdf;ajfdiuiwjr;lajv;laoisfuaoieurlkajdsflkajsdfoiuew" diff --git a/dtools/bin/remove-whitespace b/dtools/bin/remove-whitespace new file mode 100755 index 000000000..9f011be3b --- /dev/null +++ b/dtools/bin/remove-whitespace @@ -0,0 +1,3 @@ +#!/bin/bash + +sed -i -e 's/\s\+$//g' $(find . -type f | grep -v '.git' | grep -v 'png' | grep -v 'eps')
\ No newline at end of file diff --git a/dtools/bin/update_fsf_address b/dtools/bin/update_fsf_address new file mode 100755 index 000000000..608ba0a8e --- /dev/null +++ b/dtools/bin/update_fsf_address @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# +# Copyright 2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +import re +import os +import os.path +import sys +from optparse import OptionParser + +dry_run = False +modified_files = [] + +dirs_to_ignore = ('CVS', '.svn', '.deps', '.libs') +extensions_to_ignore = ('.o', '.lo', + '.a', '.la', '.lai', + '.so', '.soT', + '.pyc', '.pyo', + '.ko', '.fasl', '.rwbak', + '.tar', '.gz', '.log', + '.eps', '.ps', '.pdf', + '.png', '.jpg', '.jpeg', '.bmp', + '.dat', '.ihx', + '.diff', + '.lib', '.lst', '.rel', '.sym', '.asm', '.rst', 'mem', '.map', # sdcc output + '.rbf', '.esf', '.qpf', '.psf', '.quartus', '.bsf', '.cmp' # quartus + ) + +def destructively_remove(list, predicate): + """ + Destructively remove elements from LIST for which PREDICATE is true + """ + for i in range(len(list)): + if predicate(list[i]): + del list[i] + destructively_remove(list, predicate) + return + + +def expunge_unwanted_dirnames(dirnames): + """ + Destructively remove directory names that we don't want to visit. + This is a _very_ non-functional approach to programming... + """ + destructively_remove(dirnames, lambda d: d in dirs_to_ignore) + +def expunge_unwanted_filenames(filenames): + """ + Destructively remove filenames that we don't want to visit. + This is a _very_ non-functional approach to programming... + """ + destructively_remove(filenames, + lambda f: f.endswith('~') or os.path.splitext(f)[1] in extensions_to_ignore) + + +def walk_directory(dirname): + for dirpath, dirnames, filenames in os.walk(dirname): + expunge_unwanted_dirnames(dirnames) + expunge_unwanted_filenames(filenames) + for f in filenames: + update_one(os.path.join(dirpath, f)) + + +addr_pattern = re.compile(r'\b59 Temple Place(,| *-) *Suite 330\b', re.IGNORECASE) +addr_replacement = '51 Franklin Street' +zip_pattern = re.compile(r'\b02111-1307\b') +zip_replacement = '02110-1301' + +def update_one(filename): + f = open(filename, 'r') + s = f.read() + f.close() + t = s + t = addr_pattern.sub(addr_replacement, t) + t = zip_pattern.sub(zip_replacement, t) + if s != t: + modified_files.append(filename) + if not dry_run: + f = open(filename, 'w') + f.write(t) + + +def handle_file_or_dir(file_or_dir): + if os.path.isfile(file_or_dir): + update_one(file_or_dir) + elif os.path.isdir(file_or_dir): + walk_directory(file_or_dir) + else: + pass # ignore the other cases + + +def main(): + global dry_run + + usage = '%prog: [options] [file_or_dir...]' + parser = OptionParser (usage=usage) + parser.add_option('-l', '--list-modified-files', action='store_true', default=False, + help='List modified files to stdout [default=%default]') + parser.add_option('', '--dry-run', action='store_true', default=False, + help="Don't modify any files, just report what would be modified [default=%default]") + (options, args) = parser.parse_args() + + dry_run = options.dry_run + if options.dry_run: + options.list_modified_files = True + + for file_or_dir in args: + handle_file_or_dir(file_or_dir) + + if options.list_modified_files: + for f in modified_files: + sys.stdout.write(f + '\n') + + +if __name__ == '__main__': + main() + |