A modular system update script for Arch Linux that follows the Unix philosophy of small, focused tools working together. This script handles system updates, AUR packages, Flatpak updates, and system maintenance tasks in a reliable and maintainable way.
- Modular Design:
- Split into focused, maintainable components
- Extensible module system with priority-based execution
- Easy enable/disable via file extensions
- Comprehensive System Checks: Verifies system health before updates
- Smart Package Management:
- Supports both official repos and AUR
- Handles multiple AUR helpers (yay/paru)
- Fallback to pacman if AUR helper unavailable
- System Maintenance:
- Cleans package cache (with automatic backups)
- Removes orphaned packages (with backup lists)
- Manages system logs
- Updates mirrors (if reflector is installed)
- Error Handling:
- Proper error detection and reporting
- Graceful failure handling
- Detailed logging
- Optional Updates:
- Flatpak packages (if installed)
- oh-my-posh (if installed)
- User Interface:
- Smart terminal detection
- Automatic Nerd Font detection
- ASCII fallback for compatibility
- Educational output with context
- Progress indicators and status messages
# Clone the repository
git clone https://github.com/yourusername/arch-update.git
cd arch-update
# Run the installer
./deploy.sh
The installer will:
- Verify it's running from a git repository (required for deployment)
- Check for existing deployment:
- Warns about any local modifications
- Detects extra files not in git repository
- Offers to clean up extra files
- Create directory ~/.local/share/update-arch
- Copy all tracked files from git
- Create symlink in ~/.local/bin
- Set appropriate permissions
Note: The deployment process uses git to track files and manage changes:
- Local modifications to deployed files will be detected and reported
- Extra files in deployment directory are identified
- Users are encouraged to manage custom changes through git
Run with no arguments to see help:
update-arch
To perform updates:
update-arch --run
Available options:
-h, --help Show help message
--version Show version information
--configure-terminal Configure terminal preferences
--dry-run Show what would be updated without changes (planned)
--run Run the update process
The update process will:
- Perform system health checks
- Update system packages
- Handle AUR updates
- Clean up orphaned packages
- Manage logs
- Show system information
Core:
- update.sh: Main script orchestrator
- system-check.sh: Pre-update system health verification
- package-update.sh: Package management operations
- utils.sh: Core utilities including:
- Logging setup and helper functions
- Color-coded status messages
- Smart icon system:
- Automatic Nerd Font detection
- ASCII fallback for compatibility
- Material Design icons when supported
- Override via FORCE_ASCII_ICONS=1
- Educational message boxes with:
- Blue borders for visual structure
- Cyan headers for section titles
- Light green content for educational messages
- Adaptive icons for visual cues
- Learn-more links to documentation
Modules (in modules/):
-
Named with priority prefix like udev rules (e.g., 10-pacman.sh)
-
Organized into three main categories:
- System Modules (10-29):
- Core system maintenance tasks recommended by Arch Wiki
- Educational output explaining each maintenance operation
- Examples: package updates, mirror management, system checks
- User Modules (50-79):
- User-specific customization maintenance
- Detailed output about user-level updates
- Examples: oh-my-posh, custom AUR packages, user tools
- Status Modules (90-99):
- Post-update system status checks
- System service health verification
- System information display
- System Modules (10-29):
-
Example modules are provided but disabled by default:
- 10-example-system.sh.disabled: Template for system modules
- 50-example-user.sh.disabled: Template for user modules
- Study these examples when creating new modules
- Remove .disabled extension to activate them
- Or copy them to create new modules
-
Each module provides verbose, educational output to help users:
- Understand what maintenance tasks are being performed
- Learn system administration best practices
- Gain familiarity with Arch Linux maintenance
- Links to relevant documentation
-
Status controlled by extension:
- .sh: Module is enabled
- .disabled (or any non-.sh): Module is disabled
Required:
- bash
- sudo
- pacman
- systemd
Optional:
- yay or paru (for AUR support)
- reflector (for mirror updates)
- flatpak
- oh-my-posh
- fastfetch (for system information display)
-
System Modules (10-29):
- Essential system maintenance tasks
- Follow Arch Wiki recommendations
- Educational output for learning
- Example: 10-pacman.sh, 15-mirrors.sh
-
User Modules (50-79):
- User customization maintenance
- Personal tool updates
- Example: 50-oh-my-posh.sh
-
Status Modules (90-99):
- System health verification
- Service status checks
- System information display
Enable a module:
mv XX-modulename.disabled XX-modulename.sh && chmod +x XX-modulename.sh
Disable a module:
mv XX-modulename.sh XX-modulename.disabled
Create a new module:
update-arch --create-module -t [system|user|status]
This will:
- Automatically assign the next available number based on type:
- system: 10-49 range
- user: 50-89 range
- status: 90+ range
- Create both .sh and .md files from templates
- Make the module executable
- Guide you through:
- Module naming and description
- Git commit best practices
- Deployment instructions
Each module must implement:
- check_supported(): Returns 0 if module can run
- run_update(): Performs the actual update
The script includes smart terminal handling:
- Automatic terminal type detection
- Support for common terminal emulators
- Multiplexer detection (tmux, screen)
- Configurable preferences
- Icon set selection based on capabilities
Configure terminal preferences:
update-arch --configure-terminal
This allows you to:
- Force ASCII icons if needed
- Set preferred terminal type
- Override auto-detection
- Configure update frequency
Logs are stored in /var/log/system_updates/
with automatic rotation (keeps last 5 logs).
The script automatically creates backups during maintenance operations:
-
Package Management:
- Orphaned package lists backed up before removal
- Package cache state preserved before cleaning
- Backup location: /tmp/update-scripts/
-
System Updates:
- Package lists saved before major updates
- AUR package state preserved
- Flatpak update logs maintained
-
Permission Denied
sudo chmod +x ~/.local/share/update-arch/*.sh
-
Command Not Found
- Ensure ~/.local/bin is in your PATH
- Check if symlink exists:
ls -l ~/.local/bin/update-arch
-
AUR Helper Issues
- Script will automatically fall back to pacman
- Install yay or paru for AUR support
-
Terminal Display Issues
- Use --configure-terminal to adjust display settings
- Set FORCE_ASCII_ICONS=1 for compatibility mode
- Check terminal font support
- "System health checks failed": Check system status and logs
- "Failed to update packages": Check internet connection and pacman status
- "Failed to initialize logging": Ensure /var/log is writable
- "Module validation failed": Check module type matches its number range
~/.local/share/update-arch/deploy.sh --uninstall
Current version: 0.2.0
The version number follows semantic versioning:
- MAJOR: Incompatible API changes
- MINOR: Backwards-compatible features
- PATCH: Backwards-compatible fixes
MIT License - See LICENSE file for details
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request