From 577db69719819362932d5816daf1bc9110c6df2b Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Tue, 7 May 2013 09:36:02 -0700 Subject: [PATCH] Support conditional compilation. Signed-off-by: Tom Eastep --- Shorewall/lib.cli-std | 18 ++++++++++++++---- Shorewall/manpages/shorewall.xml | 17 +++++++++++++++-- Shorewall6/manpages/shorewall6.xml | 12 +++++++++++- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Shorewall/lib.cli-std b/Shorewall/lib.cli-std index 847a139b7..8bc68dd55 100644 --- a/Shorewall/lib.cli-std +++ b/Shorewall/lib.cli-std @@ -337,7 +337,7 @@ uptodate() { ifs="$IFS" IFS=':' - for dir in $CONFIG_PATH; do + for dir in $g_shorewalldir $CONFIG_PATH; do if [ -n "$(find ${dir} -newer $1)" ]; then IFS="$ifs" return 1; @@ -599,6 +599,7 @@ start_command() { compile_command() { local finished finished=0 + local conditional while [ $finished -eq 0 ]; do [ $# -eq 0 ] && break @@ -629,6 +630,10 @@ compile_command() { g_debug=Yes; option=${option#d} ;; + c*) + conditional=Yes; + option=${option#c} + ;; T*) g_confess=Yes option=${option#T} @@ -678,9 +683,14 @@ compile_command() { ;; esac - [ "x$file" = x- ] || progress_message3 "Compiling..." + if [ -n "$conditional" ] && uptodate $file; then + echo "$file is up to date -- no compilation required" + return 0 + else + [ "x$file" = x- ] || progress_message3 "Compiling..." - compiler $g_debugging compile $file && run_postcompile $file + compiler $g_debugging compile $file && run_postcompile $file + fi } # @@ -1579,7 +1589,7 @@ usage() # $1 = exit status echo " allow
..." echo " check [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ ]" echo " clear" - echo " compile [ -e ] [ -p ] [ -t ] [ -d ] [ -T ] [ ] [ ]" + echo " compile [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ ] [ ]" echo " delete [:] ... " echo " disable " echo " drop
..." diff --git a/Shorewall/manpages/shorewall.xml b/Shorewall/manpages/shorewall.xml index 04a946e12..6efbcc387 100644 --- a/Shorewall/manpages/shorewall.xml +++ b/Shorewall/manpages/shorewall.xml @@ -92,6 +92,8 @@ + + @@ -832,8 +834,9 @@ Compiles the current configuration into the executable file - pathname. If a directory is supplied, Shorewall - will look in that directory first for configuration files. If the + pathname. If a + directory is supplied, Shorewall will + look in that directory first for configuration files. If the pathname is omitted, the file firewall in the VARDIR (normally /var/lib/shorewall/) is assumed. A @@ -853,6 +856,16 @@ capabilities on a system with Shorewall Lite installed + The -c option was added in + Shorewall 4.5.17 and causes conditional compilation of a script. The + script specified by pathname (or implied + if pathname is omitted) is compiled + if it doesn't exist or if there is any file in the + directory or in a directory on the + CONFIG_PATH that has a modification time later than the file to be + compiled. When no compilation is needed, a message is issued and an + exit status of zero is returned. + The option causes the compiler to be run under control of the Perl debugger. diff --git a/Shorewall6/manpages/shorewall6.xml b/Shorewall6/manpages/shorewall6.xml index 3048f2fcc..53e5bded0 100644 --- a/Shorewall6/manpages/shorewall6.xml +++ b/Shorewall6/manpages/shorewall6.xml @@ -762,7 +762,17 @@ which may be produced using the command shorewall6-lite show -f capabilities > capabilities on a system with Shorewall6 Lite - installed + installed. + + The -c option was added in + Shorewall 4.5.17 and causes conditional compilation of a script. The + script specified by pathname (or implied + if pathname is omitted) is compiled + if it doesn't exist or if there is any file in the + directory or in a directory on the + CONFIG_PATH that has a modification time later than the file to be + compiled. When no compilation is needed, a message is issued and an + exit status of zero is returned. The option causes the compiler to be run under control of the Perl debugger.