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,40 +815,49 @@ sub start_disc {
$mkisofs_opts = ""; $mkisofs_opts = "";
$mkisofs_dirs = ""; $mkisofs_dirs = "";
undef @exclude_packages; @exclude_packages = ();
undef @unexclude_packages; @unexclude_packages = ();
# Change of interface here - exclude/unexclude files are now a
# colon-separated list
if (defined ($ENV{"EXCLUDE"})) { if (defined ($ENV{"EXCLUDE"})) {
my $excl_file = $ENV{"TASKDIR"} . "/" . $ENV{"EXCLUDE"}; add_excludes_from_files($ENV{"EXCLUDE"}, "exclude", \@exclude_packages)
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);
} }
if (defined ($ENV{"EXCLUDE$disknum"})) { if (defined ($ENV{"EXCLUDE$disknum"})) {
my $excl_file = $ENV{"TASKDIR"} . "/" . $ENV{"EXCLUDE$disknum"}; add_excludes_from_files($ENV{"EXCLUDE$disknum"}, "exclude", \@exclude_packages)
print LOG "Adding excludes from $excl_file\n"; }
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"; open (EXCLUDE_FILE, "< $excl_file") || die "Can't open exclude file $excl_file: $!\n";
while (defined (my $excl_pkg = <EXCLUDE_FILE>)) { while (defined (my $excl_pkg = <EXCLUDE_FILE>)) {
chomp $excl_pkg; chomp $excl_pkg;
push(@exclude_packages, $excl_pkg); push(@exclude_packages, $excl_pkg);
print LOG " $excl_pkg\n";
} }
close (EXCLUDE_FILE); 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 { sub finish_disc {
my $cddir = shift; my $cddir = shift;