Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions lib/MusicBrainz/Script/JSONDump.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ sub create_json_dump {
local $MusicBrainz::Script::MBDump::readme_text = <<'EOF';
The file under mbdump/ contains one document (entity) per line, in JSON
format, and is named according to the type of entity in the dump.
EOF

my $copying_text = <<'EOF';
The content of this dump is licensed under the CC0 license
(see COPYING-PublicDomain), except for any data under keys "annotation",
"genres", "ratings" and "tags", which is licensed under a Creative Commons
Attribution-NonCommercial-ShareAlike 3.0 license (see COPYING-CCShareAlike).
EOF

my $mbdump = MusicBrainz::Script::MBDump->new(
Expand All @@ -100,9 +107,16 @@ EOF
%mbdump_options,
);

$mbdump->write_file('COPYING', $copying_text);

$mbdump->copy_file(
catfile(DBDefs->MB_SERVER_ROOT, 'admin', 'COPYING-PublicDomain'),
'COPYING'
'COPYING-PublicDomain'
) or die $OS_ERROR;

$mbdump->copy_file(
catfile(DBDefs->MB_SERVER_ROOT, 'admin', 'COPYING-CCShareAlike'),
'COPYING-CCShareAlike'
) or die $OS_ERROR;

$mbdump->write_file('JSON_DUMPS_SCHEMA_NUMBER', "1\n");
Expand All @@ -114,7 +128,11 @@ EOF
if ($self->compression_enabled) {
$mbdump->make_tar(
"$dump_fname.tar.xz",
"mbdump/$dump_fname",
(
"mbdump/$dump_fname",
'COPYING-PublicDomain',
'COPYING-CCShareAlike',
),
'JSON_DUMPS_SCHEMA_NUMBER',
);
} else {
Expand Down
18 changes: 18 additions & 0 deletions t/script/DumpJSON.t
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ test all => sub {
File::Spec->catfile($dir, $entity, 'JSON_DUMPS_SCHEMA_NUMBER'));
chomp $got;
is($got, '1');

$got = read_file(
File::Spec->catfile($dir, $entity, 'COPYING'));
chomp $got;
ok(
$got =~ 'see COPYING-CCShareAlike',
'The COPYING file refers users to the per-license COPYING files',
);

ok(
-f File::Spec->catfile($dir, $entity, 'COPYING-PublicDomain'),
'The COPYING-PublicDomain file is included in the bundle',
);

ok(
-f File::Spec->catfile($dir, $entity, 'COPYING-CCShareAlike'),
'The COPYING-CCShareAlike file is included in the bundle',
);
};

my $test_dumps_empty_except = sub {
Expand Down