#!/usr/bin/perl =head1 NAME dh_python3-ply - generate versioned dependencies on python3-ply =cut use strict; use warnings; use Debian::Debhelper::Dh_Lib; =head1 SYNOPSIS B [B<--dependency-field> I] [S>] I... =head1 DESCRIPTION B is a debhelper program that is responsible for generating the B substitutions and adding them to substvars files. The program will look only at Python3 modules that are explicitly provided as its arguments, and will use this information to generate a strict versioned dependency on B. =head1 OPTIONS =over 4 =item B<--dependency-field> I Use BI substitution variable instead of B. =back =cut my $dependency_field = "Depends"; init(options => { "dependency-field:s" => \$dependency_field }); if (not @ARGV) { error("at least one argument is required") } foreach my $filename (@ARGV) { open FILE, $filename or error("cannot read $filename: $!"); read FILE, $_, 1024; my $is_lextab = /^_lextokens\b/m; my $is_parsetab = /^_lr_method\b/m; $is_lextab or $is_parsetab or error("$filename doesn't look like a PLY table"); (my $tabversion) = /^_tabversion\s*=\s*'([0-9.]+)'/m or error("$filename was generated by a very old PLY"); my $dependency = sprintf "python3-ply-%s-%s", $is_lextab ? "lex" : "yacc", $tabversion; # Prefer real package names of "old" versions of PLY for easier upgrades from squeeze: if ($dependency eq "python3-ply-yacc-3.2") { # PLY 3.2, 3.3 and 3.4 embeds the same version number (3.2) in parser tables. $dependency = "python3-ply (>= 3.2), python3-ply (<< 3.5) | $dependency"; } elsif ($dependency eq "python3-ply-lex-3.3") { # PLY 3.3 and 3.4 embeds their own version number in lexer tables. $dependency = "python3-ply (>= 3.3), python3-ply (<< 3.4) | $dependency"; } foreach my $package (@{$dh{DOPACKAGES}}) { addsubstvar($package, "python3-ply:$dependency_field", $dependency); } } =head1 SEE ALSO L This program is not a part of debhelper, but it is meant to be used together with it. =head1 AUTHOR Jakub Wilk =cut # vim:ts=4 sw=4 et