crossgcc: Move temp file handling into cleanup function

Move code to handle leaving temp files around into cleanup.

Change-Id: Ief346d7973f693ec06c8bef6492cf1330858d9e1
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: https://review.coreboot.org/14346
Tested-by: build bot (Jenkins)
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index ea7c2e9..98b57f7 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -332,6 +332,11 @@
 
 cleanup()
 {
+	if [ $SAVETEMPS -ne 0 ]; then
+		printf "Leaving temporary files around... ${green}ok${NC}\n"
+		return
+	fi
+
 	printf "Cleaning up temporary files... "
 	for package in $PACKAGES; do
 		rm -rf build-${TARGETARCH}-$package build-$package $(eval echo \$$package"_DIR")
@@ -811,10 +816,6 @@
 rm -f "$DESTDIR$TARGETDIR/share/$PROGNAME-*"
 cp "$PROGNAME" "$DESTDIR$TARGETDIR/share/$PROGNAME-$CROSSGCC_VERSION-$CROSGCC_COMMIT"
 
-if [ $SAVETEMPS -eq 0 ]; then
-	cleanup
-else
-	printf "Leaving temporary files around... ${green}ok${NC}\n"
-fi
+cleanup
 
 printf "\n${green}You can now run your $NAME toolchain from $TARGETDIR.${NC}\n"