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 76 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 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
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
158 changes: 158 additions & 0 deletions modules/dnf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# **`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
- 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
- Enabling/disabling COPR repos
- Adding non-free repos like `rpmfusion` and `negativo17`
- Package Management
- Installing packages via url, local rpm files, or repo packaging
- Specifying repos from which to install packages
- Removing packages
- Replacing packages with ones from another repo
- Optfix
- Setup symlinks to `/opt/` to allow certain packages to install

### Add Repository Files

- Add repos from any `https://` or `http://` URL
- Any `.repo` files located in `./files/dnf/` of your image repo

```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
```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
```

### Packages
```yaml
type: dnf
install:
packages:
- repo: repo-1
packages:
- repo-1-package-1
- repo-1-package-2
- package-3
```

### Packages from URL or File
```yaml
type: dnf
install:
packages:
- https://example.com/package-%OS_VERSION%.rpm
- custom-file.rpm # file path for /files/dnf/custom-file.rpm
```

### Install Packages from Specific Repositories
```yaml
type: dnf
install:
packages:
- repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
packages:
- package1
```

### Remove Packages
```yaml
type: dnf
remove:
packages:
- package1
- package-2
```

### Define Packages Groups
```yaml
type: dnf
group-install:
packages:
- de-package-1
- wm-package-2
```

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

### Replace Packages
```yaml
type: dnf
replace:
- from-repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
packages:
- package-1
- from-repo: repo-1
packages:
- old: old-package-2
new: new-package-2
```

### 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:
- package1
- package2
```

## Known issues

Replacing the kernel with `dnf` module is not done cleanly & some remaints of old kernel will be present.
Please use `rpm-ostree` module for this purpose until this `dnf` behavior is fixed.
Comment on lines +157 to +158
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this fixed already in some images? I think I remember hearing about this.

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