You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
308 lines
11 KiB
Bash
308 lines
11 KiB
Bash
11 years ago
|
#!/bin/bash
|
||
|
|
||
11 years ago
|
##
|
||
|
# jenkins_build.sh
|
||
10 years ago
|
# called by jenkins to build/test exiv2
|
||
11 years ago
|
# - jenkins sets environment variables
|
||
10 years ago
|
# called from terminal
|
||
11 years ago
|
# - script has build-in defaults for some environment variable
|
||
11 years ago
|
#
|
||
11 years ago
|
# arguments:
|
||
|
# status : filter last build with grep
|
||
|
#
|
||
|
# environment variables (all optional)
|
||
|
# JENKINS : URL of jenkins server. Default http://exiv2.dyndns.org:8080
|
||
11 years ago
|
##
|
||
11 years ago
|
if [ -z "$JENKINS" ]; then export JENKINS=http://exiv2.dyndns.org:8080; fi
|
||
11 years ago
|
result=0
|
||
11 years ago
|
base=$(basename $0)
|
||
11 years ago
|
if [ -z "$base" ]; then base=jenkins_build ; fi
|
||
11 years ago
|
tmp=/tmp/$base.tmp
|
||
11 years ago
|
start=$(date)
|
||
|
starts=$(date +%s)
|
||
11 years ago
|
|
||
|
##
|
||
|
# functions
|
||
|
run_tests() {
|
||
11 years ago
|
if [ "$result" == "0" ]; then
|
||
|
if [ "$tests" == true ]; then
|
||
|
make tests
|
||
|
fi
|
||
|
fi
|
||
11 years ago
|
}
|
||
|
|
||
10 years ago
|
thepath () {
|
||
11 years ago
|
if [ -d $1 ]; then
|
||
|
( cd $1;
|
||
|
pwd );
|
||
|
else
|
||
|
( cd $(dirname $1);
|
||
|
echo $(pwd)/$(basename $1) );
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
##
|
||
|
# arg: status [grep-args]
|
||
|
# example: ./jenkins_build.sh status -e URL
|
||
|
if [ "$1" == "status" ]; then
|
||
11 years ago
|
shift
|
||
|
build=$(basename $PWD)
|
||
|
declare -A expects=( [linux]=900 [macosx]=900 [cygwin]=1000 [mingw]=100 [msvc]=1200 )
|
||
|
for b in linux macosx cygwin mingw msvc ; do
|
||
|
echo $build/$b
|
||
|
curl --silent $JENKINS/job/Exiv2-$build/label=$b/lastBuild/consoleText | tee $tmp |\
|
||
|
grep -E -e SVN_[A-Z]+= -e JOB_NAME -e BUILD_ID -e Finished -e seconds $@ ;
|
||
|
declare -i lines=$(wc -l $tmp | cut -d/ -f 1)
|
||
|
declare -i expect=${expects[$b]}
|
||
|
diff=$(( lines-expect>0?lines-expect:expect-lines ))
|
||
|
msg=''
|
||
|
warn=''
|
||
|
if [ "$diff" -gt "200" ]; then warn="***" ; msg="TAKE CARE " ; fi
|
||
|
echo "${warn}${msg}lines= ${lines} expect~${expect} diff=${diff}" "${msg}${warn}"
|
||
|
echo ''
|
||
|
done
|
||
|
exit $result
|
||
11 years ago
|
fi
|
||
|
|
||
11 years ago
|
##
|
||
|
# where are we?
|
||
|
export PLATFORM=''
|
||
11 years ago
|
if [ `uname` == Darwin ]; then
|
||
|
PLATFORM=macosx
|
||
11 years ago
|
elif [ `uname -o` == Cygwin ]; then
|
||
11 years ago
|
PLATFORM=cygwin
|
||
11 years ago
|
# tweak path to ensure the correct version of perl and expr for autotools
|
||
11 years ago
|
export "PATH=/bin:$PATH"
|
||
11 years ago
|
elif [ `uname -o` == Msys ]; then
|
||
11 years ago
|
PLATFORM=mingw
|
||
11 years ago
|
else
|
||
11 years ago
|
PLATFORM=linux
|
||
11 years ago
|
fi
|
||
11 years ago
|
|
||
11 years ago
|
##
|
||
|
# set up some defaults (used when running this script from the terminal)
|
||
11 years ago
|
echo "1 target = $target platform = $PLATFORM WORKSPACE = $WORKSPACE"
|
||
11 years ago
|
if [ $PLATFORM == "macosx" -a -z "$macosx" ]; then export macosx=true ; export target=macosx ; fi
|
||
11 years ago
|
if [ $PLATFORM == "linux" -a -z "$linux" ]; then export linux=true ; export target=linux ; fi
|
||
10 years ago
|
if [ -z "$cygwin" -a ! -z "$CYGWIN" ]; then export cygwin=$CYGWIN ; fi
|
||
11 years ago
|
if [ -z "$tests" ]; then export tests=true ; fi
|
||
|
if [ -z "$WORKSPACE" ]; then export WORKSPACE="$0/$PLATFORM" ; fi
|
||
11 years ago
|
|
||
11 years ago
|
if [ -z "$target" ]; then export target=$(basename $(echo $WORKSPACE | sed -E -e 's#\\#/#g')) ; fi
|
||
11 years ago
|
echo "2 target = $target platform = $PLATFORM WORKSPACE = $WORKSPACE"
|
||
11 years ago
|
|
||
|
export PATH=$PATH:/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/bin:/usr/lib/pkgconfig:/opt/local/bin:$PWD/usr/bin:/opt/local/bin:/opt/local/sbin:/opt/pkgconfig:bin
|
||
|
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
|
||
11 years ago
|
|
||
11 years ago
|
echo ----------------------
|
||
|
export
|
||
|
echo ----------------------
|
||
|
|
||
11 years ago
|
##
|
||
|
# cleanup from last time (if there was a last time)
|
||
|
if [ -e config/config.mk ]; then
|
||
11 years ago
|
if [ -e bin ]; then
|
||
|
rm -rf bin
|
||
|
fi
|
||
|
if [ ! -e bin ]; then
|
||
|
mkdir bin
|
||
|
fi
|
||
|
make distclean
|
||
11 years ago
|
fi
|
||
|
|
||
11 years ago
|
##
|
||
|
# create ./configure
|
||
|
# we need to inspect configure to know if libssh and libcurl are options for this build
|
||
11 years ago
|
make config &>/dev/null
|
||
11 years ago
|
|
||
11 years ago
|
##
|
||
11 years ago
|
# decide what to do about curl and ssh
|
||
11 years ago
|
export withcurl='--without-curl'
|
||
|
export withssh='--without-ssh'
|
||
11 years ago
|
if [ "$curl" == "true" ]; then export withcurl=--with-curl ; fi
|
||
|
if [ "$ssh" == "true" ]; then export withssh=--with-ssh ; fi
|
||
11 years ago
|
|
||
11 years ago
|
##
|
||
|
# what kind of build is this?
|
||
11 years ago
|
build=NONE
|
||
|
|
||
11 years ago
|
if [ $PLATFORM == "linux" -a "$target" == "linux" -a "$linux" == "true" ]; then build=UNIX ; fi
|
||
11 years ago
|
if [ $PLATFORM == "macosx" -a "$target" == "macosx" -a "$macosx" == "true" ]; then build=UNIX ; fi
|
||
|
if [ $PLATFORM == "cygwin" -a "$target" == "cygwin" -a "$cygwin" == "true" ]; then build=CYGW ; fi
|
||
11 years ago
|
if [ $PLATFORM == "cygwin" -a "$target" == "mingw" -a "$mingw" == "true" ]; then build=MING ; fi
|
||
|
if [ $PLATFORM == "cygwin" -a "$target" == "msvc" -a "$msvc" == "true" ]; then build=MSVC ; fi
|
||
11 years ago
|
if [ $PLATFORM == "mingw" -a "$target" == "mingw" ]; then build=MING ; fi
|
||
11 years ago
|
|
||
|
echo "3 target = $target platform = $PLATFORM build = $build"
|
||
11 years ago
|
echo ---- path and perl -----
|
||
|
(IFS=:;for i in $PATH; do echo $i ; done)
|
||
|
echo -- which perl = $(which perl) ---
|
||
11 years ago
|
echo -- which expr = $(which expr) ---
|
||
11 years ago
|
perl --version
|
||
|
echo ---- end of path and perl ----
|
||
11 years ago
|
|
||
11 years ago
|
case "$build" in
|
||
11 years ago
|
|
||
10 years ago
|
UNIX)
|
||
11 years ago
|
echo ./configure --prefix=$PWD/usr $withcurl $withssh
|
||
|
./configure "--prefix=$PWD/usr" $withcurl $withssh
|
||
10 years ago
|
make -j "LDFLAGS=-L${PWD}/usr/lib -L${PWD}/xmpsdk/src/.libs"
|
||
11 years ago
|
make install
|
||
10 years ago
|
make -j samples "CXXFLAGS=-I${PWD}/usr/include -I${PWD}/src" "LDFLAGS=-L${PWD}/usr/lib -L${PWD}/xmpsdk/src/.libs -lexiv2"
|
||
11 years ago
|
result=$?
|
||
|
run_tests
|
||
11 years ago
|
"$PWD/usr/bin/exiv2" -v -V
|
||
11 years ago
|
;;
|
||
11 years ago
|
|
||
|
CYGW)
|
||
10 years ago
|
if [ "$x64" == true ]; then
|
||
|
export CFLAGS=-m64
|
||
|
export CXXFLAGS=-m64
|
||
|
export LDFLAGS=-m64
|
||
11 years ago
|
fi
|
||
10 years ago
|
echo make config
|
||
|
make config
|
||
|
# I've given up trying to get Cygwin to install into a local directory
|
||
|
echo ./configure ${withcurl} ${withssh}
|
||
|
./configure ${withcurl} ${withssh}
|
||
|
make -j
|
||
|
result=$?
|
||
|
make install
|
||
|
make -j samples
|
||
|
run_tests
|
||
|
/usr/local/bin/exiv2 -v -V
|
||
11 years ago
|
;;
|
||
11 years ago
|
|
||
10 years ago
|
MING)
|
||
11 years ago
|
if [ ! -z "$RECURSIVE" ]; then
|
||
11 years ago
|
export CC=$(which gcc)
|
||
|
export CXX=$(which g++)
|
||
|
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
|
||
11 years ago
|
echo --- recursive MinGW build ---
|
||
11 years ago
|
|
||
|
##########################
|
||
|
# To build curl/MinGW/64 (on 32bit MinGW):
|
||
|
# PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/:/usr/lib/pkgconfig/"
|
||
|
# cd /home/rmills/gnu/curl/curl-7.39.0>
|
||
|
# ./configure --prefix=/usr/local --disable-static --enable-shared --host=i686-x64-mingw32
|
||
|
# I haven't succeeded in getting openssl to link with curl on MinGW
|
||
|
# --with-ssl=/usr/local
|
||
|
##########################
|
||
|
if [ "$withcurl" == "--with-curl" ]; then
|
||
11 years ago
|
withcurl="--with-curl=/usr/local"
|
||
11 years ago
|
fi
|
||
|
|
||
|
##########################
|
||
|
# I have be unable to build libssh on MinGW (neither 32 nor 64 bits)
|
||
|
##########################
|
||
|
if [ "$withssh" == "--with-ssh" ]; then
|
||
11 years ago
|
echo "*** unable to build --with-ssh on MING ***"
|
||
|
withssh="--without-ssh"
|
||
11 years ago
|
fi
|
||
11 years ago
|
|
||
11 years ago
|
./configure $withcurl $withssh
|
||
10 years ago
|
make -j # DO NOT USE -j4. It seems to hang the build!
|
||
11 years ago
|
make install
|
||
10 years ago
|
make -j samples
|
||
11 years ago
|
run_tests
|
||
|
exiv2 -v -V
|
||
|
else
|
||
|
if [ -e config/config.mk ]; then make clean ; fi
|
||
|
(
|
||
|
export TMP=/tmp
|
||
|
export TEMP=$TMP
|
||
11 years ago
|
export RECURSIVE=1
|
||
|
# recursively invoke MinGW/bash with appropriate tool chain
|
||
10 years ago
|
if [ "$x64" == true ]; then
|
||
11 years ago
|
/cygdrive/c/MinGW64/msys/1.0/bin/bash.exe -c "export PATH=/c/TDM-GCC-64/bin:/c/MinGW64/bin:/c/MinGW64/msys/1.0/bin:/c/MinGW64/msys/1.0/local/bin; $0"
|
||
|
result=$?
|
||
11 years ago
|
fi
|
||
10 years ago
|
if [ "$Win32" == true ]; then
|
||
11 years ago
|
/cygdrive/c/MinGW/msys/1.0/bin/bash.exe -c "export PATH=/c/MinGW/bin:/c/MinGW/msys/1.0/bin:/c/MinGW/msys/1.0/local/bin; $0"
|
||
|
result=$?
|
||
|
fi
|
||
|
)
|
||
|
#########################################
|
||
|
## #!/bin/bash
|
||
|
## # mingw32.sh
|
||
10 years ago
|
## # invoke 32bit MinGW bash
|
||
11 years ago
|
## #
|
||
|
## export "PATH=c:\\MinGW\\bin;c:\\MinGW\\msys\\1.0\\bin;C:\\MinGW\\msys\\1.0\\local\\bin;"
|
||
|
## /cygdrive/c/MinGW/msys/1.0/bin/bash.exe $*
|
||
|
##
|
||
|
## # That's all Folks
|
||
|
## ##
|
||
|
#########################################
|
||
|
|
||
|
#########################################
|
||
|
## : mingw32.bat
|
||
|
## : invoke MinGW bash
|
||
|
## :
|
||
|
## setlocal
|
||
|
## set "PATH=c:\MinGW\bin;c:\MinGW\msys\1.0\bin;C:\MinGW\msys\1.0\local\bin;"
|
||
|
## set "PS1=\! ${PWD}> "
|
||
|
## c:\MinGW\msys\1.0\bin\bash.exe %*%
|
||
|
##
|
||
|
## : That's all Folks
|
||
|
#########################################
|
||
|
|
||
|
#########################################
|
||
|
## see http://clanmills.com/exiv2/mingw.shtml about 64bit build
|
||
|
## Install a fresh (32 bit) mingw/msys into c:\MinGW64
|
||
|
## install the 64 bit compiler from: http://tdm-gcc.tdragon.net
|
||
10 years ago
|
## I used the "on-demand" installer and "Create" put the tools in c:\TDM-GCC-64. The main change is to add the 64 bit compilers to the path BEFORE the 32 bit compilers.
|
||
11 years ago
|
## set PATH=c:\TDM-GCC-64\bin;c:\MinGW\bin;c:\MinGW\msys\1.0\bin;C:\MinGW\msys\1.0\local\bin;
|
||
|
##
|
||
|
## keep MinGW64 for 64 bit builds and /usr/lib has 64bit libraries
|
||
|
## keep MinGW for 32 bit builds and /usr/lib has 32bit libraries
|
||
|
##
|
||
|
## install msys-coreutils, binutils, autotools
|
||
|
##
|
||
|
## For pkg-config see http://clanmills.com/exiv2/mingw.shtml
|
||
|
#########################################
|
||
|
|
||
|
#########################################
|
||
|
## zlib and expat
|
||
|
## mkdir -p ~/gnu/zlib ~/gnu/expat
|
||
|
## get the tar.gz files and tar zxf them
|
||
|
## build (see http://clanmills.com/exiv2/mingw.shtml about zlib)
|
||
|
## DO THIS IN BOTH c:\MinGW and c:\MinGW64
|
||
|
#########################################
|
||
|
|
||
|
#########################################
|
||
|
## The keith bug
|
||
|
## rm -rf /c/MinGW/lib/libintl.la
|
||
|
#########################################
|
||
|
|
||
|
#########################################
|
||
|
## to build dlfcn-win32
|
||
|
## git clone https://github.com/dlfcn-win32/dlfcn-win32
|
||
|
## cd dlfcn-win32 ; ./configure --prefix=/usr --enable-shared ; make ; make install
|
||
|
#########################################
|
||
|
|
||
|
fi
|
||
11 years ago
|
;;
|
||
|
|
||
10 years ago
|
MSVC)
|
||
11 years ago
|
rm -rf $PWD/bin
|
||
10 years ago
|
mkdir $PWD/bin
|
||
11 years ago
|
|
||
11 years ago
|
PATH=$PATH:/cygdrive/c/Windows/System32
|
||
10 years ago
|
cmd.exe /c "cd $(cygpath -aw .) && call contrib\\buildserver\\jenkins_build.bat"
|
||
11 years ago
|
result=$?
|
||
11 years ago
|
;;
|
||
11 years ago
|
|
||
10 years ago
|
NONE)
|
||
11 years ago
|
echo "**************************************"
|
||
|
echo "*** no build requested for $target ***"
|
||
11 years ago
|
if [ "$target" == "cygwin" ]; then echo try export CYGWIN=true and run $(basename $0) again ; fi
|
||
11 years ago
|
echo "**************************************"
|
||
10 years ago
|
;;
|
||
11 years ago
|
esac
|
||
11 years ago
|
|
||
11 years ago
|
echo target "$target" start: "$start" finish: $(date) diff: $(( $(date +%s) - starts )) seconds
|
||
11 years ago
|
set -v
|
||
11 years ago
|
# That's all Folks!
|
||
|
##
|
||
11 years ago
|
exit $result
|