An open API service indexing awesome lists of open source software.

https://github.com/roimme65/gentoo-updater

🐧 Automatischer System-Updater für Gentoo Linux mit emerge, eix-Integration, Kernel-Checks und Konfigurations-Prüfung
https://github.com/roimme65/gentoo-updater

automation gentoo-linux update

Last synced: 2 months ago
JSON representation

🐧 Automatischer System-Updater für Gentoo Linux mit emerge, eix-Integration, Kernel-Checks und Konfigurations-Prüfung

Awesome Lists containing this project

README

          

# Gentoo System Updater

**Languages:** πŸ‡¬πŸ‡§ [English](README.md) | πŸ‡©πŸ‡ͺ [Deutsch](README.de.md)

Automated update solution for Gentoo Linux that simplifies and automates the entire system update process.

## Features

### πŸš€ Performance & Optimization
- ⚑ **Parallel Compilation** with automatic CPU detection (`--jobs` and `--load-average`)
- πŸ“Š **Intelligent Update Detection** - Rebuild kernel modules only when needed
- πŸ’Ύ **Disk Space Check** before updates
- πŸ”„ **Automatic Retry** on manifest errors

### πŸ“¦ Update Functions
- πŸ”„ **Repository Synchronisation** (`emerge --sync`)
- πŸ“š **eix Database Update** (optional)
- πŸ“¦ **System Update** (full `@world` update)
- πŸ”§ **Intelligent Kernel Module Recompilation** (NVIDIA, VirtualBox, etc.)
- 🧹 **Automatic Cleanup** (`emerge --depclean`)
- πŸ”§ **Dependency Repair** (`revdep-rebuild`)

### πŸ›‘οΈ Security & Reliability
- πŸ’Ύ **Automatic Backups** of important configuration files
- πŸ” **Blocked Packages Check** before updates
- ⚠️ **Critical Package Warning** (gcc, glibc, Python)
- πŸ“ **Full Logging System** with JSON export
- 🎯 **Robust Error Handling** with detailed logs

### πŸ“Š Monitoring & Reports
- πŸ“ˆ **Update Summary** with statistics
- 🌍 **Mirror Logging** - Shows all configured Gentoo mirrors & primary mirror
- πŸ“§ **Email Notifications** (optional)
- πŸ“ **Automatic Log Rotation**
- 🎨 **Colored Output** with clear structure

### βš™οΈ Configuration
- πŸ“„ **JSON Configuration File** for customization
- πŸ”§ **Flexible emerge Options**
- ⚑ **Dry-Run Mode** for testing

### πŸ†• v1.4.0 Advanced Parameters
- πŸŽ›οΈ **--log-level** (DEBUG/INFO/WARNING/ERROR)
- ⏭️ **--skip-*** options (sync, update, eix, cleanup, revdep)
- 🎯 **--only-*** options (execute specific steps only)
- πŸ“¦ **--max-packages N** (limit updates)
- ⏱️ **--timeout SECONDS** (set emerge timeout)
- πŸ”„ **--retry-count N** (automatic retries on failure)
- πŸ”” **--notification-webhook URL** (send notifications)
- βš™οΈ **--parallel-jobs N** (override job count)
- 🌍 **Environment Variables** (GENTOO_UPDATER_*)

## Requirements

- Gentoo Linux
- Python 3.6+
- Root/sudo privileges
- Optional: `eix` for faster package searches
- Optional: `gentoolkit` for `revdep-rebuild`

## Installation

### Method 1: Automatic Installation

```bash
git clone https://github.com/roimme65/gentoo-updater.git
cd gentoo-updater
sudo ./install.sh
```

### Method 2: Manual Installation

```bash
# Download script
git clone https://github.com/roimme65/gentoo-updater.git
cd gentoo-updater

# Make executable
chmod +x gentoo-updater.py

# Copy to /usr/local/bin (optional)
sudo cp gentoo-updater.py /usr/local/bin/gentoo-updater
```

### Method 3: PyPI (Coming in v1.4.0+)

```bash
pip install gentoo-updater
```

## Usage

### Full System Update

```bash
sudo gentoo-updater
```

### Create Configuration

On first run, create default configuration:

```bash
sudo gentoo-updater --create-config
```

This creates `/etc/gentoo-updater.conf` with options:
- **emerge_jobs**: Number of parallel jobs (auto = CPU cores)
- **emerge_load_average**: Maximum system load
- **enable_backups**: Enable automatic backups
- **backup_dir**: Backup directory
- **enable_notifications**: Enable email notifications
- **notification_email**: Email address
- **min_free_space_gb**: Minimum free space required
- **auto_depclean**: Enable automatic depclean
- **auto_revdep_rebuild**: Enable automatic revdep-rebuild
- **critical_packages**: List of critical packages
- **log_retention_days**: Log retention in days

Example config: see [gentoo-updater.conf.example](gentoo-updater.conf.example)

### Dry-Run Mode

```bash
sudo gentoo-updater --dry-run
```

### Verbose Output

```bash
sudo gentoo-updater --verbose
```

### Advanced Parameters (v1.4.0+)

```bash
# Log level control
sudo gentoo-updater --log-level DEBUG

# Skip specific steps
sudo gentoo-updater --skip-cleanup --skip-revdep

# Execute only specific steps
sudo gentoo-updater --only-sync # Only repository sync
sudo gentoo-updater --only-update # Only system update

# Limit packages
sudo gentoo-updater --max-packages 50

# Set timeout
sudo gentoo-updater --timeout 3600

# Retry on failure
sudo gentoo-updater --retry-count 3

# Override parallel jobs
sudo gentoo-updater --parallel-jobs 8

# Send webhook notification
sudo gentoo-updater --notification-webhook "https://example.com/webhook"
```

### Environment Variables (v1.4.0+)

```bash
# Enable dry-run via environment variable
GENTOO_UPDATER_DRY_RUN=true sudo gentoo-updater

# Debug logging
GENTOO_UPDATER_LOG_LEVEL=DEBUG sudo gentoo-updater

# Set timeout
GENTOO_UPDATER_TIMEOUT=3600 sudo gentoo-updater

# Enable retry
GENTOO_UPDATER_RETRY_COUNT=3 sudo gentoo-updater

# Override parallel jobs
GENTOO_UPDATER_PARALLEL_JOBS=4 sudo gentoo-updater
```

### Kernel Module Recompilation

Recompile kernel modules (useful after manual kernel update):

```bash
sudo gentoo-updater --rebuild-modules
```

This rebuilds external kernel modules:
- NVIDIA drivers (`nvidia-drivers`)
- VirtualBox modules (`virtualbox-modules`)
- ZFS modules
- Other external modules

### Custom Configuration File

```bash
sudo gentoo-updater --config /path/to/my-config.conf
```

### Show Help

```bash
gentoo-updater --help
```

## What the Script Does

The script automatically executes these steps:

1. **Repository Synchronisation**
- Reads GENTOO_MIRRORS from `/etc/portage/make.conf`
- Displays all configured mirrors
- Runs `emerge --sync` to update the Portage tree

2. **eix Database Update**
- Runs `eix-update` to update eix database (if installed)

3. **Update Check**
- Checks for available updates
- Shows list of packages to update

4. **System Update**
- Runs `emerge @world --update --deep --newuse`
- Monitors for critical package updates
- Only rebuilds kernel modules if kernel was updated

5. **Cleanup**
- Runs `emerge --depclean` to remove unused packages

6. **Dependency Repair**
- Runs `revdep-rebuild` to fix broken dependencies (if gentoolkit installed)

7. **Kernel Check**
- Shows available kernel versions
- Provides hints for manual kernel updates

8. **Configuration Check**
- Searches for ._cfg files
- Alerts about pending configuration updates

## Logs & Backups

### Logs
The script automatically creates detailed logs:
- Log file: `/var/log/gentoo-updater/update-YYYYMMDD-HHMMSS.log`
- JSON summary: `/var/log/gentoo-updater/update-YYYYMMDD-HHMMSS.json`
- Real-time output to terminal
- Automatic log rotation (default: 30 days)

### Backups
Before each update, these files are backed up:
- `/etc/portage/make.conf`
- `/etc/portage/package.use`
- `/etc/portage/package.accept_keywords`
- `/var/lib/portage/world`

Backup directory: `/var/backups/gentoo-updater/YYYYMMDD-HHMMSS/`

### Update Summary
After each update:
- 🌍 All configured Gentoo mirrors
- 🌍 Primary mirror (first available)
- Number of updated packages
- Number of removed packages
- Kernel update status
- Module rebuild status
- Errors and warnings
- Total duration

