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)
13 set NIXPKGS_SOURCETIME_PATH_OLD = \$NIXPKGS_SOURCETIME_PATH
16 set NIXPKGS_SOURCETIME_PATH_OLD = \$NIXPKGS_SOURCETIME_PATH
20 set NIXPKGS_SOURCETIME_PATH = "$SOURCETIME_PATH"
24 if ("\$PATH" != "") then
25 setenv PATH "\${NIXPKGS_SOURCETIME_PATH}:\$PATH"
27 setenv PATH "\$NIXPKGS_SOURCETIME_PATH"
29 # End of lines to add to PATH source-time utilities for Nixpkgs packaging
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
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#:\$##'\`
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-]
45 unset NIXPKGS_SOURCETIME_PATH
47 if (NIXPKGS_SOURCETIME_PATH_OLD == "") then
48 unset NIXPKGS_SOURCETIME_PATH_OLD
51 unset NIXPKGS_SOURCETIME_PATH
53 # End of lines to clean up inside PATH the source-time utilities for Nixpkgs packaging
55 cat "$FILE_TO_WORK_ON" > "$FILE_TO_PATCH"