Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

Commit

Permalink
debmaker, py2ips: make optional dependencies (Suggests in terms of De…
Browse files Browse the repository at this point in the history
…bian)
  • Loading branch information
Igor Pashev committed Oct 26, 2011
1 parent dd4a469 commit f66a630
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
16 changes: 10 additions & 6 deletions tools/debmaker.pl
Expand Up @@ -518,6 +518,7 @@ sub guess_required_deps {
my @depends = ();
my @predepends = ();
my @recommends = ();
my @suggests = ();
my @conflicts = ();
blab "Getting dependencies ...";
foreach my $dep (@{$$manifest_data{'depend'}}) {
Expand All @@ -526,7 +527,7 @@ sub guess_required_deps {
blab "Dependency: $dep_pkg ($$dep{'type'})";
push @depends, $dep_pkg if $$dep{'type'} eq 'require';
push @predepends, $dep_pkg if $$dep{'type'} eq 'origin';
# push @recommends, $dep_pkg if $$dep{'type'} eq 'optional';
push @suggests, $dep_pkg if $$dep{'type'} eq 'optional';
push @conflicts, $dep_pkg if $$dep{'type'} eq 'exclude';
}
}
Expand All @@ -537,6 +538,7 @@ sub guess_required_deps {
uniq \@provides;
uniq \@predepends;
uniq \@recommends;
uniq \@suggests;
uniq \@conflicts;
# When a program and a library are in the same package:
@depends = grep {$_ ne $debname} @depends;
Expand All @@ -558,12 +560,14 @@ sub guess_required_deps {
$control .= wrap(' ', ' ', $$manifest_data{'pkg.description'}) . "\n"
if exists $$manifest_data{'pkg.description'};

$control .= 'Provides: ' . join(', ', @provides) . "\n" if @provides;
$control .= 'Depends: ' . join(', ', @depends) . "\n" if @depends;
$control .= 'Provides: ' . join(', ', @provides) . "\n" if @provides;
$control .= 'Depends: ' . join(', ', @depends) . "\n" if @depends;
$control .= 'Pre-Depends: ' . join(', ', @predepends) . "\n" if @predepends;
$control .= 'Recommends: ' . join(', ', @recommends) . "\n" if @recommends;
$control .= 'Conflicts: ' . join(', ', @conflicts) . "\n" if @conflicts;
$control .= 'Replaces: ' . join(', ', @replaces) . "\n" if @replaces;
$control .= 'Recommends: ' . join(', ', @recommends) . "\n" if @recommends;
$control .= 'Suggests: ' . join(', ', @suggests) . "\n" if @suggests;
$control .= 'Conflicts: ' . join(', ', @conflicts) . "\n" if @conflicts;
$control .= 'Replaces: ' . join(', ', @replaces) . "\n" if @replaces;

$control .= "Installed-Size: $installed_size\n";

$control .= "Origin: $$manifest_data{'info.upstream_url'}\n"
Expand Down
34 changes: 19 additions & 15 deletions tools/py2ips.pl
Expand Up @@ -139,23 +139,27 @@ sub trim {
my_chdir '../__srcdir__';
shell_exec 'python setup.py install --root=../__destdir__ --prefix=/usr';

# FIXME: versions (kid >= 0.9.6)
my @pkg_deps = ();
my %pkg_deps = ();
if ( -f "$pkg_name.egg-info/requires.txt") {
@pkg_deps =
map { s/^([-\w]+).*/$1/; lc $_ }
grep { /^\w/ }
@{get_output "cat $pkg_name.egg-info/requires.txt"}
}
uniq \@pkg_deps;
if (grep {$_ eq 'setuptools'} @pkg_deps) {
@pkg_deps = map {$_ eq 'setuptools' ? 'distribute' : $_} @pkg_deps;
warning "Dependencies: 'setuptools' replaced with 'distribute'"
my $type = 'require'; # All deps before the first section ([...])
# are mandatory; others are optional
foreach (@{get_output "cat $pkg_name.egg-info/requires.txt"}) {
$type = 'optional' if /^\[.+\]/;
next unless /^\w/;
s/^([-.\w]+).*/$1/;
my $pkg = lc;
$pkg = 'distribute' if $pkg eq 'setuptools';
if (! exists $pkg_deps{$pkg}) {
$pkg_deps{$pkg} = $type;
} else {
warning "Dependency on `$pkg' already set to $pkg_deps{$pkg}"
if $pkg_deps{$pkg} ne $type
}
}
}
blab 'Dependencies: ', (join ', ', @pkg_deps);

my $pkg_summary = '';
for my $dir ( ("$pkg_name.egg-info", '.') ) {
for my $dir ( ("lib/$pkg_name.egg-info", "$pkg_name.egg-info", '.') ) {
if ( -f "$dir/PKG-INFO") {
$pkg_summary = get_output_line "grep Summary: $dir/PKG-INFO | sed 's/Summary: *//'";
last;
Expand All @@ -173,8 +177,8 @@ sub trim {
$ips_manifest .= "\n";

$ips_manifest .= "depend fmri=pkg:/runtime/python-$pyversion type=require\n";
$ips_manifest .= "depend fmri=pkg:/library/python-2/${_}-$pyversion type=require\n"
foreach @pkg_deps;
$ips_manifest .= "depend fmri=pkg:/library/python-2/${_}-$pyversion type=$pkg_deps{$_}\n"
foreach keys %pkg_deps;

$ips_manifest .= "\n";

Expand Down

0 comments on commit f66a630

Please sign in to comment.