From 5e1454ef4562bdcc75c213624a14e83c7959b592 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 18:46:29 +0200 Subject: Adding upstream version 3.73. Signed-off-by: Daniel Baumann --- doincludes.pl | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 doincludes.pl (limited to 'doincludes.pl') diff --git a/doincludes.pl b/doincludes.pl new file mode 100755 index 0000000..5da650a --- /dev/null +++ b/doincludes.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl +# +# doincludes directory +# +# Expands #include directives in files in the directory. This is used +# to let task package pull in the contents of metapackages, keeping the +# contents up-to-date, w/o actually pulling in the metapackages themselves, +# since some metapackages are rather prone to breakage near release time. + +my $dir=shift or die "no directory specified\n"; + +my %depends; +{ + local $/="\n\n"; + if (! open (AVAIL, "apt-cache dumpavail |")) { + warn "cannot real available info, so not exanding includes\n"; + exit; + } + while () { + my ($package)=/Package:\s*(.*?)\n/; + my ($depends)=/Depends:\s*(.*?)\n/; + $depends{$package}=$depends; + } + close AVAIL; +} + +use File::Find; +find(\&processfile, $dir); + +sub processfile { + my $file=$_; # File::Find craziness. + $file eq 'po' && -d $file && ($File::Find::prune = 1); + return if $File::Find::dir=~/\.(svn|git)/; + return unless $file =~ /^[-+_.a-z0-9]+$/ and -f $file; + my @lines; + open (IN, $file) or die "$file: $!"; + while () { + if (/#\s*endinclude/) { + if ($skipping == 0) { + die "$file: #endinclude without #include\n"; + } + $skipping=0; + } + + push @lines, $_ unless $skipping == 1; + + if (/^#\s*include\s+(\w+)/) { + my $pkg=$1; + if ($skipping) { + die "$file: nested includes near $_\n"; + } + if (! exists $depends{$pkg}) { + warn "$file: #include $1 skipped; no such package. Leaving what was there alone.\n"; + $skipping=-1; + } + else { + push @lines, "#Automatically added by doincludes.pl; do not edit.\n"; + # Split deps and remove alternates and versioned + # deps. Include the metapackage on the list. + push @lines, map { s/[|(].*//; " $_\n" } + split(/,\s+/, $depends{$pkg}), $pkg; + $skipping=1; + } + } + } + close IN; + if ($skipping == 1) { + die "$file: #include without #endinclude"; + } + + open (OUT, ">$file") or die "$file: $!"; + print OUT @lines; + close OUT; +} -- cgit v1.2.3