#128 Turn on CRB/powertools when epel-release is installed
Closed: Fixed 2 years ago by tdawson. Opened 2 years ago by tdawson.

Alot of EPEL packages require CRB/powertool for runtime dependencies. We need to get it turned on.

I am proposing that we have a helper script that we can call (instead of calling dnf, cuz we can't call dnf).

Other proposals are encouraged.


I wish you luck on that. I tried a couple of different variants but because redhat.repo gets rewritten regularly it did not stick for RHEL boxes. The powertools was probably easier to deal with and I am going off of 8.0 timeframe so things may be easier.

Yeah, I don't think this is possble without some kind of crazy subscription-manager call in %post or something, which might work somehow for rhel, but fail for centos/alma/rocky.

my memory was that calling subscription-manager inside an RPM called dnf which is in use...

my later idea was to add a repo called

[epel-needs-powertools-or-crb]
name=EPEL does not work without Powertools or CodeReadyBuilder enabled
enabled=1
baseurl=file:///dev/null
gpgcheck=1

I think you pulled me back from the precipice by nixing that idea.

If a %post script won't work, is it worth doing something like what flatpak does with a systemd service1 that's enabled by default and then disables itself after its first run?

I don't know why it didn't show up on your comment, but here is the link you are refering too.

https://src.fedoraproject.org/rpms/flatpak/blob/rawhide/f/flatpak-add-fedora-repos.service

Thank you very much. I have successfully been able to enable a repo when I install an rpm. Note, in my example I am enabling epel-testing, not CRB. Just cuz I never have epel-testing enabled, while I usually have CRB enabled.

epel-add-crb-repo.service

[Unit]
Description=Enable CRB repo

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/dnf config-manager --enable epel-testing

[Install]
WantedBy=multi-user.target

And in the spec file

# Add epel crb repositories
Source1: epel-add-crb-repo.service
...
%install
install -D -t %{buildroot}%{_unitdir} %{SOURCE1}
...
%post
%systemd_post epel-add-crb-repo.service

%preun
%systemd_preun epel-add-crb-repo.service

%postun
%systemd_postun_with_restart epel-add-crb-repo.service

%posttrans
systemctl start epel-add-crb-repo

%files
%{_unitdir}/epel-add-crb-repo.service
...

Questions and Answers about the above comment.

Question: Can't you start it in %post ?
Answer: Evidently not. It always failed if it was in %post.

Question: Will the repo get re-enabled on reboot if a user disables the repo?
Question: Can I rerun "systemctl start epel-add-crb-repo" manually ?
Answer: No. This is a "oneshot" service. And systemd means it. If you manually run the command more than once, nothing happens. Reboot, again, nothing happens.

So, here is the next problem, which should be easier than the first. Enabling CRB in RHEL is different than enabling it in CentOS Stream and other rebuilds. Does anyone have a good idea(s) on how we can have two different commands run depending on what it's installed on?

Well, RHEL is the only one using subscription-manager, the rest use dnf config-manager. We can have a script that checks for ID=rhel and if not RHEL but rhel exists in ID_LIKE, then we can have it pick up the right repo ID based on distro name, and have it fallback to known names from CentOS (powertools for 8, crb for 9).

Yep. Looks like we'll have to use a script. I had a nice fancy one line command that would figure out if it needs crb / powertools / codereadybuilder ... but it can't optionally do dnf vs subscription-manager.
I'll need to test how things work with a script vs just having the command line.

I have created a script, integrated it into the systemd stuff, and verified that it works on RHEL8, RHEL9, CentOS Stream 8 and 9, and Alma 9.
I'm not saying this is without bugs, just that it's worked on what I've tested.

My pull request is currently only for epel9.
https://src.fedoraproject.org/rpms/epel-release/pull-request/21
Once people think it's ready, I'll create a pull request for epel8 as well.

Thanks for working on this, @tdawson! I left you some comments on the PR.

Per discussions on IRC, mailing lists, committee meetings and elsewhere, changes were made to this proposal.

  • A script /usr/bin/crb was created and put in epel-release. It can can enable, disable and give the status of the crb repo.
  • This script is NOT run automatically.
  • On initial epel-release install, %post gives a recommendation to run the script.

epel-release for epel8 with these changes:
https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-a9dfc1f536
epel-release for epel9 with these changes:
https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-de0e772ee0

The epel-release's with the changes have been implemented and have been working for a while.
I am closing this with "Fixed" even though the final implementation was not what was originally asked for.

Metadata Update from @tdawson:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.

Metadata