Add crb script to allow users to --enable, --disable

or --status the CRB repo.

Signed-off-by: Troy Dawson <tdawson@redhat.com>
epel9
Troy Dawson 3 years ago
parent 65609096ed
commit 3750a54112

78
crb

@ -0,0 +1,78 @@
#!/bin/bash
# Enable / Disable / Status the codeready-builder(CRB) or equivalent repo.
###############
# Show help
###############
usage() {
echo "Usage `basename $0` [ enable | disable | status ] " >&2
echo >&2
echo "Enable, Disable, or give the status of the CodeReady Builder (CRB) repo" >&2
echo >&2
echo "Options:" >&2
echo " enable" >&2
echo " Enable the CRB repo" >&2
echo " disable" >&2
echo " Disable the CRB repo" >&2
echo " status" >&2
echo " Show if rhe CRB repo is enabled or disabled" >&2
echo " help" >&2
echo " Show this options menu" >&2
echo >&2
popd &>/dev/null
exit 1
}
# Show the status
show_status()(
# Determine if a version of CRB is enabled
crb_repo=$(dnf repolist | grep -i -e crb -e powertools -e codeready | grep -v -i -e debug -e source -e eus -e virt | awk '{print $1}')
if [ "${crb_repo}" == "" ] ; then
echo "CRB repo is disabled"
else
echo "CRB repo is enabled and named: ${crb_repo}"
fi
)
# Enable or Disable the repo
enable_disable_repo(){
command="$1"
# Determine which repo we need to change
crb_repo=$(dnf repolist --all | grep -i -e crb -e powertools -e codeready | grep -v -i -e debug -e source -e eus -e virt | awk '{print $1}')
# Determine if we are on RHEL or not, then do the correct steps
if echo "${crb_repo}" | grep -q "codeready" ; then
# Only RHEL has a repo with codeready in it, use subcription-manager
subscription-manager repos ${command} ${crb_repo}
else
# Everything else uses dnf config-manager
dnf config-manager ${command} ${crb_repo}
fi
}
###############
# Get our arguments
###############
key="$1"
case $key in
enable | --enable )
echo "Enabling CRB repo"
enable_disable_repo --enable
show_status
;;
disable | --disable )
echo "Disabling CRB repo"
enable_disable_repo --disable
show_status
;;
status | --status )
show_status
;;
* )
usage
exit 2
;;
esac
exit 0

@ -5,7 +5,7 @@
Name: epel-release Name: epel-release
Version: 9 Version: 9
Release: 2%{dist} Release: 3%{dist}
Summary: Extra Packages for Enterprise Linux repository configuration Summary: Extra Packages for Enterprise Linux repository configuration
License: GPLv2 License: GPLv2
@ -28,6 +28,9 @@ Source202: epel-testing-modular.repo
# EPEL default preset policy (borrowed from fedora's 90-default.preset) # EPEL default preset policy (borrowed from fedora's 90-default.preset)
Source300: 90-epel.preset Source300: 90-epel.preset
# Add epel crb repo
Source301: crb
BuildArch: noarch BuildArch: noarch
Requires: redhat-release >= %{version} Requires: redhat-release >= %{version}
# epel-release is only for enterprise linux, not fedora # epel-release is only for enterprise linux, not fedora
@ -82,6 +85,17 @@ install -pm 644 %{SOURCE103} %{buildroot}%{_sysconfdir}/yum.repos.d
# systemd presets # systemd presets
install -pm 644 -D %{SOURCE300} %{buildroot}%{_prefix}/lib/systemd/system-preset/90-epel.preset install -pm 644 -D %{SOURCE300} %{buildroot}%{_prefix}/lib/systemd/system-preset/90-epel.preset
# Add epel crb repo
install -D -pm744 -t %{buildroot}%{_bindir} %{SOURCE301}
%post
# Doing a check to see if crb is enabled is as hard and resource intense as enabling or disabling crb.
# So we will say crb is recommended, without first checking. But only on the initial install.
if [ "$1" -eq 1 ] ; then
echo "Many EPEL packages require the CodeReady Builder (CRB) repository."
echo "It is recommended that you run %{_bindir}/crb enable to enable the CRB repository."
fi
%files %files
%license GPL %license GPL
@ -98,7 +112,7 @@ install -pm 644 -D %{SOURCE300} %{buildroot}%{_prefix}/lib/systemd/system-preset
%endif %endif
%{_sysconfdir}/pki/rpm-gpg/* %{_sysconfdir}/pki/rpm-gpg/*
%{_prefix}/lib/systemd/system-preset/90-epel.preset %{_prefix}/lib/systemd/system-preset/90-epel.preset
%{_bindir}/crb
%if %{with next} %if %{with next}
%files -n epel-next-release %files -n epel-next-release
@ -108,6 +122,9 @@ install -pm 644 -D %{SOURCE300} %{buildroot}%{_prefix}/lib/systemd/system-preset
%changelog %changelog
* Wed Jun 29 2022 Troy Dawson <tdawson@redhat.com> - 9-3
- Add crb script
* Wed Dec 01 2021 Carl George <carl@george.computer> - 9-2 * Wed Dec 01 2021 Carl George <carl@george.computer> - 9-2
- Enable epel9 repo files - Enable epel9 repo files

Loading…
Cancel
Save