]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - tools/make-functions
Updated wireless-tools (30.pre9).
[people/pmueller/ipfire-2.x.git] / tools / make-functions
index 854477cbb079657d60246fb89b69133a8c75992a..00d7d337cd6eab53c2274b270e9c483106176672 100644 (file)
@@ -1,9 +1,28 @@
 #!/bin/bash
-############################################################################
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program 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 3 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, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+###############################################################################
 #
 # Beautifying variables & presentation & input output interface
 #
-############################################################################
+###############################################################################
 
 ## Screen Dimentions
 # Find current screen size
@@ -106,22 +125,30 @@ beautify()
                                        ;;
                        esac
                        ;;
-               build_stage_start)
+               build_stage)
                        MESSAGE=$2
+                       if [ "$STAGE_TIME_START" ]; then
+                               LAST_STAGE_TIME=$[ `date +%s` - $STAGE_TIME_START ]
+                       fi
                        STAGE_TIME_START=`date +%s`
-                       echo -ne "${BOLD}*** ${MESSAGE}${SET_VER_COL}      version${SET_OPT_COL} options"
-                       echo -ne "${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n"
-                       ;;
-               build_stage_end)
-                       STAGE_TIME_END=`date +%s`
-                       echo -ne "${BOLD}***This stage took:\t\t $[ $STAGE_TIME_END - $STAGE_TIME_START ] (secs)${NORMAL}\n"
+                       echo -ne "${BOLD}*** ${MESSAGE}${NORMAL}"
+                       if [ "$LAST_STAGE_TIME" ]; then
+                               echo -ne "${DONE} (Last stage took $LAST_STAGE_TIME secs)${NORMAL}"
+                       fi
+                       echo -ne "${BOLD}${SET_VER_COL}      version${SET_OPT_COL} options${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n"
                        ;;
                build_start)
                        BUILD_TIME_START=`date +%s`
                        ;;
                build_end)
                        BUILD_TIME_END=`date +%s`
-                       echo -ne "${BOLD}***Build is finished now!\nThis took:\t\t\t $[ $BUILD_TIME_END - $BUILD_TIME_START ] (secs)${NORMAL}\n"
+                       seconds=$[ $BUILD_TIME_END - $BUILD_TIME_START ]
+                       hours=$((seconds / 3600))
+                       seconds=$((seconds % 3600))
+                       minutes=$((seconds / 60))
+                       seconds=$((seconds % 60))
+
+                       echo -ne "${DONE}***Build is finished now and took $hours hour(s) $minutes minute(s) $seconds second(s)!${NORMAL}\n"
                        ;;
                make_pkg)
                        echo "$2" | while read PKG_VER PROGRAM OPTIONS
