#! /bin/sh . ~apt-get/apt-scripts/mkapt.conf REDHATDIR=$MIRRORDIR/distributions/redhat # The idea of full/all/quick is: # * the first time you create the apt repository, choose "full". # * each night (when updates are downloaded), relaunch with "quick" # * if extra packages are put in 'extra' repository, relaunch with "quick" # * if the main os packages change (should not), use "all" if [ $# -ne 1 -o \( "$1" != "full" -a "$1" != "all" -a "$1" != "quick" -a "$1" != "sign" \) ]; then echo "Usage: $0 [full|all|quick|sign]" echo " full: full apt repository creation" echo " all: no apt repository creation, but full indexes regeneration" echo " quick: no apt repository creation, only updates indexes regeneration" echo " sign: generate sign files only" exit 1 fi MODE=$1 ######################################################################## # each of the database definitions will contain: # # redhat_directory:apt_database:apt_package # # redhat_directory is relative to the redhat tree # apt_database is of format redhat-$version-$architecture # apt_package is the redhat package name; os or updates # REDHAT_DBS=" 8.0/en/os/i386/RedHat/RPMS:redhat-8.0-i386:os updates/8.0/en/os/i386/:redhat-8.0-i386:updates 7.3/en/os/i386/RedHat/RPMS:redhat-7.3-i386:os updates/7.3/en/os/i386/:redhat-7.3-i386:updates 7.2/en/os/i386/RedHat/RPMS:redhat-7.2-i386:os updates/7.2/en/os/i386/:redhat-7.2-i386:updates" ######################################################################## for conf_line in ${REDHAT_DBS} ; do echo echo "> $conf_line" # parse out stuff from the db name rdir=$(echo ${conf_line} | cut -d : -f 1) # redhat dir adir=$(echo ${conf_line} | cut -d : -f 2) # apt dir comp=$(echo ${conf_line} | cut -d : -f 3) # component if test -z "$rdir" -o -z "$adir" -o -z "$comp" ; then echo "$0: could not parse redhat database from list" >&2 echo " $conf_line" >&2 echo "$0 terminating!" >&2 exit 1 fi # pull out the version and architecture ver=$(echo ${adir} | sed -e 's,^.*-\([0-9].[0-9]\)-.*$,\1,;') arc=$(echo ${adir} | sed -e 's,^.*-\([^-]*\)$,\1,;') if test -z "$ver" -o -z "$arc" ; then echo "$0: could not parse apt directory parts" >&2 echo " $adir" >&2 echo "$0 terminating!" >&2 exit 1 fi # create the database case "$MODE" in full) # Create directories mkdir -p $APTDIR/$adir/redhat/base || exit 1 # Create the release file RELFILE=$APTDIR/$adir/redhat/base/release.${comp} echo "Archive: stable" > $RELFILE echo "Component: $comp" >> $RELFILE echo "Version: $ver" >> $RELFILE echo "Origin: RedHat" >> $RELFILE echo "Label: $comp" >> $RELFILE echo "Architecture: $arc" >> $RELFILE # Put the symlinks for the base OS packages cd $APTDIR/$adir/ rm -f SRPMS.${comp} if test -d "../$REDHATDIR/$rdir/../SRPMS" ; then ln -sf ../$REDHATDIR/$rdir/../SRPMS SRPMS.${comp} elif test -d "../$REDHATDIR/$rdir/../../SRPMS" ; then ln -sf ../$REDHATDIR/$rdir/../../SRPMS SRPMS.${comp} elif test -d "../$REDHATDIR/$rdir/../../../SRPMS" ; then ln -sf ../$REDHATDIR/$rdir/../../../SRPMS SRPMS.${comp} else echo "cannot find SRPMS.... faking it" >&2 mkdir -p SRPMS.${comp} fi cd $APTDIR/$adir/redhat/ rm -f RPMS.${comp} ln -sf ../../$REDHATDIR/$rdir RPMS.${comp} ;; all|quick|sign) # TODO: some error checking; are the dirs there? ;; *) echo "$0: don't know mode '$MODE'." >&2 echo "$0 terminating!" >&2 exit 1 ;; esac # test to make sure that the source dir exists. it is ok for # this dir not to exist (a binary only package tree) but the # genbasedir will complain if it's not if ! test -d $APTDIR/$adir/SRPMS.${comp} ; then mkdir -p $APTDIR/$adir/SRPMS.${comp} fi # Generate APT indexes if test "$comp" != "os" -o "$MODE" == "full" ; then if test "$MODE" != "sign" ; then genbasedir --topdir=$APTDIR --bloat --bz2only \ $adir/redhat ${comp} fi fi # Generate hash file if test "$MODE" == "sign" ; then genbasedir --topdir=$APTDIR --sign \ $adir/redhat ${comp} fi done ########################################################################### # done echo echo done. echo