build-agent-files 4.29 KB
Newer Older
1
#!/bin/bash
2
# Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre
3 4 5 6
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of buildpackage
#
7
# buildpackage is free software; you can redistribute it and/or
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.


PREFIX="$(dirname $0)"
24
GITURL="http://git.c3sl.ufpr.br/pub/scm/proinfodata/"
25
GITBASEDIR="../"
26
WEBSERVICE="seed.c3sl.ufpr.br"
27 28

# Get the configuration
29
if ! source "${PREFIX}/buildpackage.conf" 2> /dev/null; then
30
    printf "ERROR (1): Failed to load buildpackage.conf.\n"
31 32 33
    exit 1
fi

34 35
# Customizable variables. Please refer to buildpackage.conf to change these
# values
36 37 38 39
: ${AGENTDIR:="agent-files"}
: ${AGENTPACKAGEDIR:="SEED2-run"}


40
printf "====================\n$0 v0.1\n\n"
41
printf "**** Make sure that ${WEBSERVICE} webservice are up and running!!!\n"
42
printf "\nNOTE: This will take a while.\n"
43
printf "      Make sure the git update process below will run ok.\n"
44
printf "====================\n\n"
45 46


47 48
# Check if wget have been build
if ! test -f "${PREFIX}/wget-"*"/src/wget"; then
49 50 51
    printf "ERROR (2): Please run build-wget before running this script. %b" \
           "Aborting...\n"
    exit 2
52 53 54
fi

# Sanity check, we do not want dynamic linked binaries on the package
55
ldd "${PREFIX}/wget-"*"/src/wget" &> /dev/null
56
if ! test $? -eq 1; then
57 58 59
    printf "ERROR (3): The wget binary wasn't compiled with static library.%b" \
           "\nPlease, build wget using build-wget. Aborting...\n"
    exit 3
60 61
fi

62 63 64
# Ensure $GITBASEDIR directory exists
mkdir -p "${GITBASEDIR}"

65 66 67 68 69 70 71
# Ensure the repository is updated
printf "Updating git repository...\n"
if ! git pull; then
    printf "ERROR (6): Something went wrong.\n Problems executing %b" \
           "git pull(1). Aborting...\n"
    exit 6
fi
72 73
printf "\n\n"

74 75 76
# Compile the collect agent and the client
printf "Starting compilation process...\n\n"
printf "Starting client compilation...\n\n"
77 78 79 80
sleep 1

cd "${GITBASEDIR}/client"
if make && make install; then
81 82
    printf "\n\nClient compilation is finished.\n%b" \
           "Everything was fine.\n\n"
83 84
else
    printf "\n\n"
85 86 87
    printf "ERROR (7): Client compilation is finished.\n%b" \
           "Something went wrong. Aborting...\n\n"
    exit 7
88 89 90
fi
cd -

91
printf "Starting collect-parser compilation...\n\n"
92 93
sleep 1

94
cd "${GITBASEDIR}/collect"
95 96
if make && make install; then
    printf "\n\n"
97 98
    printf "Collect-parser compilation is finished.\n%b" \
           "Everything was fine.\n\n"
99 100
else
    printf "\n\n"
101 102 103
    printf "ERROR (8): Collect-parser compilation is finished.\n%b" \
           "Something went wrong. Aborting...\n\n"
    exit 8
104 105 106 107
fi
cd -

# Build the package itself
108
printf "Starting to build the package...\n"
109 110 111 112 113 114 115 116 117 118 119 120 121
OUTDIR="${AGENTDIR}/${AGENTPACKAGEDIR}/"

rm -Rf "${OUTDIR}"
mkdir -p "${OUTDIR}/client/"
mkdir -p "${OUTDIR}/lib/"

EXCLUDEFILE=$(tempfile --prefix=build-package-exclude)
cat > ${EXCLUDEFILE} << EOF
src
lib/include
lib/libxml2*/*
lib/*.tar.gz
Makefile
122 123 124 125 126
COPYING
INSTALL
NEWS
README
AUTHORS
127
TODO
128
tests
129
version
130
net/*.c
131 132
EOF

133
printf "Copying collect files... "
134
rsync -aHx --delete --exclude-from=${EXCLUDEFILE} \
135
      "${GITBASEDIR}/collect/"* "${OUTDIR}"
136
rm -Rf "${OUTDIR}/lib/libxml2"*
137
printf "done.\n"
138 139 140 141 142 143 144 145 146 147 148 149

cat > ${EXCLUDEFILE} << EOF
src
lib
Makefile
run-config.sh
COPYING
INSTALL
NEWS
README
AUTHORS
TODO
150
tests
151 152
EOF

153
printf "Copying client files... "
154 155
rsync -aHx --delete --exclude-from=${EXCLUDEFILE} \
       "${GITBASEDIR}/client/"* "${OUTDIR}/client/"
156
printf "done.\n"
157 158

BOOTSTRAP="${PREFIX}/bootstraps/bootstrap-install"
159
printf "Copying bootstrap... "
160
cp -a "${BOOTSTRAP}" "${AGENTDIR}"/
161
printf "done.\n"
162

163
printf "Copying wget binary... "
164
cp -a "${PREFIX}/wget-"*"/src/wget" "${OUTDIR}/bin/"
165
printf "done.\n"
166

167 168
rm -f "${EXCLUDEFILE}"

169
printf "\nAll done.\n\n"