python311Packages.moto: 4.2.6 -> 4.2.10
[NixPkgs.git] / pkgs / build-support / setup-hooks / patch-rc-path-hooks / patch-rc-path-csh.sh
blob5e2367003ade65818d396f279184ca9dfae16220
1 patchRcPathCsh(){
2 local FILE_TO_PATCH="$1"
3 local SOURCETIME_PATH="$2"
4 local FILE_TO_WORK_ON="$(mktemp "$(basename "$FILE_TO_PATCH").XXXXXX.tmp")"
5 cat <<EOF >> "$FILE_TO_WORK_ON"
6 # Lines to add to PATH the source-time utilities for Nixpkgs packaging
7 if (\$?NIXPKGS_SOURCETIME_PATH) then
8 if ("\$NIXPKGS_SOURCETIME_PATH" != "") then
9 if (\$?NIXPKGS_SOURCETIME_PATH_OLD) then
10 if ("\$NIXPKGS_SOURCETIME_PATH_OLD" != "")
11 set NIXPKGS_SOURCETIME_PATH_OLD = (\$NIXPKGS_SOURCETIME_PATH \$NIXPKGS_SOURCETIME_PATH_OLD)
12 else
13 set NIXPKGS_SOURCETIME_PATH_OLD = \$NIXPKGS_SOURCETIME_PATH
14 endif
15 else
16 set NIXPKGS_SOURCETIME_PATH_OLD = \$NIXPKGS_SOURCETIME_PATH
17 endif
18 endif
19 endif
20 set NIXPKGS_SOURCETIME_PATH = "$SOURCETIME_PATH"
21 if (! \$?PATH) then
22 setenv PATH ""
23 endif
24 if ("\$PATH" != "") then
25 setenv PATH "\${NIXPKGS_SOURCETIME_PATH}:\$PATH"
26 else
27 setenv PATH "\$NIXPKGS_SOURCETIME_PATH"
28 endif
29 # End of lines to add to PATH source-time utilities for Nixpkgs packaging
30 EOF
31 cat "$FILE_TO_PATCH" >> "$FILE_TO_WORK_ON"
32 cat <<EOF >> "$FILE_TO_WORK_ON"
33 # Lines to clean up inside PATH the source-time utilities for Nixpkgs packaging
34 if (\$?PATH) then
35 if ("\$PATH" != "") then
36 # Remove the inserted section, the duplicated colons, and the leading and trailing colon
37 setenv PATH \`echo "\$PATH" | @sed@ "s#\${NIXPKGS_SOURCETIME_PATH}##" | @sed@ "s#::#:#g" | @sed@ "s#^:##" | @sed@ 's#:\$##'\`
38 endif
39 endif
40 if (\$?NIXPKGS_SOURCETIME_PATH_OLD) then
41 if ("\$NIXPKGS_SOURCETIME_PATH_OLD" != "") then
42 set NIXPKGS_SOURCETIME_PATH = \$NIXPKGS_SOURCETIME_PATH_OLD[1]
43 set NIXPKGS_SOURCETIME_PATH_OLD = \$NIXPKGS_SOURCETIME_PATH_OLD[2-]
44 else
45 unset NIXPKGS_SOURCETIME_PATH
46 endif
47 if (NIXPKGS_SOURCETIME_PATH_OLD == "") then
48 unset NIXPKGS_SOURCETIME_PATH_OLD
49 endif
50 else
51 unset NIXPKGS_SOURCETIME_PATH
52 endif
53 # End of lines to clean up inside PATH the source-time utilities for Nixpkgs packaging
54 EOF
55 cat "$FILE_TO_WORK_ON" > "$FILE_TO_PATCH"
56 rm "$FILE_TO_WORK_ON"