devtool: add distclean command
Add the 'distclean' command to clean up build files, test results and
the docker container.
The purpose of this command is to remove everything built or pulled
during the build process.
@@ -595,6 +595,8 @@ cmd_help() {
echo " Outputs a rust file for each supported arch: src/seccompiler/src/syscall_table/{arch}.rs"
echo " Supported architectures: x86_64 and aarch64."
echo ""
+ echo " distclean"
+ echo " Clean up the build tree and remove the docker container."
}
# `$0 build` - build Firecracker
@@ -737,6 +739,24 @@ cmd_build() {
return $ret
}
+cmd_distclean() {
+ # List of folders to remove.
+ dirs=("build" "test_results")
+
+ for dir in "${dirs[@]}"; do
+ if [ -d "$dir" ]; then
+ say "Removing $dir"
+ rm -rf "$dir"
+ fi
+ done
+
+ # Remove devctr if it exists
+ if [ $(docker images -q "$DEVCTR_IMAGE" | wc -l) -eq "1" ]; then
+ say "Removing $DEVCTR_IMAGE"
+ docker rmi -f "$DEVCTR_IMAGE"
+ fi
+}
+
cmd_strip() {
profile="release"
libc="musl"
