22 This script updates the list of years in the copyright notices in 23 most files maintained by the GDB project. 25 Usage: cd src/gdb && python copyright.py 27 Always review the output of this script before committing it! 28 A useful command to review the output is: 29 % filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff 30 This removes the bulk of the changes which are most likely to be correct. 40 """Return the list of files to update. 42 Assumes that the current working directory when called is the root 43 of the GDB source tree (NOT the gdb/ subdirectory!). The names of 44 the files are relative to that root directory. 47 for gdb_dir
in (
'gdb',
'sim',
'include/gdb'):
48 for root, dirs, files
in os.walk(gdb_dir, topdown=
True):
50 reldirname =
"%s/%s" % (root, dirname)
51 if (dirname
in EXCLUDE_ALL_LIST
52 or reldirname
in EXCLUDE_LIST
53 or reldirname
in NOT_FSF_LIST
54 or reldirname
in BY_HAND):
57 for filename
in files:
58 relpath =
"%s/%s" % (root, filename)
59 if (filename
in EXCLUDE_ALL_LIST
60 or relpath
in EXCLUDE_LIST
61 or relpath
in NOT_FSF_LIST
62 or relpath
in BY_HAND):
66 result.append(relpath)
71 """Update the copyright header of the files in the given list. 73 We use gnulib's update-copyright script for that. 79 os.environ[
'UPDATE_COPYRIGHT_USE_INTERVALS'] =
'2' 82 update_cmd = [
'bash',
'gdb/gnulib/import/extra/update-copyright']
83 update_cmd += update_list
85 p = subprocess.Popen(update_cmd, stdout=subprocess.PIPE,
86 stderr=subprocess.STDOUT)
87 update_out = p.communicate()[0]
97 update_out = update_out.splitlines()
98 warning_string =
': warning: copyright statement not found' 99 warning_len = len(warning_string)
101 for line
in update_out:
102 if line.endswith(
'\n'):
104 if line.endswith(warning_string):
105 filename = line[:-warning_len]
114 """Check that the given file does not seem to have a copyright notice. 116 The filename is relative to the root directory. 117 This function assumes that the current working directory is that root 120 The algorigthm is fairly crude, meaning that it might return 121 some false positives. I do not think it will return any false 122 negatives... We might improve this function to handle more 123 complex cases later... 134 if 'Copyright' in line:
143 """The main subprogram.""" 144 if not os.path.isfile(
"gnulib/import/extra/update-copyright"):
145 print "Error: This script must be called from the gdb directory." 146 root_dir = os.path.dirname(os.getcwd())
150 update_files (update_list)
154 if MULTIPLE_COPYRIGHT_HEADERS:
157 "REMINDER: Multiple copyright headers must be updated by hand:" 159 for filename
in MULTIPLE_COPYRIGHT_HEADERS:
164 print "\033[31mREMINDER: The following files must be updated by hand." \
166 for filename
in BY_HAND:
183 'gdb/nat/glibc_thread_db.h',
197 "COPYING",
"COPYING.LIB",
"CVS",
"configure",
"copying.c",
198 "fdl.texi",
"gpl.texi",
"aclocal.m4",
209 MULTIPLE_COPYRIGHT_HEADERS = (
210 "gdb/doc/gdb.texinfo",
211 "gdb/doc/refcard.tex",
218 "gdb/exc_request.defs",
220 "gdb/testsuite/gdb.gdbtk/",
221 "sim/arm/armemu.h",
"sim/arm/armos.c",
"sim/arm/gdbhost.c",
222 "sim/arm/dbg_hif.h",
"sim/arm/dbg_conf.h",
"sim/arm/communicate.h",
223 "sim/arm/armos.h",
"sim/arm/armcopro.c",
"sim/arm/armemu.c",
224 "sim/arm/kid.c",
"sim/arm/thumbemu.c",
"sim/arm/armdefs.h",
225 "sim/arm/armopts.h",
"sim/arm/dbg_cp.h",
"sim/arm/dbg_rdi.h",
226 "sim/arm/parent.c",
"sim/arm/armsupp.c",
"sim/arm/armrdi.c",
227 "sim/arm/bag.c",
"sim/arm/armvirt.c",
"sim/arm/main.c",
"sim/arm/bag.h",
228 "sim/arm/communicate.c",
"sim/arm/gdbhost.h",
"sim/arm/armfpe.h",
230 "sim/common/cgen-fpu.c",
"sim/common/cgen-fpu.h",
231 "sim/common/cgen-accfp.c",
232 "sim/mips/m16run.c",
"sim/mips/sim-main.c",
233 "sim/moxie/moxie-gdb.dts",
235 "sim/ppc/filter.h",
"sim/ppc/gen-support.h",
"sim/ppc/ld-insn.h",
236 "sim/ppc/hw_sem.c",
"sim/ppc/hw_disk.c",
"sim/ppc/idecode_branch.h",
237 "sim/ppc/sim-endian.h",
"sim/ppc/table.c",
"sim/ppc/hw_core.c",
238 "sim/ppc/gen-support.c",
"sim/ppc/gen-semantics.h",
"sim/ppc/cpu.h",
239 "sim/ppc/sim_callbacks.h",
"sim/ppc/RUN",
"sim/ppc/Makefile.in",
240 "sim/ppc/emul_chirp.c",
"sim/ppc/hw_nvram.c",
"sim/ppc/dc-test.01",
241 "sim/ppc/hw_phb.c",
"sim/ppc/hw_eeprom.c",
"sim/ppc/bits.h",
242 "sim/ppc/hw_vm.c",
"sim/ppc/cap.h",
"sim/ppc/os_emul.h",
243 "sim/ppc/options.h",
"sim/ppc/gen-idecode.c",
"sim/ppc/filter.c",
244 "sim/ppc/corefile-n.h",
"sim/ppc/std-config.h",
"sim/ppc/ld-decode.h",
245 "sim/ppc/filter_filename.h",
"sim/ppc/hw_shm.c",
246 "sim/ppc/pk_disklabel.c",
"sim/ppc/dc-simple",
"sim/ppc/misc.h",
247 "sim/ppc/device_table.h",
"sim/ppc/ld-insn.c",
"sim/ppc/inline.c",
248 "sim/ppc/emul_bugapi.h",
"sim/ppc/hw_cpu.h",
"sim/ppc/debug.h",
249 "sim/ppc/hw_ide.c",
"sim/ppc/debug.c",
"sim/ppc/gen-itable.h",
250 "sim/ppc/interrupts.c",
"sim/ppc/hw_glue.c",
"sim/ppc/emul_unix.c",
251 "sim/ppc/sim_calls.c",
"sim/ppc/dc-complex",
"sim/ppc/ld-cache.c",
252 "sim/ppc/registers.h",
"sim/ppc/dc-test.02",
"sim/ppc/options.c",
253 "sim/ppc/igen.h",
"sim/ppc/registers.c",
"sim/ppc/device.h",
254 "sim/ppc/emul_chirp.h",
"sim/ppc/hw_register.c",
"sim/ppc/hw_init.c",
255 "sim/ppc/sim-endian-n.h",
"sim/ppc/filter_filename.c",
256 "sim/ppc/bits.c",
"sim/ppc/idecode_fields.h",
"sim/ppc/hw_memory.c",
257 "sim/ppc/misc.c",
"sim/ppc/double.c",
"sim/ppc/psim.h",
258 "sim/ppc/hw_trace.c",
"sim/ppc/emul_netbsd.h",
"sim/ppc/psim.c",
259 "sim/ppc/ppc-instructions",
"sim/ppc/tree.h",
"sim/ppc/README",
260 "sim/ppc/gen-icache.h",
"sim/ppc/gen-model.h",
"sim/ppc/ld-cache.h",
261 "sim/ppc/mon.c",
"sim/ppc/corefile.h",
"sim/ppc/vm.c",
262 "sim/ppc/INSTALL",
"sim/ppc/gen-model.c",
"sim/ppc/hw_cpu.c",
263 "sim/ppc/corefile.c",
"sim/ppc/hw_opic.c",
"sim/ppc/gen-icache.c",
264 "sim/ppc/events.h",
"sim/ppc/os_emul.c",
"sim/ppc/emul_generic.c",
265 "sim/ppc/main.c",
"sim/ppc/hw_com.c",
"sim/ppc/gen-semantics.c",
266 "sim/ppc/emul_bugapi.c",
"sim/ppc/device.c",
"sim/ppc/emul_generic.h",
267 "sim/ppc/tree.c",
"sim/ppc/mon.h",
"sim/ppc/interrupts.h",
268 "sim/ppc/cap.c",
"sim/ppc/cpu.c",
"sim/ppc/hw_phb.h",
269 "sim/ppc/device_table.c",
"sim/ppc/lf.c",
"sim/ppc/lf.c",
270 "sim/ppc/dc-stupid",
"sim/ppc/hw_pal.c",
"sim/ppc/ppc-spr-table",
271 "sim/ppc/emul_unix.h",
"sim/ppc/words.h",
"sim/ppc/basics.h",
272 "sim/ppc/hw_htab.c",
"sim/ppc/lf.h",
"sim/ppc/ld-decode.c",
273 "sim/ppc/sim-endian.c",
"sim/ppc/gen-itable.c",
274 "sim/ppc/idecode_expression.h",
"sim/ppc/table.h",
"sim/ppc/dgen.c",
275 "sim/ppc/events.c",
"sim/ppc/gen-idecode.h",
"sim/ppc/emul_netbsd.c",
276 "sim/ppc/igen.c",
"sim/ppc/vm_n.h",
"sim/ppc/vm.h",
277 "sim/ppc/hw_iobus.c",
"sim/ppc/inline.h",
278 "sim/testsuite/sim/bfin/s21.s",
"sim/testsuite/sim/mips/mips32-dsp2.s",
281 if __name__ ==
"__main__":
def may_have_copyright_notice(filename)
def update_files(update_list)