Home · About · Download · Documentation · Getting Help · Google+

Installation/SCM: wwBuild.sh

File wwBuild.sh, 2.9 KB (added by jms, 6 years ago)

Shell script which automates a build from the SVN repository

Line 
1#!/bin/bash
2#
3# Build Warewulf from SVN sources
4#
5
6usage()
7{
8    echo;
9    echo "Usage: $(basename $0) [top source dir]";
10    echo;
11    echo "Example: $(basename $0) ~/development";
12    echo;
13    echo "$(basename $0) expects the top source directory to exist. If it does, and there";
14    echo "  is a warewulf subdirectory, that will be used and an \"svn update\" will be ran.";
15    echo "  Other wise, the the Warewulf source will be pulled from the Subversion repository.";
16    echo;
17    exit 1;
18}
19
20testdir()
21{
22    [ -d $1 ] || usage;
23}
24
25_CWD=`pwd`;
26SVNREPO="https://warewulf.lbl.gov/svn/trunk"
27RPMDIR="$HOME/rpmbuild"
28WWINST=0;
29
30# WWPKG can include (* = Required):
31#  common    -- warewulf common*
32#  vnfs      -- VNFS scripts
33#  provision -- Node Provisioning
34#  nhc       -- Node Health Check
35#  monitor   -- Node Monitoring
36#  ipmi      -- IPMI Subsystem
37WWPKG="common vnfs provision nhc monitor ipmi"
38
39if [ $# -ne 1 ]; then
40    usage;
41else
42    testdir $1;
43fi
44
45if rpm -qa | grep 'warewulf-common' 2>/dev/null 1>/dev/null; then
46    WWINST=1;
47fi
48
49top_srcdir=$(echo $1 | tr -d '\n');
50
51cd $top_srcdir;
52
53if [ ! -d ./warewulf ]; then
54    echo "Warewulf source does not exist in: $top_srcdir";
55    echo "Downloading from: $SVNREPO";
56    echo;
57    sleep 1;
58
59    # Check if we even have subversion...
60    if ! svn --version --quiet 2>/dev/null 1>/dev/null; then
61        echo "ERROR: Subversion is required. Install the Subversion Package.";
62        echo;
63
64        cd ${_CWD};
65        exit 254;
66    fi
67
68    # Grab the SVN Trunk and put it into warewulf
69    svn checkout ${SVNREPO} warewulf;
70else
71    cd ./warewulf;
72    svn update;
73fi
74
75if [ ! -d $RPMDIR/SOURCES ]; then
76    mkdir -p ${RPMDIR}/{SOURCES,SPECS}
77fi
78
79cd $top_srcdir;
80for pkg in $WWPKG; do
81    cd warewulf/$pkg;
82
83    echo "Generating confguration files for: $pkg";
84    # Run autogen
85    ./autogen.sh --prefix=/usr --sysconfdir=/etc --localstatedir=/var
86
87    make
88    [ $? -eq 0 ] || (echo; echo "Error building ${pkg}"; break; exit 1);
89
90    make test
91    [ $? -eq 0 -o $? -eq 2 ] || (echo; echo "Error with make test -- ${pkg}"; break; exit 1);
92
93    make dist-gzip;
94
95    [ ! -z $DISTCHECK ] && make distcheck;
96
97    /bin/cp -a ./warewulf-${pkg}*.tar.gz ${RPMDIR}/SOURCES/;
98
99    rpmbuild -bb ./warewulf-*.spec;
100
101    if [ "x${pkg}" = "xcommon" -a $WWINST -eq 0 ]; then
102        echo "Installing warewulf-common for requirements.";
103        rpm -Uhiv ${RPMDIR}/RPMS/noarch/warewulf-common*.rpm
104    fi
105
106    # Cleanup build
107    make maintainer-clean;
108
109    cd $top_srcdir;
110done
111
112if [ $WWINST -eq 0 ]; then
113    echo;
114    echo "Removing warewulf-common";
115    echo;
116
117    rpm -e warewulf-common;
118fi
119
120if [ ! -z $DOINST ]; then
121    rpm -Uhiv ${RPMDIR}/RPMS/{noarch,x86_64}/warewulf-*.rpm;
122fi
123
124cd $_CWD;
125
126# vim:filetype=sh:syntax=sh:expandtab:ts=4:sw=4: