Skip to content

Instantly share code, notes, and snippets.

@t0mmyt
Last active August 29, 2015 14:23
Show Gist options
  • Save t0mmyt/dd846240de818a4fdc0e to your computer and use it in GitHub Desktop.
Save t0mmyt/dd846240de818a4fdc0e to your computer and use it in GitHub Desktop.
Script to make (or update) a yum repo
#!/bin/bash
# Script to make (or update) a yum repo
workers=4
REPOS=()
# To add a repo, REPOS+=("name or description|directory")
REPOS+=("Centos 7 x86_64 - live|/var/repo/repo/live/7/x86_64/")
REPOS+=("Centos 6 x86_64 - live|/var/repo/repo/live/6/x86_64/")
#REPOS+=("Centos 5 x86_64 - live|/var/repo/repo/live/5/x86_64/")
for i in $(seq 0 $((${#REPOS[@]} -1)))
do
name=${REPOS[i]%|*}
path=${REPOS[i]#*|}
header="Updating ${name}"
echo "$header"
echo ${header//?/=}
( cd $path && createrepo --workers=${workers} . ) ||\
echo "Updating ${name} FAILED!!"
done
#!/bin/env python
import sys
import subprocess
repos = [
{
'name': 'Centos 6 x86_64',
'path': '/srv/repo/centos/6/x86_64/',
'rsync': 'rsync.mirrorservice.org/mirror.centos.org/6.6/os/x86_64/Packages/',
},
{
'name': 'Centos 6 x86_64 Updates',
'path': '/srv/repo/centos-updates/6/x86_64/',
'rsync': 'rsync.mirrorservice.org/mirror.centos.org/6/updates/x86_64/Packages/',
},
{
'name': 'EPEL EL6',
'path': '/srv/repo/epel/6/x86_64/',
'rsync': 'rsync.mirrorservice.org/dl.fedoraproject.org/pub/epel/6/x86_64/',
},
]
for repo in (repos):
try:
subprocess.check_call(['/usr/bin/rsync', '-avvz', "rsync://" + repo['rsync'], repo['path']])
except subprocess.CalledProcessError as e:
print "rsync://%s\nRsync for %s exited non-zero. Bailing out" % (repo['rsync'],repo['name'])
try:
subprocess.check_call(['/usr/bin/createrepo', '--update', '.'], cwd=repo['path'])
except subprocess.CalledProcessError as e:
print "Create repo for %s (%s) exited non-zero. Bailing out" % (repo['name'], repo['path'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment