File: convert-to-dh-r

package info (click to toggle)
dh-r 20190121
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 200 kB
  • sloc: perl: 1,739; sh: 283; makefile: 21
file content (42 lines) | stat: -rwxr-xr-x 1,125 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl

# This script attempts to convert the dependencies of an existing R package
# from using CDBS to use dh-r.
# It should be run from the root of an R package, and will write a new
# d/control file to stdout.
# Note that this completely replaces the existing binary Depends, Recommends,
# Suggests with substvar versions - if your package has dependencies which
# are not either shlibs or R then they will be lost!

use feature say;
use strict;

use Dpkg::Control::Info;
use Dpkg::Deps;

my $ctrl = Dpkg::Control::Info->new();
my $src = $ctrl->get_source();
my $bin = $ctrl->get_pkg_by_idx(1);


$bin->{Depends} = "\${R:Depends}, \${misc:Depends}, \${shlibs:Depends}";
if (defined $bin->{Recommends}) {
    $bin->{Recommends} = "\${R:Recommends}";
}
if (defined $bin->{Suggests}) {
    $bin->{Suggests} = "\${R:Suggests}";
}

my @bdeps = Dpkg::Deps::deps_parse($src->{"Build-Depends"})->get_deps();

if (grep(/^cdbs/, @bdeps)) {
    @bdeps = grep {!/^cdbs/} @bdeps;
}

if (! grep(/^dh-r/, @bdeps)) {
    push (@bdeps, "dh-r");
}

$src->{"Build-Depends"} = Dpkg::Deps::deps_concat(@bdeps);

say $ctrl->output();