We use some add-on packages from EPEL . Since we want to peg packages to specific versions only, and to reduce the number of servers that connect directly to the internet, we decided to build a local mirror for the EPEL repository.
Install dependencies.
yum install httpd yum-utils createrepo
Patch reposync to add option for "flattened" directories. (By default, reposync creates a directory named after the repo ID for placing the downloaded packages.)
cat > reposync.patch
--- /usr/bin/reposync.bak 2012-11-13 13:30:37.000000000 +0800
+++ /usr/bin/reposync 2012-11-13 13:34:47.000000000 +0800
@@ -117,6 +117,8 @@ def parseArgs():
help="enable yum plugin support")
parser.add_option("-m", "--downloadcomps", default=False, action="store_true",
help="also download comps.xml")
+ parser.add_option("-f", "--flatdir", dest='flatdir', default=False, action="store_true",
+ help="flatten directory; do not add repoid")
(opts, args) = parser.parse_args()
return (opts, args)
@@ -186,7 +188,11 @@ def main():
else:
download_list = list(reposack)
- local_repo_path = opts.destdir + '/' + repo.id
+ if opts.flatdir:
+ local_repo_path = opts.destdir;
+ else:
+ local_repo_path = opts.destdir + '/' + repo.id
+
if opts.delete and os.path.exists(local_repo_path):
current_pkgs = localpkgs(local_repo_path)
cp /usr/bin/reposync{,.bak}
patch < reposync.patch
Create the repository directories.
mkdir -p /srv/repos/epel{,.staging}/5/{x86_64,i386,noarch}
Start downloading the repo.
reposync -a x86_64 -r epel -p /srv/repos/epel.staging -l -m -f
Copy the packages to staging first.
cd /srv/repos/epel.staging/
for a in {x86_64,i386,noarch} ; do \
find . -maxdepth 1 -iname "*$a*" -exec cp -v {} 5/$a/ \; ; \
cp -f comps.xml 5/$a/ ;
done
Create repo metadata.
for a in {x86_64,i386,noarch} ; do \
createrepo -v -g comps.xml 5/$a/ ; \
done
Add the following configuration file to /etc/httpd/conf.d/.
ServerAdmin admin@email.org
ServerName fqdn.of.repo.server
DocumentRoot /srv/repos
KeepAlive On
KeepAliveTimeout 2
MaxKeepAliveRequests 100
AddType application/octet-stream .iso
AddType application/octet-stream .rpm
Options +Indexes +FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Header set Cache-Control "must-revalidate"
ExpiresActive On
ExpiresDefault "now"
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" %I %O \"%{User-Agent}i\"" combined
Restart Apache.
Use the following yum repo config in /etc/yum.repos.d/.
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
baseurl=http://fqdn.of.repo.server/epel/5/$basearch
### mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
To test:
sudo yum repolist