Commit d076ea8d authored by Sebastien Moretti's avatar Sebastien Moretti

Fix Description/Summary parsing + Add new licenses + Better requirement display

parent 031fd477
......@@ -6,7 +6,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.5';
my $VERSION = '0.1.7';
use Cwd 'abs_path';
use DateTime;
......@@ -191,17 +191,19 @@ if ( -e "$desc_file" && -s "$desc_file" ){
chomp $Description;
$Description =~ s{\n}{ }g;
$Description =~ s{ +}{ }g;
$Description =~ s{\s*Authors\@R.+}{};
$Description .= '.' if ( $Description !~ /[\.\!\?]$/ );
$Description = $text->format($Description);
chomp $Description;
$Summary =~ s{ +}{ }mg;
$Summary =~ s{ *Authors\@R.+}{};
$Summary =~ s{\s*Authors\@R.+}{};
$Summary = trim($Summary);
$Summary =~ s{\.$}{} if ( $Summary !~ /\.\.$/ );
$Summary = ucfirst($Summary);
my $deps = join(',', uniq @Deps);
# Get Bioconductor package list for right dependencies between Bioconductor and CRAN
if ( $Source ne 'cran' ){
# if ( $Source ne 'cran' ){
my @Bioc_urls = ("http://bioconductor.org/packages/$B_version/bioc/src/contrib/PACKAGES",
"http://bioconductor.org/packages/$B_version/data/annotation/src/contrib/PACKAGES",
"http://bioconductor.org/packages/$B_version/data/experiment/src/contrib/PACKAGES",
......@@ -217,7 +219,7 @@ if ( -e "$desc_file" && -s "$desc_file" ){
split("\n", $content);
}
}
}
# }
# Print raw spec
get_template($Version, $Summary, $License, $Description, $Source, $ori_version, $deps);
......@@ -266,16 +268,20 @@ sub format_license {
'CPL' => 'CPL',
'EPL' => 'EPL',
'EPL (>= 1.0)' => 'EPL',
'FreeBSD | GPL-2 | file LICENSE' => 'GPLv2',
'GPL' => 'GPL+',
'GPL (== 2)' => 'GPLv2',
'GPL (> 2)' => 'GPLv3+',
'GPL (>=2)' => 'GPLv2+',
'GPL (>= 2)' => 'GPLv2+',
'GPL (>= 2) + file LICENSE' => 'GPLv2+ with exceptions',
'GPL (>= 2.0)' => 'GPLv2+',
'GPL (>=2.0)' => 'GPLv2+',
'GPL (>= 2.1)' => 'GPLv2+',
'GPL (>= 2.14)' => 'GPLv2+',
'GPL (>= 3)' => 'GPLv3+',
'GPL (>= 3.0)' => 'GPLv3+',
'GPL (>=3.0)' => 'GPLv3+',
'GPL-2' => 'GPLv2',
'GPL-2 + file LICENSE' => 'GPLv2 with exceptions',
'GPL-2 | GPL-3' => 'GPLv2+',
......@@ -371,6 +377,7 @@ sub get_template {
my $DepsR = '';
for my $dep ( split(/,\s*/, $deps) ){
my $is_R = 0;
my ($depsB, $depsR) = ('', '');
next if ( $dep eq '' );
if ( $dep =~ /[<>=]/ ){ # has version restriction
$dep =~ s{(\S)\(}{$1 (}; # For cases like R(>= 2.10)
......@@ -386,25 +393,36 @@ sub get_template {
}
if ( $is_R==1 ){
$DepsB .= "BuildRequires: $dep\n";
$DepsR .= "Requires: $dep\n";
$depsB .= "BuildRequires: $dep\n";
$depsR .= "Requires: $dep\n";
}
elsif ( get_R_base_package($dep) || $is_R==2 ){
$DepsB .= "BuildRequires: R-$dep\n";
$DepsR .= "Requires: R-$dep\n";
$depsB .= "BuildRequires: R-$dep\n";
$depsR .= "Requires: R-$dep\n";
}
# Distinct between CRAN (e.g. R311-XML) and Bioconductor packages (e.g. R311-Bioconductor-Biobase)
else {
my @field = split(' ', $dep);
if ( exists $bioc_packages{$field[0]} ){
$DepsB .= "BuildRequires: R$R_package-Bioconductor-$dep\n";
$DepsR .= "Requires: R$R_package-Bioconductor-$dep\n";
$depsB .= "BuildRequires: R$R_package-Bioconductor-$dep\n";
$depsR .= "Requires: R$R_package-Bioconductor-$dep\n";
}
else {
$DepsB .= "BuildRequires: R$R_package-$dep\n";
$DepsR .= "Requires: R$R_package-$dep\n";
$depsB .= "BuildRequires: R$R_package-$dep\n";
$depsR .= "Requires: R$R_package-$dep\n";
}
}
my @part = split(/\s+/, $depsB);
if ( scalar @part == 2 ){ # Without version dependencies
$DepsB .= $depsB;
$DepsR .= $depsR;
}
else {
shift @part;
# Align versions for better display
$DepsB .= sprintf("%-15s %-38s %2s %s\n", 'BuildRequires:', @part);
$DepsR .= sprintf("%-15s %-38s %2s %s\n", 'Requires:', @part);
}
}
# Log
......@@ -440,13 +458,13 @@ URL: $URL
Source0: $Source0
Prefix: %{_prefix}
BuildRequires: R = %{_R_version}
BuildRequires: R-core = %{_R_version}
BuildRequires: R-devel = %{_R_version}
BuildRequires: R = %{_R_version}
BuildRequires: R-core = %{_R_version}
BuildRequires: R-devel = %{_R_version}
$DepsB
Requires: R = %{_R_version}
Requires: R-core = %{_R_version}
Requires: R = %{_R_version}
Requires: R-core = %{_R_version}
$DepsR
%description
......
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