| 1 |
decopy(1) -- Automatic debian/copyright generator |
| 2 |
================================================= |
| 3 |
|
| 4 |
## SYNTAX |
| 5 |
|
| 6 |
`decopy` [options] [files or dirs] |
| 7 |
|
| 8 |
## DESCRIPTION |
| 9 |
|
| 10 |
Decopy is a tool that automates creating and updating the debian/copyright |
| 11 |
files. It does this by parsing all files in a source tree, figuring out the |
| 12 |
copyright attribution and license for each file (when possible) and then |
| 13 |
structuring the output in the copyright format 1.0. |
| 14 |
|
| 15 |
## USAGE |
| 16 |
|
| 17 |
Simply running `decopy` in the source tree that needs to be parsed will process |
| 18 |
all files in the tree, group them by license, wildcard those groups and generate |
| 19 |
the proper output to be written to the debian/copyright file. |
| 20 |
|
| 21 |
If the source tree already includes a debian/copyright file, it will be used as |
| 22 |
input for files where the license could not be inferred, for the copyright of |
| 23 |
the debian directory and for the license snippets. The license texts for well |
| 24 |
known licenses are filled in automatically (see **--fill-licenses**); any that |
| 25 |
are not recognised need to be filled in manually. |
| 26 |
|
| 27 |
The files or directories specified as positional arguments can be used to limit |
| 28 |
the processing to the indicated subset instead of processing the complete source |
| 29 |
tree. |
| 30 |
|
| 31 |
## EXAMPLES |
| 32 |
|
| 33 |
On top of the simple `decopy` usage, these examples show some of the most common |
| 34 |
usecases. Please see the following sections for detailed explanations of what |
| 35 |
each of the parameters do. |
| 36 |
|
| 37 |
* `decopy --root src/hello-1.0/ --output src/hello-1.0/debian/copyright`: |
| 38 |
This runs the parser in the hello-1.0 source tree and generates the |
| 39 |
debian/copyright file in the source tree (the debian/ directory needs to |
| 40 |
pre-exist this call). |
| 41 |
|
| 42 |
* `decopy --mode partial src/3rdparty/ninja`: |
| 43 |
This shows the licensing and copyright information for the |
| 44 |
`src/3rdparty/ninja` directory. Only that directory is analyzed and the |
| 45 |
output includes only files contained in it. |
| 46 |
|
| 47 |
* `decopy --group-by copyright`: |
| 48 |
This processes the complete current source tree, paragraphs are split |
| 49 |
not only according to the licenses but also according to the copyright |
| 50 |
owners. |
| 51 |
|
| 52 |
* `decopy src`: |
| 53 |
This will process the src directory but, provided debian/copyright already |
| 54 |
exists, show the complete updated debian/copyright file. |
| 55 |
|
| 56 |
## COMMON OPTIONS |
| 57 |
|
| 58 |
* `--mode <mode>`: |
| 59 |
Indicates the mode to use when generating the output. The **full** mode |
| 60 |
(default) will generate a complete debian/copyright file, even if only some |
| 61 |
files were processed (the rest of the contents are taken from the original |
| 62 |
debian/copyright file). The **partial** mode will only print the |
| 63 |
copyright and licensing information for the indicated files. The **changed** |
| 64 |
mode restricts processing to the files that changed since the |
| 65 |
debian/copyright file was last committed to git (see **--changed** and |
| 66 |
**--since** below). |
| 67 |
|
| 68 |
* `--changed`: |
| 69 |
Shorthand for **--mode changed**. Scopes the run to the files that changed |
| 70 |
since the debian/copyright file was last committed. This requires the source |
| 71 |
tree to be a git repository; if the changed set cannot be computed (git is |
| 72 |
not available, the tree is not a repository, or the copyright file is |
| 73 |
untracked) decopy warns and falls back to a full scan. |
| 74 |
|
| 75 |
* `--since <ref>`: |
| 76 |
Baseline git ref for **--changed**. Defaults to the commit that last |
| 77 |
modified the debian/copyright file. |
| 78 |
|
| 79 |
* `--output <file>`, `-o <file>`: |
| 80 |
Store the generated output in the indicated file. This will overwrite the |
| 81 |
file if it already exists. |
| 82 |
|
| 83 |
* `--root <path>`: |
| 84 |
Process the indicated path instead of the current directory. |
| 85 |
|
| 86 |
* `--spdx`, `--no-spdx`: |
| 87 |
When **--spdx** is given, license short names are rendered using their SPDX |
| 88 |
identifiers instead of the DEP-5 copyright format names. The default is |
| 89 |
**--no-spdx**, which uses the DEP-5 names. |
| 90 |
|
| 91 |
* `--fill-licenses`, `--no-fill-licenses`: |
| 92 |
When **--fill-licenses** (the default) is given, the **License:** stanzas in |
| 93 |
the generated output are filled in with the corresponding license text: a |
| 94 |
reference to `/usr/share/common-licenses` for the licenses shipped there, or |
| 95 |
the full text for other well known licenses. With **--no-fill-licenses** the |
| 96 |
license text is left as a `TODO` placeholder to be filled in manually. |
| 97 |
|
| 98 |
* `--list-license-files`, `--no-list-license-files`: |
| 99 |
Whether the license files of the source tree (`COPYING*`, `COPYRIGHT`, |
| 100 |
`LICENSE*`) get an entry of their own in the generated output. Such a file |
| 101 |
carries a license text but is not itself licensed under it, so listing it is |
| 102 |
redundant (lintian reports `license-file-listed-in-debian-copyright`). The |
| 103 |
default is **--no-list-license-files**, which drops those entries, both the |
| 104 |
ones decopy would generate and the ones an existing `debian/copyright` |
| 105 |
already has. The licenses found in them are still used for the directory |
| 106 |
that holds them. |
| 107 |
|
| 108 |
## EXPLAIN MODE |
| 109 |
|
| 110 |
Instead of regenerating debian/copyright, decopy can report what is out of date |
| 111 |
in the existing file, which is useful as a check (e.g. in CI). |
| 112 |
|
| 113 |
* `--explain`: |
| 114 |
Report what is out of date in debian/copyright instead of regenerating it: |
| 115 |
stale Files paragraphs, patterns that no longer match any file, files whose |
| 116 |
license changed, new files that are not yet covered and copyright holders |
| 117 |
that have drifted. Nothing is written; decopy exits with status 1 if |
| 118 |
anything is stale and 0 if the file is up to date. |
| 119 |
|
| 120 |
## GROUPING CRITERIA |
| 121 |
|
| 122 |
The generated output will always create separate paragraphs for groups of files |
| 123 |
with different licenses, additionally, it can also split paragraphs according to |
| 124 |
the following grouping options. |
| 125 |
|
| 126 |
* `--group-by <criteria>`: |
| 127 |
When grouping by **license** (default), all copyright owners of different |
| 128 |
files with the same license are listed together. When grouping by |
| 129 |
**copyright**, each different group of copyright owners is listed |
| 130 |
separatedly (files that have the exact same list of copyright owners are |
| 131 |
listed together). |
| 132 |
|
| 133 |
* `--split-on-license`: |
| 134 |
When a subdirectory has its own license file (COPYING, LICENSE, etc), the |
| 135 |
subdirectory is given its own paragraph, even if it has the same license as |
| 136 |
the main directory. This is the default. |
| 137 |
|
| 138 |
* `--no-split-on-license`: |
| 139 |
Even if a subdirectory has its own license file, the contents are listed |
| 140 |
together with other files in the tree that have the same license. |
| 141 |
|
| 142 |
* `--split-debian`: |
| 143 |
Even if the contents of the debian/ subdirectory have the same license as the |
| 144 |
main content, split it onto a separate paragraph. This is the default. |
| 145 |
|
| 146 |
* `--no-split-debian`: |
| 147 |
If the contents of the debian/ subdirectory have the same license as the main |
| 148 |
content, they are listed together. |
| 149 |
|
| 150 |
## ARCHIVE EXPANSION |
| 151 |
|
| 152 |
Archive files (tar, zip and similar) found in the source tree are expanded and |
| 153 |
their contents are parsed as if they were regular files, so that licenses and |
| 154 |
copyright holders embedded inside archives are detected. |
| 155 |
|
| 156 |
* `--expand-archives`, `--no-expand-archives`: |
| 157 |
Enable or disable expanding archive files into their contents. Expansion is |
| 158 |
enabled by default (**--expand-archives**). |
| 159 |
|
| 160 |
* `--max-archive-depth <n>`: |
| 161 |
Maximum depth of nested archive expansion (archives contained inside other |
| 162 |
archives). Defaults to 1. |
| 163 |
|
| 164 |
* `--max-archive-member-size <bytes>`: |
| 165 |
Skip archive members larger than this many bytes. Defaults to 10 MB. |
| 166 |
|
| 167 |
## IMAGE METADATA |
| 168 |
|
| 169 |
Images frequently state their author and license only in embedded metadata |
| 170 |
rather than in a comment: SVG files carry an RDF block written by the drawing |
| 171 |
program, and raster images carry the equivalent XMP or PNG text chunks. Decopy |
| 172 |
reads the authorship fields of both (`dc:creator` and `dc:rights` in RDF, |
| 173 |
`Author`, `Artist` and `Creator` in raster metadata) and uses them as the |
| 174 |
copyright holder when the file states none anywhere else. A holder found in the |
| 175 |
file itself is always preferred, so the metadata only fills a gap. |
| 176 |
|
| 177 |
No year is taken from the metadata: the date fields images carry are re-save |
| 178 |
timestamps far more often than authorship years, and a wrong year in a copyright |
| 179 |
notice is worse than no year at all. |
| 180 |
|
| 181 |
Rights and copyright fields are treated with more suspicion than authorship |
| 182 |
ones, because the tools that write them are routinely pointed at a license |
| 183 |
instead: a value that names a license is reported as the license and not as a |
| 184 |
copyright holder. |
| 185 |
|
| 186 |
Reading raster metadata requires **exiftool**. Without it those files fall back |
| 187 |
to the plain text reader, which skips binary files, so no holder or license is |
| 188 |
reported for them at all. SVG needs no external tool. |
| 189 |
|
| 190 |
## LOG LEVEL OPTIONS |
| 191 |
|
| 192 |
The default logging shows WARN and ERROR messages. It can be modified with the |
| 193 |
following flags: |
| 194 |
|
| 195 |
* `--debug`: |
| 196 |
Show DEBUG, INFO, WARN and ERROR messages. |
| 197 |
|
| 198 |
* `--verbose`, `-v`: |
| 199 |
Show INFO, WARN and ERROR messages. |
| 200 |
|
| 201 |
* `--quiet`, `-q`: |
| 202 |
Show only ERROR messages. |
| 203 |
|
| 204 |
## LESS COMMON OPTIONS |
| 205 |
|
| 206 |
* `--copyright-file <filename>`: |
| 207 |
Specify a different copyright file to be used as a base for the processing. |
| 208 |
Defaults to `debian/copyright` |
| 209 |
|
| 210 |
* `--text`, `-a`: |
| 211 |
Parse all files as text files, instead of using the different parsers |
| 212 |
according to the file types (e.g. using exiftool for images). |
| 213 |
|
| 214 |
* `--jobs <n>`, `-j <n>`: |
| 215 |
Number of jobs to run in parallel while processing files. Use 0 (the |
| 216 |
default) to pick a value automatically based on the available CPUs. |
| 217 |
|
| 218 |
* `--glob`, `--no-glob`: |
| 219 |
Enable or disable the use of glob (wildcard) patterns in the `Files:` field |
| 220 |
of the generated output. Globbing is enabled by default (**--glob**). |
| 221 |
|
| 222 |
* `--progress`, `--no-progress`: |
| 223 |
Show or hide the progress bar while processing files. The progress bar is |
| 224 |
shown by default (**--progress**). |
| 225 |
|
| 226 |
* `--exclude <regex>`, `-X <regex>`: |
| 227 |
Exclude files from the generated copyright: an excluded file is neither |
| 228 |
parsed nor given an entry of its own. The argument is an ordinary |
| 229 |
case-insensitive regular expression, anchored at the start of the file's |
| 230 |
path relative to the source root, so `-X 'doc/'` excludes a top-level |
| 231 |
`doc/` but not `src/doc/`, and matching an extension needs a leading `.*` |
| 232 |
(`-X '.*\.jpg$'`). The option is repeatable and every pattern given |
| 233 |
applies, so unrelated exclusions need not be folded into one alternation |
| 234 |
(`-X '^build/' -X '^po/'`). Each pattern matching no file is reported as a |
| 235 |
warning, naming that pattern. As a special case, `debian/copyright` and |
| 236 |
`debian/changelog` are always excluded. |
| 237 |
|
| 238 |
* `--gitignore`, `--no-gitignore`: |
| 239 |
Honour the repository's ignore lists (`.gitignore` and `.git/info/exclude`) |
| 240 |
while walking the tree, so ignored files are not parsed. This is enabled by |
| 241 |
default (**--gitignore**); use **--no-gitignore** to parse ignored files too. |
| 242 |
This requires the `pathspec` module; without it the option has no effect. |
| 243 |
The **Files-Excluded** patterns from the header of an existing |
| 244 |
debian/copyright file are always honoured, regardless of this option. |
| 245 |
|
| 246 |
## COMPARISON WITH OTHER HELPERS |
| 247 |
|
| 248 |
Decopy was inspired by previous copyright helpers like [copyright-helper by |
| 249 |
Modestas Vainius][1], licensecheck(1) by Jonas Smedegaard, or the copyright |
| 250 |
helper shipped with debmake(1), written by Osamu Aoki. |
| 251 |
|
| 252 |
[1]: https://anonscm.debian.org/cgit/users/modax/copyright-helper.git/ |
| 253 |
|
| 254 |
The main difference with all of them, is that decopy aims to detects as many |
| 255 |
licenses as possible, including many more that those in the other helpers, as |
| 256 |
well as the fact that it's capable of processing more than just plain text |
| 257 |
files. |
| 258 |
|
| 259 |
Additionally, while it is possible to use it for the creation of the copyright |
| 260 |
file, its main usecase is to keep the copyright file updated with any changes |
| 261 |
that are done to the source tree as time passes. |
| 262 |
|
| 263 |
## AUTHORS |
| 264 |
|
| 265 |
Decopy was written by Maximiliano Curia. The debian packaging and this manpage |
| 266 |
were created by Margarita Manterola. |
| 267 |
|
| 268 |
## COPYRIGHT |
| 269 |
|
| 270 |
Decopy and all the associated code and documentation are released under the ISC |
| 271 |
license. |
| 272 |
|
| 273 |
|