]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Added some new functions for editing rootfiles.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 20 Jan 2009 16:32:19 +0000 (17:32 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 20 Jan 2009 16:32:19 +0000 (17:32 +0100)
tools/make-check
tools/make-include
tools/make-interactive
tools/make-rootfiles [new file with mode: 0644]

index 76c64d43b8499dc82be9f1463c7f64171ad60ca7..9b2c0ba03ea332c680d863a708f08ca759806f0a 100644 (file)
@@ -86,58 +86,6 @@ check_build() {
        check_common "GNU which"                        "which --version | head -n1"
 }
 
-check_rootfiles() {
-       ACTION=$1
-
-       echo -n " Running rootfile checks"
-
-       ROOTFILES=$(find $BASEDIR/src/rootfiles/{core,extras,debug}/ -type f)
-
-       case "$ACTION" in
-               --fix)
-                       echo -n " and fix"
-
-                       # Remove leading pluses and replace them by '#'
-                       for i in $ROOTFILES; do
-                               [ ! -f $i ] && continue
-                               sed -e "s/^+/#/g" -i $i
-                       done
-                       ;;
-               "")
-                       : # If no option was given we do nothing.
-                       ;;
-               *)
-                       exiterror "This is not a valid option: $ACTION"
-                       ;;
-       esac
-
-       echo -n "..." # End the line
-
-       for i in $ROOTFILES; do
-               # Leading slashes
-               grep -q ^/ $i
-               if [ "$?" -eq "0" ]; then
-                       dialogerror "Please check your rootfile of \"$(basename $i)\" for leading slashes."
-                       exit 1
-               fi
-
-               # Leading plusses
-               grep -q ^+ $i
-               if [ "$?" -eq "0" ]; then
-                       dialogerror "Please check your rootfile of \"$(basename $i)\" for leading plusses."
-                       exit 1
-               fi
-
-               # Empty lines
-               grep -q ^$ $i
-               if [ "$?" -eq "0" ]; then
-                       dialogerror "Please check your rootiles of \"$(basename $i)\" for empty lines."
-                       exit 1
-               fi
-       done
-       beautify message DONE
-}
-
 check_code() {
     ACTION=$1
     ARGS="--recurse"
@@ -171,7 +119,7 @@ check_sanity() {
 
        echo "Checking sanity of working directory..."
 
-       check_rootfiles $*
+       rootfiles_check $*
        check_code $*
 
 }
index 9259e29cb9dd8190d089287f85130ee578a5950e..0b87de129b77f4dcdee8d83fe63b4f2f0c6e2778 100644 (file)
@@ -59,6 +59,7 @@ mkdir $BASEDIR/log_${TARGET}/ 2>/dev/null
 . $BASEDIR/tools/make-compilers
 . $BASEDIR/tools/make-git
 . $BASEDIR/tools/make-packages
+. $BASEDIR/tools/make-rootfiles
 . $BASEDIR/tools/make-vm
 . $BASEDIR/tools/make-cron
 
index b6c660c2b6e0a225fe5a8ea8a31ba0c92a750ed2..3e9834cb00a19c5772a977be772b01a6bc614d9a 100644 (file)
@@ -192,9 +192,6 @@ check)
                                exit 1
                        fi
                        ;;
-               rootfiles)
-                       check_rootfiles $3
-                       ;;
                sanity)
                        check_sanity $3
                        ;;
@@ -316,6 +313,27 @@ pull)
        getsource
        ;;
 
+rootfiles|rf)
+       case "$2" in
+               check|ch)
+                       rootfiles_check $3
+                       ;;
+               commit|ci|update|up)
+                       rootfiles_commit
+                       ;;
+               copy|cp)
+                       shift 2
+                       rootfiles_copy $@
+                       ;;
+               fix)
+                       rootfiles_check --fix
+                       ;;
+               *)
+                       usage
+                       ;;
+       esac
+       ;;
+
 vm|qemu)
        case "$2" in
                boot|start|run)
