#!/bin/sh # $Id: genaptrep.sh 3099 2005-04-04 18:38:20Z thias $ # # Quick script to generate apt repositories for Red Hat Linux # Hacked in a few minutes by Matthias Saou http://freshrpms.net/ # (ugly script? yeah, probably ;-)) # Local configuration # The distribution (for a custom one, you could just use a different name) DISTR=redhat # The directory where the apt "tree" is (where apt.tar.gz was extracted) APTDIR=/var/ftp/pub/apt # The directory where your (partial) local Red Hat Linux mirror resides MIRRORDIR=/var/ftp/pub/redhat/linux # The directory where your (partial) local Freshrpms.net mirror resides FRESHRPMS=/var/ftp/pub/freshrpms # Everything else... normally, no need to change anything, but go ahead ;-) if [ -z "$1" ]; then echo "Usage : $0 " echo "Example repository modules include 'rh80', 'rh80-up', 'rh80-fr'" exit 1 fi hash() { # Usage : hash LG=$1 ARCH=$2 shift 2 genbasedir --hashonly \ ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH} $* >/dev/null 2>/dev/null } configured() { # Usage : configured LG=$1 ARCH=$2 MODL=$3 test -r "${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/base/release.${MODL}" return $? } gen() { # Usage : gen LG=$1 ARCH=$2 MODL=$3 if ! `which genbasedir >/dev/null 2>&1`; then echo "The \"genbasedir\" command was not found! Please install apt first." return 1 fi echo -n "Generating ${DISTR}/${VERSION}/${LG}/${ARCH} ${MODL} : " if configured ${LG} ${ARCH} ${MODL}; then echo "patience..." genbasedir --flat --bloat --progress \ ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH} ${MODL} else echo "skipped (no release.${MODL} file)" return 1 fi } updates() { # Usage : updates LG=$1 ARCH=$2 SEARCHARCH="-name *.${ARCH}.rpm" # Ugly hack because of ix86 stuff [ "${ARCH}" = "i386" ] && SEARCHARCH="-name *86.rpm -o -name *.athlon.rpm" shift 2 rm -f ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/RPMS.updates/* find ${MIRRORDIR}/updates/${VERSION}/${LG}/ -type f ! -name *.src.rpm \ \( ${SEARCHARCH} -o -name *.noarch.rpm \) \ -exec ln {} ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/RPMS.updates/ \ 2>/dev/null \; } dma() { # Usage : dma LG=$1 ARCH=$2 SEARCHARCH="-name *.${ARCH}.rpm" # Ugly hack because of ix86 stuff [ "${ARCH}" = "i386" ] && SEARCHARCH="-name *86.rpm -o -name *.athlon.rpm" shift 2 rm -f ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/RPMS.dma/* find ${MIRRORDIR}/${VERSION}/${LG}/DMA/ -type f ! -name *.src.rpm \ \( ${SEARCHARCH} -o -name *.noarch.rpm \) \ -exec ln {} ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/RPMS.dma/ \ 2>/dev/null \; rm -f ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/SRPMS.dma/* find ${MIRRORDIR}/${VERSION}/${LG}/DMA/ -type f -name *.src.rpm \ -exec ln {} ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/SRPMS.dma/ \ 2>/dev/null \; } freshrpms() { # Usage : freshrpms LG=$1 ARCH=$2 SEARCHARCH="-name *.${ARCH}.rpm" # Ugly hack because of ix86 stuff [ "${ARCH}" = "i386" ] && SEARCHARCH="-name *86.rpm -o -name *.athlon.rpm" shift 2 rm -f ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/RPMS.freshrpms/* rm -f ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/SRPMS.freshrpms/* find ${FRESHRPMS}/${DISTR}/${VERSION}/ -type f \ ! -name *.src.rpm \( ${SEARCHARCH} -o -name *.noarch.rpm \) \ -exec ln {} ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/RPMS.freshrpms/ \ 2>/dev/null \; find ${FRESHRPMS}/${DISTR}/${VERSION}/ -type f -name *.src.rpm \ -exec ln {} ${APTDIR}/${DISTR}/${VERSION}/${LG}/${ARCH}/SRPMS.freshrpms/ \ 2>/dev/null \; } ######################### ### Red Hat Linux 8.0 ### ######################### VERSION="8.0" hash80() { hash en i386 os updates freshrpms } ### os if [ "$1" = "rh80" ]; then gen en i386 os && \ hash80 fi ### updates if [ "$1" = "rh80-up" ]; then updates en i386 && \ gen en i386 updates && \ hash80 fi ### freshrpms if [ "$1" = "rh80-fr" ]; then freshrpms en i386 && \ gen en i386 freshrpms && \ hash80 fi ######################### ### Red Hat Linux 7.3 ### ######################### VERSION="7.3" hash73() { hash en i386 os updates freshrpms } ### os if [ "$1" = "rh73" ]; then gen en i386 os && \ hash73 fi ### updates if [ "$1" = "rh73-up" ]; then updates en i386 && \ gen en i386 updates && \ hash73 fi ### freshrpms if [ "$1" = "rh73-fr" ]; then freshrpms en i386 && \ gen en i386 freshrpms && \ hash73 fi ######################### ### Red Hat Linux 7.2 ### ######################### VERSION="7.2" hash72() { hash en i386 os updates freshrpms hash ja i386 os hash en ia64 os updates hash en s390 os updates } ### os if [ "$1" = "rh72" ]; then gen en i386 os gen ja i386 os gen en ia64 os gen en s390 os hash72 fi ### updates if [ "$1" = "rh72-up" ]; then updates en i386 gen en i386 updates updates en ia64 gen en ia64 updates updates en s390 gen en s390 updates hash72 fi ### freshrpms if [ "$1" = "rh72-fr" ]; then freshrpms en i386 && \ gen en i386 freshrpms && \ hash72 fi ######################### ### Red Hat Linux 7.1 ### ######################### VERSION="7.1" hash71() { hash en i386 os powertools updates freshrpms hash kr i386 os hash en ia64 os updates } ### os + powertools if [ "$1" = "rh71" ]; then gen en i386 os gen en i386 powertools gen kr i386 os gen en ia64 os hash71 fi ### updates + powertools updates if [ "$1" = "rh71-up" ]; then updates en i386 && \ gen en i386 updates updates en ia64 && \ gen en ia64 updates hash71 fi ### freshrpms if [ "$1" = "rh71-fr" ]; then freshrpms en i386 && \ gen en i386 freshrpms && \ hash71 fi ######################### ### Red Hat Linux 7.0 ### ######################### VERSION="7.0" hash70() { hash en i386 os dma powertools updates freshrpms hash ja i386 os hash tc i386 os } ### os + powertools if [ "$1" = "rh70" ]; then gen en i386 os gen en i386 powertools dma en i386 && \ gen en i386 dma gen ja i386 os gen tc i386 os hash70 fi ### updates + powertools updates if [ "$1" = "rh70-up" ]; then updates en i386 && \ gen en i386 updates updates ja i386 && \ gen ja i386 updates hash70 fi ### freshrpms if [ "$1" = "rh70-fr" ]; then freshrpms en i386 && \ gen en i386 freshrpms && \ hash70 fi