#!/bin/bash # Copyright Stephen Collier 2014,2015 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Set builder for specfile BUILDER="Stephen Collier " MESSAGE="" INDEX=0 function version_gt() { [[ ( "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" == "$1" ) && ( "$1" != "$2" ) ]] } function update_rpm_to_latest_src { MOCK_CFG=$1 TYPE=$2 ARCH=$3 # Read list of rpms to be processed while read RPM do echo $RPM # Get latest src rpm version FILE=`ls /var/ftp/pub/home/SRPMS/"$RPM"* | sort -rV | sed -n 1p | sed -e 's/.*\///g' | sed -e 's/\.src\.rpm//'` if [ "$ARCH" = "i686" -o "$ARCH" = "i586" -o "$ARCH" = "i486" ] then RPMS_ARCH="i686" else RPMS_ARCH=$ARCH fi echo "here2" if ! ( test -f /var/ftp/pub/home/RPMS/"$TYPE"/"$RPMS_ARCH"/"$FILE".*."$ARCH".rpm || test -f /var/ftp/pub/home/RPMS/"$TYPE"/"$RPMS_ARCH"/"$FILE".*.noarch.rpm ) then #clean the cache for new updates - just metadata would be better but #I can't see how to do it echo "here3" timeout -s 9 30m mock -r $MOCK_CFG --scrub=yum-cache echo "here4" echo "mock building $FILE for $TYPE" timeout -s 9 4h mock -r $MOCK_CFG rebuild /var/ftp/pub/home/SRPMS/"$FILE".src.rpm MESSAGE="$MESSAGE\nBuilt for $TYPE $ARCH $FILE" echo $MESSAGE rsync -av --exclude '*-debuginfo-*' /var/lib/mock/$MOCK_CFG/root/builddir/build/RPMS/ /var/ftp/pub/home/RPMS/$TYPE/$RPMS_ARCH if test -f /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* then rsync -av /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* /var/ftp/pub/home/RPMS/debug/$TYPE/$RPMS_ARCH fi homerepo $TYPE $RPMS_ARCH fi done < /var/local/git/mythtv/rpms-$2-$ARCH } function update_mythweb_git_version { # Move to master git repository cd /var/local/git/mythtv/mythweb # Pull latest git pull # Find what lastest is GIT_DESCRIBE=`git describe` # Pull information apart to be usefull GIT_TAG=`git describe | awk '{print substr($1,2); }' | awk '{split($0,a,"-"); print a[1] }'` LIB_VERSION=`echo -n $GIT_TAG | cut -d'.' -f1` GIT_COMMITS=`git describe | awk '{split($0,a,"-"); print a[2] }'` # If we hit an exact tag we will not get any commits so need to set it if [ -z $GIT_COMMIT ]; then GIT_COMMIT="0" fi # last update stores the last commit number that was built read LAST < ../last_mythweb_update.txt read VERSION < ../last_mythweb_version.txt read RELEASE < ../last_mythweb_release.txt RELEASE=`expr $RELEASE + 1` LASTDATE=`stat -c "%Y" ../last_mythweb_update.txt` NOW=`date -d now +"%s"` DAYSDIFF=$((($NOW-$LASTDATE)/(60*60*24))) echo $DAYSDIFF #Check for new version and set flag NEWVERSION=0 if version_gt $GIT_TAG $VERSION; then echo "NEW VERSION Mythweb" NEWVERSION=1 RELEASE=1 git archive --format=tar --prefix=mythweb-$GIT_TAG/ v$GIT_TAG | bzip2 > ~/rpmbuild/SOURCES/mythweb-$GIT_TAG.tar.bz2 fi # if last less greater or equal to 3 then rebuild or # the last commit was 7 days ago and we have not built it # or there is a new version echo $GIT_COMMITS $LAST if [[ ( $GIT_COMMITS -ge $((LAST+3)) ) || (( $DAYSDIFF -gt 7 ) && ( $GIT_COMMITS -ge $((LAST+1)) )) || ( $NEWVERSION -gt 0 ) ]]; then # reindex to fix up dirty on git 1.7.6 or earlier git update-index --refresh # reindex to fix up dirty on git 1.7.6 or earlier # Fix up mythtv version SOURCE_VERSION=$(git describe --dirty || git describe || echo Unknown) BRANCH=$(git branch --no-color | sed -e '/^[^\*]/d' -e 's/^\* //' -e 's/(no branch)/exported/') #create diff git patches git diff --no-prefix v$GIT_TAG >~/rpmbuild/SOURCES/mythweb-$GIT_TAG-gitfixes.patch # modify the spec file with the information from above sed 's/^#%global libversion.*$/#%global libversion '$LIB_VERSION'/' ~/rpmbuild/SPECS/mythweb.spec > ~/rpmbuild/SPECS/mythweb.spec.tmp sed 's/^Version:.*$/Version: '$GIT_TAG'/' ~/rpmbuild/SPECS/mythweb.spec.tmp > ~/rpmbuild/SPECS/mythweb.spec.tmp.1 sed 's/^Release:.*$/Release: '$RELEASE'%{?dist}/' ~/rpmbuild/SPECS/mythweb.spec.tmp.1 > ~/rpmbuild/SPECS/mythweb.spec.tmp # add coment to changelog in spec filr DATE_STR=`date +'%a %b %d %Y'` sed 's/^%changelog/%changelog\n* '"$DATE_STR"' '"$BUILDER"' - '$GIT_TAG'-'$RELEASE'\n- Update to latest git fixes ('$GIT_DESCRIBE').\n/' ~/rpmbuild/SPECS/mythweb.spec.tmp > ~/rpmbuild/SPECS/mythweb.spec.tmp.1 # make a backup of spec for rollback if build failure cp ~/rpmbuild/SPECS/mythweb.spec ~/rpmbuild/SPECS/mythweb.spec.$RELEASE.orig cp ~/rpmbuild/SPECS/mythweb.spec.tmp.1 ~/rpmbuild/SPECS/mythweb.spec cp ~/rpmbuild/SPECS/mythweb.spec ~/rpmbuild/SPECS/mythweb.spec.$RELEASE # remove temorary spec files rm ~/rpmbuild/SPECS/mythweb.spec.tmp.1 rm ~/rpmbuild/SPECS/mythweb.spec.tmp # build srpm timeout -s 9 30m mock -r $MOCK_CFG --buildsrpm --spec ~/rpmbuild/SPECS/mythweb.spec --sources ~/rpmbuild/SOURCES # rollback spec in case of failure cp ~/rpmbuild/SPECS/mythweb.spec.$RELEASE.orig ~/rpmbuild/SPECS/mythweb.spec # copy srpm to ftp server make it non type cp /var/lib/mock/$MOCK_CFG/result/mythweb-$GIT_TAG-$RELEASE.$TAG.src.rpm /var/ftp/pub/home/SRPMS/mythweb-$GIT_TAG-$RELEASE.src.rpm # success so update the spec cp ~/rpmbuild/SPECS/mythweb.spec.$RELEASE ~/rpmbuild/SPECS/mythweb.spec rm ~/rpmbuild/SPECS/mythweb.spec.$RELEASE # update the commit log to current echo $GIT_COMMITS > ../last_mythweb_update.txt echo $RELEASE > ../last_mythweb_release.txt echo $GIT_TAG > ../last_mythweb_version.txt fi } function update_mythtv_git_version { # Move to master git repository cd /var/local/git/mythtv/mythtv # Pull latest git pull # Find what lastest is GIT_DESCRIBE=`git describe` # Pull information apart to be usefull GIT_TAG=`git describe | awk '{print substr($1,2); }' | awk '{split($0,a,"-"); print a[1] }'` LIB_VERSION=`echo -n $GIT_TAG | cut -d'.' -f1,2` GIT_COMMITS=`git describe | awk '{split($0,a,"-"); print a[2] }'` # If we hit an exact tag we will not get any commits so need to set it if [ -z $GIT_COMMIT ]; then GIT_COMMIT="0" fi # last update stores the last commit number that was built read LAST < ../last_update.txt read VERSION < ../last_version.txt read RELEASE < ../last_release.txt RELEASE=`expr $RELEASE + 1` LASTDATE=`stat -c "%Y" ../last_update.txt` NOW=`date -d now +"%s"` DAYSDIFF=$((($NOW-$LASTDATE)/(60*60*24))) echo $DAYSDIFF $LAST $GIT_COMMITS #Check for new version and set flag NEWVERSION=0 if version_gt $GIT_TAG $VERSION; then echo "NEW VERSION Mythtv" NEWVERSION=1 RELEASE=1 cd mythtv git archive --format=tar --prefix=mythtv-$GIT_TAG/ v$GIT_TAG | bzip2 > ~/rpmbuild/SOURCES/mythtv-$GIT_TAG.tar.bz2 cd ../mythplugins git archive --format=tar --prefix=mythplugins-$GIT_TAG/ v$GIT_TAG | bzip2 > ~/rpmbuild/SOURCES/mythplugins-$GIT_TAG.tar.bz2 cd ../ fi # if last less greater or equal to 5 then rebuild or # the last commit was 7 days ago and we have not built it # or there is a new version if [[ ( $GIT_COMMITS -ge $((LAST+3)) ) || (( $DAYSDIFF -gt 6 ) && ( $GIT_COMMITS -ge $((LAST+1)) )) || ( $NEWVERSION -gt 0 ) ]]; then # reindex to fix up dirty on git 1.7.6 or earlier git update-index --refresh # Fix up mythtv version SOURCE_VERSION=$(git describe --dirty || git describe || echo Unknown) BRANCH=$(git branch --no-color | sed -e '/^[^\*]/d' -e 's/^\* //' -e 's/(no branch)/exported/') #temporary for broken patch for binary if [ $GIT_TAG == "0.27.5" ] then cd mythtv git archive --format=tar --prefix=mythtv-$GIT_TAG/ v$GIT_TAG | bzip2 > ~/rpmbuild/SOURCES/mythtv-$GIT_TAG.tar.bz2 cd ../mythplugins git archive --format=tar --prefix=mythplugins-$GIT_TAG/ v$GIT_TAG | bzip2 > ~/rpmbuild/SOURCES/mythplugins-$GIT_TAG.tar.bz2 cd ../ cat /dev/null >~/rpmbuild/SOURCES/mythtv-$GIT_TAG-gitfixes.patch cat /dev/null >~/rpmbuild/SOURCES/mythplugins-$GIT_TAG-gitfixes.patch else #create diff git patches git diff --ext-diff --no-prefix v$GIT_TAG mythtv >~/rpmbuild/SOURCES/mythtv-$GIT_TAG-gitfixes.patch git diff --ext-diff --no-prefix v$GIT_TAG mythplugins >~/rpmbuild/SOURCES/mythplugins-$GIT_TAG-gitfixes.patch fi #create diff patch for version cat > ~/rpmbuild/SOURCES/version-$GIT_TAG.patch < ~/rpmbuild/SPECS/mythtv.spec.tmp sed 's/^Version:.*$/Version: '$GIT_TAG'/' ~/rpmbuild/SPECS/mythtv.spec.tmp > ~/rpmbuild/SPECS/mythtv.spec.tmp.1 sed 's/^Release:.*$/Release: '$RELEASE'%{?dist}/' ~/rpmbuild/SPECS/mythtv.spec.tmp.1 > ~/rpmbuild/SPECS/mythtv.spec.tmp # add coment to changelog in spec filr DATE_STR=`date +'%a %b %d %Y'` sed 's/^%changelog/%changelog\n* '"$DATE_STR"' '"$BUILDER"' - '$GIT_TAG'-'$RELEASE'\n- Update to latest git fixes ('$GIT_DESCRIBE').\n/' ~/rpmbuild/SPECS/mythtv.spec.tmp > ~/rpmbuild/SPECS/mythtv.spec.tmp.1 # make a backup of spec for rollback if build failure cp ~/rpmbuild/SPECS/mythtv.spec ~/rpmbuild/SPECS/mythtv.spec.$RELEASE.orig cp ~/rpmbuild/SPECS/mythtv.spec.tmp.1 ~/rpmbuild/SPECS/mythtv.spec cp ~/rpmbuild/SPECS/mythtv.spec ~/rpmbuild/SPECS/mythtv.spec.$RELEASE # remove temorary spec files rm ~/rpmbuild/SPECS/mythtv.spec.tmp.1 rm ~/rpmbuild/SPECS/mythtv.spec.tmp # build srpm timeout -s 9 4h mock -r $MOCK_CFG --buildsrpm --spec ~/rpmbuild/SPECS/mythtv.spec --sources ~/rpmbuild/SOURCES # rollback spec in case of failure cp ~/rpmbuild/SPECS/mythtv.spec.$RELEASE.orig ~/rpmbuild/SPECS/mythtv.spec # copy srpm to ftp server make it non type cp /var/lib/mock/$MOCK_CFG/result/mythtv-$GIT_TAG-$RELEASE.$TAG.src.rpm /var/ftp/pub/home/SRPMS/mythtv-$GIT_TAG-$RELEASE.src.rpm # success so update the spec cp ~/rpmbuild/SPECS/mythtv.spec.$RELEASE ~/rpmbuild/SPECS/mythtv.spec rm ~/rpmbuild/SPECS/mythtv.spec.$RELEASE # update the commit log to current echo $GIT_COMMITS > ../last_update.txt echo $RELEASE > ../last_release.txt echo $GIT_TAG > ../last_version.txt fi } function check_get_nvidia_version { # check for if need to get new nvdia version # NVIDIA_VERSION=$1 echo $NVIDIA_VERSION # while read NVIDIA_VERSION # do # Build the version if ! test -f ~/rpmbuild/SPECS/nvidia-graphics$NVIDIA_VERSION.spec then # Get SOURCE Files cd ~/rpmbuild/SOURCES if ! test -f ~/rpmbuild/SOURCES/NVIDIA-Linux-x86_64-$NVIDIA_VERSION.run then wget --tries 10 http://us.download.nvidia.com/XFree86/Linux-x86_64/$NVIDIA_VERSION/NVIDIA-Linux-x86_64-$NVIDIA_VERSION.run fi if ! test -f ~/rpmbuild/SOURCES/NVIDIA-Linux-x86-$NVIDIA_VERSION.run then wget --tries 10 http://us.download.nvidia.com/XFree86/Linux-x86/$NVIDIA_VERSION/NVIDIA-Linux-x86-$NVIDIA_VERSION.run fi cd ~/rpmbuild/SPECS # Get nvidia base version NVIDIA_BASE=`echo $NVIDIA_VERSION | sed -e 's/\..*//'` echo "base="$NVIDIA_BASE # copy the previus revision to modify cp `ls nvidia-graphics$NVIDIA_BASE*.spec | sort -V | tail -1` nvidia-graphics$NVIDIA_VERSION.spec # modify the spec file with the information from above sed 's/^Version:.*$/Version: '$NVIDIA_VERSION'/' ~/rpmbuild/SPECS/nvidia-graphics$NVIDIA_VERSION.spec > ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp let RELEASE=`cat ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp | grep "Release:" | sed -e 's/^Release: //' | sed -e 's/%{?dist}//'`+1 sed 's/^Release:.*$/Release: '$RELEASE'%{?dist}/' ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp > ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp.1 # add coment to changelog in spec filr DATE_STR=`date +'%a %b %d %Y'` sed 's/^%changelog/%changelog\n* '"$DATE_STR"' '"$BUILDER"' - '$NVIDIA_VERSION'-'$RELEASE'\n- Update to latest nvidia version ('$NVIDIA_VERSION').\n/' ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp.1 > ~/rpmbuild/SPECS/nvidia-graphics$NVIDIA_VERSION.spec # remove temorary spec files rm ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp.1 rm ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp fi # done < /var/local/git/mythtv/nvidia-$1 } function check_get_nvidia_wrapper { # check for if need to get new nvidia version for long or short lived # TYPE=$1 while read NVIDIA_VERSION do # Build the version echo "/var/ftp/pub/home/SRPMS/nvidia-graphics-$TYPE-$NVIDIA_VERSION*.src.rpm" if ! test -f /var/ftp/pub/home/SRPMS/nvidia-graphics-$TYPE-$NVIDIA_VERSION*.src.rpm then # modify the spec file with the information from above sed 's/^Version:.*$/Version: '$NVIDIA_VERSION'/' ~/rpmbuild/SPECS/nvidia-graphics-$TYPE.spec > ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp let RELEASE=`cat ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp | grep "Release:" | sed -e 's/^Release: //' | sed -e 's/%{?dist}//'`+1 sed 's/^Release:.*$/Release: '$RELEASE'%{?dist}/' ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp > ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp.1 # add coment to changelog in spec filr DATE_STR=`date +'%a %b %d %Y'` sed 's/^%changelog/%changelog\n* '"$DATE_STR"' '"$BUILDER"' - '$NVIDIA_VERSION'-'$RELEASE'\n- Update to latest nvidia version ('$NVIDIA_VERSION').\n/' ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp.1 > ~/rpmbuild/SPECS/nvidia-graphics-$TYPE.spec # remove temorary spec files rm ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp.1 rm ~/rpmbuild/SPECS/nvidia-graphics.spec.tmp mock_build_rpm.sh nvidia-graphics-$TYPE fi done < /var/local/git/mythtv/nvidia-$TYPE.txt } function check_new_nvidia_version { # check for a new nvdia version # TYPE=$1 # Check if new nvidia version x86_64 NVIDIA_LONG=`curl -s http://www.nvidia.com/object/unix.html | grep "Latest Long Lived Branch" | awk -F ">|<" ' {print$3}' | grep "[0-9].[0-9]" | sort -Vr | tail -n 1` NVIDIA_SHORT=`curl -s http://www.nvidia.com/object/unix.html | grep "Latest Short Lived Branch" | awk -F ">|<" ' {print$3}' | grep "[0-9].[0-9]" | sort -Vr | head -n 1` NVIDIA_LEGACY340=`curl -s http://www.nvidia.com/object/unix.html | grep "Latest Legacy GPU version (340" | awk -F ">|<" ' {print$3}' | grep "[0-9].[0-9]" | sort -Vr | head -n 1` NVIDIA_LEGACY304=`curl -s http://www.nvidia.com/object/unix.html | grep "Latest Legacy GPU version (304" | awk -F ">|<" ' {print$3}' | grep "[0-9].[0-9]" | sort -Vr | head -n 1` NVIDIA_LEGACY71=`curl -s http://www.nvidia.com/object/unix.html | grep "Latest Legacy GPU version (71" | awk -F ">|<" ' {print$3}' | grep "[0-9].[0-9]" | sort -Vr | head -n 1` NVIDIA_LEGACY96=`curl -s http://www.nvidia.com/object/unix.html | grep "Latest Legacy GPU version (96" | awk -F ">|<" ' {print$3}' | grep "[0-9].[0-9]" | sort -Vr | head -n 1` NVIDIA_LEGACY173=`curl -s http://www.nvidia.com/object/unix.html | grep "Latest Legacy GPU version (173" | awk -F ">|<" ' {print$3}' | grep "[0-9].[0-9]" | sort -V | head -n 1` if [ $NVIDIA_LONG != `cat /var/local/git/mythtv/nvidia-long-lived.txt` ] then check_get_nvidia_version $NVIDIA_LONG echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-long-lived.txt fi if [ $NVIDIA_SHORT != `cat /var/local/git/mythtv/nvidia-short-lived.txt` ] then check_get_nvidia_version $NVIDIA_SHORT echo $NVIDIA_SHORT > /var/local/git/mythtv/nvidia-short-lived.txt fi if [ $NVIDIA_LEGACY304 != `cat /var/local/git/mythtv/nvidia-legacy-304.txt` ] then check_get_nvidia_version $NVIDIA_LEGACY304 echo $NVIDIA_LEGACY304 > /var/local/git/mythtv/nvidia-legacy-304.txt fi if [ $NVIDIA_LEGACY340 != `cat /var/local/git/mythtv/nvidia-legacy-340.txt` ] then check_get_nvidia_version $NVIDIA_LEGACY340 echo $NVIDIA_LEGACY340 > /var/local/git/mythtv/nvidia-legacy-340.txt fi if [ $NVIDIA_LEGACY71 != `cat /var/local/git/mythtv/nvidia-legacy-71.86.txt` ] then check_get_nvidia_version $NVIDIA_LEGACY71 echo $NVIDIA_LEGACY71 > /var/local/git/mythtv/nvidia-legacy-71.86.txt fi if [ $NVIDIA_LEGACY173 != `cat /var/local/git/mythtv/nvidia-legacy-173.14.txt` ] then check_get_nvidia_version $NVIDIA_LEGACY173 echo $NVIDIA_LEGACY173 > /var/local/git/mythtv/nvidia-legacy-173,14.txt fi if [ $NVIDIA_LEGACY96 != `cat /var/local/git/mythtv/nvidia-legacy-96.43.txt` ] then check_get_nvidia_version $NVIDIA_LEGACY96 echo $NVIDIA_LEGACY96 > /var/local/git/mythtv/nvidia-legacy-96.43.txt fi echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-el6 echo $NVIDIA_SHORT >> /var/local/git/mythtv/nvidia-el6 echo $NVIDIA_LEGACY304 >> /var/local/git/mythtv/nvidia-el6 echo $NVIDIA_LEGACY340 >> /var/local/git/mythtv/nvidia-el6 echo "352.21" >> /var/local/git/mythtv/nvidia-el6 # echo $NVIDIA_LEGACY71 >> /var/local/git/mythtv/nvidia-el6 # echo $NVIDIA_LEGACY96 >> /var/local/git/mythtv/nvidia-el6 # echo $NVIDIA_LEGACY173 >> /var/local/git/mythtv/nvidia-el6 echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-el7 echo $NVIDIA_SHORT >> /var/local/git/mythtv/nvidia-el7 echo $NVIDIA_LEGACY304 >> /var/local/git/mythtv/nvidia-el7 echo $NVIDIA_LEGACY340 >> /var/local/git/mythtv/nvidia-el7 echo "352.21" >> /var/local/git/mythtv/nvidia-el7 echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-el8 echo $NVIDIA_SHORT >> /var/local/git/mythtv/nvidia-el8 echo $NVIDIA_LEGACY304 >> /var/local/git/mythtv/nvidia-el8 echo $NVIDIA_LEGACY340 >> /var/local/git/mythtv/nvidia-el8 echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-f24 echo $NVIDIA_SHORT >> /var/local/git/mythtv/nvidia-f24 echo $NVIDIA_LEGACY304 >> /var/local/git/mythtv/nvidia-f24 echo $NVIDIA_LEGACY340 >> /var/local/git/mythtv/nvidia-f24 #echo "352.21" >> /var/local/git/mythtv/nvidia-f24 echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-f25 echo $NVIDIA_SHORT >> /var/local/git/mythtv/nvidia-f25 #echo $NVIDIA_LEGACY304 >> /var/local/git/mythtv/nvidia-f25 echo $NVIDIA_LEGACY340 >> /var/local/git/mythtv/nvidia-f25 echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-f26 echo $NVIDIA_SHORT >> /var/local/git/mythtv/nvidia-f26 #echo $NVIDIA_LEGACY304 >> /var/local/git/mythtv/nvidia-f26 echo $NVIDIA_LEGACY340 >> /var/local/git/mythtv/nvidia-f26 echo $NVIDIA_LONG > /var/local/git/mythtv/nvidia-f27 echo $NVIDIA_SHORT >> /var/local/git/mythtv/nvidia-f27 #echo $NVIDIA_LEGACY304 >> /var/local/git/mythtv/nvidia-f27 echo $NVIDIA_LEGACY340 >> /var/local/git/mythtv/nvidia-f27 echo $NVIDIA_LONG echo $NVIDIA_SHORT echo $NVIDIA_LEGACY304 echo $NVIDIA_LEGACY340 #echo $NVIDIA_LEGACY71 #echo $NVIDIA_LEGACY96 #echo $NVIDIA_LEGACY173 } function mock_build_nvidia_rpm { # mock utility to create rpm from spec # # Check if we have a new kernel MOCK_CFG=$1 TYPE=$2 ARCH=$3 SITE=$4 echo $MOCK_CFG $TYPE $ARCH $SITE curl --connect-timeout 240 --max-time 900 -s $SITE --list-only | awk 'match($0, />kernel-[0-9][a-z,A-Z,0-9,_,.,-]+.rpm/ /' | sort -V | tail -1 > /var/local/git/mythtv/latest_"$TYPE"_"$ARCH"_kernel.txt read KERNEL < /var/local/git/mythtv/latest_"$TYPE"_"$ARCH"_kernel.txt echo $KERNEL KERNELVERSION=`echo -n $KERNEL | cut -d '-' -f2,3 | sed -e 's/\.[xi_1-9]*\.rpm//'` #if diff /var/local/git/mythtv/latest_"$TYPE"_"$ARCH"_kernel.txt /var/local/git/mythtv/last_"$TYPE"_"$ARCH"_kernel.txt || [ ! -s /var/local/git/mythtv/latest_"$TYPE"_"$ARCH"_kernel.txt ] >/dev/null ; then echo 'No new kernel' # Move to the versions # Read list of rpms to be processed while read NVIDIA_VERSION do # Build the version RELEASE=`cat ~/rpmbuild/SPECS/nvidia-graphics$NVIDIA_VERSION.spec | grep "Release:" | sed -e 's/^Release: //' | sed -e 's/%{?dist}//'` echo $NVIDIA_VERSION $RELEASE if ! test -f /var/ftp/pub/home/SRPMS/nvidia-graphics$NVIDIA_VERSION-$NVIDIA_VERSION-$RELEASE.src.rpm then # build srpm timeout -s 9 1h mock -r "$MOCK_CFG" --buildsrpm --spec ~/rpmbuild/SPECS/nvidia-graphics$NVIDIA_VERSION.spec --sources ~/rpmbuild/SOURCES # copy srpm to ftp server make it non type if test -f /var/lib/mock/$MOCK_CFG/result/nvidia-graphics$NVIDIA_VERSION-$NVIDIA_VERSION-$RELEASE.*.src.rpm then srpm_name=$(ls /var/lib/mock/$MOCK_CFG/result/nvidia-graphics$NVIDIA_VERSION-$NVIDIA_VERSION-$RELEASE.*.src.rpm | cut -d'/' -f7,7 | sed -e 's/el6.//') else srpm_name=$(ls /var/lib/mock/$MOCK_CFG.tmp/result/nvidia-graphics$NVIDIA_VERSION-$NVIDIA_VERSION-$RELEASE.*.src.rpm | cut -d'/' -f7,7 | sed -e 's/el6.//') fi cp /var/lib/mock/$MOCK_CFG/result/nvidia-graphics$NVIDIA_VERSION-$NVIDIA_VERSION-$RELEASE*.src.rpm /var/ftp/pub/home/SRPMS/$srpm_name fi SRPM=`ls /var/ftp/pub/home/SRPMS/nvidia-graphics$NVIDIA_VERSION-$NVIDIA_VERSIONE* | sort -rV | sed -n 1p ` RPMVER=`echo -n $SRPM | cut -d '-' -f3- | sed -e 's/\.src\.rpm//'` echo "/var/ftp/pub/home/RPMS/$TYPE/$ARCH/nvidia-graphics$NVIDIA_VERSION-kmdl-$KERNELVERSION-$RPMVER.*.rpm" if ! test -f /var/ftp/pub/home/RPMS/$TYPE/$ARCH/nvidia-graphics$NVIDIA_VERSION-kmdl-$KERNELVERSION*-$RPMVER.*.rpm then if ! test -f /var/ftp/pub/home/RPMS/$TYPE/$ARCH/nvidia-graphics$NVIDIA_VERSION-$RPMVER.*.rpm then echo "build new nvidia driver $RPMVER" #sudo mock --scrub=yum-cache -r $MOCK_CFG timeout -s 9 30m sudo mock --define "kmdl_userland 1" -r $MOCK_CFG rebuild $SRPM #check for libs and copy if necessary MESSAGE="$MESSAGE\nBuilt for $TYPE $ARCH nvidia-graphics$NVIDIA_VERSION" echo $MESSAGE if [ "$ARCH" = "i686" -o "$ARCH" = "i586" -o "$ARCH" = "i486" ] then sudo rsync -av --exclude '*-debuginfo-*' /var/lib/mock/$MOCK_CFG/root/builddir/build/RPMS/ /var/ftp/pub/home/RPMS/$TYPE/i686 if test -f /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* then sudo rsync -av /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* /var/ftp/pub/home/RPMS/debug/$TYPE/i686 fi homerepo $TYPE i686 else sudo rsync -av --exclude '*-debuginfo-*' /var/lib/mock/$MOCK_CFG/root/builddir/build/RPMS/ /var/ftp/pub/home/RPMS/$TYPE/$ARCH if test -f /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* then sudo rsync -av /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* /var/ftp/pub/home/RPMS/debug/$TYPE/$ARCH fi homerepo $TYPE $ARCH fi fi #sudo mock --scrub=yum-cache -r $MOCK_CFG echo "build new nvidia kmdl $RPMVER $KERNELVERSION" timeout -s 9 1h sudo mock --define "kmdl_userland 0" -r $MOCK_CFG rebuild $SRPM MESSAGE="$MESSAGE\nBuilt for $TYPE $ARCH nvidia-graphics$NVIDIA_VERSION for $KERNEL" echo $MESSAGE if [ "$ARCH" = "i686" -o "$ARCH" = "i586" -o "$ARCH" = "i486" ] then sudo rsync -av --exclude '*-debuginfo-*' /var/lib/mock/$MOCK_CFG/root/builddir/build/RPMS/ /var/ftp/pub/home/RPMS/$TYPE/i686 if test -f /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* then sudo rsync -av /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* /var/ftp/pub/home/RPMS/debug/$TYPE/i686 fi homerepo $TYPE i686 else sudo rsync -av --exclude '*-debuginfo-*' /var/lib/mock/$MOCK_CFG/root/builddir/build/RPMS/ /var/ftp/pub/home/RPMS/$TYPE/$ARCH if test -f /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* then sudo rsync -av /var/lib/mock/$MOCK_CFG/result/*-debuginfo-* /var/ftp/pub/home/RPMS/debug/$TYPE/$ARCH fi homerepo $TYPE $ARCH fi fi done < /var/local/git/mythtv/nvidia-$2 } # Set bailout on error MOCK_CFG=$1 TAG=$2 ARCH=$3 REPO=$4 echo "here 0" # Check if already running don't wnat to run more than 1 # Check for file update_mythtv_rpm ps_mythtvbuild=`ps cax | grep -c update_mythtv_r` echo "here 0a" if [ $ps_mythtvbuild != 2 ]; then echo "File mythtvbuild in progress... $ps_mythtvbuild" exit 1 fi echo "here 0b" ps_mockbuild=`ps cax | grep -c mock` if [ $ps_mockbuild -gt 0 ]; then echo "File mock in progress... $ps_mockbuild" exit 1 fi set -e echo "here 1" #expect /usr/local/bin/fix_repo.exp $MOCK_CFG echo $TAG $ARCH if ! ( test -d /var/ftp/pub/home/RPMS/"$TAG"/"$ARCH"/ ) then mkdir -p /var/ftp/pub/home/RPMS/"$TAG"/"$ARCH"/ mkdir -p /var/ftp/pub/home/RPMS/"$TAG"/"$ARCH"/repoview mkdir -p /var/ftp/pub/home/RPMS/"$TAG"/"$ARCH"/repodata mkdir -p /var/ftp/pub/home/RPMS/debug/"$TAG"/"$ARCH"/ cp /var/ftp/pub/home/RPMS/el7/x86_64/atrpms-rpm-config* /var/ftp/pub/home/RPMS/"$TAG"/"$ARCH"/ homerepo $TAG $ARCH update_rpm_to_latest_src "$MOCK_CFG" "$TAG" "$ARCH" fi #update_rpm_to_latest_src "$MOCK_CFG" "$TAG" "$ARCH" # Move to master git repository cd /var/local/git/mythtv/mythtv # Check for new nvidia driver #check_new_nvidia_version "$TAG" # Build the nvidia drivers #mock_build_nvidia_rpm "$MOCK_CFG" "$TAG" "$ARCH" "$REPO" #Build the pseudo rpms if needed #check_get_nvidia_wrapper "long-lived" #check_get_nvidia_wrapper "short-lived" #check_get_nvidia_wrapper "legacy-304" #check_get_nvidia_wrapper "legacy-340" echo "here 2" if [ $TAG = "el6" ] then check_get_nvidia_wrapper "legacy-71.86" check_get_nvidia_wrapper "legacy-96.43" check_get_nvidia_wrapper "legacy-173.14" fi #Update mythtv sources update_mythtv_git_version update_mythweb_git_version #build and rpms that have new src rpms update_rpm_to_latest_src "$MOCK_CFG" "$TAG" "$ARCH" rsync -av /usr/local/bin/homerepo /var/ftp/pub/home/scripts/usr_local_bin/ rsync -av /usr/local/bin/rpmbuild_cron /var/ftp/pub/home/scripts/usr_local_bin/ rsync -av /usr/local/bin/update_mythtv_rpm /var/ftp/pub/home/scripts/usr_local_bin/ # rsync to update set +e #rsync to upstream server and update last update file if changes #if [ `rsync -aiz --delete --password-file=/usr/local/etc/pass.txt /var/ftp/pub/home/ jeronimo@167.160.167.42::scrpms-up | wc -l` != '0' ]; then # date --utc > /var/ftp/pub/home/last_update; # rsync -avz --delete --password-file=/usr/local/etc/pass.txt /var/ftp/pub/home/ jeronimo@167.160.167.42::scrpms-up 2>&1 >/tmp/rsync$$ #fi if [ `rsync -aiz --delete --password-file=/usr/local/etc/pass.txt /var/ftp/pub/home/* jeronimo@45.58.49.250::scrpms-up | wc -l` != '0' ]; then date --utc > /var/ftp/pub/home/last_update; rsync -avz --delete --password-file=/usr/local/etc/pass.txt /var/ftp/pub/home/* jeronimo@45.58.49.250::scrpms-up 2>&1 >/tmp/rsync$$ fi echo $MESSAGE if [ -n "$MESSAGE" ]; then echo -e $MESSAGE | mailx -s "scrpms updated rpms" "scrpms-users@googlegroups.com" fi exit 0 #expect /usr/local/bin/fix_repo.exp $MOCK_CFG