Starting from Scratch ===================== First of course, unpack a clean source tree: $ sudo rm -Rf tmp $ sudo prokit build $root -bcT nop . Next get a list of all C source files (706 files as of version 1.32.0) that may be built into the `busybox` binary: $ cd tmp/src/ tmp/src$ find * -name '*.[ch]' -a \! -path 'examples/*' \ > -a \! -path 'scripts/*' -a \! -path 'shell/*_test/*' | sort 0<../../.files The most common license notice text (in 359 files as of version 1.32.0) is "Licensed under GPLv2 or later, see file LICENSE in this source tree." The second most common text (in 210 files) is "Licensed under GPLv2, see file LICENSE in this source tree." Some (5) files contain both notices: tmp/src$ cat ../../.files | xargs grep -Fl \ > 'Licensed under GPLv2 or later, see file LICENSE in this source tree.' \ > | xargs grep -Fl \ > 'Licensed under GPLv2, see file LICENSE in this source tree.' archival/bbunzip.c coreutils/cat.c libbb/hash_md5_sha.c loginutils/cryptpw.c util-linux/mount.c Extract copyright comments from these (354 and 205) files: tmp/src$ cat ../../.files | xargs grep -Fl \ > 'Licensed under GPLv2 or later, see file LICENSE in this source tree.' \ > | grep -Ev > '^(archival/bbunzip.c|coreutils/cat.c|libbb/hash_md5_sha.c'\ > '|loginutils/cryptpw.c|util-linux/mount.c)$' > | xargs ../../extract-copyright-comments \ > 1>../../.copyright-comments.gplv2orlater tmp/src$ cat ../../.files | xargs grep -Fl \ > 'Licensed under GPLv2, see file LICENSE in this source tree.' \ > | grep -Ev > '^(archival/bbunzip.c|coreutils/cat.c|libbb/hash_md5_sha.c'\ > '|loginutils/cryptpw.c|util-linux/mount.c)$' > | xargs ../../extract-copyright-comments \ > 1>../../.copyright-comments.gplv2 This can take around 55 minutes total on a 3.3-GHz Opteron 4238 CPU. Edit the files `copyright`, `.copyright-comments.gplv2orlater`, and `.copyright-comments.gplv2`. Find all the unusual copyright and license notices (e.g. portions of code copied from elsewhere under other licenses), list them separately in `copyright`, and remove them from the `.copyright-comments.*` files. Also remove comments where "(c)" appears as C code rather than as a copyright symbol (found in at least `shell/shell_common.c`). With only files with simply the common license notices remaining, extract the file names: $ printf '%s, ' $(grep -v '^[[:space:]]' .copyright-comments.gplv2orlater) \ > | fold -s -w 81 | sed 's/ $//; $s/,$//' $ printf '%s, ' $(grep -v '^[[:space:]]' .copyright-comments.gplv2) \ > | fold -s -w 81 | sed 's/ $//; $s/,$//' Add these file names and the copyright and license notices to `copyright`. Next extract copyright comments from the files found earlier to have both GPLv2-or-later and GPLv2-only license notices: tmp/src$ ../../extract-copyright-comments \ > archival/bbunzip.c coreutils/cat.c libbb/hash_md5_sha.c \ > loginutils/cryptpw.c util-linux/mount.c \ > 1>../../.copyright-comments.gplv2both Edit the files `copyright` and `.copyright-comments.gplv2both`, moving copyright and license notices from the latter to the former. Now extract copyright comments from all the other (147 in version 1.32.0) files: tmp/src$ cat ../../.files | xargs grep -FL \ > 'Licensed under GPLv2 or later, see file LICENSE in this source tree.' \ > | xargs grep -FL \ > 'Licensed under GPLv2, see file LICENSE in this source tree.' \ > | xargs ../../extract-copyright-comments \ > 1>../../.copyright-comments.other And again edit `copyright` and `.copyright-comments.other`, moving copyright and license notices from the latter to the former. Also manually check the shell scripts under `applets_sh/` for copyright and license notices. As of version 1.32.0 there are two files with no such notices, and since these scripts are embedded as-is into the `busybox` binary, it's unlikely that there will ever be any verbose comments. Upgrading to a New Upstream Version =================================== Before upgrading, unpack a clean source tree of the old version: $ sudo rm -Rf tmp $ sudo prokit build $root -bcT nop . Next get a list of all C source files (706 files as of version 1.32.0) that may be built into the `busybox` binary, and extract all the copyright comments: $ cd tmp/src/ tmp/src$ find * -name '*.[ch]' -a \! -path 'examples/*' \ > -a \! -path 'scripts/*' -a \! -path 'shell/*_test/*' | \ > xargs ../../extract-copyright-comments 1>../../.copyright-comments.old Now upgrade to the new upstream version (by editing `changelog` and downloading the new upstream source archive). Unpack a clean source tree of the new version, and then get the copyright commands from all relevant C source files in the new version: $ sudo rm -Rf tmp $ sudo prokit build $root -bcT nop . $ cd tmp/src/ tmp/src$ find * -name '*.[ch]' -a \! -path 'examples/*' \ > -a \! -path 'scripts/*' -a \! -path 'shell/*_test/*' | \ > xargs ../../extract-copyright-comments 1>../../.copyright-comments.new This can take around 55 minutes total on a 3.3-GHz Opteron 4238 CPU. Finally compare the differences between the old and new copyright comments, and add these changes to the `copyright` file: $ diff -u .copyright-comments.old .copyright-comments.new | less Vim Tips ======== Open File Under Cursor ---------------------- Open the `copyright` file and one of the `.copyright-comments.*` files by either running the shell command `vim -O copyright .copyright-comments.gplv2orlater` from the package root directory or running from `tmp/src/` the shell command ` vim -O ../../copyright ../../.copyright-comments.gplv2orlater`. In the former case, run `:cd tmp/src/` within Vim. Making `tmp/src/` Vim's working directory allows source file names under the cursor to be opened, for example using `gf` to open a file in a new tab. File Name Header ---------------- Record a macro to quickly underline headers by entering `qhyypVr-q` from normal mode. Run the macro by entering `@h`. Note that such a macro cannot be repeated using `.` and that it will clobber the unnamed register. Common Licenses Paragraph ------------------------- Position the cursor on the first of the three quoted lines below and, in normal mode, enter `3"lyy`. Then, those three lines can be pasted in normal mode using `"lp` or in insert mode using `l`. """ On this system, a copy of the GNU General Public License may be found at . """