LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File fetch.sh of Package build-udba-recipes (Project home:bmanojlovic:UDBA)

#!/bin/sh
# Asumption:
# 1) you are in folder which bellow has root of UDBA project
# 2) you have configured osc already... (this is first but ... :) )
CURRDATE=$(date +"%Y%m%d")
OSC=/usr/bin/osc
WRKF=$(mktemp -d /tmp/udba-recipes-XXXX)
PRJF=$(pwd)
cd $WRKF
while read line ; do
	echo $line | grep -q "^#"
	if [ $? -ne 0 ]; then
		PROJECT=$(echo $line | cut -d\| -f 1)
		PACKAGE=$(echo $line | cut -d\| -f 2)
		SUMMARY=$(echo $line | cut -d\| -f 3)
		$OSC co ${PROJECT} ${PACKAGE}
		X=$(cd "${PROJECT}/${PACKAGE}" ;$OSC info)
		REVISION=$(cd "${PROJECT}/${PACKAGE}" ;$OSC info|grep ^Revision:|cut -d" " -f 2)
		cd $PROJECT
		tar --numeric-owner --owner=root --group=root --exclude ".osc" -zvcf ${PACKAGE}.tar.gz ${PACKAGE}
		# folder can exist in current folder we just don't care really (-p)
		mkdir -p ${PRJF}/udba-${PACKAGE}
		mv ${PACKAGE}.tar.gz $PRJF/udba-${PACKAGE}
		cp ${PRJF}/TEMPLATE.spec.in  ${PRJF}/udba-${PACKAGE}/udba-${PACKAGE}.spec
		sed -i "s/@PROJECT_NAME@/${PROJECT}/g" ${PRJF}/udba-${PACKAGE}/udba-${PACKAGE}.spec
		sed -i "s/@PACKAGE_NAME@/${PACKAGE}/g" ${PRJF}/udba-${PACKAGE}/udba-${PACKAGE}.spec
		sed -i "s/@VERSION@/${REVISION}/g" ${PRJF}/udba-${PACKAGE}/udba-${PACKAGE}.spec
		sed -i "s/@PACKAGE_SUMMARY@/${SUMMARY}/g" ${PRJF}/udba-${PACKAGE}/udba-${PACKAGE}.spec
		if [ -d ${PRJF}/../udba-${PACKAGE} ]; then
			PKGREVISION=$(grep -i ^version: ${PRJF}/../udba-${PACKAGE}/udba-${PACKAGE}.spec|sed -e 's/[vV]ersion:[\t ]//')
			if [ ${PKGREVISION} -ne ${REVISION} ] ; then
				echo "Recipe package for udba-${PACKAGE} changed: replacing old package"
				cp -a ${PRJF}/udba-${PACKAGE}/ ${PRJF}/../
				(cd ${PRJF}/../udba-${PACKAGE};osc commit -m "updated to latest revision:${REVISION}")
			else
				echo "Recipe package not changed"
			fi
		else
			# there is no already created folder for this recipe create it 
			echo "Recipe package for udba-${PACKAGE} does not exist: creating"
			(cd ${PRJF}/..; osc mkpac udba-${PACKAGE})
			cp -a ${PRJF}/udba-${PACKAGE}/ ${PRJF}/../
			(cd ${PRJF}/../udba-${PACKAGE}; osc add *;osc commit -m "initial import")
		fi
	fi
done < ${OLDPWD}/DRIVER_PROJECTS

if [ $WRKF != "/" ] ; then
	rm -rf $WRKF
fi