diff --git a/README.md b/README.md
index 0a68b3c..511ae1d 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,9 @@ is maintained as a git repository, and portzap allows the repository to be clone
* **portzap unpack**
This command should be run as root. It copies `/tmp/ports` to `/usr/ports`.
+* **portzap rmtree**
+ This command can be run as root, or a regular user. It removes `/tmp/ports`.
+
## Sources
* [Source code (GitHub)](https://github.com/0x1eef/portzap)
diff --git a/bin/portzap b/bin/portzap
index 21edde7..59b2b84 100755
--- a/bin/portzap
+++ b/bin/portzap
@@ -36,7 +36,7 @@ user_is_not_root() {
# Commands
help() {
- echo Usage: portzap "clone|pull|unpack"
+ echo "Usage: portzap clone|pull|unpack|rmtree"
}
clone() {
@@ -45,7 +45,12 @@ clone() {
echo "The clone command should not be run as root."
exit 1
fi
- rm -rf $stage_dir
+ if [ -e "$stage_dir/.git" ];
+ then
+ echo "$stage_dir has already been cloned."
+ echo "Run 'portzap pull', or 'portzap rmtree' instead."
+ exit 1
+ fi
git clone --depth 1 $source $stage_dir
}
@@ -60,7 +65,7 @@ pull() {
cd $stage_dir
git pull --rebase origin hardenedbsd/main
else
- echo "Run 'portzap clone' first"
+ echo "Run 'portzap clone' first."
exit 1
fi
}
@@ -74,6 +79,18 @@ unpack() {
cp -Rfv /tmp/ports /usr/
}
+rmtree() {
+ if [ -e $stage_dir ];
+ then
+ echo "Please wait."
+ rm -rf $stage_dir
+ echo "OK: removed $stage_dir"
+ else
+ echo "$stage_dir does not exist."
+ exit 1
+ fi
+}
+
case $1 in
"clone")
exit_on_missing_deps
@@ -89,6 +106,10 @@ case $1 in
unpack
break
;;
+ "rmtree")
+ rmtree
+ break
+ ;;
*)
help
break