Skip to content

Commit

Permalink
patchExternalProjectGit: fail if URL or rev doesn't match
Browse files Browse the repository at this point in the history
This catches when packages update their vendored version but we haven't
updated on our end. Try to fix all usages of patchExternalProjectGit so
they are correct now.
  • Loading branch information
lopsided98 committed Jul 24, 2024
1 parent c7e6f7c commit 80b46d5
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 78 deletions.
15 changes: 0 additions & 15 deletions distros/distro-overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ let
'';
});

novatel-oem7-driver = (patchExternalProjectGit rosSuper.novatel-oem7-driver {
url = "https://github.com/novatel/novatel_edie";
fetchgitArgs = {
rev = "d02ccc2dfe531d642c1e2ca8a8c0f8205c856f23";
hash = "sha256-ZQ7z9vQ8quI+SoNhB93tTw5LQe07UAKdbJJpaMj1C6I=";
};
}).overrideAttrs ({ ... }: {
dontFixCmake = true;
});

ompl = rosSuper.ompl.overrideAttrs ({
patches ? [], ...
}: {
Expand Down Expand Up @@ -381,11 +371,6 @@ let
'';
});

uncrustify-vendor = patchVendorUrl rosSuper.uncrustify-vendor {
url = "https://github.com/uncrustify/uncrustify/archive/uncrustify-0.68.1.tar.gz";
sha256 = "04ndwhcn9iv3cy4p5wgh5z0vx2sywqlydyympn9m3h5458w1aijh";
};

urdf = patchBoostPython rosSuper.urdf;
};

