diff -urN a/debbuild b/debbuild --- a/debbuild 2022-02-21 18:16:40.744711483 +0300 +++ b/debbuild 2022-02-21 18:36:10.249542683 +0300 @@ -193,6 +193,10 @@ } if ($cmdopts{type} eq 'b') { + # Make a copy of spec lowercased and `_` replaced with `-` to do some magic + (my $spec_lc = lc(basename($specglobals{specfile}))) =~ tr/_/-/; + $spec_lc = dirname($specglobals{specfile})."/".$spec_lc; + qx ( $specglobals{__cp} -a $specglobals{specfile} $spec_lc ) if ( $specglobals{specfile} ne $spec_lc ); # Need to read the spec file to find the tarball. Note that # this also generates most of the shell script required. parse_spec($specglobals{specfile}); @@ -306,18 +310,36 @@ sub load_config { # Load user configuration, permitting local override my $homedir = $ENV{HOME} // $ENV{LOGDIR} // (getpwuid($<))[7]; - foreach my $macros ( ("$static_config{debconfigdir}/macros", - glob("$static_config{debconfigdir}/macros.d/macros.*"), - "$static_config{sysconfdir}/debbuild/macros", - glob("$static_config{sysconfdir}/debbuild/macros.*"), - "$homedir/.debmacros") ) { + vdebug("Loading ...", 3, "load_config"); + my @cfgs = ("$static_config{debconfigdir}/macros", + glob("$static_config{debconfigdir}/macros.d/macros.*"), + "$static_config{sysconfdir}/rpm/macros", + glob("$static_config{sysconfdir}/rpm/macros.*"), + "$static_config{sysconfdir}/debbuild/macros", + glob("$static_config{sysconfdir}/debbuild/macros.*"), + "$homedir/.rpmmacros", + "$homedir/.debmacros"); + my %cfl = (); + my %ercd = (); + while ( my $macros = shift @cfgs ) { + next if $cfl{$macros} and not ( $macros eq "$homedir/.debmacros" or $macros eq "$homedir/.rpmmacros" ); open my $MACROS,$macros or next; # should we warn about missing macro files? + vdebug("Loading $macros ...", 3, "load_config"); while (<$MACROS>) { next unless my ($macro,$eq,$value) = /^%(\w+(?:\([^)]*\))?)(=|\s*)(.+)$/s; $value = read_multiline_macro($value, $MACROS); chomp($value); + vdebug("($macros): $macro = $value", 5, "load_config"); store_value('define', $macro, $eq eq '=' ? $specglobals{$value} : $value); + if ( $macro eq '_rpmconfigdir' and not $ercd{$macros} ) { + $ercd{$macros} = 1; + unshift @cfgs, expandmacros($value)."/macros", + glob(expandmacros($value)."/macros.d/macros.*"); + push @cfgs, "$homedir/.rpmmacros", "$homedir/.debmacros" + if $macros eq "$homedir/.debmacros" or $macros eq "$homedir/.rpmmacros"; + } } + $cfl{$macros} = 1; close $MACROS; } } # end load_config() @@ -1603,6 +1625,7 @@ qx($specglobals{__du} -s --apparent-size $specglobals{buildroot}/$pkg) =~ /(\d+)/; + my $maintainer = defined $pkgdata{main}{packager} ? $pkgdata{main}{packager} : expandmacros('%{_deb_maintainer}'); my $control = "Package: $pkgdata{$pkg}{name}\n". 'Version: '.format_version($pkg)."\n". ( defined $pkgdata{$pkg}{group} ? @@ -1610,8 +1633,8 @@ "Priority: optional\n". "Architecture: $pkgdata{$pkg}{arch}\n". "Installed-Size: $installedsize\n". - ( defined $pkgdata{main}{packager} ? - "Maintainer: $pkgdata{main}{packager}\n" : '' ). + ( $maintainer ? + "Maintainer: $maintainer\n" : '' ). "Description: $pkgdata{$pkg}{summary}\n$pkgdata{$pkg}{description}\n". ( defined $pkgdata{main}{url} ? "Homepage: $pkgdata{main}{url}\n" : '' ); @@ -1764,6 +1787,16 @@ $pkg = unify_pkg_name($pkg); + # Fix strict version checking by including release and epoch in case of specifying the packages currently building + if ( $rel eq '=' ) { + foreach my $p ( keys(%pkgdata) ) { + if ( $ver eq $pkgdata{main}{version} ) { + $ver = (defined $pkgdata{main}{epoch} ? "$pkgdata{main}{epoch}:" : '').$ver."-".$pkgdata{main}{release}; + last; + } + } + } + return ($pkg,$rel,$ver); } # end splitver()