copr enbale
This commit is contained in:
parent
d59a4fe592
commit
75e8f2db85
2 changed files with 160 additions and 23 deletions
59
README.md
59
README.md
|
|
@ -1,10 +1,11 @@
|
|||
# Forge - A Home-Manager Like Tool for Fedora
|
||||
|
||||
A lightweight configuration management tool for Fedora that provides dotfile management and package installation functionality through a centralized TOML configuration.
|
||||
A lightweight configuration management tool for Fedora that provides COPR repository management, dotfile management and package installation functionality through a centralized TOML configuration.
|
||||
|
||||
## Overview
|
||||
|
||||
Forge is a bash script that helps you manage your Fedora system configuration by:
|
||||
- Managing COPR repositories (enable/disable automatically)
|
||||
- Installing and managing system packages via dnf
|
||||
- Managing dotfiles through symlinks to actual files
|
||||
- Centralized configuration via a single `forge.toml` file
|
||||
|
|
@ -53,17 +54,19 @@ Creates:
|
|||
- `~/.config/forge/forge.toml` - Central configuration file
|
||||
|
||||
### `switch`
|
||||
Apply the current configuration (install packages, deploy dotfiles).
|
||||
Apply the current configuration (enable COPR, install packages, deploy dotfiles).
|
||||
|
||||
```bash
|
||||
./forge switch
|
||||
```
|
||||
|
||||
This command:
|
||||
1. Installs all packages listed in `forge.toml`
|
||||
2. Creates symlinks for all configured dotfiles
|
||||
3. Creates backups of existing files before replacing them
|
||||
4. Updates the last switch timestamp
|
||||
1. Enables all COPR repositories listed in `forge.toml`
|
||||
2. Disables COPR repositories that are no longer configured
|
||||
3. Installs all packages listed in `forge.toml`
|
||||
4. Creates symlinks for all configured dotfiles
|
||||
5. Creates backups of existing files before replacing them
|
||||
6. Updates the last switch timestamp
|
||||
|
||||
### `status`
|
||||
Show current configuration status and information.
|
||||
|
|
@ -75,7 +78,7 @@ Show current configuration status and information.
|
|||
Displays:
|
||||
- Configuration directory paths
|
||||
- Last switch timestamp
|
||||
- List of configured packages and dotfiles
|
||||
- List of configured COPR repositories, packages and dotfiles
|
||||
|
||||
### `help`
|
||||
Show help message with all available commands.
|
||||
|
|
@ -97,6 +100,12 @@ The central configuration file located at `~/.config/forge/forge.toml`:
|
|||
version = "1.0"
|
||||
last_switch = null
|
||||
|
||||
[copr]
|
||||
# COPR repositories to enable
|
||||
# Just list COPR repository names - presence means enable, absence means don't enable
|
||||
copr.fedorainfracloud.org/username/repository
|
||||
copr.fedorainfracloud.org/anotheruser/anotherrepo
|
||||
|
||||
[packages]
|
||||
# List of packages to install using dnf
|
||||
# Just list package names - presence means install, absence means don't install
|
||||
|
|
@ -126,6 +135,18 @@ backup_dir = "backup"
|
|||
- `version`: Configuration file version
|
||||
- `last_switch`: Timestamp of last switch operation (auto-updated)
|
||||
|
||||
#### `[copr]`
|
||||
List of COPR repositories to enable via `dnf copr enable`. **Just list COPR repository names** - presence means enable, absence means don't enable.
|
||||
|
||||
**Examples:**
|
||||
```toml
|
||||
[copr]
|
||||
copr.fedorainfracloud.org/username/repository
|
||||
copr.fedorainfracloud.org/anotheruser/anotherrepo
|
||||
```
|
||||
|
||||
To remove a COPR repository, simply delete the line containing the repository name. Forge will automatically disable it during the next switch.
|
||||
|
||||
#### `[packages]`
|
||||
List of packages to install via dnf. **Just list package names** - presence means install, absence means don't install.
|
||||
|
||||
|
|
@ -168,6 +189,13 @@ Additional configuration options:
|
|||
|
||||
## How It Works
|
||||
|
||||
### COPR Repository Management
|
||||
COPR repositories are managed through the `[copr]` section in `forge.toml`:
|
||||
- **Add COPR repo**: Simply add the repository name on a new line
|
||||
- **Remove COPR repo**: Delete the line containing the repository name
|
||||
- **Automatic cleanup**: Forge automatically disables COPR repos that are removed from configuration
|
||||
- **No flags needed**: Just presence/absence of the repository name matters
|
||||
|
||||
### Package Management
|
||||
Packages are managed through the `[packages]` section in `forge.toml`:
|
||||
- **Add package**: Simply add the package name on a new line
|
||||
|
|
@ -195,9 +223,12 @@ Before creating symlinks, Forge:
|
|||
# Initialize forge
|
||||
./forge init
|
||||
|
||||
# Edit forge.toml to add packages
|
||||
# Edit forge.toml to add COPR repos and packages
|
||||
nano ~/.config/forge/forge.toml
|
||||
|
||||
# Add to [copr] section:
|
||||
copr.fedorainfracloud.org/username/cool-repo
|
||||
|
||||
# Add to [packages] section:
|
||||
git
|
||||
vim
|
||||
|
|
@ -230,6 +261,17 @@ nano ~/.config/forge/forge.toml
|
|||
./forge switch
|
||||
```
|
||||
|
||||
### COPR Repository Management Examples
|
||||
```toml
|
||||
[copr]
|
||||
# Development tools COPR
|
||||
copr.fedorainfracloud.org/development/tools
|
||||
copr.fedorainfracloud.org/user/neovim-nightly
|
||||
|
||||
# To remove a COPR repo, just delete the line
|
||||
# Forge will automatically disable it during the next switch
|
||||
```
|
||||
|
||||
### Package Management Examples
|
||||
```toml
|
||||
[packages]
|
||||
|
|
@ -269,6 +311,7 @@ git commit -m "Updated vim configuration"
|
|||
## Dependencies
|
||||
|
||||
- `dnf` - Fedora package manager
|
||||
- `dnf-plugins-core` - For COPR repository management
|
||||
- `sed` - For updating configuration file (usually pre-installed)
|
||||
|
||||
## Migration from Previous Version
|
||||
|
|
|
|||
100
forge
100
forge
|
|
@ -50,6 +50,13 @@ init() {
|
|||
version = "1.0"
|
||||
last_switch = null
|
||||
|
||||
[copr]
|
||||
# COPR repositories to enable
|
||||
# Just list COPR repository names - presence means enable, absence means don't enable
|
||||
# Examples:
|
||||
# copr.fedorainfracloud.org/username/repository
|
||||
# copr.fedorainfracloud.org/anotheruser/anotherrepo
|
||||
|
||||
[packages]
|
||||
# List of packages to install using dnf
|
||||
# Just list package names - presence means install, absence means don't install
|
||||
|
|
@ -102,10 +109,71 @@ parse_toml() {
|
|||
elif [[ "$section" == "packages" && "$line" =~ ^([^=]+)$ ]]; then
|
||||
local package="${BASH_REMATCH[1]// /}"
|
||||
echo "$section:$package"
|
||||
# Parse COPR repository names (just keys without values in copr section)
|
||||
elif [[ "$section" == "copr" && "$line" =~ ^([^=]+)$ ]]; then
|
||||
local copr_repo="${BASH_REMATCH[1]// /}"
|
||||
echo "$section:$copr_repo"
|
||||
fi
|
||||
done <"$FORGE_TOML"
|
||||
}
|
||||
|
||||
# Enable COPR repositories from forge.toml
|
||||
enable_copr_repos() {
|
||||
log_info "Enabling COPR repositories..."
|
||||
|
||||
local copr_enabled=false
|
||||
|
||||
while IFS='=' read -r entry; do
|
||||
local section="${entry%%:*}"
|
||||
local copr_repo="${entry#*:}"
|
||||
|
||||
if [[ "$section" == "copr" && -n "$copr_repo" ]]; then
|
||||
copr_enabled=true
|
||||
log_info "Enabling COPR repository: $copr_repo"
|
||||
if sudo dnf copr enable -y "$copr_repo"; then
|
||||
log_success "Enabled COPR: $copr_repo"
|
||||
else
|
||||
log_error "Failed to enable COPR: $copr_repo"
|
||||
fi
|
||||
fi
|
||||
done < <(parse_toml)
|
||||
|
||||
if [[ "$copr_enabled" == false ]]; then
|
||||
log_info "No COPR repositories to enable"
|
||||
fi
|
||||
}
|
||||
|
||||
# Disable COPR repositories that are no longer in forge.toml
|
||||
disable_copr_repos() {
|
||||
log_info "Checking for COPR repositories to disable..."
|
||||
|
||||
# Get currently enabled COPR repos
|
||||
local enabled_repos=$(sudo dnf copr list --enabled 2>/dev/null | grep -E "copr\.fedorainfracloud\.org" | awk '{print $1}' || true)
|
||||
|
||||
# Get configured COPR repos from forge.toml
|
||||
local configured_repos=""
|
||||
while IFS='=' read -r entry; do
|
||||
local section="${entry%%:*}"
|
||||
local copr_repo="${entry#*:}"
|
||||
|
||||
if [[ "$section" == "copr" && -n "$copr_repo" ]]; then
|
||||
configured_repos="$configured_repos $copr_repo"
|
||||
fi
|
||||
done < <(parse_toml)
|
||||
|
||||
# Disable repos that are enabled but not configured
|
||||
for repo in $enabled_repos; do
|
||||
if [[ ! " $configured_repos " =~ " $repo " ]]; then
|
||||
log_info "Disabling COPR repository: $repo"
|
||||
if sudo dnf copr disable -y "$repo"; then
|
||||
log_success "Disabled COPR: $repo"
|
||||
else
|
||||
log_error "Failed to disable COPR: $repo"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Install packages from forge.toml
|
||||
install_packages() {
|
||||
log_info "Installing packages..."
|
||||
|
|
@ -194,6 +262,12 @@ switch() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Enable COPR repositories
|
||||
enable_copr_repos
|
||||
|
||||
# Disable COPR repositories that are no longer configured
|
||||
disable_copr_repos
|
||||
|
||||
# Install packages
|
||||
install_packages
|
||||
|
||||
|
|
@ -226,6 +300,25 @@ status() {
|
|||
echo " Last switch: Never"
|
||||
fi
|
||||
|
||||
echo
|
||||
log_info "COPR Repositories:"
|
||||
local copr_count=0
|
||||
while IFS='=' read -r entry; do
|
||||
local section="${entry%%:*}"
|
||||
local copr_repo="${entry#*:}"
|
||||
|
||||
if [[ "$section" == "copr" && -n "$copr_repo" ]]; then
|
||||
echo " $copr_repo"
|
||||
((copr_count++))
|
||||
fi
|
||||
done < <(parse_toml)
|
||||
|
||||
if [[ $copr_count -eq 0 ]]; then
|
||||
echo " No COPR repositories configured"
|
||||
else
|
||||
echo " Total: $copr_count COPR repositories"
|
||||
fi
|
||||
|
||||
echo
|
||||
log_info "Packages:"
|
||||
local package_count=0
|
||||
|
|
@ -280,12 +373,13 @@ show_help() {
|
|||
|
||||
COMMANDS:
|
||||
init Initialize configuration structure (creates forge.toml)
|
||||
switch Apply configuration (install packages, deploy dotfiles)
|
||||
switch Apply configuration (enable COPR, install packages, deploy dotfiles)
|
||||
status Show current configuration status
|
||||
help Show this help message
|
||||
|
||||
FEATURES:
|
||||
- TOML-based configuration in forge.toml
|
||||
- COPR repository management (enable/disable automatically)
|
||||
- Package management via dnf
|
||||
- Dotfile management via symlinks
|
||||
- Automatic backup of existing files
|
||||
|
|
@ -293,11 +387,11 @@ show_help() {
|
|||
|
||||
FILES:
|
||||
$FORGE_DIR/ Main configuration directory
|
||||
$FORGE_TOML Configuration file for packages and dotfiles
|
||||
$FORGE_TOML Configuration file for COPR, packages and dotfiles
|
||||
|
||||
EXAMPLES:
|
||||
forge init
|
||||
# Edit $FORGE_TOML to add packages and dotfiles
|
||||
# Edit $FORGE_TOML to add COPR repos, packages and dotfiles
|
||||
forge switch
|
||||
forge status
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue