Fix Unicode character issues in apt-layer scriptlets and recompile with clean source

This commit is contained in:
robojerk 2025-07-12 12:54:28 -07:00
parent 32a427ace4
commit d160a1a4e5
19 changed files with 965 additions and 146 deletions

File diff suppressed because it is too large Load diff

144
dos2unix.sh Normal file
View file

@ -0,0 +1,144 @@
#!/bin/bash
# dos2unix mimic script
# Converts DOS/Windows line endings (CRLF) to Unix line endings (LF)
# Function to display usage
usage() {
echo "Usage: $0 [OPTIONS] FILE..."
echo "Convert DOS/Windows line endings to Unix line endings"
echo ""
echo "Options:"
echo " -h, --help Show this help message"
echo " -n, --newfile Create new file with .unix extension"
echo " -b, --backup Create backup with .bak extension"
echo " -q, --quiet Suppress output messages"
echo ""
echo "Examples:"
echo " $0 file.txt"
echo " $0 -n file.txt"
echo " $0 -b file.txt"
echo " $0 *.txt"
exit 1
}
# Function to convert file
convert_file() {
local input_file="$1"
local output_file="$2"
local backup="$3"
local quiet="$4"
# Check if input file exists
if [ ! -f "$input_file" ]; then
echo "Error: File '$input_file' not found" >&2
return 1
fi
# Check if file has DOS line endings
if ! grep -q $'\r' "$input_file"; then
[ "$quiet" != "true" ] && echo "dos2unix: converting file $input_file to Unix format..."
[ "$quiet" != "true" ] && echo "dos2unix: $input_file: No conversion needed (already Unix format)"
return 0
fi
# Create backup if requested
if [ "$backup" = "true" ]; then
if ! cp "$input_file" "${input_file}.bak"; then
echo "Error: Cannot create backup file" >&2
return 1
fi
[ "$quiet" != "true" ] && echo "dos2unix: created backup: ${input_file}.bak"
fi
# Convert line endings using sed
if sed 's/\r$//' "$input_file" > "$output_file"; then
[ "$quiet" != "true" ] && echo "dos2unix: converting file $input_file to Unix format..."
# If output file is different from input (newfile mode), show message
if [ "$input_file" != "$output_file" ]; then
[ "$quiet" != "true" ] && echo "dos2unix: converted to $output_file"
fi
return 0
else
echo "Error: Failed to convert $input_file" >&2
return 1
fi
}
# Parse command line arguments
newfile=false
backup=false
quiet=false
files=()
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage
;;
-n|--newfile)
newfile=true
shift
;;
-b|--backup)
backup=true
shift
;;
-q|--quiet)
quiet=true
shift
;;
-*)
echo "Error: Unknown option $1" >&2
usage
;;
*)
files+=("$1")
shift
;;
esac
done
# Check if at least one file is provided
if [ ${#files[@]} -eq 0 ]; then
echo "Error: No files specified" >&2
usage
fi
# Process each file
exit_code=0
for file in "${files[@]}"; do
# Expand wildcards
for expanded_file in $file; do
if [ -f "$expanded_file" ]; then
if [ "$newfile" = "true" ]; then
# Create new file with .unix extension
output_file="${expanded_file}.unix"
else
# Overwrite original file
output_file="$expanded_file"
fi
if [ "$newfile" = "true" ]; then
# For newfile mode, we can directly convert
convert_file "$expanded_file" "$output_file" "$backup" "$quiet"
else
# For in-place conversion, use temporary file
temp_file=$(mktemp)
if convert_file "$expanded_file" "$temp_file" "$backup" "$quiet"; then
mv "$temp_file" "$expanded_file"
else
rm -f "$temp_file"
exit_code=1
fi
fi
else
echo "Error: File '$expanded_file' not found" >&2
exit_code=1
fi
done
done
exit $exit_code

View file

@ -88,7 +88,7 @@ validate_json_files() {
print_error "Invalid JSON in file: $json_file"
exit 1
fi
print_status " Validated: $json_file"
print_status "â Validated: $json_file"
done
fi
}
@ -114,7 +114,7 @@ convert_line_endings() {
if grep -q $'\r' "$file" 2>/dev/null; then
print_status "Converting Windows line endings to Unix: $file"
if "$dos2unix_cmd" -q "$file"; then
print_status " Converted: $file"
print_status "â Converted: $file"
else
print_warning "Failed to convert line endings for: $file"
fi
@ -530,28 +530,28 @@ print_status "Lines of code: $(wc -l < "$OUTPUT_FILE")"
print_status ""
print_status "The compiled apt-layer.sh is now self-contained and includes:"
print_status " Particle-OS configuration integration"
print_status " Transactional operations with automatic rollback"
print_status " Traditional chroot-based layer creation"
print_status " Container-based layer creation (Apx-style)"
print_status " OCI export/import integration"
print_status " Live overlay system (rpm-ostree style)"
print_status " Bootloader integration (UEFI/GRUB/systemd-boot)"
print_status " Advanced package management (Enterprise features)"
print_status " Layer signing & verification (Enterprise security)"
print_status " Centralized audit & reporting (Enterprise compliance)"
print_status " Automated security scanning (Enterprise security)"
print_status " Admin utilities (Health monitoring, performance analytics, maintenance)"
print_status " Multi-tenant support (Enterprise features)"
print_status " Atomic deployment system with rollback"
print_status " rpm-ostree compatibility layer (1:1 command mapping)"
print_status " ComposeFS backend integration"
print_status " Dependency validation and error handling"
print_status " Comprehensive JSON configuration system"
print_status " Direct dpkg installation (Performance optimization)"
print_status " All dependencies merged into a single file"
print_status "â Particle-OS configuration integration"
print_status "â Transactional operations with automatic rollback"
print_status "â Traditional chroot-based layer creation"
print_status "â Container-based layer creation (Apx-style)"
print_status "â OCI export/import integration"
print_status "â Live overlay system (rpm-ostree style)"
print_status "â Bootloader integration (UEFI/GRUB/systemd-boot)"
print_status "â Advanced package management (Enterprise features)"
print_status "â Layer signing & verification (Enterprise security)"
print_status "â Centralized audit & reporting (Enterprise compliance)"
print_status "â Automated security scanning (Enterprise security)"
print_status "â Admin utilities (Health monitoring, performance analytics, maintenance)"
print_status "â Multi-tenant support (Enterprise features)"
print_status "â Atomic deployment system with rollback"
print_status "â rpm-ostree compatibility layer (1:1 command mapping)"
print_status "â ComposeFS backend integration"
print_status "â Dependency validation and error handling"
print_status "â Comprehensive JSON configuration system"
print_status "â Direct dpkg installation (Performance optimization)"
print_status "â All dependencies merged into a single file"
print_status ""
print_status "🎉 Particle-OS apt-layer compilation complete with all features!"
print_status "ð Particle-OS apt-layer compilation complete with all features!"
print_status ""
print_status "Usage:"
@ -590,4 +590,4 @@ print_status " sudo ./apt-layer.sh --list"
print_status " sudo ./apt-layer.sh --help"
print_status ""
print_status "Ready for distribution! 🚀"
print_status "Ready for distribution! ð"

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Utility functions for Particle-OS apt-layer Tool
# These functions provide system introspection and core utilities
@ -514,14 +515,14 @@ get_system_info() {
echo "Architecture: $(uname -m)"
echo "Available modules:"
if modprobe -n squashfs >/dev/null 2>&1; then
echo " squashfs module available"
echo " â squashfs module available"
else
echo " squashfs module not available"
echo " â squashfs module not available"
fi
if modprobe -n overlay >/dev/null 2>&1; then
echo " overlay module available"
echo " â overlay module available"
else
echo " overlay module not available"
echo " â overlay module not available"
fi
}

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Enhanced dependency checking and validation for Particle-OS apt-layer Tool
check_dependencies() {
local command_type="${1:-}"
@ -97,9 +98,9 @@ check_dependencies() {
echo ""
if [[ ${#missing_tools[@]} -gt 0 ]]; then
echo "📦 Missing system packages:"
echo "ð¦ Missing system packages:"
for tool in "${missing_tools[@]}"; do
echo " $tool"
echo " ⢠$tool"
done
echo ""
echo " Install with: sudo apt install -y ${missing_tools[*]}"
@ -107,9 +108,9 @@ check_dependencies() {
fi
if [[ ${#missing_scripts[@]} -gt 0 ]]; then
echo "📜 Missing or non-executable scripts:"
echo "ð Missing or non-executable scripts:"
for script in "${missing_scripts[@]}"; do
echo " $script"
echo " ⢠$script"
done
echo ""
echo " Ensure scripts are installed and executable:"
@ -118,9 +119,9 @@ check_dependencies() {
fi
if [[ ${#missing_modules[@]} -gt 0 ]]; then
echo "🔧 Missing kernel modules:"
echo "ð§ Missing kernel modules:"
for module in "${missing_modules[@]}"; do
echo " $module"
echo " ⢠$module"
done
echo ""
echo " Load modules with: sudo modprobe ${missing_modules[*]}"
@ -128,10 +129,10 @@ check_dependencies() {
echo ""
fi
echo "💡 Quick fix for common dependencies:"
echo "ð¡ Quick fix for common dependencies:"
echo " sudo apt install -y squashfs-tools jq coreutils util-linux"
echo ""
echo "🔍 For more information, run: apt-layer --help"
echo "ð For more information, run: apt-layer --help"
echo ""
exit 1
@ -264,7 +265,7 @@ show_actionable_error() {
case "$error_type" in
"missing_dependencies")
echo "🔧 To fix this issue:"
echo "ð§ To fix this issue:"
echo " 1. Install missing dependencies:"
echo " sudo apt update"
echo " sudo apt install -y $packages"
@ -277,7 +278,7 @@ show_actionable_error() {
echo ""
;;
"permission_denied")
echo "🔐 Permission issue detected:"
echo "ð Permission issue detected:"
echo " This command requires root privileges."
echo ""
echo " Run with sudo:"
@ -285,7 +286,7 @@ show_actionable_error() {
echo ""
;;
"invalid_arguments")
echo "📝 Invalid arguments provided:"
echo "ð Invalid arguments provided:"
echo " Check the command syntax and try again."
echo ""
echo " For help, run:"
@ -294,7 +295,7 @@ show_actionable_error() {
echo ""
;;
"system_not_initialized")
echo "🚀 System not initialized:"
echo "ð System not initialized:"
echo " Particle-OS needs to be initialized first."
echo ""
echo " Run initialization:"
@ -302,7 +303,7 @@ show_actionable_error() {
echo ""
;;
"disk_space")
echo "💾 Insufficient disk space:"
echo "ð¾ Insufficient disk space:"
echo " Free up space or use a different location."
echo ""
echo " Check available space:"
@ -310,7 +311,7 @@ show_actionable_error() {
echo ""
;;
*)
echo " Unknown error occurred."
echo "â Unknown error occurred."
echo " Please check the error message above."
echo ""
echo " For help, run: apt-layer --help"
@ -318,10 +319,10 @@ show_actionable_error() {
;;
esac
echo "📚 For more information:"
echo " apt-layer --help"
echo " apt-layer --help-full"
echo " apt-layer --examples"
echo "ð For more information:"
echo " ⢠apt-layer --help"
echo " ⢠apt-layer --help-full"
echo " ⢠apt-layer --examples"
echo ""
}

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Transaction management for Particle-OS apt-layer Tool
# Provides atomic operations with automatic rollback and recovery

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Traditional layer creation for Ubuntu uBlue apt-layer Tool
# Provides chroot-based package installation for layer creation

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Container-based layer creation for Ubuntu uBlue apt-layer Tool
# Provides Apx-style isolated container installation with ComposeFS backend

View file

@ -172,7 +172,7 @@ get_live_overlay_status() {
echo "=== Live Overlay Status ==="
if is_live_overlay_active; then
log_success " Live overlay is ACTIVE" "apt-layer"
log_success "â Live overlay is ACTIVE" "apt-layer"
# Show mount details
if mountpoint -q "$LIVE_OVERLAY_MOUNT_POINT"; then
@ -190,22 +190,22 @@ get_live_overlay_status() {
log_info "Packages installed in overlay: $package_count" "apt-layer"
fi
else
log_warning "⚠️ Overlay mount point not mounted" "apt-layer"
log_warning "â ï¸ Overlay mount point not mounted" "apt-layer"
fi
# Check for active processes
if check_active_processes; then
log_warning "⚠️ Active processes detected - overlay cannot be stopped" "apt-layer"
log_warning "â ï¸ Active processes detected - overlay cannot be stopped" "apt-layer"
fi
else
log_info " Live overlay is not active" "apt-layer"
log_info "â¹ Live overlay is not active" "apt-layer"
# Check if system supports live overlay
if check_live_overlay_support >/dev/null 2>&1; then
log_info " System supports live overlay" "apt-layer"
log_info "â¹ System supports live overlay" "apt-layer"
log_info "Use '--live-overlay start' to start live overlay" "apt-layer"
else
log_warning "⚠️ System does not support live overlay" "apt-layer"
log_warning "â ï¸ System does not support live overlay" "apt-layer"
fi
fi

View file

@ -1,5 +1,6 @@
#!/bin/bash
# OCI Integration for Particle-OS apt-layer Tool
# Provides ComposeFS OCI export/import functionality for container-based layer creation
# Provides ComposeFS â OCI export/import functionality for container-based layer creation
# OCI registry configuration
declare -A OCI_REGISTRY_CONFIG
@ -539,9 +540,9 @@ oci_status() {
echo "=== OCI Tool Configuration ==="
echo "Preferred tool: $OCI_TOOL"
echo "Available tools:"
command -v skopeo &> /dev/null && echo " skopeo"
command -v podman &> /dev/null && echo " podman"
command -v docker &> /dev/null && echo " docker"
command -v skopeo &> /dev/null && echo " â skopeo"
command -v podman &> /dev/null && echo " â podman"
command -v docker &> /dev/null && echo " â docker"
echo ""
echo "=== OCI Workspace ==="

View file

@ -975,9 +975,9 @@ get_advanced_package_info() {
echo ""
echo "Security Information:"
if check_package_signature "$package"; then
echo " Package is signed"
echo " â Package is signed"
else
echo " Package is not signed"
echo " â Package is not signed"
fi
# Size information

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Atomic deployment system for Ubuntu uBlue apt-layer Tool
# Implements commit-based state management and true system upgrades (not package upgrades)
@ -314,7 +315,7 @@ atomic_status() {
fi
if [[ -n "$pending_deployment" ]]; then
echo "⚠️ Pending deployment will activate on next boot"
echo "â ď¸ Pending deployment will activate on next boot"
fi
}

View file

@ -1,3 +1,4 @@
#!/bin/bash
# rpm-ostree compatibility layer for Ubuntu uBlue apt-layer Tool
# Provides 1:1 command compatibility with rpm-ostree

View file

@ -657,11 +657,11 @@ get_layer_signing_status() {
# Check if layer exists
if [[ ! -f "$layer_path" ]]; then
echo " Layer file not found"
echo " â Layer file not found"
return 1
fi
echo " Layer file exists"
echo " â Layer file exists"
# Check for signatures
local signature_db="$LAYER_SIGNING_SIGNATURES_DIR/signatures.json"
@ -679,21 +679,21 @@ get_layer_signing_status() {
local signed_at
signed_at=$(echo "$signature_info" | jq -r '.signed_at // "unknown"')
echo " Signed with $method using key: $key_name"
echo " Signature status: $status"
echo " Signed at: $signed_at"
echo " â Signed with $method using key: $key_name"
echo " â Signature status: $status"
echo " â Signed at: $signed_at"
else
echo " No signature found"
echo " â No signature found"
fi
else
echo " Signature database not found"
echo " â Signature database not found"
fi
# Check for revocation
if check_layer_revocation "$layer_path"; then
echo " Layer is revoked"
echo " â  Layer is revoked"
else
echo " Layer is not revoked"
echo " â Layer is not revoked"
fi
echo ""

View file

@ -9,10 +9,10 @@ YELLOW='\033[1;33m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m'
CHECK=""
WARN="⚠️ "
CROSS=""
INFO=" "
CHECK="в"
WARN="в пё "
CROSS="в"
INFO="в№пё "
# --- Helper: Check for WSL ---
is_wsl() {

View file

@ -521,16 +521,16 @@ check_tenant_health() {
# Check tenant exists
if [[ ! -d "$tenant_dir" ]]; then
echo " Tenant directory not found"
echo "â Tenant directory not found"
return 1
fi
if ! jq -e ".tenants[] | select(.name == \"$tenant_name\")" "$tenant_db" > /dev/null 2>&1; then
echo " Tenant not found in database"
echo "â Tenant not found in database"
return 1
fi
echo " Tenant exists"
echo "â Tenant exists"
# Check directory structure
local missing_dirs=()
@ -541,9 +541,9 @@ check_tenant_health() {
done
if [[ ${#missing_dirs[@]} -gt 0 ]]; then
echo "⚠️ Missing directories: ${missing_dirs[*]}"
echo "â ï¸ Missing directories: ${missing_dirs[*]}"
else
echo " Directory structure complete"
echo "â Directory structure complete"
fi
# Check quota usage
@ -556,7 +556,7 @@ check_tenant_health() {
storage_used=$(echo "$tenant_info" | jq -r '.quotas.used_storage_gb')
storage_max=$(echo "$tenant_info" | jq -r '.quotas.max_storage_gb')
echo "📊 Resource Usage:"
echo "ð Resource Usage:"
echo " Layers: $layers_used/$layers_max"
echo " Storage: ${storage_used}GB/${storage_max}GB"
@ -565,14 +565,14 @@ check_tenant_health() {
local storage_percent=$((storage_used * 100 / storage_max))
if [[ $layer_percent -gt 80 ]]; then
echo "⚠️ Layer quota usage high: ${layer_percent}%"
echo "â ï¸ Layer quota usage high: ${layer_percent}%"
fi
if [[ $storage_percent -gt 80 ]]; then
echo "⚠️ Storage quota usage high: ${storage_percent}%"
echo "â ï¸ Storage quota usage high: ${storage_percent}%"
fi
echo " Tenant health check complete"
echo "â Tenant health check complete"
}
# Multi-tenant command handler

View file

@ -683,25 +683,25 @@ cloud_security_status() {
# Check if system is initialized
if [[ -d "$cloud_security_dir" ]]; then
echo " System initialized: $cloud_security_dir"
echo "â System initialized: $cloud_security_dir"
# Check configuration
local config_file="$cloud_security_dir/cloud-security-config.json"
if [[ -f "$config_file" ]]; then
echo " Configuration: $config_file"
echo "â Configuration: $config_file"
local enabled_providers=$(jq -r '.enabled_providers[]' "$config_file" 2>/dev/null | tr '\n' ', ' | sed 's/,$//')
echo " Enabled providers: $enabled_providers"
else
echo " Configuration missing"
echo "â Configuration missing"
fi
# Check directories
local dirs=("scans" "policies" "reports" "integrations")
for dir in "${dirs[@]}"; do
if [[ -d "$cloud_security_dir/$dir" ]]; then
echo " $dir directory: $cloud_security_dir/$dir"
echo "â $dir directory: $cloud_security_dir/$dir"
else
echo " $dir directory missing"
echo "â $dir directory missing"
fi
done
@ -710,13 +710,13 @@ cloud_security_status() {
local policy_count=$(find "$cloud_security_dir/policies" -name "*.json" 2>/dev/null | wc -l)
local report_count=$(find "$cloud_security_dir/reports" -name "*.json" 2>/dev/null | wc -l)
echo "📊 Statistics:"
echo "ð Statistics:"
echo " Security scans: $scan_count"
echo " Policy files: $policy_count"
echo " Compliance reports: $report_count"
else
echo " System not initialized"
echo "â System not initialized"
echo " Run 'cloud-security init' to initialize"
fi
}

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Direct dpkg installation for Particle-OS apt-layer Tool
# Provides faster, more controlled package installation using dpkg directly

View file

@ -1,3 +1,4 @@
#!/bin/bash
# Main execution and command dispatch for Particle-OS apt-layer Tool
# Show concise usage information