summaryrefslogtreecommitdiffstats
path: root/README.copyright
blob: a32ed9e7e67b42af46a67dfa4b3c3a3c71e38903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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 `<CTRL-W>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 `<CTRL-R>l`.

"""

On this system, a copy of the GNU General Public License may be found at
<file:///usr/share/common-licenses/GPL-2>.
"""