Expand Down
6 changes: 2 additions & 4 deletions distros/foxy/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ rosSelf: rosSuper: with rosSelf.lib; {

mcap-vendor = patchExternalProjectGit (patchExternalProjectGit rosSuper.mcap-vendor {
url = "https://github.com/foxglove/mcap.git";
fetchgitArgs = {
rev = "dc6561d9ba867901709e36526dcf7f7359861e9c";
hash = "sha256-cWBZgCgxssM3xZZPbZlU1yYlZUD7KJ/wiYSgPXNjwzU=";
};
rev = "dc6561d9ba867901709e36526dcf7f7359861e9c";
fetchgitArgs.hash = "sha256-cWBZgCgxssM3xZZPbZlU1yYlZUD7KJ/wiYSgPXNjwzU=";
}) {
url = "https://github.com/lz4/lz4.git";
fetchgitArgs = {
Expand Down
44 changes: 32 additions & 12 deletions distros/humble/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ in with lib; {
];
});

# This is a newer version than the build system tries to download, but this
# version doesn't try to run host platform binaries on the build platform.
foonathan-memory-vendor = patchExternalProjectGit rosSuper.foonathan-memory-vendor {
url = "https://github.com/foonathan/memory.git";
originalRev = "v0.7-1";
rev = "v0.7-2";
fetchgitArgs.hash = "sha256-5nJNW0xwjSCc0Egq1zv0tIsGvAh1Xbnu8190A1ZP+VA=";
};

gazebo = self.gazebo_11;

google-benchmark-vendor = lib.patchExternalProjectGit rosSuper.google-benchmark-vendor {
url = "https://github.com/google/benchmark.git";
fetchgitArgs = {
rev = "c05843a9f622db08ad59804c190f98879b76beba";
hash = "sha256-h/e2vJacUp7PITez9HPzGc5+ofz7Oplso44VibECmsI=";
};
rev = "c05843a9f622db08ad59804c190f98879b76beba";
fetchgitArgs.hash = "sha256-h/e2vJacUp7PITez9HPzGc5+ofz7Oplso44VibECmsI=";
};

iceoryx-hoofs = rosSuper.iceoryx-hoofs.overrideAttrs ({
Expand All @@ -39,6 +46,15 @@ in with lib; {
];
});

lely-core-libraries = lib.patchExternalProjectGit rosSuper.lely-core-libraries {
url = "https://gitlab.com/lely_industries/lely-core.git";
rev = "b63a0b6f79d3ea91dc221724b42dae49894449fc";
fetchgitArgs = {
hash = "sha256-x9JCU2Ryssq424n90IzVOxixnvsoYTukyCOL3zNbwt4=";
leaveDotGit = true;
};
};

libphidget22 = patchVendorUrl rosSuper.libphidget22 {
url = "https://www.phidgets.com/downloads/phidget22/libraries/linux/libphidget22/libphidget22-1.19.20240304.tar.gz";
hash = "sha256-GpzGMpQ02s/X/XEcGoozzMjigrbqvAu81bcb7QG+36E=";
Expand All @@ -58,21 +74,17 @@ in with lib; {

libyaml-vendor = patchExternalProjectGit rosSuper.libyaml-vendor {
url = "https://github.com/yaml/libyaml.git";
fetchgitArgs = {
rev = "2c891fc7a770e8ba2fec34fc6b545c672beb37e6";
hash = "sha256-S7PnooyfyAsIiRAlEPGYkgkVACGaBaCItuqOwrq2+qM=";
};
rev = "2c891fc7a770e8ba2fec34fc6b545c672beb37e6";
fetchgitArgs.hash = "sha256-S7PnooyfyAsIiRAlEPGYkgkVACGaBaCItuqOwrq2+qM=";
};

mcap-vendor = patchExternalProjectGit (patchVendorUrl rosSuper.mcap-vendor {
url = "https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.8.0.tar.gz";
sha256 = "sha256-KDP3I0QwjqWGOfOzY6DPF2aVgK56tDX0PzsQTP9u9Ug=";
}) {
url = "https://github.com/lz4/lz4.git";
fetchgitArgs = {
rev = "d44371841a2f1728a3f36839fd4b7e872d0927d3";
hash = "sha256-f7GZgOzUrkAfw1mqwlIKQQqDvkvIahGlHvq6AL+aAvA=";
};
rev = "d44371841a2f1728a3f36839fd4b7e872d0927d3";
fetchgitArgs.hash = "sha256-f7GZgOzUrkAfw1mqwlIKQQqDvkvIahGlHvq6AL+aAvA=";
};

moveit-kinematics = rosSuper.moveit-kinematics.overrideAttrs ({
Expand All @@ -83,6 +95,14 @@ in with lib; {
propagatedBuildInputs = propagatedBuildInputs ++ [ rosSelf.moveit-ros-planning ];
});

novatel-oem7-driver = (patchExternalProjectGit rosSuper.novatel-oem7-driver {
url = "https://github.com/novatel/novatel_edie";
rev = "d02ccc2dfe531d642c1e2ca8a8c0f8205c856f23";
fetchgitArgs.hash = "sha256-ZQ7z9vQ8quI+SoNhB93tTw5LQe07UAKdbJJpaMj1C6I=";
}).overrideAttrs ({ ... }: {
dontFixCmake = true;
});

plotjuggler-ros = rosSuper.plotjuggler-ros.overrideAttrs ({
patches ? [], nativeBuildInputs ? [], ...
}: {
Expand Down
24 changes: 12 additions & 12 deletions distros/iron/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ in with lib; {
];
});

foonathan-memory-vendor = patchExternalProjectGit rosSuper.foonathan-memory-vendor {
url = "https://github.com/foonathan/memory.git";
rev = "v0.7-3";
fetchgitArgs.hash = "sha256-nLBnxPbPKiLCFF2TJgD/eJKJJfzktVBW3SRW2m3WK/s=";
};

gazebo = self.gazebo_11;

google-benchmark-vendor = lib.patchExternalProjectGit rosSuper.google-benchmark-vendor {
url = "https://github.com/google/benchmark.git";
fetchgitArgs = {
rev = "0d98dba29d66e93259db7daa53a9327df767a415";
hash = "sha256-yUiFxi80FWBmTZgqmqTMf9oqcBeg3o4I4vKd4djyRWY=";
};
rev = "0d98dba29d66e93259db7daa53a9327df767a415";
fetchgitArgs.hash = "sha256-yUiFxi80FWBmTZgqmqTMf9oqcBeg3o4I4vKd4djyRWY=";
};

iceoryx-hoofs = rosSuper.iceoryx-hoofs.overrideAttrs ({
Expand All @@ -46,21 +50,17 @@ in with lib; {

libyaml-vendor = patchExternalProjectGit rosSuper.libyaml-vendor {
url = "https://github.com/yaml/libyaml.git";
fetchgitArgs = {
rev = "2c891fc7a770e8ba2fec34fc6b545c672beb37e6";
hash = "sha256-S7PnooyfyAsIiRAlEPGYkgkVACGaBaCItuqOwrq2+qM=";
};
rev = "2c891fc7a770e8ba2fec34fc6b545c672beb37e6";
fetchgitArgs.hash = "sha256-S7PnooyfyAsIiRAlEPGYkgkVACGaBaCItuqOwrq2+qM=";
};

mcap-vendor = patchExternalProjectGit (patchVendorUrl rosSuper.mcap-vendor {
url = "https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.8.0.tar.gz";
sha256 = "sha256-KDP3I0QwjqWGOfOzY6DPF2aVgK56tDX0PzsQTP9u9Ug=";
}) {
url = "https://github.com/lz4/lz4.git";
fetchgitArgs = {
rev = "d44371841a2f1728a3f36839fd4b7e872d0927d3";
hash = "sha256-f7GZgOzUrkAfw1mqwlIKQQqDvkvIahGlHvq6AL+aAvA=";
};
rev = "d44371841a2f1728a3f36839fd4b7e872d0927d3";
fetchgitArgs.hash = "sha256-f7GZgOzUrkAfw1mqwlIKQQqDvkvIahGlHvq6AL+aAvA=";
};

rviz-ogre-vendor = rosSuper.rviz-ogre-vendor.overrideAttrs ({
Expand Down
16 changes: 10 additions & 6 deletions distros/jazzy/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ in {
];
});

foonathan-memory-vendor = lib.patchExternalProjectGit rosSuper.foonathan-memory-vendor {
url = "https://github.com/foonathan/memory.git";
rev = "v0.7-3";
fetchgitArgs.hash = "sha256-nLBnxPbPKiLCFF2TJgD/eJKJJfzktVBW3SRW2m3WK/s=";
};

gazebo = self.gazebo_11;

google-benchmark-vendor = lib.patchExternalProjectGit rosSuper.google-benchmark-vendor {
url = "https://github.com/google/benchmark.git";
fetchgitArgs = {
rev = "344117638c8ff7e239044fd0fa7085839fc03021";
hash = "sha256-gztnxui9Fe/FTieMjdvfJjWHjkImtlsHn6fM1FruyME=";
};
rev = "344117638c8ff7e239044fd0fa7085839fc03021";
fetchgitArgs.hash = "sha256-gztnxui9Fe/FTieMjdvfJjWHjkImtlsHn6fM1FruyME=";
};

iceoryx-hoofs = rosSuper.iceoryx-hoofs.overrideAttrs ({
Expand All @@ -41,9 +45,9 @@ in {

lely-core-libraries = lib.patchExternalProjectGit rosSuper.lely-core-libraries {
url = "https://gitlab.com/lely_industries/lely-core.git";
rev = "b63a0b6f79d3ea91dc221724b42dae49894449fc";
fetchgitArgs = {
rev = "7824cbb2ac08d091c4fa2fb397669b938de9e3f5";
sha256 = "sha256-Ykmnz/zlEXmkyRO9AHMprML7uKbNer2zu4i9PDHfgxw=";
hash = "sha256-x9JCU2Ryssq424n90IzVOxixnvsoYTukyCOL3zNbwt4=";
leaveDotGit = true;
};
};
Expand Down
20 changes: 12 additions & 8 deletions distros/rolling/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ in {
];
});

foonathan-memory-vendor = lib.patchExternalProjectGit rosSuper.foonathan-memory-vendor {
url = "https://github.com/foonathan/memory.git";
rev = "v0.7-3";
fetchgitArgs.hash = "sha256-nLBnxPbPKiLCFF2TJgD/eJKJJfzktVBW3SRW2m3WK/s=";
};

gazebo = self.gazebo_11;

google-benchmark-vendor = lib.patchExternalProjectGit rosSuper.google-benchmark-vendor {
url = "https://github.com/google/benchmark.git";
fetchgitArgs = {
rev = "344117638c8ff7e239044fd0fa7085839fc03021";
hash = "sha256-gztnxui9Fe/FTieMjdvfJjWHjkImtlsHn6fM1FruyME=";
};
rev = "344117638c8ff7e239044fd0fa7085839fc03021";
fetchgitArgs.hash = "sha256-gztnxui9Fe/FTieMjdvfJjWHjkImtlsHn6fM1FruyME=";
};

iceoryx-hoofs = rosSuper.iceoryx-hoofs.overrideAttrs ({
Expand All @@ -41,9 +45,9 @@ in {

lely-core-libraries = lib.patchExternalProjectGit rosSuper.lely-core-libraries {
url = "https://gitlab.com/lely_industries/lely-core.git";
rev = "b63a0b6f79d3ea91dc221724b42dae49894449fc";
fetchgitArgs = {
rev = "7824cbb2ac08d091c4fa2fb397669b938de9e3f5";
sha256 = "sha256-Ykmnz/zlEXmkyRO9AHMprML7uKbNer2zu4i9PDHfgxw=";
hash = "sha256-x9JCU2Ryssq424n90IzVOxixnvsoYTukyCOL3zNbwt4=";
leaveDotGit = true;
};
};
Expand All @@ -54,8 +58,8 @@ in {
};

mcap-vendor = lib.patchVendorUrl rosSuper.mcap-vendor {
url = "https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v1.3.0.tar.gz";
hash = "sha256-Qaz26F11VWxkQH8HfgVJLTHbHwmeByQu8ENkuyk5rPE=";
url = "https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v1.1.0.tar.gz";
hash = "sha256-HLKuny6RDusuk7OrcidE0YBbnaRXZOT9iHA7ZpQTNQ0=";
};

rviz-ogre-vendor = lib.patchAmentVendorGit rosSuper.rviz-ogre-vendor {
Expand Down
24 changes: 6 additions & 18 deletions distros/ros2-overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,10 @@ rosSelf: rosSuper: with rosSelf.lib; {

fmilibrary-vendor = patchExternalProjectGit rosSuper.fmilibrary-vendor {
url = "https://github.com/modelon-community/fmi-library.git";
fetchgitArgs = {
rev = "2.1";
sha256 = "177rlw1ba1y0ahi8qfpg0sflh8mjdl6fmffwjg2a5vxyxwdwrjvh";
};
};

# This is a newer version than the build system tries to download, but this
# version doesn't try to run host platform binaries on the build platform.
foonathan-memory-vendor = patchExternalProjectGit rosSuper.foonathan-memory-vendor {
url = "https://github.com/foonathan/memory.git";
fetchgitArgs = {
rev = "v0.7-2";
sha256 = "sha256-5nJNW0xwjSCc0Egq1zv0tIsGvAh1Xbnu8190A1ZP+VA=";
};
# Uses ${fmilibrary_version}, so can't match
originalRev = "";
rev = "2.2.3";
fetchgitArgs.hash = "sha256-i8EtjPMg39S/3RyoUaXm5A8Nu/NbgAwjxRCdyh2elyU=";
};

gmock-vendor = rosSuper.gmock-vendor.overrideAttrs ({
Expand Down Expand Up @@ -117,10 +107,8 @@ rosSelf: rosSuper: with rosSelf.lib; {

rig-reconfigure = patchExternalProjectGit rosSuper.rig-reconfigure {
url = "https://github.com/ocornut/imgui.git";
fetchgitArgs = {
rev = "3ea0fad204e994d669f79ed29dcaf61cd5cb571d";
sha256 = "sha256-v9FP9zJvul+2zRGaIugNDBCR9xZqCY8U90Dfe6fXpJM=";
};
rev = "v1.89.8-docking";
fetchgitArgs.hash = "sha256-eY8lRsonPfDRTMCPhInT9rQ6lSaJPsXpkh428OKpTnA=";
};

rmw-implementation = rosSuper.rmw-implementation.overrideAttrs ({
Expand Down
23 changes: 20 additions & 3 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,32 @@

patchExternalProjectGit = pkg: {
url,
rev,
originalRev ? rev,
originalUrl ? url,
file ? "CMakeLists.txt",
fetchgitArgs ? {}
}: pkg.overrideAttrs ({
postPatch ? "", ...
}: {
postPatch = ''
sed -i '\|GIT_REPOSITORY\s.*${originalUrl}|c\
URL "${self.fetchgit ({ inherit url; } // fetchgitArgs)}"' \
postPatch = let
script = ''
$0 ~ "GIT_REPOSITORY[[:blank:]]+" originalUrl \
{ print "URL \"" path "\""; foundUrl=1; next } \
{ print }
$0 ~ "GIT_TAG[[:blank:]]+" originalRev { print; foundRev=1 }
END {
if (!foundUrl) print "patchExternalProjectGit: did not find URL: " originalUrl > "/dev/stderr"
if (!foundRev) print "patchExternalProjectGit: did not find revision: " originalRev > "/dev/stderr"
exit !(foundUrl && foundRev)
}
'';
in ''
awk -i inplace \
-v originalUrl=${lib.escapeShellArg originalUrl} \
-v originalRev=${lib.escapeShellArg originalRev} \
-v path=${lib.escapeShellArg (self.fetchgit ({ inherit url rev; } // fetchgitArgs))} \
${lib.escapeShellArg script} \
${lib.escapeShellArg file}
'' + postPatch;
});
Expand Down

0 comments on commit 80b46d5

Please sign in to comment.