Project

General

Profile

glideinwms-build.sh

local rpm build script for glideinwms - Anthony Tiradani, 08/05/2014 04:05 PM

 
1
#!/bin/bash
2

    
3
mock_targets="slf6-x86_64"
4
current_directory=`pwd`
5

    
6
# if the repo path is not supplied, we will assume that this script has been included in the repo, 
7
# that it is being executed from the repository path
8
given_path=${1:-$current_directory}
9
git_repo_path=`cd "${given_path}"; pwd`
10
branch=${2:-master}
11

    
12
echo "Welcome to mock-build.sh"
13
echo
14
echo "..Mock Targets:        ${mock_targets}"
15
echo "..Git Repository Path: ${git_repo_path}"
16
echo "..Git Branch:          ${branch}"
17

    
18
cd ${git_repo_path}
19
PACKAGE=`grep 'Name:'    *spec | awk ' { print $2 } '`
20
VERSION=`grep 'Version:' *spec | awk ' { print $2 } '`
21
cd ${current_directory}
22

    
23
echo "..Package:             ${PACKAGE}"
24
echo "..Version:             ${VERSION}"
25
echo
26
echo "..build starting"
27

    
28
# build the rpm with mock from the git repo
29
for mock_target in $mock_targets
30
do
31
    echo "....building ${PACKAGE} for target -> $mock_target"
32
    mock -r $mock_target \
33
         --scm-enable \
34
         --scm-option method=git \
35
         --scm-option package=${PACKAGE} \
36
         --scm-option git_get="git clone file:///${git_repo_path} ${PACKAGE}" \
37
         --scm-option spec="${PACKAGE}.spec" \
38
         --scm-option branch=${branch} \
39
         --scm-option write_tar=True -v  > mock_output 2>&1
40
    export result=$?
41
    if [ $result -eq 0 ]; then
42
        echo "....RPM directory: /var/lib/mock/${mock_target}/result/"
43
    else
44
        echo "....BUILD ERROR"
45
        echo "....To see what error just occured, you can examine ${current_directory}/mock_output"
46
        echo "....Additional info can be found in the logs in /var/lib/mock/${mock_target}/result/"
47
    fi
48
done
49

    
50
echo "build finished with exit code: ${result}"