Select Git revision
build-agent-files
build-agent-files 5.41 KiB
#!/bin/bash
# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of buildpackage
#
# collect-agent is free software; you can redistribute it and/or
# 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)"
# Get the configuration
if ! source "${PREFIX}/buildpackage.conf" 2>/dev/null; then
echo "error: failed to load buildpackage.conf"
exit 1
fi
# Customizable variables, please refer to
# buildpackage.conf to change these values
: ${GITBASEDIR:="../"}
: ${GITUSER:="git"}
: ${GITSERVER:="git.c3sl.ufpr.br"}
: ${WEBSERVICE:="seed.c3sl.ufpr.br"}
: ${AGENTDIR:="agent-files"}
: ${AGENTPACKAGEDIR:="SEED2-run"}
printf "====================\n"
printf "$0 v0.1\n"
printf "\n"
printf "**** Make sure that ${WEBSERVICE} webservice are up and running!!!\n"
printf "\n"
printf "NOTE: This will take a while.\n"
printf " Make sure the git update process below will run ok.\n"
printf "====================\n"
printf "\n"
# Check if wget have been build
if ! test -f "${PREFIX}/wget-"*"/src/wget"; then
printf "PLEASE USE build-wget BEFORE RUNNNING THIS SCRIPT!!\n"
printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n"
exit 1
fi
# Sanity check, we do not want dynamic linked binaries on the package
ldd "${PREFIX}/wget-"*"/src/wget" &>/dev/null
if ! test $? -eq 1; then
printf "THE wget BINARY HAVE NOT BEEN COMPILED WITH STATIC LIBRARY!!\n"
printf "PLEASE, BUILD wget USIGN build-wget!!\n"
printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n"
exit 1
fi
# Make sure all repositories are ok
printf "Updating git repositories...\n"
for repo in "${GITBASEDIR}/client:client" "${GITBASEDIR}/coleta:coleta"; do
REPOPATH="$(echo $repo |cut -d: -f1)"
REPONAME="$(echo $repo |cut -d: -f2)"
printf "${REPONAME}...\n"
# Check the environment
if ! cd "${REPOPATH}" 2>/dev/null; then
if ! cd "${GITBASEDIR}" 2>/dev/null; then
printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n"
printf "MAKE SURE THAT GITBASEDIR EXISTS AND HAVE ACCESS TO IT.\n"
printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n"
exit 1
else
printf "git-clone ${REPONAME}...\n"
if git-clone ${GITUSER}@${GITSERVER}:seed2/${REPONAME}.git; then
cd - &>/dev/null
cd "${REPOPATH}"
else
printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n"
printf "PROBLEMS EXECUTING GIT-CLONE...\n"
printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n"
exit 1
fi
fi
fi
if ! git pull; then
printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n"
printf "PROBLEMS EXECUTING GIT-PULL...\n"
printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n"
exit 1
fi
cd - &>/dev/null
done
printf "\n\n"
# Compile agent and collect
printf "Starting compilation proccess...\n\n"
printf "Starting compiling client..\n\n"
sleep 1
cd "${GITBASEDIR}/client"
if make && make install; then
printf "\n\n"
printf "Client compilation is finished.\n"
printf "EVERYTHING WAS FINE\n\n"
else
printf "\n\n"
printf "Client compilation is finished.\n"
printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n"
printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n"
exit 1
fi
cd -
printf "Starting compiling collect-parser...\n\n"
sleep 1
cd "${GITBASEDIR}/coleta"
if make && make install; then
printf "\n\n"
printf "Collect-parser compilation is finished.\n"
printf "EVERYTHING WAS FINE\n\n"
else
printf "\n\n"
printf "Collect-parser compilation is finished.\n"
printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n"
printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n"
exit 1
fi
cd -
# Build the package itself
printf "Starting build the package...\n"
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
TODO
tests
EOF
printf "Copying collect files..."
rsync -aHx --delete --exclude-from=${EXCLUDEFILE} \
"${GITBASEDIR}/coleta/"* "${OUTDIR}"
rm -Rf "${OUTDIR}/lib/libxml2"*
printf " done\n"
cat > ${EXCLUDEFILE} << EOF
src
lib
Makefile
run-config.sh
COPYING
INSTALL
NEWS
README
AUTHORS
TODO
tests
EOF
printf "Copying client files..."
rsync -aHx --delete --exclude-from=${EXCLUDEFILE} \
"${GITBASEDIR}/client/"* "${OUTDIR}/client/"
printf " done\n\n"
BOOTSTRAP="${PREFIX}/bootstraps/bootstrap-install"
printf "Copying bootstrap..."
cp -a "${BOOTSTRAP}" "${AGENTDIR}"/
printf " done\n\n"
printf "Copying wget binary..."
cp -a "${PREFIX}/wget-"*"/src/wget" "${OUTDIR}/bin/"
printf " done\n\n"
rm -f "${EXCLUDEFILE}"
printf "All done.\n"