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

Commit 554ccd1

Browse files
author
Igor Pashev
committed
debmaker.pl: implemented "provides" feature (mapping from "original_name")
1 parent 4e5fb0b commit 554ccd1

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tools/debmaker.pl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,10 @@ sub get_debpkg_names {
301301
# => web-browser-elinks
302302
# browser-elinks
303303
# elinks
304+
# Also works for "original_name"=pkg:/web/browser/elinks:usr/bin/Elinks
304305
my ($fmri) = @_;
305306
my @names = ();
306-
if ($fmri =~ m,^(?:pkg:/)?([^@]+)(?:@.+)?$,) {
307+
if ($fmri =~ m,^(?:pkg:/)?([^:@]+)(?:[:@].+)?$,) {
307308
my $pkg = $1;
308309
my @parts = split /\//, $pkg;
309310
while (@parts) {
@@ -315,6 +316,9 @@ sub get_debpkg_names {
315316
fatal "Can't parse FMRI to get dpkg name: `$fmri'";
316317
}
317318
}
319+
sub get_debpkg_name {
320+
return (get_debpkg_names @_)[0]
321+
}
318322

319323
sub get_ips_version {
320324
# pkg:/web/browser/[email protected],5.11-1.1
@@ -431,14 +435,13 @@ sub guess_required_deps {
431435
my $debname = shift @provides; # main name (web-browser-elinks)
432436
my $debsection = get_pkg_section $debname;
433437
my $debpriority = exists $$manifest_data{'pkg.priority'} ? $$manifest_data{'pkg.priority'} : 'optional';
438+
my @replaces = ();
434439

435440
foreach my $l (@{$$manifest_data{'legacy'}}) {
436-
push @provides, $$l{'pkg'};
441+
push @provides, get_debpkg_name $$l{'pkg'};
437442
}
438-
my $provides_str = join(', ', @provides);
439443
my $pkgdir = "$DEBS_DIR/$debname";
440444
blab "Main package name: $debname";
441-
blab "Other names: $provides_str";
442445

443446
my $ipsversion = get_ips_version $$manifest_data{'pkg.fmri'};
444447
my $debversion = undef;
@@ -462,6 +465,7 @@ sub guess_required_deps {
462465
my $dir_name = "$pkgdir/$$dir{'path'}";
463466
my_mkdir $dir_name, $$dir{'mode'};
464467
my_chown $$dir{'owner'}, $$dir{'group'}, $dir_name;
468+
push @replaces, get_debpkg_name $$dir{original_name} if exists $$dir{original_name};
465469
}
466470
}
467471

@@ -487,6 +491,7 @@ sub guess_required_deps {
487491
my_chmod $$file{'mode'}, $dst;
488492

489493
push @conffiles, $$file{'path'} if exists $$file{'preserve'};
494+
push @replaces, get_debpkg_name $$file{original_name} if exists $$file{original_name};
490495
}
491496
}
492497

@@ -528,11 +533,13 @@ sub guess_required_deps {
528533
push @depends, @{guess_required_deps($pkgdir)};
529534

530535
uniq \@depends;
531-
# When a program and a library are in the same package:
532-
@depends = grep {$_ ne $debname} @depends;
536+
uniq \@replaces;
537+
uniq \@provides;
533538
uniq \@predepends;
534539
uniq \@recommends;
535540
uniq \@conflicts;
541+
# When a program and a library are in the same package:
542+
@depends = grep {$_ ne $debname} @depends;
536543

537544

538545
my $control = '';
@@ -544,17 +551,19 @@ sub guess_required_deps {
544551
$control .= "Maintainer: $MAINTAINER\n";
545552
$control .= "Architecture: $ARCH\n";
546553

554+
547555
$control .= "Description: $$manifest_data{'pkg.summary'}\n";
548556
$changes{'Description'} .= "\n $debname - $$manifest_data{'pkg.summary'}";
549557

550558
$control .= wrap(' ', ' ', $$manifest_data{'pkg.description'}) . "\n"
551559
if exists $$manifest_data{'pkg.description'};
552560

553-
$control .= "Provides: $provides_str\n";
561+
$control .= 'Provides: ' . join(', ', @provides) . "\n" if @provides;
554562
$control .= 'Depends: ' . join(', ', @depends) . "\n" if @depends;
555563
$control .= 'Pre-Depends: ' . join(', ', @predepends) . "\n" if @predepends;
556564
$control .= 'Recommends: ' . join(', ', @recommends) . "\n" if @recommends;
557565
$control .= 'Conflicts: ' . join(', ', @conflicts) . "\n" if @conflicts;
566+
$control .= 'Replaces: ' . join(', ', @replaces) . "\n" if @replaces;
558567
$control .= "Installed-Size: $installed_size\n";
559568

560569
$control .= "Origin: $$manifest_data{'info.upstream_url'}\n"
@@ -571,7 +580,6 @@ sub guess_required_deps {
571580
write_file "$pkgdir/DEBIAN/conffiles", (join "\n", @conffiles);
572581
}
573582

574-
575583
my $preinst = '';
576584
my $postinst = '';
577585
my $prerm = '';

0 commit comments

Comments
 (0)