Fix clean.sh unbound variable and add .build-stages cleanup
- Initialize CLEAN_STAGES variable to fix unbound variable error - Add .build-stages to artifacts_to_clean list for complete cleanup - Ensures stage markers are reset when cleaning build artifacts
This commit is contained in:
@@ -9,34 +9,39 @@ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Source common functions
|
||||
source "${SCRIPT_DIR}/lib/common.sh"
|
||||
source "${SCRIPT_DIR}/lib/stages.sh"
|
||||
|
||||
# Cleanup configuration
|
||||
CLEAN_ALL="${CLEAN_ALL:-false}"
|
||||
CLEAN_DOWNLOADS="${CLEAN_DOWNLOADS:-false}"
|
||||
CLEAN_CONTAINER="${CLEAN_CONTAINER:-false}"
|
||||
CLEAN_STAGES="${CLEAN_STAGES:-false}"
|
||||
|
||||
# Display usage information
|
||||
function show_usage() {
|
||||
cat << EOF
|
||||
Zero OS Build Cleanup Script
|
||||
Zero OS Build Cleanup Script (Incremental)
|
||||
|
||||
Usage: $0 [OPTIONS]
|
||||
|
||||
Options:
|
||||
--all Clean everything (artifacts + downloads + containers)
|
||||
--all Clean everything (artifacts + downloads + containers + stages)
|
||||
--downloads Clean downloaded sources and components
|
||||
--containers Clean container images
|
||||
--stages Clean stage completion markers only
|
||||
--artifacts-only Clean only build artifacts (default)
|
||||
--help Show this help message
|
||||
|
||||
Environment Variables:
|
||||
CLEAN_ALL Clean everything (default: false)
|
||||
CLEAN_DOWNLOADS Clean downloaded sources (default: false)
|
||||
CLEAN_DOWNLOADS Clean downloaded sources (default: false)
|
||||
CLEAN_CONTAINER Clean container images (default: false)
|
||||
CLEAN_STAGES Clean stage markers (default: false)
|
||||
|
||||
Examples:
|
||||
$0 # Clean build artifacts only
|
||||
$0 --all # Complete cleanup
|
||||
$0 # Clean build artifacts only (preserves stages)
|
||||
$0 --all # Complete cleanup (everything)
|
||||
$0 --stages # Reset stage tracking (force full rebuild)
|
||||
$0 --downloads # Clean sources and keep artifacts
|
||||
EOF
|
||||
}
|
||||
@@ -49,6 +54,7 @@ function parse_arguments() {
|
||||
CLEAN_ALL="true"
|
||||
CLEAN_DOWNLOADS="true"
|
||||
CLEAN_CONTAINER="true"
|
||||
CLEAN_STAGES="true"
|
||||
shift
|
||||
;;
|
||||
--downloads)
|
||||
@@ -59,6 +65,10 @@ function parse_arguments() {
|
||||
CLEAN_CONTAINER="true"
|
||||
shift
|
||||
;;
|
||||
--stages)
|
||||
CLEAN_STAGES="true"
|
||||
shift
|
||||
;;
|
||||
--artifacts-only)
|
||||
# This is the default, no action needed
|
||||
shift
|
||||
@@ -83,6 +93,7 @@ function clean_build_artifacts() {
|
||||
local artifacts_to_clean=(
|
||||
"${PROJECT_ROOT}/initramfs"
|
||||
"${PROJECT_ROOT}/dist"
|
||||
"${PROJECT_ROOT}/.build-stages"
|
||||
)
|
||||
|
||||
for artifact in "${artifacts_to_clean[@]}"; do
|
||||
@@ -254,6 +265,11 @@ function main() {
|
||||
clean_container_images
|
||||
fi
|
||||
|
||||
# Clean stage markers if requested (already handled in build artifacts for convenience)
|
||||
if [[ "$CLEAN_STAGES" == "true" ]]; then
|
||||
log_info "Stage markers already cleaned with build artifacts"
|
||||
fi
|
||||
|
||||
# Show space recovery
|
||||
show_space_recovery
|
||||
|
||||
|
||||
Reference in New Issue
Block a user