Hi, I am using shorewall on a small "embedded" board and I don't
have/want "make" installed. At present there are two calls to make in
/sbin/shorewall and neither do anything interesting other than check if
"some file newer than some other file" (something we can easily do
without make)
Additionally, I tried copying gnu make across but the performance is
pretty poor:
$ time make
make: Nothing to be done for `all'.
real 0m 0.48s
user 0m 0.35s
sys 0m 0.09s
So the attached patch uses "find" to instead check if any shorewall
files have been updated (could also have been done in pure shell code
easily enough if it's a worry that find is installed?)
Notes:
- There is a redundant function "automake_restore_file", which emulates
the complete make function - I left this in the patch purely in case
there was some desire to simplify the make file (probably not, so likely
it's dead code?)
- The new function to check if anything changed is
"automake_restore_needed" - this should probably be moved to one of the
/usr/share/shorewall/lib.xxx files - I left it in the main file for the
patch since surely I will pick the wrong place to move it....
Grateful if you would consider accepting this functionality into the
next shorewall release (for me a large performance increase, and
eliminated of a dependency)
Thanks
Ed W
--- /sbin/shorewall.orig
+++ /sbin/shorewall
@@ -310,6 +310,32 @@
}
#
+# Emulate "make". Update restore file only if older than rules
+#
+automake_restore_needed() {
+ if [ -n "$(find ${CONFDIR} -newer ${VARDIR}/${RESTOREFILE})" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+automake_restore_file() {
+ if automake_restore_needed; then
+ qt /sbin/shorewall -q save
+ if qt /sbin/shorewall -q restart; then
+ qt /sbin/shorewall -q save
+ else
+ # Some kind of error occurred
+ /sbin/shorewall -q restart 2>&1 | tail >&2
+ return 1
+ fi
+ fi
+
+ return 0
+}
+
+#
# Run the compiler
#
compiler() {
@@ -468,29 +494,24 @@
esac
if [ -n "${g_fast}${AUTOMAKE}" ]; then
- if qt mywhich make; then
- restorefile=$RESTOREFILE
+ restorefile=$RESTOREFILE
- if [ -z "$g_fast" ]; then
- #
- # Automake -- use the last compiled script
- #
- RESTOREFILE=firewall
- fi
+ if [ -z "$g_fast" ]; then
+ #
+ # Automake -- use the last compiled script
+ #
+ RESTOREFILE=firewall
+ fi
- export RESTOREFILE
+ export RESTOREFILE
- if ! make -qf ${CONFDIR}/Makefile; then
+ if automake_restore_needed; then
g_fast=
AUTOMAKE=
- fi
-
- RESTOREFILE=$restorefile
- else
- g_fast=
- AUTOMAKE=
fi
+ RESTOREFILE=$restorefile
+
if [ -n "$g_fast" ]; then
g_restorepath=${VARDIR}/$RESTOREFILE
@@ -747,15 +768,13 @@
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
if [ -z "$g_fast" -a -n "$AUTOMAKE" ]; then
- if qt mywhich make; then
- #
- # RESTOREFILE is exported by get_config()
- #
- restorefile=$RESTOREFILE
- RESTOREFILE=firewall
- make -qf ${CONFDIR}/Makefile && g_fast=Yes
- RESTOREFILE=$restorefile
- fi
+ #
+ # RESTOREFILE is exported by get_config()
+ #
+ restorefile=$RESTOREFILE
+ RESTOREFILE=firewall
+ automake_restore_needed || g_fast=Yes
+ RESTOREFILE=$restorefile
fi
if [ -z "$g_fast" ]; then
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Shorewall-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-users