@@ -370,6 +397,7 @@ ipfiremake() {
                                                TERM=$TERM PS1='\u:\w\$ ' \
                                                PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
                                                VERSION=$VERSION \
+                                               CORE=$CORE \
                                                CONFIG_ROOT=$CONFIG_ROOT \
                                                NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
                                                CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
@@ -393,25 +421,31 @@ ipfiremake() {
 }
 
 ipfiredist() {
-       if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
-               echo "`date -u '+%b %e %T'`: Packaging $1" | tee -a $LOGFILE
-               chroot $LFS /tools/bin/env -i   HOME=/root \
-                                               TERM=$TERM PS1='\u:\w\$ ' \
-                                               PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
-                                               VERSION=$VERSION \
-                                               CONFIG_ROOT=$CONFIG_ROOT \
-                                               NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
-                                               CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
-                                               CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
-                                               KVER=$KVER IPFVER="$IPFVER" \
-                                               BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
-                   /bin/bash -x -c "cd /usr/src/lfs && \
-                   make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
-               if [ $? -ne 0 ]; then
-                       exiterror "Packaging $1"
-               fi
+       lfsmakecommoncheck $*
+       [ $? == 1 ] && return 0
+       
+       local PKG_TIME_START=`date +%s`
+       chroot $LFS /tools/bin/env -i   HOME=/root \
+                                       TERM=$TERM PS1='\u:\w\$ ' \
+                                       PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
+                                       VERSION=$VERSION \
+                                       CONFIG_ROOT=$CONFIG_ROOT \
+                                       NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
+                                       CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
+                                       CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
+                                       KVER=$KVER IPFVER="$IPFVER" \
+                                       BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
+                                       /bin/bash -x -c "cd /usr/src/lfs && \
+                                       make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
+
+       local COMPILE_SUCCESS=$?
+       local PKG_TIME_END=`date +%s`
+
+       if [ $COMPILE_SUCCESS -ne 0 ]; then
+               beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
+               exiterror "Packaging $*";
        else
-               exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
+               beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
        fi
        return 0
 }
@@ -459,19 +493,16 @@ batch_script() {
 
        if [ "$IPFIRE_REBUILD" -eq "0" ]; then
                export IPFIRE_START_TIME=`date`
+
+               $0 clean
                evaluate 1
 
-               echo -ne "### RUNNING SVN-UPDATE"
-               $0 svn update
-               evaluate 1 mail_me SVNUPDATE
+               $0 git update --force
+               evaluate 1 mail_me UPDATE
 
                echo "### EXPORT SOURCES"
-               $0 svn dist
-               evaluate 1 mail_me SVNDIST
-
-               echo "### RUNNING PREFETCH"
-               $0 downloadsrc | grep -q "md5 difference"
-               evaluate 1 mail_me PREFETCH
+               $0 git dist
+               evaluate 1 mail_me DIST
        fi
 
        echo "### RUNNING BUILD"
@@ -486,8 +517,8 @@ batch_script() {
        $0 upload paks
        evaluate 1 mail_me PAKS
 
-       echo -n "${BOLD}***SUCCESS!${NORMAL}"
-       evaluate 0 mail_me SUCCESS
+       echo -ne "${BOLD}***SUCCESS!${NORMAL}"
+       mail_me success
        exit 0
 }
 
@@ -498,14 +529,14 @@ watch_screen() {
 }
 
 mail_me() {
-       chmod 755 tools/sendEmail
-       ATTACHMENT=/tmp/ipfire-build-logs-R$SVN_REVISION.tar.gz
+       echo "From: $MAIL_FROM" > /tmp/ipfire_mail_body.$$
+       echo "To: $MAIL_TO" >> /tmp/ipfire_mail_body.$$
        case "$1" in
                success)
-                       SUBJECT="SUCCESS: IPFIRE-BUILD R$SVN_REVISION on `hostname`"
-                       cat <<END > /tmp/ipfire_mail_body
-Building IPFire on `hostname` in Revision $SVN_REVISION was successfull!
-You can find the ISO on your ftp server.
+                       cat <<END >> /tmp/ipfire_mail_body.$$
+Subject: SUCCESS: IPFIRE-BUILD on `hostname`
+Building IPFire on `hostname` was successfull!
+You can find the ISO on your ftp server if you told the script where it is.
 
 Statistics:
 -----------
@@ -519,8 +550,8 @@ END
                echo -ne "${BOLD}***Sending success message${NORMAL}"
                ;;
                *)
-                       SUBJECT="ERROR $1: IPFIRE-BUILD R$SVN_REVISION on `hostname`"
-                       cat <<END > /tmp/ipfire_mail_body
+                       cat <<END >> /tmp/ipfire_mail_body.$$
+Subject: ERROR $1: IPFIRE-BUILD on `hostname`
 When I was building IPFire on `hostname`, I have found an ERROR with name $1!
 Here you can see the logs and detect the reason for this error.
 
@@ -536,22 +567,15 @@ END
                echo -ne "${BOLD}***Sending error message${NORMAL}"
                ;;
        esac
-       tar cfz $ATTACHMENT log/_build*
-       cat /tmp/ipfire_mail_body | tools/sendEmail -q \
-               -f $IPFIRE_MAIL_FROM \
-               -t $IPFIRE_MAIL_REPORT \
-               -u $SUBJECT \
-               -s $IPFIRE_MAIL_SERVER:25 \
-               -xu $IPFIRE_MAIL_USER \
-               -xp $IPFIRE_MAIL_PASS \
-               -l log/_build.mail.log \
-               -a $ATTACHMENT # -v
+
+sleep 15
+       python tools/sendEmail < /tmp/ipfire_mail_body.$$
        if [ "$?" -eq "0" ]; then
                beautify message DONE
        else
                beautify message FAIL
        fi
-       rm -f /tmp/ipfire_mail_body $ATTACHMENT
+       rm -f /tmp/ipfire_mail_body.$$
 }
 
 make_config() {
@@ -622,13 +646,15 @@ make_config() {
                echo -ne "You should enter a mail server to login...\n"
                echo -ne "Please type the url: "
                read MAIL_SERVER
+               echo -ne "Please type where the email is from: "
+               read MAIL_FROM
                echo -ne "Please type the username: "
                read MAIL_USER
                echo -ne "Please type the password (hidden): "
                read -s MAIL_PASS
                
        fi
-       echo -ne "${BOLD}***Saving...${NORMAL}"
+       echo -ne "\n${BOLD}***Saving...${NORMAL}"
        cat <<END > $BASEDIR/.config
 ### iso server
 FTP_ISO_URL=$FTP_ISO_URL
@@ -642,6 +668,7 @@ FTP_CACHE_USER=$FTP_CACHE_USER
 FTP_CACHE_PASS=$FTP_CACHE_PASS
 ### mail reports
 MAIL_TO="$MAIL_TO"
+MAIL_FROM=$MAIL_FROM
 MAIL_SERVER=$MAIL_SERVER
 MAIL_USER=$MAIL_USER
 MAIL_PASS=$MAIL_PASS
@@ -687,10 +714,21 @@ stop_tftpd() {
 }
 
 reload_tftpd() {
-       if [ -e $BASEDIR/ipfire-$VERSION-pxe-$MACHINE.tgz ]; then
+       if [ -e $BASEDIR/ipfire-$VERSION.$MACHINE-pxe.tgz ]; then
                mkdir -p $BASEDIR/tftpboot
-               tar xfz $BASEDIR/ipfire-$VERSION-pxe-$MACHINE.tgz -C $BASEDIR/tftpboot
+               tar xfz $BASEDIR/ipfire-$VERSION.$MACHINE-pxe.tgz -C $BASEDIR/tftpboot
                return 0
        fi
        return 1
 }
+
+update_langs() {
+               echo -ne "Checking the translations for missing or obsolete strings..."
+               chmod 755 $BASEDIR/tools/{check_strings.pl,sort_strings.pl,check_langs.sh}
+               $BASEDIR/tools/sort_strings.pl en
+               $BASEDIR/tools/sort_strings.pl de
+               $BASEDIR/tools/check_strings.pl en > $BASEDIR/doc/language_issues.en
+               $BASEDIR/tools/check_strings.pl de > $BASEDIR/doc/language_issues.de
+               $BASEDIR/tools/check_langs.sh > $BASEDIR/doc/language_missings
+               beautify message DONE
+}