de-duplicate FAKECHROOT_CMD_SUBST variable

This commit is contained in:
Johannes Schauer Marin Rodrigues 2023-01-23 15:01:21 +01:00
parent 4974f59248
commit d554c0b469
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -2602,20 +2602,23 @@ sub run_prepare {
$subst{ldconfig}
= '/usr/libexec/mmdebstrap/ldconfig.fakechroot';
}
my @fakechrootsubst = ();
my %fakechrootsubst;
foreach my $d (split ':', $ENV{PATH}) {
foreach my $k (sort keys %subst) {
foreach my $k (sort %subst) {
if (-e "$d/$k") {
push @fakechrootsubst, "$d/$k=$subst{$k}";
$fakechrootsubst{"$d/$k=$subst{$k}"} = 1;
}
}
}
if (defined $ENV{FAKECHROOT_CMD_SUBST}
&& $ENV{FAKECHROOT_CMD_SUBST} ne "") {
push @fakechrootsubst, split /:/, $ENV{FAKECHROOT_CMD_SUBST};
foreach my $e (split /:/, $ENV{FAKECHROOT_CMD_SUBST}) {
$fakechrootsubst{$e} = 1;
}
}
## no critic (Variables::RequireLocalizedPunctuationVars)
$ENV{FAKECHROOT_CMD_SUBST} = join ':', @fakechrootsubst;
$ENV{FAKECHROOT_CMD_SUBST} = join ':',
(sort keys %fakechrootsubst);
}
if (defined $ENV{FAKECHROOT_EXCLUDE_PATH}
&& $ENV{FAKECHROOT_EXCLUDE_PATH} ne "") {