[Yum] how to update custom repo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 16 March 2005 05:37, Earl wrote:
> Need to create a custom repo for local (airgap) use.
> Repo will be comprised of approx 5-10 RPMS from 3
> different existing repos and about 200 from the Fedora
> CORE 3 base.  Don't want to maintain a full mirror of
> the 3 repos I only use 5-10 RPMS from...
>
> Question is how to keep all of the RPMS in my custom
> repo current?

I do this by using yum update on *one* machine to stay
current, and then move the downloaded rpms to a local
repository and re-running createrepo on it.

You have to make sure that *all* the affected packages are
installed on this machine.

I then use the local repo(s) for all my *other* local workstations
in place of the official one(s).

I use the script (yum 2.x) below. (without the line wrapping)

Fred.

#!/bin/bash
#
#  move rpms from yum's cache to local repositories
#  and re-create the repo metadata
#

FEDORA_VERSION=`rpm -q --queryformat '%{VERSION}' fedora-release`
case $FEDORA_VERSION in
 "3" | "2" | "1")
  YUM_BASE=/var/ftp/pub/fc$FEDORA_VERSION/yum
  ;;
        *)
  echo -e "**Error** unknown fedora version: $FEDORA_VERSION"
  exit 1
  ;;
esac

YUM_CACHE=/var/cache/yum

cd $YUM_CACHE
YUM_C_DEL=`find . -type d -maxdepth 1|grep -E '(-ftp|dvd|localbuilds)'                                                                   
sed 's:^./::'`
YUM_C_MOV=`find . -type d -maxdepth 1|grep -Ev '(-ftp|dvd|localbuilds|^.$)'| 
sed 's:^./::'`

YUM_DATE=`date +"%Y%m%d-%H%M%S"`

echo
echo -e "deleting files from ..."
for d in $YUM_C_DEL; do
 cd $YUM_CACHE/$d/packages
 YUM_C_FILES=`find . -name '*.rpm' | sed 's:^./::'`
 echo -e "  `pwd`:"
 for f in $YUM_C_FILES; do
  echo -e "      $f"
  rm -f $f
 done
done

echo
cd $YUM_CACHE
YUM_C_FILES=`find . -name '*.rpm'|grep -vE '.(i386|i586|noarch).rpm' | sed 
's:^./::'`
if [ "x$YUM_C_FILES" != "x" ]; then
 echo -e "warning downloaded i686 / athlon / src packages found:"
 for f in $YUM_C_FILES; do
  echo -e "  $f"
 done
 echo -ne "    abort [y]/n?"
 read -n 1 -a YUM_CMD
 if [ -z $YUM_CMD ] || [ $YUM_CMD != "n" ]; then
  echo -e "    aborted."
  exit 1
 fi
 echo
fi

echo -e "moving source packages from ..."
for d in $YUM_C_MOV; do
 YUM_C_FROM=$YUM_CACHE/$d/packages
 YUM_C_TO=$YUM_BASE/$d/SRPMS
 if [ ! -d $YUM_C_TO ]; then
  mkdir -p $YUM_C_TO
 fi
 cd $YUM_C_FROM
 YUM_C_FILES=`find . -name '*.src.rpm' | sed 's:^./::'`
 echo -e "  `pwd` to $YUM_C_TO:"
 for f in $YUM_C_FILES; do
  echo -e "      $f"
  mv $YUM_C_FROM/$f $YUM_C_TO
 done
done

echo -e "moving packages from ..."
for d in $YUM_C_MOV; do
 YUM_C_FROM=$YUM_CACHE/$d/packages
 YUM_C_TO=$YUM_BASE/$d/RPMS
 if [ ! -d $YUM_C_TO ]; then
  mkdir -p $YUM_C_TO
 fi
 cd $YUM_C_FROM
 YUM_C_FILES=`find . -name '*.rpm' | sed 's:^./::'`
 echo -e "  `pwd` to $YUM_C_TO:"
 for f in $YUM_C_FILES; do
  echo -e "      $f"
  mv $YUM_C_FROM/$f $YUM_C_TO
 done
done

echo
echo -ne "resync repositories for non-yum FTP sources y/[n]?"
read -n 1 -a YUM_CMD
if [ $YUM_CMD == "y" ]; then
 echo -e "    ok."
 cd $YUM_BASE
 YUM_C_MOV="`find . -type d -maxdepth 1|grep -E '(-ftp)'| sed 's:^./::'` 
$YUM_C_MOV"
else
 echo -e "    skipped."
fi

echo -ne "resync localbuilds repository y/[n]?"
read -n 1 -a YUM_CMD
if [ $YUM_CMD == "y" ]; then
 echo -e "    ok."
 cd $YUM_BASE
 YUM_C_MOV="`find . -type d -maxdepth 1|grep -E '(localbuilds)'| sed 
's:^./::'` $YUM_C_MOV"
else
 echo -e "    skipped."
fi

echo
for d in $YUM_C_MOV; do
 YUM_C_TO=$YUM_BASE/$d
 cd $YUM_C_TO
 echo -e "resync repo data for repository `pwd` ...\n"
 case $FEDORA_VERSION in
  "2"  | "1")
   rm -rf headers
   yum-arch -vv -l -s . ./headers|tee ./yum-arch-$YUM_DATE
   ;;
  *) 
   rm -rf repodata
   createrepo -v -p .|tee createrepo-$YUM_DATE
   ;;
 esac
 echo -e ""
done




[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux