makedist/obsoleted/merge-repository.sh
2011-05-04 02:30:35 +02:00

78 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
#
# Utility for merging two repositories
#
# usage: merge-repository.sh <source> <dest>
#
# Copyright (c) 2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
. defs.inc.sh
SOURCE_REP=/var/ftp/pub/QiLinux/devel/
DEST_REP=/var/ftp/pub/QiLinux/devel-sc/
#DEST_REP=/var/ftp/pub/QiLinux/devel-sc/nonflat/
ARCH=i586
SOURCE_RPMS_DIR=$SOURCE_REP/RPMS/$ARCH
SOURCE_SRPMS_DIR=$SOURCE_REP/SRPMS
DEST_RPMS_DIR=$DEST_REP/RPMS/$ARCH
DEST_SRPMS_DIR=$DEST_REP/SRPMS
[ ! -e $LOCALSTATEDIR/merge-repository-RPMS ] && FORCE_WRITE=true
for pkgfile in $SOURCE_RPMS_DIR/*.rpm; do
pkgname=`echo $pkgfile | sed "s|.*/\(.*\)-\([^-]*\)-[^-]*|\1|"`
pkgname=`echo $pkgname | sed "s|\+|\\\\\+|"`
pkgver=`echo $pkgfile | sed "s|.*/.*-\([^-]*-[^-]\)\.*|\1|"`
[ -e $DEST_RPMS_DIR ] && \
dest_pkgfile=`find $DEST_RPMS_DIR/ -maxdepth 1 -regex ".*/${pkgname}-[^-]*-[^-]*.rpm" 2>/dev/null` ||
dest_pgfile=
if [ ! "$dest_pkgfile" ]; then
[ "$FORCE_WRITE" ] && \
echo $pkgfile >> $LOCALSTATEDIR/merge-repository-RPMS ||
echo $pkgfile
else
dest_pkgname=`echo $dest_pkgfile | sed "s|.*/\(.*\)-\([^-]*\)-[^-]*|\1|"`
dest_pkgver=`echo $dest_pkgfile | sed "s|.*/.*-\([^-]*-[^-]\)\.*|\1|"`
[ "$FORCE_WRITE" ] && \
echo "$dest_pkgname $pkgver $dest_pkgver " >> $LOCALSTATEDIR/merge-repository-RPMS-excluded ||
echo "$dest_pkgname $pkgver $dest_pkgver "
fi
done
for pkgfile in $SOURCE_SRPMS_DIR/*.src.rpm; do
pkgname=`echo $pkgfile | sed "s|.*/\(.*\)-\([^-]*\)-[^-]*|\1|"`
pkgname=`echo $pkgname | sed "s|\+|\\\\\+|g"`
pkgver=`echo $pkgfile | sed "s|.*/.*-\([^-]*-[^-]\)\.*|\1|"`
dest_pkgfile=`find $DEST_SRPMS_DIR/ -maxdepth 1 -regex ".*/${pkgname}-[^-]*-[^-]*.src.rpm"`
#echo $pkgname
if [ ! "$dest_pkgfile" ]; then
[ "$FORCE_WRITE" ] && echo $pkgfile >> $LOCALSTATEDIR/merge-repository-SRPMS
else
dest_pkgname=`echo $dest_pkgfile | sed "s|.*/\(.*\)-\([^-]*\)-[^-]*|\1|"`
dest_pkgver=`echo $dest_pkgfile | sed "s|.*/.*-\([^-]*-[^-]\)\.*|\1|"`
[ "$FORCE_WRITE" ] && echo "$dest_pkgname $pkgver $dest_pkgver" >> $LOCALSTATEDIR/merge-repository-SRPMS-excluded
fi
done
}
echo "Merging SRPMS repository"
while read line; do
[ "$FORCE_COPY" ] && cp --preserve $line $DEST_SRPMS_DIR/
done < $LOCALSTATEDIR/merge-repository-SRPMS
echo "Merging RPMS repository"
while read line; do
[ "$FORCE_COPY" ] && cp --preserve $line $DEST_RPMS_DIR/
done < $LOCALSTATEDIR/merge-repository-RPMS