Commit 88055c25 authored by smoretti's avatar smoretti

Improve parsing and rendering + Parse LinkingTo:

parent d657b536
......@@ -7,7 +7,7 @@ use diagnostics;
# Sebastien Moretti from the Vital-IT (http://www.vital-it.ch) Center
# for high-performance computing of the SIB Swiss Institute of Bioinformatics.
my $VERSION = '0.1.1';
my $VERSION = '0.1.2';
use DateTime;
use File::Slurp;
......@@ -44,8 +44,8 @@ if ( !$test_options || $package eq '' || $R_version eq '0' ){
print "\n\tInvalid or missing argument:
\te.g. $0 -package=<PACKAGE NAME> -R_version=<VERSION OF R> [-R_package=<R PACKAGE VERSION> -B_version=<Bioconductor version> -debug]
\t-package Package name e.g. SRAdb
\t-R_version Version of R e.g. 3.1.1
\t-R_package Version of R package e.g. 311 (by default R_version without dots)
\t-R_version Version of R e.g. 3.2.2
\t-R_package Version of R package e.g. 322 (by default R_version without dots)
\t-B_version Version of Bioconductor (by default last release)
\t-debug More verbose
\n";
......@@ -98,6 +98,7 @@ my %bioc_packages;
if ( -e "$desc_file" && -s "$desc_file" ){
my ($Name, $Summary, $Version, $Description, $License) = ('', '', 0, '', '');
my @Deps;
my $requirements = '';
my ($flag_desc, $flag_require, $flag_summary) = (0, 0, 0);
my $ori_version = 0;
LINE:
......@@ -113,8 +114,8 @@ if ( -e "$desc_file" && -s "$desc_file" ){
$flag_require = 0;
}
elsif ( $flag_require==1 ){
push @Deps, map { trim($_) }
split(/ *, */, $line);
chomp $line;
$requirements .= $line;
}
if ( $flag_summary==1 && $line =~ /^\w+:/ ){
......@@ -145,19 +146,27 @@ if ( -e "$desc_file" && -s "$desc_file" ){
$Description = $1."\n";
$flag_desc = 1;
}
elsif ( $line =~ /^Depends:\s*(.+)/ || $line =~ /^Imports:\s*(.+)/ ){
push @Deps, map { trim($_) }
split(/ *, */, $1);
elsif ( $line =~ /^Depends:\s*(.+)/ || $line =~ /^Imports:\s*(.+)/ || $line =~ /^LinkingTo:\s*(.+)/ ){
if ( $requirements ne '' ){
$requirements .= ', ';
}
$requirements .= $1;
$flag_require = 1;
}
#TODO Add SystemRequirements but strange format most of the time
}
$requirements =~ s{ +}{ }g;
push @Deps, map { trim($_) }
split(/ *, */, $requirements);
# Fix extra spaces
$Description =~ s{ +}{}mg;
chomp $Description;
$Description .= '.' if ( $Description !~ /[\.\!\?]$/ );
$Summary =~ s{ +}{ }mg;
$Summary = trim($Summary);
$Summary = trim($Summary);
$Summary =~ s{\.$}{} if ( $Summary !~ /\.\.$/ );
my $deps = join(',', uniq @Deps);
# Get Bioconductor package list for right dependencies between Bioconductor and CRAN
......@@ -326,13 +335,15 @@ sub get_template {
# Dependencies
my $DepsB = '';
my $DepsR = '';
for my $dep ( split(',', $deps) ){
for my $dep ( split(/,\s*/, $deps) ){
my $is_R = 0;
next if ( $dep eq '' );
if ( $dep =~ /[<>=]/ ){ # has version restriction
my @field = split(' ', $dep);
$dep =~ s{(\S)\(}{$1 (}; # For cases like R(>= 2.10)
my @field = split(/\s+/, $dep);
$is_R = 1 if ( $field[0] eq 'R' ); # If R is mentioned it is associated with a version
$is_R = 2 if ( get_R_base_package($field[0]) );
my $ori_version = $field[2];
my $ori_version = $field[-1];
$ori_version =~ s{\)}{}g;
my $fixed_version = $ori_version;
$fixed_version =~ s{\-}{\.}g;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment