From fd878c44f25ee436209fa15107d13f979ee11655 Mon Sep 17 00:00:00 2001
From: Mar Alegre <mar@mar.alemor.org>
Date: Tue, 13 Apr 2021 13:50:00 -0400
Subject: [PATCH] added redo option to pdm-build

---
 .install/bin/pdm-build | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/.install/bin/pdm-build b/.install/bin/pdm-build
index 43baab2..aef52d4 100755
--- a/.install/bin/pdm-build
+++ b/.install/bin/pdm-build
@@ -30,7 +30,8 @@ If second argument is omitted, the directory where the files were found is used
 as the image name.
 
 Options:
-  -s        Squash all newly built layers in the image into a single layer
+  -s        Squash all layers in the image into a single layer
+  -r        Redo build from scratch instead of using cached layers
   -d        Debug mode: don't delete the temporary container created by the script
             when encountering an error
   -t [tag]  Tag the image with the given string. Can be used multiple times to assign
@@ -39,11 +40,13 @@ Options:
 
 # Handle options
 opt_squash=0
+opt_redo=0
 opt_debug=0
 opt_tags=()
 while getopts ':sdt:h' arg; do
     case $arg in
         s) opt_squash=1;;
+        r) opt_redo=1;;
         d) opt_debug=1;;
         t) opt_tags+=("${OPTARG}");;
         h) echo "$help"; exit 0;;
@@ -81,7 +84,10 @@ fi
 
 buildopts=""
 if [[ $opt_squash -eq 1 ]]; then
-    buildopts="$buildopts --squash"
+    buildopts="$buildopts --squash-all"
+fi
+if [[ $opt_redo -eq 1 ]]; then
+    buildopts="$buildopts --no-cache"
 fi
 
 # tell buildah to build images in docker format instead of the default OCI format