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 [ -n "\${NIXPKGS_SOURCETIME_PATH-}" ]; then
8 NIXPKGS_SOURCETIME_PATH_OLD="\$NIXPKGS_SOURCETIME_PATH;\${NIXPKGS_SOURCETIME_PATH_OLD-}"
10 NIXPKGS_SOURCETIME_PATH="$SOURCETIME_PATH"
11 if [ -n "\$PATH" ]; then
12 PATH="\$NIXPKGS_SOURCETIME_PATH:\$PATH";
14 PATH="\$NIXPKGS_SOURCETIME_PATH"
17 # End of lines to add to PATH source-time utilities for Nixpkgs packaging
19 cat "$FILE_TO_PATCH" >> "$FILE_TO_WORK_ON"
20 cat <<EOF >> "$FILE_TO_WORK_ON"
21 # Lines to clean up inside PATH the source-time utilities for Nixpkgs packaging
22 if [ -n "\${PATH-}" ]; then
23 PATH="\$(echo "\$PATH" | @sed@ "s#\$NIXPKGS_SOURCETIME_PATH##" | @sed@ "s#::#:#g" | @sed@ "s#^:##" | @sed@ "s#:\\\$##")"
26 if [ -n "\${NIXPKGS_SOURCETIME_PATH_OLD-}" ]; then
27 NIXPKGS_SOURCETIME_PATH="\$(echo "\$NIXPKGS_SOURCETIME_PATH_OLD" | @sed@ "s#\\([^;]\\);.*#\\1#")"
28 NIXPKGS_SOURCETIME_PATH_OLD="\$(echo "\$NIXPKGS_SOURCETIME_PATH_OLD" | @sed@ "s#[^;];\\(.*\\)#\\1#")"
30 unset NIXPKGS_SOURCETIME_PATH
32 if [ -z "\${NIXPKGS_SOURCETIME_PATH_OLD-}" ]; then
33 unset NIXPKGS_SOURCETIME_PATH_OLD
35 # End of lines to clean up inside PATH the source-time utilities for Nixpkgs packaging
37 cat "$FILE_TO_WORK_ON" > "$FILE_TO_PATCH"