jump to navigation

create a local yum repository May 7, 2007

Posted by TSAI HONG-BIN in Linux.
trackback

first thing first, you need to have packages in hand to become a “repository.” So, let’s start from rsync-ing the packages. Here is my daily rsync scripts:

/* start of the script */

#!/bin/sh
#mirror-yum.sh

DATE=`/bin/date +%Y-%m-%d`
OUTDIR=’/var/log’
MIRROR=’YOUR_OWN_PLACE’
OUTFILE=$OUTDIR/rsync-log-$DATE.log
archs=( i386 x86_64 )
releasevers=( 6 5 3 )

mirror_command(){

/bin/nice /usr/bin/rsync -rxvt \
–exclude=development/ \
–exclude=SRPMS/ \
–exclude=repodata/ \
–exclude=*debuginfo* \
–exclude=*i18* \
–exclude=debug/ \
–exclude=testing/ \
$2 \
$1 >> $OUTFILE

createrepo -q -c $MIRROR/cache $1 > /dev/null 2>&1

}

mirror_freshrpms(){
DEST_DIR=$MIRROR/freshrpms/$1/$2
[ -d $DEST_DIR ] || mkdir -p $DEST_DIR
mirror_command $DEST_DIR rsync://ayo.freshrpms.et/pub/freshrpms/ayo/fedora/linux/$1/$2/RPMS.freshrpms
}

mirror_core(){

DEST_DIR=$MIRROR/fedora/core/$1/$2/os/
[ -d $DEST_DIR ] || mkdir -p $DEST_DIR
mirror_command $DEST_DIR rsync://mirrors.kernel.org/fedora/core/$1/$2/os
}

mirror_updates(){

DEST_DIR=$MIRROR/fedora/core/updates/$1/$2
[ -d $DEST_DIR ] || mkdir -p $DEST_DIR
mirror_command $DEST_DIR rsync://mirrors.kernel.org/fedora/core/updates/$1/$2
}

mirror_extras(){
DEST_DIR=$MIRROR/fedora/extras/$1/$2
[ -d $DEST_DIR ] || mkdir -p $DEST_DIR
mirror_command $DEST_DIR rsync://mirrors.kernel.org/fedora/extras/$1/$2
}

for releasever in ${releasevers[@]}
do

for arch in ${archs[@]}
do

mirror_core $releasever $arch
mirror_updates $releasever $arch
mirror_extras $releasever $arch
mirror_freshrpms $releasever $arch

done

done

/* end of the script */

Well, ya, part of the script is copied from http://fedoranews.org/contributors/hal_canary/yum/.

There’re only few lines worth of mentioning. “rsync” to download the packages and “createrepo” to create repository index. Usually you’ll see online yum repository examples give a path like /var/www/html/, which somewhat implies the protocol that yum follows: HTTP.

No doubt, please check /etc/yum.repos.d/fedora-core.repo. You’ll see a line with “baseurl=” initial. Edit this line to your path. For example, if I can access my yum repository through http://192.168.0.1/yum/fedora/core/6/i386/os/, then I shall have executed `createrepo /PATH_TO_YUM_ROOT/yum/fedora/linux/core/6/i386/os/`. Point baseurl to “http://192.168.0.1/yum/fedora/core/$releasever/$arch/os/” and save, exit. Then you shall see a list of available RPMs by running `yum list.`

Except for core, there are updates, extras RPMs available (released by Fedora). If you feel like to add 3rd party packages repository like freshrpms, just follow my scripts. Don’t worry about the directory tree, you can create it whatever you like it, just make sure that it’s accessible via HTTP.

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: