From ce14214a7ab44b790e6f7b24276fed471f94faed Mon Sep 17 00:00:00 2001 From: aweiteka Date: Tue, 21 Jan 2014 13:53:36 -0500 Subject: [PATCH] Support list of Red Hat channels and repos When registering to RHN or RHSM a list of space-separated channels or repositories may be provided. This allows control over which packages are available to the system during build. Note, the optional channel or repository is added by default since diskimage-builder requires access to its packages. This list is for additional channels or repos. Change-Id: I9cf90d47ab1d09f5491f574132410438f9e294e3 --- elements/rhel/README.md | 2 ++ elements/rhel/pre-install.d/00-rhsm | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/elements/rhel/README.md b/elements/rhel/README.md index efa9a254..b7b64a52 100644 --- a/elements/rhel/README.md +++ b/elements/rhel/README.md @@ -10,9 +10,11 @@ Certificate-based Red Hat Subscription Managment (RHSM) is the default registrat * Set DIB_RHSM_USER and DIB_RHSM_PASSWORD to register the system with RHSM during the image building process. This will apply the associated Red Hat Enterprise Linux Server subscription so the latest package updates can be applied. At the end of the image building process, the system will be unregistered from RHSM. * Set DIB_RHSM_POOL to a subscription pool if you do not want the system to use the `--auto-attach` feature of `subscription-manager`. +* Set DIB_RHSM_REPOS to a space-separated list of Red Hat repositories to enable. ## Red Hat Network (RHN) Set `DIB_REG_TYPE=rhn` for Red Hat Network (RHN classic) registration. The image building process will register the system to RHN and apply the associated Red Hat Enterprise Linux Server subscription so the latest package updates can be applied. At the end of the image building process, the system will be unregistered from RHN. * For RHN username/password authentication set DIB_RHSM_USER and DIB_RHSM_PASSWORD. +* Set DIB_RHN_CHANNELS to a space-separated list of RHN channels to add. Example: `DIB_RHN_CHANNELS=rhel-x86_64-server-6 rhel-x86_64-server-6-rhscl-1`. diff --git a/elements/rhel/pre-install.d/00-rhsm b/elements/rhel/pre-install.d/00-rhsm index 75f928a2..9c4438f2 100755 --- a/elements/rhel/pre-install.d/00-rhsm +++ b/elements/rhel/pre-install.d/00-rhsm @@ -10,6 +10,11 @@ if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ] sleep 1 # optional channel required for diskimage-builder dependency channels="-a -c rhel-x86_64-server-optional-6" + if [[ -n "$DIB_RHN_CHANNELS" ]]; then + for chan in $DIB_RHN_CHANNELS; do + channels="$channels -a -c $chan" + done + fi rhn-channel --user=$DIB_RHSM_USER --password=$DIB_RHSM_PASSWORD $channels rhn-channel -l else @@ -23,6 +28,11 @@ if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ] fi # optional repo required for diskimage-builder dependency repos="--enable rhel-6-server-optional-rpms" + if [[ -n "$DIB_RHSM_REPOS" ]]; then + for repo in $DIB_RHSM_REPOS; do + repos="$repos --enable $repo" + done + fi subscription-manager repos $repos subscription-manager repos --list fi