Skip to content

Commit 104b23e

Browse files
authored
[Auditor] Deal with symlinked libtool files (#1199)
1 parent fcbbb40 commit 104b23e

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/Auditor.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,21 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
187187
# remove *.la files generated by GNU libtool
188188
la_files = collect_files(prefix, endswith(".la"))
189189
for f in la_files
190-
# sanity check: first byte should be '#', first line should contain 'libtool'
191-
line = readline(f)
192-
if length(line) == 0 || line[1] != '#' || !occursin("libtool", line)
190+
# Make sure the file still exists on disk
191+
if isfile(f)
192+
# sanity check: first byte should be '#', first line should contain 'libtool'
193+
line = readline(f)
194+
if length(line) == 0 || line[1] != '#' || !occursin("libtool", line)
195+
continue
196+
end
197+
elseif !islink(f)
198+
# If the file doesn't exist on disk but it's a symlink, it's a broken link to a
199+
# no-longer-existing libtool file, we still want to remove it. In any other
200+
# case, continue.
193201
continue
194202
end
195203
# remove it
196-
@info("removing libtool file $f")
204+
@info("Removing libtool file $f")
197205
rm(f; force=true)
198206
end
199207

test/auditing.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,21 @@ end
286286
platform = Platform("x86_64", os)
287287
mktempdir() do build_path
288288
build_output_meta = nothing
289-
@test_logs (:info, r"removing libtool file .*/destdir/lib/libfoo.la$") match_mode=:any begin
289+
@test_logs (:info, r"Removing libtool file .*/destdir/lib/libfoo.la$") (:info, r"Removing libtool file .*/destdir/lib/libqux.la$") match_mode=:any begin
290290
build_output_meta = autobuild(
291291
build_path,
292292
"libfoo",
293293
v"1.0.0",
294294
# Copy in the libfoo sources
295295
[DirectorySource(build_tests_dir)],
296-
# Build libfoo using autotools to create a real .la file,
297-
# and also create a fake .la file (which should not be removed)
298-
libfoo_autotools_script * "\ntouch \${prefix}/lib/libbar.la",
296+
# Build libfoo using autotools to create a real .la file, and also
297+
# create a fake .la file (which should not be removed). Create also a
298+
# symlink libqux.la -> libfoo.la, which will be broken after libfoo.la
299+
# has been deleted: remove libqux.la as well
300+
libfoo_autotools_script * raw"""
301+
touch ${prefix}/lib/libbar.la
302+
ln -s ${prefix}/lib/libfoo.la ${prefix}/lib/libqux.la
303+
""",
299304
# Build for our platform
300305
[platform],
301306
# The products we expect to be build
@@ -309,10 +314,11 @@ end
309314
tarball_path, tarball_hash = build_output_meta[platform][1:2]
310315
@test isfile(tarball_path)
311316

312-
# Test that `libfoo.la` has been removed but `libbar.la` hasn't
317+
# Test that `libfoo.la` and `libqux.la` have been removed but `libbar.la` hasn't
313318
contents = list_tarball_files(tarball_path)
314319
@test "lib/libbar.la" in contents
315320
@test !("lib/libfoo.la" in contents)
321+
@test !("lib/libqux.la" in contents)
316322
end
317323
end
318324
end

0 commit comments

Comments
 (0)