diff --git a/tools/make-rootfiles b/tools/make-rootfiles
new file mode 100644 (file)
index 0000000..902ce61
--- /dev/null
@@ -0,0 +1,123 @@
+#!/bin/bash
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2008, 2009  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/>.       #
+#                                                                             #
+###############################################################################
+
+for path in \
+       $BASEDIR/src/rootfiles/{core,debug,extras}/$TARGET/ \
+       $BASEDIR/src/rootfiles/{core,debug,extras}/; do
+       [ -d "$path" ] && ROOTFILES_DIR="$ROOTFILES_DIR $path"
+done
+
+rootfiles_check() {
+       ACTION=$1
+
+       echo -n " Running rootfile checks"
+
+       ROOTFILES=$(find $BASEDIR/src/rootfiles/{core,extras,debug}/ -type f)
+
+       case "$ACTION" in
+               --fix)
+                       echo -n " and fix"
+
+                       # Remove leading pluses and replace them by '#'
+                       for i in $ROOTFILES; do
+                               [ ! -f $i ] && continue
+                               sed -e "s/^+/#/g" -i $i
+                       done
+                       ;;
+               "")
+                       : # If no option was given we do nothing.
+                       ;;
+               *)
+                       exiterror "This is not a valid option: $ACTION"
+                       ;;
+       esac
+
+       echo -n "..." # End the line
+
+       for i in $ROOTFILES; do
+               # Leading slashes
+               grep -q ^/ $i
+               if [ "$?" -eq "0" ]; then
+                       dialogerror "Please check your rootfile of \"$(basename $i)\" for leading slashes."
+                       exit 1
+               fi
+
+               # Leading plusses
+               grep -q ^+ $i
+               if [ "$?" -eq "0" ]; then
+                       dialogerror "Please check your rootfile of \"$(basename $i)\" for leading plusses."
+                       exit 1
+               fi
+
+               # Empty lines
+               grep -q ^$ $i
+               if [ "$?" -eq "0" ]; then
+                       dialogerror "Please check your rootiles of \"$(basename $i)\" for empty lines."
+                       exit 1
+               fi
+       done
+       beautify message DONE
+}
+
+rootfiles_commit() {
+       rootfiles_check
+       git_commit -m "Rootfile update." $ROOTFILES_DIR
+}
+
+rootfiles_copy() {
+       for i in $@; do
+               (       unset NAME VERSION
+                       ROOTFILE=$(rootfiles_findone $i)
+                       if [ "$ROOTFILE" = "" ]; then
+                               dialogerror "Rootfile of \"$i\" not found. Create it first."
+                               return 1
+                       fi
+                       eval $(pkg_info $i)
+                       for j in $NAME{-$VERSION,} \
+                               $(sed 's/\([a-z]\)\([a-zA-Z0-9]*\)/\u\1\2/g' <<< $NAME){,$VERSION}; do
+                               LOGFILE=$(find $BASEDIR/log_$TARGET/ -type f -name $j ! -name *_old)
+                               [ -n "$LOGFILE" ] && break
+                       done
+                       if [ -z "$LOGFILE" ]; then
+                               dialogerror "No rootfile of \"$i\" in $LOG_DIR."
+                               return 1
+                       fi
+                       echo -n "Copying rootfile from \"$(basename $LOGFILE)\" to $ROOTFILE."
+                       cp -f $LOGFILE $ROOTFILE
+                       if [ "$?" -eq "0" ]; then
+                               beautify message DONE
+                       else
+                               beautify message FAIL
+                       fi
+               ) || break
+       done
+}
+
+rootfiles_findone() {
+       echo $(find $ROOTFILES_DIR -maxdepth 1 -type f ! -name *_changed \
+                       ! -name *_no_rootfile -name $1 | head -n 1)
+}
+
+rootfiles_find() {
+       for i in $@; do
+               rootfiles_findone $i
+       done
+}