Skip to content

Commit

Permalink
percona: fix references to utilities in scripts
Browse files Browse the repository at this point in the history
I encountered errors when attempting to run Vitess which calls out to
mysqld_safe[1]. Several utilities are needed in order for it to run e.g.
grep, sed, env, ps, date, hostname, etc.

Additionally, if ps, kill, and grep aren't available to
scripts/CMakeLists.txt, mysqld_start can end up getting generated with
syntax errors as FIND_PROC will be substituted into the script template
as an empty string[2][3].

The presence of systemd in percona-server_innovation seems to prevent
mysqld_multi from being built on Linux so it gets patched conditionally.

This same patch could be applied to MySQL if desired.

[1]: https://github.com/vitessio/vitess/blob/v20.0.1/go/vt/mysqlctl/mysqld.go#L363-L369
[2]: https://github.com/percona/percona-server/blob/79c1086e8272ea96f162b25121b58e1b01ff853b/scripts/CMakeLists.txt#L255
[3]: https://github.com/percona/percona-server/blob/79c1086e8272ea96f162b25121b58e1b01ff853b/scripts/mysqld_safe.sh#L869
  • Loading branch information
joshheinrichs-shopify committed Jul 31, 2024
1 parent d42f9eb commit a5dcd41
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
17 changes: 14 additions & 3 deletions pkgs/servers/sql/percona-server/innovation.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ lib, stdenv, fetchurl, bison, cmake, pkg-config
, boost, icu, libedit, libevent, lz4, ncurses, openssl, perl, protobuf, re2, readline, zlib, zstd, libfido2
, numactl, cctools, CoreServices, developer_cmds, libtirpc, rpcsvc-proto, curl, DarwinTools, nixosTests
, coreutils, procps, gnused, gnugrep, hostname, makeWrapper
, systemd
# Percona-specific deps
, coreutils, cyrus_sasl, gnumake, openldap
, cyrus_sasl, gnumake, openldap
# optional: different malloc implementations
, withJemalloc ? false, withTcmalloc ? false, jemalloc, gperftools
}:
Expand All @@ -20,8 +21,11 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-GeuifzqCkStmb4qYa8147XBHvMogYwfsn0FyHdO4WEg";
};

nativeBuildInputs = [ bison cmake pkg-config ]
++ lib.optionals (!stdenv.isDarwin) [ rpcsvc-proto ];
nativeBuildInputs = [
bison cmake pkg-config makeWrapper
# required for scripts/CMakeLists.txt
coreutils gnugrep procps
] ++ lib.optionals (!stdenv.isDarwin) [ rpcsvc-proto ];

patches = [
./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch
Expand Down Expand Up @@ -88,6 +92,13 @@ stdenv.mkDerivation (finalAttrs: {
moveToOutput "lib/*.a" $static
so=${stdenv.hostPlatform.extensions.sharedLibrary}
ln -s libmysqlclient$so $out/lib/libmysqlclient_r$so
wrapProgram $out/bin/mysqld_safe --prefix PATH : ${lib.makeBinPath [ coreutils procps gnugrep gnused hostname ]}
wrapProgram $out/bin/mysql_config --prefix PATH : ${lib.makeBinPath [ coreutils gnused ]}
wrapProgram $out/bin/ps_mysqld_helper --prefix PATH : ${lib.makeBinPath [ coreutils gnugrep ]}
wrapProgram $out/bin/ps-admin --prefix PATH : ${lib.makeBinPath [ coreutils gnugrep ]}
'' + lib.optionalString stdenv.isDarwin ''
wrapProgram $out/bin/mysqld_multi --prefix PATH : ${lib.makeBinPath [ coreutils gnugrep ]}
'';

passthru = {
Expand Down
16 changes: 13 additions & 3 deletions pkgs/servers/sql/percona-server/lts.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{ lib, stdenv, fetchurl, bison, cmake, pkg-config
, boost, icu, libedit, libevent, lz4, ncurses, openssl, perl, protobuf, re2, readline, zlib, zstd, libfido2
, numactl, cctools, CoreServices, developer_cmds, libtirpc, rpcsvc-proto, curl, DarwinTools, nixosTests
, coreutils, procps, gnused, gnugrep, hostname, makeWrapper
# Percona-specific deps
, coreutils, cyrus_sasl, gnumake, openldap
, cyrus_sasl, gnumake, openldap
}:

stdenv.mkDerivation (finalAttrs: {
Expand All @@ -14,8 +15,11 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-iktEvZz3mjjmJ16PX51OjSwwiFS3H9W/XRco//Q6aEQ=";
};

nativeBuildInputs = [ bison cmake pkg-config ]
++ lib.optionals (!stdenv.isDarwin) [ rpcsvc-proto ];
nativeBuildInputs = [
bison cmake pkg-config makeWrapper
# required for scripts/CMakeLists.txt
coreutils gnugrep procps
] ++ lib.optionals (!stdenv.isDarwin) [ rpcsvc-proto ];

patches = [
./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch
Expand Down Expand Up @@ -73,6 +77,12 @@ stdenv.mkDerivation (finalAttrs: {
moveToOutput "lib/*.a" $static
so=${stdenv.hostPlatform.extensions.sharedLibrary}
ln -s libmysqlclient$so $out/lib/libmysqlclient_r$so
wrapProgram $out/bin/mysqld_safe --prefix PATH : ${lib.makeBinPath [ coreutils procps gnugrep gnused hostname ]}
wrapProgram $out/bin/mysql_config --prefix PATH : ${lib.makeBinPath [ coreutils gnused ]}
wrapProgram $out/bin/ps_mysqld_helper --prefix PATH : ${lib.makeBinPath [ coreutils gnugrep ]}
wrapProgram $out/bin/ps-admin --prefix PATH : ${lib.makeBinPath [ coreutils gnugrep ]}
wrapProgram $out/bin/mysqld_multi --prefix PATH : ${lib.makeBinPath [ coreutils gnugrep ]}
'';

passthru = {
Expand Down

0 comments on commit a5dcd41

Please sign in to comment.