Skip to content

Commit

Permalink
Make pkg-config files relocatable post-installation
Browse files Browse the repository at this point in the history
  • Loading branch information
albinahlback committed Oct 24, 2024
1 parent 49f57bf commit b9a9965
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Auditor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,33 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
rm(f; force=true)
end

# Make sure that `prefix` in pkg-config files *.pc points to the right
# directory.
pc_files = collect_files(prefix, endswith(".pc"))
for fs in pc_files
# Make sure the file still exists on disk
if !isfile(fs)
continue

Check warning on line 218 in src/Auditor.jl

View check run for this annotation

Codecov / codecov/patch

src/Auditor.jl#L217-L218

Added lines #L217 - L218 were not covered by tests
end

fs = open(file, "r")

Check warning on line 221 in src/Auditor.jl

View check run for this annotation

Codecov / codecov/patch

src/Auditor.jl#L221

Added line #L221 was not covered by tests

# We want to replace every instance of `prefix=...` with
# `prefix=${pcfiledir}/../..`
content = ""
str = readline(fs, keep = true)
while !isempty(str)
tmp = replace(str, r"^prefix=.*$" => s"prefix=${pcfiledir}/../..")
content = content * tmp
str = readline(fs, keep = true)

Check warning on line 230 in src/Auditor.jl

View check run for this annotation

Codecov / codecov/patch

src/Auditor.jl#L225-L230

Added lines #L225 - L230 were not covered by tests
end

close(fs)
fs = open(file, "w")
write(fs, content)
close(fs)

Check warning on line 236 in src/Auditor.jl

View check run for this annotation

Codecov / codecov/patch

src/Auditor.jl#L233-L236

Added lines #L233 - L236 were not covered by tests
end

if Sys.iswindows(platform)
# We also cannot allow any symlinks in Windows because it requires
# Admin privileges to create them. Orz
Expand Down

0 comments on commit b9a9965

Please sign in to comment.