Extend exclude-file handling

Now take a colon-separated list to allow for more than one to be
used. And refactor to reduce repetition.
This commit is contained in:
Steve McIntyre 2023-07-04 17:14:04 +01:00
parent 1824a66933
commit 00ea28267d
1 changed files with 48 additions and 39 deletions

View File

@ -815,39 +815,48 @@ sub start_disc {
$mkisofs_opts = "";
$mkisofs_dirs = "";
undef @exclude_packages;
undef @unexclude_packages;
@exclude_packages = ();
@unexclude_packages = ();
# Change of interface here - exclude/unexclude files are now a
# colon-separated list
if (defined ($ENV{"EXCLUDE"})) {
my $excl_file = $ENV{"TASKDIR"} . "/" . $ENV{"EXCLUDE"};
print LOG "Adding excludes from $excl_file\n";
open (EXCLUDE_FILE, "< $excl_file") || die "Can't open exclude file $excl_file: $!\n";
while (defined (my $excl_pkg = <EXCLUDE_FILE>)) {
chomp $excl_pkg;
push(@exclude_packages, $excl_pkg);
}
close (EXCLUDE_FILE);
add_excludes_from_files($ENV{"EXCLUDE"}, "exclude", \@exclude_packages)
}
if (defined ($ENV{"EXCLUDE$disknum"})) {
my $excl_file = $ENV{"TASKDIR"} . "/" . $ENV{"EXCLUDE$disknum"};
print LOG "Adding excludes from $excl_file\n";
add_excludes_from_files($ENV{"EXCLUDE$disknum"}, "exclude", \@exclude_packages)
}
if (defined ($ENV{"UNEXCLUDE$disknum"})) {
add_excludes_from_files($ENV{"UNEXCLUDE$disknum"}, "unexclude", \@unexclude_packages)
}
}
sub add_excludes_from_files {
my $files_list = shift;
my $verb = shift;
my $listref = shift;
foreach my $entry (split(':', $files_list)) {
my $excl_file = $ENV{"TASKDIR"} . "/" . $entry;
parse_exclude_file($excl_file, $verb, $listref)
}
}
sub parse_exclude_file {
my $excl_file = shift;
my $verb = shift;
my $listref = shift;
my @list = @$listref;
print " Adding packages to $verb list from $excl_file\n";
print LOG "Adding packages to $verb list from $excl_file\n";
open (EXCLUDE_FILE, "< $excl_file") || die "Can't open exclude file $excl_file: $!\n";
while (defined (my $excl_pkg = <EXCLUDE_FILE>)) {
chomp $excl_pkg;
push(@exclude_packages, $excl_pkg);
print LOG " $excl_pkg\n";
}
close (EXCLUDE_FILE);
}
if (defined ($ENV{"UNEXCLUDE$disknum"})) {
my $excl_file = $ENV{"TASKDIR"} . "/" . $ENV{"UNEXCLUDE$disknum"};
print LOG "Adding unexcludes from $excl_file\n";
open (EXCLUDE_FILE, "< $excl_file") || die "Can't open unexclude file $excl_file: $!\n";
while (defined (my $excl_pkg = <EXCLUDE_FILE>)) {
chomp $excl_pkg;
push(@unexclude_packages, $excl_pkg);
}
close (EXCLUDE_FILE);
}
}
sub finish_disc {