unit: Remove dangerous slash from index names

This commit is contained in:
Rodrigo Arias 2020-12-03 16:33:48 +01:00
parent 5e9adf3fe6
commit 1bdeca9e7d

View File

@ -10,6 +10,7 @@
}: }:
with stdenv.lib; with stdenv.lib;
with builtins;
let let
@ -38,6 +39,9 @@ let
firstStage = (x: x.programPath) (elemAt linkStages 0); firstStage = (x: x.programPath) (elemAt linkStages 0);
jsonConf = writeText "garlic_config.json" (builtins.toJSON conf); jsonConf = writeText "garlic_config.json" (builtins.toJSON conf);
safeUnitName = replaceStrings ["/" "$"] ["_" "_"] conf.unitName;
safeExpName = replaceStrings ["/" "$"] ["_" "_"] conf.expName;
in in
builtins.trace "evaluating unit ${conf.unitName}" builtins.trace "evaluating unit ${conf.unitName}"
stdenv.mkDerivation { stdenv.mkDerivation {
@ -72,14 +76,14 @@ stdenv.mkDerivation {
export GARLIC_UNIT=$(basename $out) export GARLIC_UNIT=$(basename $out)
# Create an index entry # Create an index entry
rm -f "\$GARLIC_INDEX/${conf.unitName}" \ rm -f "\$GARLIC_INDEX/${safeUnitName}" \
"\$GARLIC_INDEX/${conf.expName}" "\$GARLIC_INDEX/${safeExpName}"
ln -Tfs "../out/\$GARLIC_UNIT" \ ln -Tfs "../out/\$GARLIC_UNIT" \
"\$GARLIC_INDEX/${conf.unitName}" "\$GARLIC_INDEX/${safeUnitName}"
ln -Tfs "../out/\$GARLIC_EXPERIMENT" \ ln -Tfs "../out/\$GARLIC_EXPERIMENT" \
"\$GARLIC_INDEX/${conf.expName}" "\$GARLIC_INDEX/${safeExpName}"
if [ -e "\$GARLIC_UNIT" ]; then if [ -e "\$GARLIC_UNIT" ]; then
>&2 echo "skipping, unit path already exists: \$GARLIC_UNIT" >&2 echo "skipping, unit path already exists: \$GARLIC_UNIT"