Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dnf module #377

Open
wants to merge 87 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
fd4ad28
feat: `dnf` module
fiftydinar Dec 22, 2024
cd91b05
chore: Add support for native installation of repos
fiftydinar Dec 22, 2024
cf3d495
docs: Revise the note about %OS_VERSION% in repos
fiftydinar Dec 22, 2024
2f392e7
fix: missing quote in echo
fiftydinar Dec 22, 2024
6d1047f
fix: Get raw COPR repos array elements without JSON brackets
fiftydinar Dec 22, 2024
9d13c87
chore: Auto-confirm prompts (`-y`) when adding repos
fiftydinar Dec 22, 2024
1396a18
fix: Accidental syntax error for `done`
fiftydinar Dec 22, 2024
b898af2
chore: Remove useless echo
fiftydinar Dec 22, 2024
6523979
chore: Install & remove using `dnf` in single operation cases
fiftydinar Dec 22, 2024
97566b8
docs: Add note that URL is not preferred for copr repos
fiftydinar Dec 22, 2024
0bb79d0
fix: `/opt` symlink issue & migrate removal + install to `dnf`
fiftydinar Dec 22, 2024
70c5766
chore: Document code some more
fiftydinar Dec 22, 2024
e01ed40
docs: Fix note about using install & remove at the same time
fiftydinar Dec 22, 2024
7d4aff9
chore: Add `dnf` to `modules.json`
fiftydinar Dec 22, 2024
a4e9ba4
chore: Add support for replacing packages
fiftydinar Dec 22, 2024
7da24f5
chore: Add option to enable or disable installation of weak dependencies
fiftydinar Dec 22, 2024
d495b6a
docs: Style backtick fix
fiftydinar Dec 22, 2024
1137c8b
fix(rpm-ostree): Symlinking `/opt/` multiple times caused an error
fiftydinar Dec 22, 2024
eb522e3
chore: Rename `weak-dependencies` to `install-weak-dependencies` & ad…
fiftydinar Dec 22, 2024
57f8b22
chore: Change `copr: user/project` formt to `COPR user/project`
fiftydinar Dec 22, 2024
7a5bcea
fix: Syntax error due to redundant `fi`
fiftydinar Dec 22, 2024
c7ae430
fix: Restore logic about not removing any newlines to COPR repos
fiftydinar Dec 22, 2024
b1a7c6f
feat: Add removal & installation of RPM groups
fiftydinar Dec 22, 2024
b7c0206
docs: Style fix
fiftydinar Dec 22, 2024
feb0d71
chore: Make sorting order in typespec better
fiftydinar Dec 22, 2024
fba3840
typespec: Minor leftover fix
fiftydinar Dec 22, 2024
e27ba39
chore: Fix typespec replace definition
fiftydinar Dec 22, 2024
a53dd5b
chore: Add mutter-patched COPR to module.yml
fiftydinar Dec 22, 2024
1a81609
fix: Forgot to replace `rpm-ostree` to `dnf` when checking for local …
fiftydinar Dec 23, 2024
a72ae5c
fix: Adding local file repos
fiftydinar Dec 23, 2024
2790123
fix: Replacing packages
fiftydinar Dec 23, 2024
ecffeae
chore: Make error message consistent
fiftydinar Dec 23, 2024
84f89d0
chore: Begin implementation of specific flag options for every instal…
fiftydinar Dec 23, 2024
5d7f34b
chore: Simplify printing log message for install packages
fiftydinar Dec 23, 2024
7fc5a24
feat: Add dnf flags to all operations
fiftydinar Dec 23, 2024
63f745b
feat: Add `remove-unused-dependencies` option for package removal
fiftydinar Dec 23, 2024
b474a5a
chore: Fix group-remove typespec
fiftydinar Dec 23, 2024
770bb33
chore: Fix group-install typespec
fiftydinar Dec 23, 2024
d8a9006
chore: Fix remove typespec
fiftydinar Dec 23, 2024
33065b4
chore: Fix install typespec
fiftydinar Dec 23, 2024
3423190
chore: Remove leftover global `install-weak-dependencies` option
fiftydinar Dec 23, 2024
f176120
chore: Remove redundant dnf5 plugin check
fiftydinar Dec 23, 2024
7458b4b
fix: dnf group remove command missed `group` prefix
fiftydinar Dec 23, 2024
ce4163c
fix: Don't quote the flags, else dnf will see it as an empty argument…
fiftydinar Dec 24, 2024
c8043a4
fix: Don't quote the flags, else dnf will see it as an empty argument…
fiftydinar Dec 24, 2024
aa92eff
fix: Don't quote the flags, else dnf will see it as an empty argument…
fiftydinar Dec 24, 2024
8265b85
fix: Don't quote the flags, else dnf will see it as an empty argument…
fiftydinar Dec 24, 2024
c9f4fb0
fix: Don't quote the flags, else dnf will see it as an empty argument…
fiftydinar Dec 24, 2024
92df6a0
fix: Don't quote the flags, else dnf will see it as an empty argument…
fiftydinar Dec 24, 2024
e66b176
Merge branch 'main' into dnf-module
fiftydinar Dec 25, 2024
4920cc4
chore: Add separate `copr` array
fiftydinar Dec 25, 2024
7612cc2
fix: Assume yes for copr enable
gmpinder Dec 26, 2024
4c17647
Merge branch 'main' into dnf-module
gmpinder Dec 30, 2024
f2d6adf
feat: Add optfix systemd service
gmpinder Dec 30, 2024
72bd1db
chore: Update `rpm-ostree` from main
fiftydinar Jan 3, 2025
533bc57
Start work on making this a nushell module
gmpinder Feb 2, 2025
e06e9d1
Merge branch 'main' into dnf-module
gmpinder Feb 11, 2025
120285d
docs: create the skeleton for a new readme
xynydev Feb 18, 2025
00d3ee6
Abstract the generation of install args
gmpinder Feb 18, 2025
dc051c0
fix: Optfix script dir changes and module.yml docs
gmpinder Feb 18, 2025
0003b97
Merge branch 'main' into dnf-module
gmpinder Feb 19, 2025
e86be19
feat: Add nonfree repo additions
gmpinder Feb 19, 2025
360c7e9
fix: Go back to removing repo files and clean up negativo repos befor…
gmpinder Feb 24, 2025
a2fd86f
chore: Update README documentation
gmpinder Mar 7, 2025
d967c53
Merge branch 'main' into dnf-module
fiftydinar Mar 10, 2025
0e12722
docs: Add known issue about replacing kernel
fiftydinar Mar 10, 2025
286ea43
docs: Reorder repo category according to module order
fiftydinar Mar 10, 2025
919bfac
docs: Merge disabling & enabling repos section
fiftydinar Mar 10, 2025
0d03d7b
chore: Fix grammar in log message about installing `from` repo
fiftydinar Mar 10, 2025
0ac6938
docs: Add example of `old/new` replacement format
fiftydinar Mar 10, 2025
8dd4e31
Merge branch 'main' into dnf-module
fiftydinar Mar 11, 2025
425a55e
docs: Update module.yml to use old and new keys for replace
gmpinder Mar 19, 2025
6557643
docs: Clean up example snippets
gmpinder Mar 21, 2025
42db552
fix: Install dnf5 plugins when necessary if not installed
gmpinder Mar 25, 2025
61c81e0
docs: Create a layout for the features
gmpinder Mar 27, 2025
d110cc5
docs: Add more descriptions
gmpinder Mar 27, 2025
2f3cfb0
docs: readme refinement
xynydev Mar 29, 2025
1d30435
docs: establish headline-level split between package & repo management
xynydev Mar 29, 2025
e3be7ea
docs: fix typo
xynydev Mar 29, 2025
734cdc0
docs: emphasize temporariness of kernel replacement issue
xynydev Mar 29, 2025
2abb673
chore: streamline example
xynydev Mar 29, 2025
43de904
docs: add note about brave
xynydev Mar 29, 2025
040367c
docs: add section for installation options / flags
xynydev Mar 29, 2025
7684af9
fix: fix repo file disablement key
xynydev Mar 29, 2025
cf32705
fix: Allow local keys to be added
gmpinder Mar 30, 2025
fdaa6bb
fix: Ensure global config args are respected if no overrides exist
gmpinder Mar 30, 2025
6573462
docs: Add more information about the replace process
gmpinder Mar 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-individual.nu
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let images = ls modules | each { |moduleDir|
cd $moduleDir.name

# module is unversioned
if ($"($moduleDir.name | path basename).sh" | path exists) {
if (glob $"($moduleDir.name | path basename).{sh,nu}" | any { path exists }) {

print $"(ansi cyan)Found(ansi reset) (ansi cyan_bold)unversioned(ansi reset) (ansi cyan)module:(ansi reset) ($moduleDir.name | path basename)"

Expand Down
4 changes: 2 additions & 2 deletions build-unified.nu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mkdir ./modules-latest
ls modules | each { |moduleDir|

# module is unversioned
if ($"($moduleDir.name)/($moduleDir.name | path basename).sh" | path exists) {
if (glob $"($moduleDir.name)/($moduleDir.name | path basename).{sh,nu}" | any { path exists }) {

print $"(ansi cyan)Found(ansi reset) (ansi cyan_bold)unversioned(ansi reset) (ansi cyan)module:(ansi reset) ($moduleDir.name | path basename)"

Expand Down Expand Up @@ -56,4 +56,4 @@ let digest = (
print $"(ansi cyan)Signing image:(ansi reset) ($env.REGISTRY)/modules@($digest)"
cosign sign -y --key env://COSIGN_PRIVATE_KEY $"($env.REGISTRY)/modules@($digest)"

print $"(ansi green_bold)DONE!(ansi reset)"
print $"(ansi green_bold)DONE!(ansi reset)"
1 change: 1 addition & 0 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"https://raw.githubusercontent.com/blue-build/modules/main/modules/gschema-overrides/module.yml",
"https://raw.githubusercontent.com/blue-build/modules/main/modules/justfiles/module.yml",
"https://raw.githubusercontent.com/blue-build/modules/main/modules/rpm-ostree/module.yml",
"https://raw.githubusercontent.com/blue-build/modules/main/modules/dnf/module.yml",
"https://raw.githubusercontent.com/blue-build/modules/main/modules/initramfs/module.yml",
"https://raw.githubusercontent.com/blue-build/modules/main/modules/script/module.yml",
"https://raw.githubusercontent.com/blue-build/modules/main/modules/signing/module.yml",
Expand Down
233 changes: 233 additions & 0 deletions modules/dnf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
# **`dnf` Module**

The `dnf` module offers pseudo-declarative package and repository management using [`dnf5`](https://github.com/rpm-software-management/dnf).

## Features

This module is capable of:

- Repository Management
- Enabling/disabling COPR repos
- Adding repo files via url or local files
- Removing repos by specifying the repo name
- Automatically cleaning up any repos added in the module
- Adding keys for repos via url or local files
- Adding non-free repos like `rpmfusion` and `negativo17`
- Package Management
- Installing packages from RPM urls, local RPM files, or package repositories
- Installing packages from a specific repository
- Removing packages
- Replacing installed packages with versions from another repository
- Optfix
- Setup symlinks to `/opt/` to allow certain packages to install

## Repository Management

### Add Repository Files

- Add repos from
- any `https://` or `http://` URL
- any `.repo` files located in `./files/dnf/` of your image repo
- If the OS version is included in the file name or URL, you can substitute it with the `%OS_VERSION%` magic string
- The version is gathered from the `VERSION_ID` field of `/usr/lib/os-release`

```yaml
type: dnf
repos:
files:
- https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
- custom-file.repo # file path for /files/dnf/custom-file.repo
```

### Add COPR Repositories

- [COPR](https://copr.fedorainfracloud.org/) contains software repositories maintained by fellow Fedora users

```yaml
type: dnf
repos:
copr:
- atim/starship
- trixieua/mutter-patched
```

### Disable/Enable Repositories

```yaml
type: dnf
repos:
files:
add:
- repo1
- repo2
remove:
- repo3
copr:
enable:
- ryanabx/cosmic-epoch
disable:
- kylegospo/oversteer
```

### Add Repository Keys

```yaml
type: dnf
repos:
keys:
- https://example.com/repo-1.asc
- key2.asc
```

## Package Management

### Packages from Any Repository

```yaml
type: dnf
install:
packages:
- package-1
- package-2
```

### Packages from URL or File

- If the OS version is included in the file name or URL, you can substitute it with the `%OS_VERSION%` magic string
- The version is gathered from the `VERSION_ID` field of `/usr/lib/os-release`

```yaml
type: dnf
install:
packages:
- https://example.com/package-%OS_VERSION%.rpm
- custom-file.rpm # install files/dnf/custom-file.rpm from the image repository
```

### Install Packages from Specific Repositories

- Set `repo` to the name of the RPM repository, not the name or URL of the repo file

```yaml
type: dnf
install:
packages:
- repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
packages:
- package-1
```

### Remove Packages

```yaml
type: dnf
remove:
packages:
- package-1
- package-2
```

### Install Package Groups

- See list of all package groups by running `dnf5 group list --hidden` on a live system
- Set the option `with-optional` to `true` to enable installation of optional packages in package groups

```yaml
type: dnf
group-install:
with-optional: true
packages:
- de-package-1
- wm-package-2
```

### Remove Package Groups
```yaml
type: dnf
group-remove:
packages:
- de-package-2
```

### Replace Packages
- You can specify one or more packages that will be swapped from another repo
- This process uses `distro-sync` to perform this operation
- All packages not specifying `old:` and `new:` will be swapped in a single transaction

```yaml
type: dnf
replace:
- from-repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
packages:
- package-1
```

- If a package has a different name in another repo, you can use the `old:` and `new:` properties
- This process uses `swap` to perform this operation for each set
- This process is ran before `distro-sync`

```yaml
type: dnf
replace:
- from-repo: repo-1
packages:
- old: old-package-2
new: new-package-2
```

### Installation options

The following options can specified in the package installation, group installation, and package replacement sections.

- `install-weak-deps` enables installation of the weak dependencies of RPMs
- Enabled by default
- Corresponds to the [`--setopt=install_weak_deps=True` / `--setopt=install_weak_deps=False`](https://dnf5.readthedocs.io/en/latest/dnf5.conf.5.html#install-weak-deps-options-label) flag
- `skip-unavailable` enables skipping packages unavailable in repositories without erroring out
- Disabled by default
- Corresponds to the [`--skip-unavailable`](https://dnf5.readthedocs.io/en/latest/commands/install.8.html#options) flag
- `skip-broken` enables skipping broken packages without erroring out
- Disabled by default
- Corresponds to the [`--skip-broken`](https://dnf5.readthedocs.io/en/latest/commands/install.8.html#options) flag
- `allow-erasing` allows removing packages in case of dependency problems during package installation
- Disabled by default
- Corresponds to the [`--allowerasing`](https://dnf5.readthedocs.io/en/latest/commands/install.8.html#options) flag

```yaml
type: dnf
install:
skip-unavailable: true
packages:
...
group-install:
skip-unavailable: true
packages:
...
replace:
- from-repo: repo-1
allow-erasing: true
packages:
...
```

## Optfix

- Optfix is a script used to work around problems with certain packages that install into `/opt/`
- These issues are caused by Fedora Atomic storing `/opt/` at the location `/var/opt/` by default, while `/var/` is only writeable on a live system
- The script works around these issues by moving the folder to `/usr/lib/opt/` and creating the proper symlinks at runtime
- Specify a list of folders inside `/opt/`

```yaml
type: dnf
optfix:
- brave.com
- foldername
```

## Known issues

Replacing the kernel with the `dnf` module is not done cleanly at the moment & some remaints of old kernel will be present.
Please use the `rpm-ostree` module for this purpose until this `dnf` behavior is fixed.

## Note

This documentation page uses the installation of the Brave Browser as an example of a package that required a custom repository, with a custom key, and an optfix configuration to install properly. This is not an official endorsement of the Brave Browser by the BlueBuild project.
11 changes: 11 additions & 0 deletions modules/dnf/bluebuild-optfix.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Create symbolic links for directories in /usr/lib/opt/ to /var/opt/
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/libexec/bluebuild/optfix.sh
RemainAfterExit=no

[Install]
WantedBy=default.target
Loading