Re: Snort 3: Add --disable-txt-docs option to configure_cmake.sh patches

Y M via Snort-devel <[email protected]> Tue, 20 Mar 2018 16:25:08 +0000
Newsgroups gmane.comp.security.ids.snort.devel
Message-ID <CY1PR17MB036253E5B2173789B2EEE359A8AB0@CY1PR17MB0362.namprd17.prod.outlook.com>
Hi Michael,


I applied the patch, which had some errors. I tried different ways and ended up with the same results, unless I am doing it wrong. Outputs are attached.


Thanks.

YM

________________________________
From: Snort-devel <[email protected]> on behalf of Michael Altizer via Snort-devel <[email protected]>
Sent: Tuesday, March 20, 2018 5:45:45 PM
To: [email protected]
Subject: Re: [Snort-devel] Snort 3: Add --disable-txt-docs option to configure_cmake.sh patches

Ok, thanks.  I've attached a patch that should remove the bashisms from all but one of the scripts (which won't execute normally) if you would like to try it.  We'll also pull in your patch since it seems like a useful option to have even if the scripts are working.

On 03/19/2018 11:22 AM, Y M via Snort-devel wrote:

Hi Michael,


Tested with #!/bin/sh on CentOS and FreeBSD. On CentOS it went okay. On FreeBSD, the make output is shown below. Doing an install afterwards did not create the $prefix/doc directory.


[98%] Built target snort
Scanning dependencies of target all_built_sources
[ 98%] Documents: building config.txt with
[ 98%] Documents: building counts.txt with
[ 98%] Documents: building modules.txt with
[ 98%] Documents: building plugins.txt with
[ 98%] Documents: building signals.txt with
../../doc/scripts/generate_help.sh: [[: not found
[ 99%] Documents: building builtin.txt with
../../doc/scripts/generate_help.sh: [[: not found
[ 99%] Documents: building help.txt with
[ 99%] Documents: building options.txt with
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_list.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
[ 99%] Documents: building gids.txt with
[ 99%] Documents: building codec.txt with
[ 99%] Documents: building connector.txt with
../../doc/scripts/generate_list.sh: [[: not found
[ 99%] Documents: building basic.txt with
../../doc/scripts/generate_module.sh: [[: not found
../../doc/scripts/generate_module.sh: [[: not found
[ 99%] Documents: building data.txt with
[ 99%] Documents: building ips_action.txt with
[100%] Documents: building inspector.txt with
[100%] Documents: building ips_option.txt with
../../doc/scripts/generate_module.sh: [[: not found
../../doc/scripts/generate_module.sh: [[: not found
../../doc/scripts/generate_module.sh: [[: not found
../../doc/scripts/generate_module.sh: [[: not found
../../doc/scripts/generate_module.sh: [[: not found
[100%] Documents: building logger.txt with
../../doc/scripts/generate_module.sh: [[: not found
[100%] Documents: building version.txt
[100%] Documents: building commands.txt with
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
../../doc/scripts/generate_help.sh: [[: not found
[100%] Documents: building snort2lua_cmds.txt
[100%] Built target all_built_sources
Scanning dependencies of target snort_manuals
[100%] Built target snort_manuals

________________________________
From: Snort-devel <[email protected]><mailto:[email protected]> on behalf of Michael Altizer via Snort-devel <[email protected]><mailto:[email protected]>
Sent: Monday, March 19, 2018 5:49:50 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: [Snort-devel] Snort 3: Add --disable-txt-docs option to configure_cmake.sh patches

On 03/16/2018 10:32 AM, Y M via Snort-devel wrote:

Hi,


The attached patch files will add a new option --disable-txt-docs to the configure_cmake.sh script, and wrap the generation of Snort $prefix/doc/* in doc/CMakeList.txt with logic to check if the new option is set. If the option is used, the text files and the $prefix/doc directory will not be generated. This is possible thanks to the existing logic to handle MAKE_TEXT_DOC.


This change stems from the fact that the scripts: doc/scripts/generate_help.sh, doc/scripts/generate_list.sh, and doc/scripts/generate_module.sh use bash "#!/usr/bin/env bash" for the shell. On a pristine FreeBSD image or in cases bash is not installed, the make script will fail with the below error with no obvious way on how to proceed with compiling Snort 3. This occurs in Snort builds 243 and 244.


Scanningdependencies of target codecs
[ 97%] Building CXX object src/codecs/CMakeFiles/codecs.dir/codec_api.cc.o
[ 98%] Linking CXX static library libcodecs.a
[ 98%] Built target codecs
Scanning dependencies of target snort
[ 98%] Building CXX object src/CMakeFiles/snort.dir/main.cc.o
[ 98%] Linking CXX executable snort
[ 98%] Built target snort
Scanning dependencies of target all_built_sources
[ 98%] Documents: building counts.txt with
[ 98%] Documents: building modules.txt with
[ 98%] Documents: building plugins.txt with
[ 98%] Documents: building signals.txt with
[ 98%] Documents: building builtin.txt with
[ 98%] Documents: building options.txt with
[ 98%] Documents: building config.txt with
env: bash: No such file or directory
--- doc/counts.txt ---
*** [doc/counts.txt] Error code 127

...


With the changes applied, Snort builds successfully. I am not sure if this is the best way to handle it, but it avoids missing with the shell scripts portability among the different shells.


Thanks.

YM



Thanks for the patch, but since you seem to have a bash-less FreeBSD system handy, could you try just changing them all to use #!/bin/sh and see if there were any actual bash-isms?  If not, we'll just swap the interpreter.



_______________________________________________
Snort-devel mailing list
[email protected]<mailto:[email protected]>
https://lists.snort.org/mailman/listinfo/snort-devel

Please visit http://blog.snort.org for the latest news about Snort!

_______________________________________________
Snort-devel mailing list
[email protected]
https://lists.snort.org/mailman/listinfo/snort-devel

Please visit http://blog.snort.org for the latest news about Snort!
make_output.txt (text/plain, 2.7 KB)
Scanning dependencies of target all_built_sources
[ 98%] Documents: building modules.txt with 
sh: ../../doc/scripts/generate_help.sh: not found
--- doc/modules.txt ---
*** [doc/modules.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
[ 98%] Documents: building plugins.txt with 
sh: ../../doc/scripts/generate_help.sh: not found
--- doc/plugins.txt ---
*** [doc/plugins.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
[ 98%] Documents: building config.txt with 
[ 99%] Documents: building builtin.txt with 
sh: ../../doc/scripts/generate_help.sh: not found
[ 99%] Documents: building counts.txt with 
--- doc/config.txt ---
*** [doc/config.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
[ 99%] Documents: building signals.txt with 
[ 99%] Documents: building options.txt with 
sh: ../../doc/scripts/generate_help.sh: not found
sh: ../../doc/scripts/generate_list.sh: not found
--- doc/counts.txt ---
*** [doc/counts.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
--- doc/builtin.txt ---
*** [doc/builtin.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
[ 99%] Documents: building help.txt with 
sh: ../../doc/scripts/generate_help.sh: not found
--- doc/options.txt ---
*** [doc/options.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
sh: ../../doc/scripts/generate_help.sh: not found
--- doc/signals.txt ---
*** [doc/signals.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
sh: ../../doc/scripts/generate_help.sh: not found
--- doc/help.txt ---
*** [doc/help.txt] Error code 127

make[2]: stopped in /root/source/xsnort/build
8 errors

make[2]: stopped in /root/source/xsnort/build
--- doc/CMakeFiles/all_built_sources.dir/all ---
*** [doc/CMakeFiles/all_built_sources.dir/all] Error code 2

make[1]: stopped in /root/source/xsnort/build
1 error

make[1]: stopped in /root/source/xsnort/build
*** [all] Error code 2

make: stopped in /root/source/xsnort/build
1 error

make: stopped in /root/source/xsnort/build

root@snort-bsd:~/source/xsnort/build # ls -l ../doc/scripts/
total 36
-rwxr-xr-x  1 root  wheel  665 Mar 20 15:55 generate_help.sh
-rwxr-xr-x  1 root  wheel  674 Mar 20 15:53 generate_help.sh.orig
-rw-r--r--  1 root  wheel  596 Mar 20 15:55 generate_help.sh.rej
-rwxr-xr-x  1 root  wheel  472 Mar 20 15:55 generate_list.sh
-rwxr-xr-x  1 root  wheel  481 Mar 20 15:53 generate_list.sh.orig
-rw-r--r--  1 root  wheel  178 Mar 20 15:55 generate_list.sh.rej
-rwxr-xr-x  1 root  wheel  447 Mar 20 15:55 generate_module.sh
-rwxr-xr-x  1 root  wheel  447 Mar 20 15:53 generate_module.sh.orig
-rw-r--r--  1 root  wheel  259 Mar 20 15:55 generate_module.sh.rej
patch_output.txt (text/plain, 4.5 KB)
root@snort-bsd:~/source/xsnort # patch -p1 -i build-Remove-bashisms-from-most-shell-scripts.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From 6e04230b31d4a8ab6c79c2e8db24c02a6dbb72c8 Mon Sep 17 00:00:00 2001
|From: Michael Altizer <[email protected]>
|Date: Mon, 19 Mar 2018 21:18:12 -0400
|Subject: [PATCH] build: Remove bashisms from most shell scripts
|
|---
| configure_cmake.sh             |  3 +--
| doc/dev_guide.sh               |  2 +-
| doc/online_manual.sh           |  6 +++---
| doc/scripts/generate_help.sh   |  8 ++++----
| doc/scripts/generate_list.sh   |  4 ++--
| doc/scripts/generate_module.sh |  4 ++--
| extra/configure_cmake.sh       |  3 +--
| extra/generate_boilerplate.sh  | 20 ++++++++------------
| 8 files changed, 22 insertions(+), 28 deletions(-)
|
|diff --git a/configure_cmake.sh b/configure_cmake.sh
|index 959d81e43..52bef51f9 100755
|--- a/configure_cmake.sh
|+++ b/configure_cmake.sh
--------------------------
Patching file configure_cmake.sh using Plan A...
Hunk #1 failed at 400.
1 out of 1 hunks failed--saving rejects to configure_cmake.sh.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/doc/dev_guide.sh b/doc/dev_guide.sh
|index c794c40d2..5ec4477b6 100755
|--- a/doc/dev_guide.sh
|+++ b/doc/dev_guide.sh
--------------------------
Patching file doc/dev_guide.sh using Plan A...
Hunk #1 succeeded at 1 with fuzz 2.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/doc/online_manual.sh b/doc/online_manual.sh
|index 393197cfa..e57b1d35f 100755
|--- a/doc/online_manual.sh
|+++ b/doc/online_manual.sh
--------------------------
Patching file doc/online_manual.sh using Plan A...
Hunk #1 succeeded at 1 with fuzz 2.
Hunk #2 failed at 38.
1 out of 2 hunks failed--saving rejects to doc/online_manual.sh.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/doc/scripts/generate_help.sh b/doc/scripts/generate_help.sh
|index e516bee05..b6b704777 100755
|--- a/doc/scripts/generate_help.sh
|+++ b/doc/scripts/generate_help.sh
--------------------------
Patching file doc/scripts/generate_help.sh using Plan A...
Hunk #1 succeeded at 1 with fuzz 2.
Hunk #2 failed at 7.
Hunk #3 failed at 26.
2 out of 3 hunks failed--saving rejects to doc/scripts/generate_help.sh.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/doc/scripts/generate_list.sh b/doc/scripts/generate_list.sh
|index 3a6f125cc..6cbc62fce 100755
|--- a/doc/scripts/generate_list.sh
|+++ b/doc/scripts/generate_list.sh
--------------------------
Patching file doc/scripts/generate_list.sh using Plan A...
Hunk #1 succeeded at 1 with fuzz 2.
Hunk #2 failed at 7.
1 out of 2 hunks failed--saving rejects to doc/scripts/generate_list.sh.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/doc/scripts/generate_module.sh b/doc/scripts/generate_module.sh
|index 34d23760d..119810421 100755
|--- a/doc/scripts/generate_module.sh
|+++ b/doc/scripts/generate_module.sh
--------------------------
Patching file doc/scripts/generate_module.sh using Plan A...
Hunk #1 failed at 1.
1 out of 1 hunks failed--saving rejects to doc/scripts/generate_module.sh.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/extra/configure_cmake.sh b/extra/configure_cmake.sh
|index 882d2ed39..f201ea62c 100755
|--- a/extra/configure_cmake.sh
|+++ b/extra/configure_cmake.sh
--------------------------
Patching file extra/configure_cmake.sh using Plan A...
Hunk #1 failed at 86.
1 out of 1 hunks failed--saving rejects to extra/configure_cmake.sh.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/extra/generate_boilerplate.sh b/extra/generate_boilerplate.sh
|index 9fef33850..fae591de3 100755
|--- a/extra/generate_boilerplate.sh
|+++ b/extra/generate_boilerplate.sh
--------------------------
Patching file extra/generate_boilerplate.sh using Plan A...
Hunk #1 failed at 1.
Hunk #2 failed at 13.
2 out of 2 hunks failed--saving rejects to extra/generate_boilerplate.sh.rej
Hmm...  Ignoring the trailing garbage.
done