$srcrpmdirpath = `sudo chroot '$scratch' su -c "rpm --eval %{_srcrpmdir} 2>/dev/null" - abuild`;
{
# If mounted dirs left inside chroot we have to unmount them
- my $escaped_scratch = $scratch =~ s#/#\\/#gr;
- my $scratch_mnts = `sudo mount | awk '/$escaped_scratch/{print \$3}'`;
- my @scratch_mnt_list = split("\n", $scratch_mnts);
- foreach my $scratch_mnt (@scratch_mnt_list) {
- safe_umount($scratch_mnt);
+ open my $file, '<', "/proc/self/mountinfo" or die $!;
+ while (<$file>) {
+ chomp;
+ next if ($_ !~ /$scratch/);
+ my @mount_info= split(' ', $_);
+ debug("Unmounting $mount_info[4]");
+ safe_umount($mount_info[4]);
}
}
}