On 10/27/2014 04:20 PM, Steven Haigh wrote:
On 28/10/2014 1:05 AM, Pat Riehecky wrote:
On 10/26/2014 12:39 AM, Steven Haigh wrote:
On 25/10/2014 10:28 PM, Shane Voss wrote:
On 25/10/14 05:06, Steven Haigh wrote:> I also want to go and put a
custom URL in the sl6x.repo to go to my
local repository that I mirror.
That means I'd want to turn this:
[snip]
to this:
The only change I can see was inserting your server in the baseurl.
Perhaps this is only needed in the sl6x section.
This bit of sed should do it:
sed -i '/\[sl6x\]/,/\[/ { /baseurl/ {
h ; s!http:.*scientific/!https://my.internal.server/sl! ; p ;
g ; s/baseurl=/ / } }' /etc/yum.repos.d/sl6x.repo
It is "parsing" the URL in as much as you seem to need to replicate the
bit of the existing one after 'scientific/'.
Hope that helps.
Help? That is near magic!
I did a bit of tweaking and ended up with this:
sed -i '/\[sl6x.*\]/,/\n\n/ { /baseurl/ {
h ; s!http:.*scientific/!https://my.server/path/to/sl! ; p ;
g ; s/baseurl=/ / } }' /etc/yum.repos.d/sl6x.repo
This uses the \n\n as the end of field marker - it seemed that using [
would cause it to not match the middle repo - as its next evaluation was
against sl6x-security].
That will now loop through all the repos defined in sl6x.repo and add a
local mirror to them all.
Thanks for this pointer - I certainly wouldn't have come up with this
one by myself....
The 'yum-config-manager' (provided by yum-utils) utility may be of more
help.
Hi Pat!
I did come across this - but there are a couple of reasons I asked for
something else...
You can't ADD a new URL to an existing repo - I update a local mirror of
the sl6x / sl6x-security / sl6x-fastbugs repos - and therefore want to
insert my URL into the baseurl section via the kickstart. The actions I
do are:
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/sl.repo
## Enable the sl6x, sl6x-security and sl6x-fastbugs repos....
sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/sl6x.repo
sed -i 's/#mirrorlist=/mirrorlist=/g' /etc/yum.repos.d/sl6x.repo
## Add local repos to the baseurl list for fast updates.
sed -i '/baseurl/ {
h ; s!http:.*scientific/!https://internal.server/path/to/sl! ; p ;
g ; s/baseurl=/ / }' /etc/yum.repos.d/sl6x.repo
True, the enabled= lines could be done via yum-config-manager, however
you can't inject a URL or change the mirrorlist options (that I've found
anyway!).
After only just getting round to using kickstart (after years of just
uncompressing an archive), this info is VERY helpful.
Have you looked into augeas? I've found it very helpful for targeted edits.
# augtool
augtool> ls /files/etc/yum.repos.d/sl.repo/sl/
name = Scientific Linux $releasever - $basearch
baseurl[1] =
http://ftp.scientificlinux.org/linux/scientific/$releasever/$basearch/os/
baseurl[2] =
http://ftp1.scientificlinux.org/linux/scientific/$releasever/$basearch/os/
baseurl[3] =
http://ftp2.scientificlinux.org/linux/scientific/$releasever/$basearch/os/
baseurl[4] =
ftp://ftp.scientificlinux.org/linux/scientific/$releasever/$basearch/os/
#comment =
mirrorlist=http://ftp.scientificlinux.org/linux/scientific/mirrorlist/sl-base-6.txt
enabled = 1
gpgcheck = 1
gpgkey[1] = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl
gpgkey[2] = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl6
gpgkey[3] = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-cern
augtool> rm /files/etc/yum.repos.d/sl.repo/sl/baseurl
rm : /files/etc/yum.repos.d/sl.repo/sl/baseurl 4
augtool> set /files/etc/yum.repos.d/sl.repo/sl/baseurl test
augtool> ls /files/etc/yum.repos.d/sl.repo/sl/
name = Scientific Linux $releasever - $basearch
#comment =
mirrorlist=http://ftp.scientificlinux.org/linux/scientific/mirrorlist/sl-base-6.txt
enabled = 1
gpgcheck = 1
gpgkey[1] = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl
gpgkey[2] = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl6
gpgkey[3] = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-cern
baseurl = test
augtool> save
--
Pat Riehecky
Scientific Linux developer
http://www.scientificlinux.org/