#!/usr/bin/bash
APP_PATH=$1
MIRRORPATH="/mnt/lalis/mirror"
ARCH="x86_64 i586 armv7hl aarch64"
if [ -e "/usr/local/etc/cp2mirror.conf" ]; then
echo "utilisation de /usr/local/etc/cp2mirror.conf"
. /usr/local/etc/cp2mirror.conf
fi
if [ -z $APP_PATH ] || ! [ -d $APP_PATH ]; then
echo "argument invalide"
exit 1
for VERSION in `ls -A $MIRRORPATH/mageia/distrib`
do
echo "$MIRRORPATH/mageia/distrib/$VERSION"
if [ "$VERSION" -eq "cauldron" ]; then
VSTRING="cauldron"
else
VSTRING="mga$VERSION"
rsync -aP $APP_PATH/SRPMS/*."$VSTRING".* $MIRRORPATH/lalis/$VERSION/SRPMS/core/updates/
if [ -e "$APP_PATH/RPMS/noarch" ]; then
NOARCH=1
for i in $ARCH; do
if [ $NOARCH ]; then
echo "noarch"
ARCH_O="noarch"
echo "arch"
ARCH_O=$i
if [ -e "$APP_PATH/RPMS/$ARCH_O/" ]; then
if ! [ -e "$MIRRORPATH/lalis/$VERSION/$i/media/core/updates/" ]; then
/usr/bin/mkdir -p "$MIRRORPATH/lalis/$VERSION/$i/media/core/updates/"
echo "rsync -aP $APP_PATH/RPMS/$ARCH_O/*.mga"$VERSION".* $MIRRORPATH/lalis/$VERSION/$i/media/core/updates/"
rsync -aP $APP_PATH/RPMS/$ARCH_O/*.mga"$VERSION".* $MIRRORPATH/lalis/$VERSION/$i/media/core/updates/
gendistrib --nobadrpm --blind --skipmissingdir $MIRRORPATH/lalis/$VERSION/$i
done