Changeset 158


Ignore:
Timestamp:
Jan 17, 2018, 11:00:43 PM (6 years ago)
Author:
g7moreau
Message:
  • Add make-copyright command
Location:
trunk/project-meta
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/project-meta/project-meta

    r157 r158  
    2828   'make-author'     => \&cmd_make_author,
    2929   'make-licence'    => \&cmd_make_licence,
     30   'make-copyright'  => \&cmd_make_copyright,
    3031   );
    3132
     
    139140
    140141   my $current_dir = Cwd::getcwd();
    141    my $template_author = '/usr/share/project-meta/template.d/AUTHORS.tt';
    142142
    143143   my $acronym    = $meta->{'project'}{'acronym'};
     
    202202
    203203################################################################
     204
     205sub cmd_make_copyright {
     206   my $meta = YAML::Syck::LoadFile("PROJECT-META.yml");
     207
     208   my $current_dir = Cwd::getcwd();
     209
     210   if (-f "$current_dir/COPYRIGHT.txt") {
     211      # Test for manual or automatically generated file
     212      # Automatically generated file by project-meta
     213      my $automatic;
     214      open my $fh, '<', "$current_dir/COPYRIGHT.txt" or die $!;
     215      for my $line (<$fh>) {
     216         $line =~ m/Automatically generated .* project-meta/i and $automatic++;
     217         }
     218      close $fh;
     219
     220      if (not $automatic) {
     221         print "Warning: COPYRIGHT.txt already exists\n";
     222         return;
     223         }
     224
     225      print "Warning: update COPYRIGHT.txt\n";
     226      }
     227
     228   my $tt = Template->new(INCLUDE_PATH => '/usr/share/project-meta/template.d');
     229   my $msg_format = '';
     230   $tt->process('COPYRIGHT.tt',
     231      {
     232         title       => $meta->{'project'}{'title'},
     233         acronym     => $meta->{'project'}{'acronym'},
     234         authorlist  => $meta->{'project'}{'authors'},
     235         description => $meta->{'project'}{'short-description'},
     236         licence     => $meta->{'public-dap'}{'data-licence'},
     237         doi         => $meta->{'publication'}{'doi'},
     238         urldoi      => $meta->{'publication'}{'url'},
     239      }, \$msg_format) || die $tt->error;
     240
     241   open my $fh,  '>', "$current_dir/COPYRIGHT.txt" or die $!;
     242   print $fh "$msg_format\n\n";
     243   close $fh;
     244   }
     245
     246################################################################
Note: See TracChangeset for help on using the changeset viewer.