aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate/src
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/populate/src')
-rw-r--r--pkgs/populate/src/sh.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/pkgs/populate/src/sh.rs b/pkgs/populate/src/sh.rs
index 7f179e4..77d2463 100644
--- a/pkgs/populate/src/sh.rs
+++ b/pkgs/populate/src/sh.rs
@@ -61,7 +61,8 @@ remove_tree() {
/// the link points into the store, like the links populate puts there
/// itself, and make_room_for_link PATH NAME makes room at PATH for a link
/// into the store, which Nix only puts in place of another link into the
-/// store.
+/// store, removing what else is there with remove_tree, which REMOVE_TREE
+/// defines.
pub const LINKS: &str = r#"
remove_link() {
if test -L "$1"; then
@@ -82,7 +83,7 @@ remove_foreign_link() {
make_room_for_link() {
remove_foreign_link "$1" "$2"
if ! test -L "$1" && test -e "$1"; then
- rm -fR "$1"
+ remove_tree "$1"
fi
}
"#;
@@ -329,7 +330,8 @@ fi
/// with a link to the result at PATH, printing the result, and changed if
/// the link changed.
pub fn derivation() -> String {
- LINKS.to_string()
+ REMOVE_TREE.to_string()
+ + LINKS
+ r#"
old=$(readlink "$1") || old=
make_room_for_link "$1" "$2"
@@ -454,7 +456,8 @@ git_problems() (
/// the commit checked out, on lines of their own; what commands print goes
/// to standard error.
pub fn git() -> String {
- LINKS.to_string()
+ REMOVE_TREE.to_string()
+ + LINKS
+ GIT_PROBLEMS
+ r#"
# What commands print goes to standard error. None of them gets the
@@ -485,7 +488,7 @@ deliver_git() {
# elsewhere.
remove_link "$path" "$name"
if test -L "$path"/.git || ! test -d "$path"/.git; then
- rm -fR "$path"
+ remove_tree "$path"
fi
# A .git directory can name places elsewhere too, which Git's commands
# change, or commands, which they run. Populate only uses a work tree
@@ -499,7 +502,7 @@ deliver_git() {
if test -n "$reclone"; then
>&2 printf "replacing the Git work tree '%s', because %s...\n" \
"$name" "$problems"
- rm -fR "$path"
+ remove_tree "$path"
else
>&2 printf 'error: populate doesn'"'"'t use the Git work tree %s, because %s. Fix that, remove the work tree, or set the source'"'"'s reclone to true to replace it by a fresh clone.\n' \
"$name" "$problems"
@@ -1217,7 +1220,7 @@ if test -n "$patch_dir"; then
)
fi
remove_foreign_link "$target_path" "$target_name"
-rm -fR "$target_path"
+remove_tree "$target_path"
mv "$work" "$target_path"
write_key "$key_file" "$key"
echo changed