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"
echo "Checking sanity of working directory..."
- check_rootfiles $*
+ rootfiles_check $*
check_code $*
}
--- /dev/null
+#!/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
+}