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

or --status the CRB repo.

Signed-off-by: Troy Dawson <tdawson@redhat.com>
epel8
Troy Dawson 2 years ago
parent 52cd948183
commit 61026af609

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

@ -1,6 +1,6 @@
Name: epel-release Name: epel-release
Version: 8 Version: 8
Release: 15%{dist} Release: 16%{dist}
Summary: Extra Packages for Enterprise Linux repository configuration Summary: Extra Packages for Enterprise Linux repository configuration
License: GPLv2 License: GPLv2
@ -23,6 +23,9 @@ Source103: epel-next-testing.repo
Source105: epel-modular.repo Source105: epel-modular.repo
Source106: epel-testing-modular.repo Source106: epel-testing-modular.repo
# 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
@ -62,6 +65,17 @@ install -pm 644 %{SOURCE100} %{SOURCE101} %{SOURCE102} %{SOURCE103} %{SOURCE105}
%{buildroot}%{_sysconfdir}/yum.repos.d %{buildroot}%{_sysconfdir}/yum.repos.d
install -pm 644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/systemd/system-preset/90-epel.preset install -pm 644 -D %{SOURCE3} %{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
%doc README-epel-8-packaging.md %doc README-epel-8-packaging.md
@ -72,6 +86,7 @@ install -pm 644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/systemd/system-preset/9
%config(noreplace) %{_sysconfdir}/yum.repos.d/epel-testing-modular.repo %config(noreplace) %{_sysconfdir}/yum.repos.d/epel-testing-modular.repo
%{_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
%files -n epel-next-release %files -n epel-next-release
@ -80,6 +95,9 @@ install -pm 644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/systemd/system-preset/9
%changelog %changelog
* Thu Jun 30 2022 Troy Dawson <tdawson@redhat.com> - 8-16
- Add crb script
* Mon Mar 14 2022 Troy Dawson <tdawson@redhat.com> - 8-15 * Mon Mar 14 2022 Troy Dawson <tdawson@redhat.com> - 8-15
- Remove the use of $releasever ( rhbz#1969500 ) - Remove the use of $releasever ( rhbz#1969500 )

Loading…
Cancel
Save