|
Packit |
857059 |
#!/bin/bash
|
|
Packit |
857059 |
# github servers where WFR repos are found
|
|
Packit |
857059 |
server1=git-amr-1.devtools.intel.com:29418
|
|
Packit |
857059 |
server2=git-amr-2.devtools.intel.com:29418
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Usage()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
echo "Usage: gitpull.sh [-PSdcv] [-b branch] [-t topdir] [-g gitdir] [repo ...]" >&2
|
|
Packit |
857059 |
echo " -P - skip pulling/cloning from repro" >&2
|
|
Packit |
857059 |
echo " -S - skip building and expanding the srpm" >&2
|
|
Packit |
857059 |
echo " -d - diff against CVS" >&2
|
|
Packit |
857059 |
echo " -c - copy to CVS" >&2
|
|
Packit |
857059 |
echo " -v - verbose output" >&2
|
|
Packit |
857059 |
echo " -b branch - git branch to checkout" >&2
|
|
Packit |
857059 |
echo " (by default will read branch name from CVS commitids)" >&2
|
|
Packit |
857059 |
echo " -t topdir - top directory in CVS tree (default is $PWD)" >&2
|
|
Packit |
857059 |
echo " -g gitdir - parent directory for git repo(s) (defailt is GIT_REPOS)" >&2
|
|
Packit |
857059 |
echo " repo - list of wfr repos to operate on, default is all repos" >&2
|
|
Packit |
857059 |
exit 2
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# a few aren't working yet
|
|
Packit |
857059 |
repos="wfr-driver wfr-firmware wfr-psm wfr-diagtools-sw"
|
|
Packit |
857059 |
repos="$repos wfr-lite wfr-ibacm wfr-libverbs"
|
|
Packit |
857059 |
repos="$repos wfr-libibumad"
|
|
Packit |
857059 |
repos="$repos wfr-mvapich2"
|
|
Packit |
857059 |
repos="$repos wfr-openmpi"
|
|
Packit |
857059 |
repos="$repos wfr-gasnet"
|
|
Packit |
857059 |
repos="$repos wfr-openshmem"
|
|
Packit |
857059 |
repos="$repos wfr-openshmem-tests"
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# skip this, linux kernel 3.12.18 for devel
|
|
Packit |
857059 |
#repos="$repos wfr-linux-devel"
|
|
Packit |
857059 |
|
|
Packit |
857059 |
in_branch=
|
|
Packit |
857059 |
pull=y
|
|
Packit |
857059 |
makesrpm=y
|
|
Packit |
857059 |
diff=n
|
|
Packit |
857059 |
copy=n
|
|
Packit |
857059 |
topdir=$PWD
|
|
Packit |
857059 |
gitdir=GIT_REPOS
|
|
Packit |
857059 |
verbose=n
|
|
Packit |
857059 |
while getopts PSdcvb:t:g: param
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
case $param in
|
|
Packit |
857059 |
P) pull=n;;
|
|
Packit |
857059 |
S) makesrpm=n;;
|
|
Packit |
857059 |
d) diff=y;;
|
|
Packit |
857059 |
c) copy=y;;
|
|
Packit |
857059 |
v) verbose=y;;
|
|
Packit |
857059 |
b) in_branch="$OPTARG";;
|
|
Packit |
857059 |
t) topdir="$OPTARG";;
|
|
Packit |
857059 |
g) gitdir="$OPTARG";;
|
|
Packit |
857059 |
*) Usage;;
|
|
Packit |
857059 |
esac
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
shift $((OPTIND -1))
|
|
Packit |
857059 |
if [ $# -gt 0 ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
repos="$*"
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ ! -d $topdir ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "gitpull: FAILED: topdir Directory Not Found: $topdir" >&2
|
|
Packit |
857059 |
Usage
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
if [ ! -d $gitdir ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "gitpull: FAILED: gitdir Directory Not Found: $gitdir" >&2
|
|
Packit |
857059 |
Usage
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# convert topdir to an absolute path
|
|
Packit |
857059 |
if [ `echo $topdir | cut -c 1` != '/' ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
topdir=$PWD/$topdir
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
# convert gitdir to an absolute path
|
|
Packit |
857059 |
if [ `echo $gitdir | cut -c 1` != '/' ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
gitdir=$PWD/$gitdir
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
[ $verbose = y ] && echo "Using topdir= $topdir; gitdir= $gitdir"
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# different repo servers
|
|
Packit |
857059 |
get_server()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
case $1 in
|
|
Packit |
857059 |
wfr-lite|wfr-openshmem|wfr-oshmem|wfr-openshmem-tests) echo $server1;;
|
|
Packit |
857059 |
*) echo $server2;;
|
|
Packit |
857059 |
esac
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# some repos have names different from Ofed/ tree name, remap
|
|
Packit |
857059 |
get_ofed_dir()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
case $1 in
|
|
Packit |
857059 |
wfr-ibacm) echo "ibacm";;
|
|
Packit |
857059 |
wfr-libibumad) echo "libibumad";;
|
|
Packit |
857059 |
wfr-openshmem-tests) echo "wfr-openshmem-tests/openshmem-test-suite";;
|
|
Packit |
857059 |
*) echo "$1";;
|
|
Packit |
857059 |
esac
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
get_git_branch()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
if [ ! -e $topdir/Ofed/$1/commitids ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "FAILED: Unable to get git branch. Not Found: $topdir/Ofed/$1/commitids" >&2
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
tail -1 $topdir/Ofed/$1/commitids|cut -f 1 -d ' '
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
for i in $repos
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
branch=$in_branch
|
|
Packit |
857059 |
ofed_dir=`get_ofed_dir $i`
|
|
Packit |
857059 |
echo "Processing git repo $i against Ofed/$ofed_dir"
|
|
Packit |
857059 |
if [ $pull = y ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
# lookup git branch in commitids file in CVS
|
|
Packit |
857059 |
if [ x"$branch" = x ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
branch=`get_git_branch $ofed_dir`
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
if [ x"$branch" = x ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "FAILED: unable to determine git branch for $i" >&2
|
|
Packit |
857059 |
continue
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
[ $verbose = y ] && echo "Using git branch $branch"
|
|
Packit |
857059 |
|
|
Packit |
857059 |
## get the latest copy of source from the repos
|
|
Packit |
857059 |
if [ ! -d $gitdir/$i ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
server=`get_server $i`
|
|
Packit |
857059 |
[ $verbose = y ] && echo "(cd $gitdir; git clone ssh://$USER@$server/$i)"
|
|
Packit |
857059 |
(cd $gitdir; git clone ssh://$USER@$server/$i)
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
[ $verbose = y ] && echo "(cd $gitdir/$i; git pull)"
|
|
Packit |
857059 |
(cd $gitdir/$i; git pull)
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
##Next, checkout the desired branch in each directory
|
|
Packit |
857059 |
[ $verbose = y ] && echo "(cd $gitdir/$i; git checkout $branch )"
|
|
Packit |
857059 |
(cd $gitdir/$i; git checkout $branch )
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
if [ ! -d $gitdir/$i ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "FAILED: Need to pull, Directory not found: $gitdir" >&2
|
|
Packit |
857059 |
continue
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
##show the branch we are on
|
|
Packit |
857059 |
(cd $gitdir/$i; git branch )
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $makesrpm = y ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
if [ ! -e $gitdir/$i/makesrpm.sh ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "FAILED: Unable to makesrpm, File not found: $gitdir/$i/makesrpm.sh" >&2
|
|
Packit |
857059 |
continue
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
##make the srpm
|
|
Packit |
857059 |
[ $verbose = y ] && echo "rm -rf $gitdir/$i/SOURCE_TREE"
|
|
Packit |
857059 |
rm -rf $gitdir/$i/SOURCE_TREE
|
|
Packit |
857059 |
[ $verbose = y ] && echo "(cd $gitdir/$i/; bash -x ./makesrpm.sh )"
|
|
Packit |
857059 |
(cd $gitdir/$i/; bash -x ./makesrpm.sh )
|
|
Packit |
857059 |
|
|
Packit |
857059 |
##expand it
|
|
Packit |
857059 |
if [ `ls $gitdir/$i/SRPMS/*.src.rpm|wc -l` != 1 ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "FAILED: srpm missing or too many, File not found: $gitdir/$i/SRPMS/*.src.rpm" >&2
|
|
Packit |
857059 |
continue
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
[ $verbose = y ] && echo "Expanding source into $gitdir/$i/SOURCE_TREE"
|
|
Packit |
857059 |
(cd $gitdir/$i/; mkdir SOURCE_TREE; $topdir/MakeTools/expand_source.sh -d SOURCE_TREE SRPMS/*.src.rpm)
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $diff = y ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
if [ ! -e $gitdir/$i/SOURCE_TREE/package_list ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "FAILED: Unable to diff, File not found: $gitdir/$i/SOURCE_TREE/package_list" >&2
|
|
Packit |
857059 |
continue
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
## use package_list because srpm name is not necessarily $i
|
|
Packit |
857059 |
package=`head -1 $gitdir/$i/SOURCE_TREE/package_list`
|
|
Packit |
857059 |
[ $verbose = y ] && echo "Diff $gitdir/$i/SOURCE_TREE/$package/ $topdir/Ofed/$ofed_dir/ ..."
|
|
Packit |
857059 |
diff -b -u --no-dereference --exclude CVS --exclude .git --exclude package_list -r $gitdir/$i/SOURCE_TREE/$package/ $topdir/Ofed/$ofed_dir/
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $copy = y ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
if [ ! -e $gitdir/$i/SOURCE_TREE/package_list ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "FAILED: Unable to copy, File not found: $gitdir/$i/SOURCE_TREE/package_list" >&2
|
|
Packit |
857059 |
continue
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
[ $verbose = y ] && echo "Replacing source in $topdir/Ofed/$i ..."
|
|
Packit |
857059 |
##copy expanded srpm source from SOURCE_TREE to CVS Ofed/ tree
|
|
Packit |
857059 |
##remove existing files in Ofed/ checkout
|
|
Packit |
857059 |
find $topdir/Ofed/$ofed_dir/src/ ! -type d| grep -v CVS|xargs rm -f
|
|
Packit |
857059 |
##replace with new files from srpm
|
|
Packit |
857059 |
## use package_list because srpm name is not necessarily $i
|
|
Packit |
857059 |
package=`head -1 $gitdir/$i/SOURCE_TREE/package_list`
|
|
Packit |
857059 |
# use find to avoid symlinks, make_symlinks will handle them when build
|
|
Packit |
857059 |
#cp -r $gitdir/$i/SOURCE_TREE/$package/* $topdir/Ofed/$ofed_dir/
|
|
Packit |
857059 |
(cd $gitdir/$i/SOURCE_TREE/$package; find . -type d -o -type f|cpio -pdvum $topdir/Ofed/$ofed_dir/)
|
|
Packit |
857059 |
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done 2>&1|tee -a gitpull.log
|