python311Packages.moto: 4.2.6 -> 4.2.10
[NixPkgs.git] / pkgs / build-support / setup-hooks / patch-rc-path-hooks / patch-rc-path-posix.sh
bloba3740d4436d95e5d7d3d0a563aa56f518264c4fe
1 patchRcPathPosix(){
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-}"
9 fi
10 NIXPKGS_SOURCETIME_PATH="$SOURCETIME_PATH"
11 if [ -n "\$PATH" ]; then
12 PATH="\$NIXPKGS_SOURCETIME_PATH:\$PATH";
13 else
14 PATH="\$NIXPKGS_SOURCETIME_PATH"
16 export PATH
17 # End of lines to add to PATH source-time utilities for Nixpkgs packaging
18 EOF
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#:\\\$##")"
24 export PATH
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#")"
29 else
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
36 EOF
37 cat "$FILE_TO_WORK_ON" > "$FILE_TO_PATCH"
38 rm "$FILE_TO_WORK_ON"