diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:08:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:08:26 +0000 |
commit | 59845ba9b3df5df775cf8c5a65d30375b984e3c7 (patch) | |
tree | 6c5c6d57676acf601505f35e53194e5e7a86f0c3 /doincludes.pl | |
parent | Initial commit. (diff) | |
download | tasksel-170c0af568505caebc020d496bb0a14f2d783280.tar.xz tasksel-170c0af568505caebc020d496bb0a14f2d783280.zip |
Adding upstream version 3.68+deb11u1.upstream/3.68+deb11u1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'doincludes.pl')
-rwxr-xr-x | doincludes.pl | 74 |
1 files changed, 74 insertions, 0 deletions
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 (<AVAIL>) { + 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 (<IN>) { + 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; +} |