From: Michael Tremer Date: Tue, 20 Jan 2009 16:32:19 +0000 (+0100) Subject: Added some new functions for editing rootfiles. X-Git-Tag: v3.0-alpha1~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b07899d15bf9b1e27cdf72deaa8e7dc529bb96eb;p=ipfire-3.x.git Added some new functions for editing rootfiles. --- diff --git a/tools/make-check b/tools/make-check index 76c64d43b..9b2c0ba03 100644 --- a/tools/make-check +++ b/tools/make-check @@ -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 $* } diff --git a/tools/make-include b/tools/make-include index 9259e29cb..0b87de129 100644 --- a/tools/make-include +++ b/tools/make-include @@ -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 diff --git a/tools/make-interactive b/tools/make-interactive index b6c660c2b..3e9834cb0 100644 --- a/tools/make-interactive +++ b/tools/make-interactive @@ -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 index 000000000..902ce612b --- /dev/null +++ b/tools/make-rootfiles @@ -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 . # +# # +############################################################################### + +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 +}