Skip to content

Commit

Permalink
Automatic repo mirroring feature
Browse files Browse the repository at this point in the history
A local repo will mirror a remote by prefixing it with "mirror:". For example,

myrepo = mirror:remoterepo

Refer to updated instructions.txt for more info.
  • Loading branch information
dtmateojr authored May 21, 2019
1 parent 7145c07 commit 007f79a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion dtmrepo
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ISREGISTERED="Current"

LOCALMARKER="local:"
SPACEWALKMARKER="swalk:"
MIRRORMARKER="mirror:"

usage() {
echo
Expand Down Expand Up @@ -308,6 +309,11 @@ update_repo() {
_REPOID=${_REPOSPEC[1]}
spacewalk_enable ${_DISTRO} || return 1
_SWALK=1
elif [ "${_REPOID:0:${#MIRRORMARKER}}" == "${MIRRORMARKER}" ]; then
IFS=: read -ra _REPOSPEC <<<${_REPOID}
_REPOID=${_REPOSPEC[1]}
_SYNCALL=''
_DELETE='-d'
fi

(
Expand Down Expand Up @@ -358,6 +364,9 @@ download_package() {
_REPOID=${_REPOSPEC[1]}
spacewalk_enable ${_DISTRO} || return 1
_SWALK=1
elif [ "${_REPOID:0:${#MIRRORMARKER}}" == "${MIRRORMARKER}" ]; then
IFS=: read -ra _REPOSPEC <<<${_REPOID}
_REPOID=${_REPOSPEC[1]}
fi

(
Expand Down Expand Up @@ -408,7 +417,7 @@ gen_repodata() {

if [ "${SELECT}" -eq 1 ]; then
_PROTECTREPO=1
elif [ "${MIRROR}" -eq 1 ]; then
elif [ "${MIRROR}" -eq 1 -o "${_REPOID:0:${#MIRRORMARKER}}" == "${MIRRORMARKER}" ]; then
_PROTECTREPO=1
elif [ ! -z "${protectrepo}" ]; then
echo ${_REPODIR} | egrep -q "$(echo ${protectrepo} | sed -r 's/[ ,]+/|/g')" && _PROTECTREPO=1
Expand Down
9 changes: 8 additions & 1 deletion instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ This will register and initialise dtmrepo. During registration it will ask for y
epel = epel-5-x86_64
foo = local:/var/dtmrepo/foo/el5/x86_64
misc = swalk:some-spacewalk-channel
dev = mirror:dev-el5
====================================================

There are two sections: [control] and [repos]. The [control] section may override some of the global configuration options. In the example above it overrides the the number of package versions to keep. The [repos] section defines the different repositories that will be synced. The format is "targetdir = repoid". The targetdir corresponds to the directory REPDODIR/rhel5s-x86_64/targetdir and repoid is a real yum repository that is preconfigured under INSTALLDIR/etc/dtmrepo.repos.d/.
Expand All @@ -106,6 +107,8 @@ This will register and initialise dtmrepo. During registration it will ask for y

Put the repo configurations under the directory specified in "reposdir" of the custom yum configuration specified in "yumconf" of INSTALLDIR/etc/dtmrepo.conf.

If the repoid is prefixed by "mirror:" then an update operation will mirror that repo. Local packages that are no longer present in the source repo will be deleted.

The second type of repoid is not a real repository but just a collection of packages stored in a directory somewhere. This is specified by the identifier local:. In the example above, /var/dtmrepo/foo/el5/x86_64 need not contain a repodata. If the directory already exists where it's supposed to be under repodata (i.e. /var/dtmrepo/rhel5s-x86_64/foo) then it is left untouched otherwise a symlink that points to the source directory is created under the said repodata.

The third type of repoid is for Spacewalk channels. For this to work, the dtmrepo server needs to be registered with Spacewalk obviously. If the distro matches the distro of the dtmrepo server then the "swalk" marker is not needed. If the distro is a "fake" distro, i.e. you are fetching EL7 packages from a EL6 dtmrepo server, then you need to register first (see Section IV) and the "swalk" marker is required.
Expand Down Expand Up @@ -159,7 +162,8 @@ dtmrepo accepts several commandline options namely:
-r : comma-separated list of repos to process. If not specified then all repos are processed
-u : sync packages
-g : generate repodata
-s : download selected packages and all dependencies. This option disables -u and temporarily protects the entire repo so that the packages are not deleted during repodata creation. Has no effect on "local:" repos.
-m : mirror; implies -a, -u and -g
-s : download selected packages and all dependencies. This option disables -u and temporarily protects the entire repo so that the packages are not deleted during repodata creation. Has no effect on "local:" repos. Automatically performs -g.
-p : purge undeclared repo directories
-f : force the operation. Normally, dtmrepo will not attempt to generate new repodata if it's newer than any package in the repo.
-x : autofix. Red Hat subscription-manager automatically updates the subscription certificate. This option automatically updates master.repo with the new cert.
Expand All @@ -183,6 +187,9 @@ VI. Usage Examples
dtmrepo -ug -r epel
sync and generate repo data for epel on all distros

dtmrepo -mv -r epel
mirror the epel repo for all distros

dtmrepo -u -r foo,bar
sync foo and bar repos on all distros

Expand Down

0 comments on commit 007f79a

Please sign in to comment.