Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixLibtool(): replace /usr/bin/file in ./configure, add file to common-path.nix #168413

Merged
merged 1 commit into from May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkgs/stdenv/common-path.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@
pkgs.bash
pkgs.patch
pkgs.xz.bin

# The `file` command is added here because an enormous number of
# packages have a vendored dependency upon `file` in their
# `./configure` script, due to libtool<=2.4.6, or due to
# libtool>=2.4.7 in which the package author decided to set FILECMD
# when running libtoolize. In fact, file-5.4.6 *depends on itself*
# and tries to invoke `file` from its own ./configure script.
pkgs.file
]
3 changes: 3 additions & 0 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ rec {
gmp
libiconv
brotli.lib
file
] ++ lib.optional haveKRB5 libkrb5) ++
(with pkgs."${finalLlvmPackages}"; [
libcxx
Expand Down Expand Up @@ -561,6 +562,7 @@ rec {
gmp
libiconv
brotli.lib
file
] ++ lib.optional haveKRB5 libkrb5) ++
(with pkgs."${finalLlvmPackages}"; [
libcxx
Expand Down Expand Up @@ -737,6 +739,7 @@ rec {
brotli.lib
cc.expand-response-params
libxml2.out
file
] ++ lib.optional haveKRB5 libkrb5
++ lib.optionals localSystem.isAarch64 [
pkgs.updateAutotoolsGnuConfigScriptsHook
Expand Down
15 changes: 15 additions & 0 deletions pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,21 @@ configurePhase() {
echo "fixing libtool script $i"
fixLibtool "$i"
done

# replace `/usr/bin/file` with `file` in any `configure`
# scripts with vendored libtool code. Preserve mtimes to
# prevent some packages (e.g. libidn2) from spontaneously
# autoreconf'ing themselves
CONFIGURE_MTIME_REFERENCE=$(mktemp configure.mtime.reference.XXX)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We handle quoting in a very lax way in nixpkgs, but I think at least in places like setup.sh we should do it properly.

Copy link
Author

@ghost ghost May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean if $TMPDIR contains spaces, I presume? I guess that is possible.

I am generally pretty paranoid about shell quoting issues which is why I used multiple -execdir lines instead of a single -execdir bash ....

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find . \
-executable \
-type f \
-name configure \
-execdir grep -l 'GNU Libtool is free software; you can redistribute it and/or modify' {} \; \
-execdir touch -r {} "$CONFIGURE_MTIME_REFERENCE" \; \
-execdir sed -i s_/usr/bin/file_file_g {} \; \
-execdir touch -r "$CONFIGURE_MTIME_REFERENCE" {} \;
rm -f "$CONFIGURE_MTIME_REFERENCE"
fi

if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion pkgs/stdenv/linux/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ in
# Simple executable tools
concatMap (p: [ (getBin p) (getLib p) ]) [
gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed
gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed file
]
# Library dependencies
++ map getLib (
Expand Down