diff --git a/proinfodatadeb/build-debian-package b/proinfodatadeb/build-debian-package new file mode 100755 index 0000000000000000000000000000000000000000..d013c7aeef6e53ae829453f34f012e9d58d7f4a2 --- /dev/null +++ b/proinfodatadeb/build-debian-package @@ -0,0 +1,102 @@ +#!/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 +# +# buildpackage 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. + +DIR=$(dirname $0) + +printf "Make sure client was already compiled. If you don't think so, run \ +build-agent-files. Continue? [y/N] " +read ans +if [[ "$ans" != "y" ]]; then + printf "Aborting.\n" + exit 0 +fi + +printf "Do you want to create a package without INEP request while boot? \ +(Needed if you want to create a package for RUCA project)? [y/N] " +read inepreq + +# Do not compile getSchoolInfo if there will not be the INEP request +if [[ "${inepreq}" != "y" ]]; then + printf "Compiling getSchoolInfo..." + + cd ${DIR}/getSchoolInfo + make + if test $? -ne 0 ; then + printf "Error while compiling getSchoolInfo! Aborting.\n" + exit 1 + fi + cd - &> /dev/null + printf "done.\n" +fi + +# Always copy the agent files +printf "Copying agent files..." + +DESTDIR=${DIR}/package/opt/seed_mec/SEED2 +mkdir -p ${DESTDIR} +cp -a ${DIR}/../agent/agent-files/SEED2-run/* ${DESTDIR} + +printf "done.\n" + +printf "Generating Debian Package..." + +# Remove /etc/{init.d/*,rc2.d/*} if there will not be the INEP request +if [[ "${inepreq}" == "y" ]]; then + TMPDIR=$(mktemp -d) + cp -a ${DIR}/package/etc/ ${TMPDIR} + rm -rf ${DIR}/package/etc +fi + +fakeroot dpkg -b package ${DIR} + +if [[ "${inepreq}" == "y" ]]; then + # Restore /etc directory + cp -a ${TMPDIR}/etc ${DIR}/package + rm -rf ${TMPDIR} +fi + +if test $? -ne 0 ; then + printf "Error while generating Debian package! Aborting.\n" + exit 2 +fi + +printf "done.\n" + +printf "Cleaning..." + +cd ${DIR}/getSchoolInfo +make distclean +makeret=$? + +cd - &>/dev/null +rm -rf ${DIR}/package/opt/ +rmret1=$? + +rm -rf ${DIR}/package/usr/ +rmret2=$? + +# If $makeret is equal to zero OR $rmret is equal to zero OR $rmret2 is +# equal to zero, print an error, but do not abort. +if test $makeret -ne 0 -o $rmret1 -ne 0 -o $rmret2 -ne 0; then + printf "Warning while cleaning!\n" +fi + +printf "done.\n"