## Troubleshooting

### "Script requires root privileges"

```bash
sudo gentoo-updater
```

### Manifest quarantine errors

The script automatically handles manifest errors by:
1. Deleting the quarantine directory
2. Automatic retry of sync

If problems persist:

```bash
sudo rm -rf /var/db/repos/gentoo/.tmp-unverified-download-quarantine
sudo emerge --sync
```

### Missing kernel modules after kernel update

```bash
sudo gentoo-updater --rebuild-modules
```

### eix not found

```bash
sudo emerge --ask app-portage/eix
```

### revdep-rebuild not found

```bash
sudo emerge --ask app-portage/gentoolkit
```

## FAQ

**Q: Why are kernel modules not rebuilt?**

A: This is normal and correct! Modules are rebuilt only when:
- βœ… A kernel update occurred during system update, OR
- βœ… Running kernel β‰  Installed kernel (after manual kernel compilation)

Modules are NOT rebuilt when:
- ❌ Kernel is already compiled for current version

Why? To make updates faster! (5-10 minutes faster)

**Q: How do I force module rebuild?**

A: Use `--rebuild-modules` option:
```bash
sudo gentoo-updater --rebuild-modules
```

**Q: How long does an update take?**

A: Depends on update scope:
- **Without kernel update**: 5-10 minutes (modules NOT recompiled)
- **With kernel update**: 15-25 minutes (NVIDIA/VirtualBox modules recompiled)

**Q: What if I manually update the kernel?**

A: After manual kernel build:
```bash
eselect kernel set
cd /usr/src/linux
make oldconfig && make && make modules_install && make install
grub-mkconfig -o /boot/grub/grub.cfg

# Then:
sudo gentoo-updater --rebuild-modules
```

The script automatically detects kernel mismatch and rebuilds modules.

## Differences from Other Distributions

Gentoo requires more manual steps than other distributions:
- **Kernel Compilation** is manual (not automated)
- βœ… But: Kernel modules are automatically rebuilt!
- **Configuration Updates** require `dispatch-conf` or `etc-update`
- **Compilation** can take a long time (depends on hardware and USE flags)
- **USE flag changes** may require recompilation

## Common Use Cases

### Complete Weekend Update
```bash
sudo gentoo-updater
# Wait for completion...
# Check kernel updates and configs
# Reboot system
```

### Quick Module Rebuild After Manual Kernel Update
```bash
# After manual kernel build:
sudo gentoo-updater --rebuild-modules
sudo reboot
```

### Testing Without Changes
```bash
sudo gentoo-updater --dry-run
```

## License

MIT License - See LICENSE file

## Contributing

Contributions are welcome! Please create a pull request or open an issue.

## Changelog

### v1.4.0 (2026-02-06) - πŸ†• Advanced Parameters
- πŸŽ›οΈ **New Parameters:** --log-level, --skip-*, --only-*, --max-packages, --timeout, --retry-count, --notification-webhook, --parallel-jobs
- 🌍 **Environment Variables:** Full environment variable support (GENTOO_UPDATER_*)
- πŸ“ **Documentation:** Updated help with examples and environment variable docs
- ✨ **v1.4.0 Ready for PyPI:** All parameters fully implemented

### v1.3.3 (2026-02-06) - 🌍 Mirror Logging
- 🌍 **New Feature:** Mirror Logging
- Reads GENTOO_MIRRORS from `/etc/portage/make.conf`
- Displays all configured mirrors during repository sync
- Logs primary mirror to log file and JSON summary
- πŸ“Š Enhanced statistics with mirror information
- πŸ“ Improved logging during repository sync

## Author

Created for Gentoo Linux users

## See Also

- [Gentoo Wiki - Updating Gentoo](https://wiki.gentoo.org/wiki/Handbook:AMD64/Working/Portage#Updating_Gentoo)
- [Gentoo Wiki - eix](https://wiki.gentoo.org/wiki/Eix)
- [Gentoo Wiki - gentoolkit](https://wiki.gentoo.org/wiki/Gentoolkit)
- [GitHub Repository](https://github.com/roimme65/gentoo-updater)
- [Release Notes](https://github.com/roimme65/gentoo-updater/releases)