Skip to content

Commit 0e4f090

Browse files
committed
lcov: Make package handling more robust
Apply some changes to --from-package and --to-package handling to better handle failures: - Abort if tar tool is not available - Abort if no data file is found in package file - Ensure that temporary directories can be deleted Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent f87d980 commit 0e4f090

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

bin/lcov

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,17 +930,21 @@ sub get_package($)
930930
local *HANDLE;
931931

932932
info("Reading package $file:\n");
933-
info(" data directory .......: $dir\n");
934933
$file = abs_path($file);
935934
chdir($dir);
936935
open(HANDLE, "-|", "tar xvfz '$file' 2>/dev/null")
937936
or die("ERROR: could not process package $file\n");
937+
$count = 0;
938938
while (<HANDLE>) {
939939
if (/\.da$/ || /\.gcda$/) {
940940
$count++;
941941
}
942942
}
943943
close(HANDLE);
944+
if ($count == 0) {
945+
die("ERROR: no data file found in package $file\n");
946+
}
947+
info(" data directory .......: $dir\n");
944948
$build = read_file("$dir/$pkg_build_file");
945949
if (defined($build)) {
946950
info(" build directory ......: $build\n");
@@ -1014,6 +1018,10 @@ sub create_package($$$;$)
10141018
my ($file, $dir, $build, $gkv) = @_;
10151019
my $cwd = getcwd();
10161020

1021+
# Check for availability of tar tool first
1022+
system("tar --help > /dev/null")
1023+
and die("ERROR: tar command not available\n");
1024+
10171025
# Print information about the package
10181026
info("Creating package $file:\n");
10191027
info(" data directory .......: $dir\n");
@@ -4146,6 +4154,9 @@ sub abort_handler($)
41464154

41474155
sub temp_cleanup()
41484156
{
4157+
# Ensure temp directory is not in use by current process
4158+
chdir("/");
4159+
41494160
if (@temp_dirs) {
41504161
info("Removing temporary directories.\n");
41514162
foreach (@temp_dirs) {

0 commit comments

Comments
 (0)