Anyone using FreeBSD?

@slh Thanks for the reply, although I'm not exactly sure what to make of it.

According to FreeBSD their version of getopt:

Rewrite of getopt(1) with the following features:

* It can do anything that the GNU getopt(3) routines can do.
* It can cope with spaces and shell metacharacters within arguments.
* It can parse long parameters.
* It can shuffle parameters, so you can mix options and other parameters
  on the command-line.
* It can be easily identified as an enhanced getopt(1) from within shell
* It can report parse errors as coming from the shell script.
* It compiles cleanly with both libc-5 and glibc-2.

Not really sure what to do in this case... however I have just noticed that renaming getopt to gnugetopt resolved the error.

If (Free)BSD getopt is sufficient, the best solution would be to modify the getopt detection to flag it as correct.

1 Like

Well, when I copy FreeBSD's getopt as gnugetopt, somewhere on the path, then things work, which suggests that it is sufficient. Although I'm not really sure what needs to be done.

@slh Unfortunately I can't understand the code in this test. Does it check for the presence of gnugetopt and fail if not present?

@slh I have just realised that FreeBSD has a builtin getopt, but there is also a FreeBSD pkg misc/getopt which is the one that needs to be used, so adding the line

/usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \

sorts things out.

If that works for you, please follow, to get it merged into master.

1 Like

I'd just like to report that after running my script over and over many times, I have actually got as far an OpenWrt Configuration menu, so I'm very pleased with progress. Now to learn how to use it!

@slh I created a patch:-

--- include/<--->2021-12-03 21:03:44.406974000 +0000
+++ include/<---->2021-12-03 21:56:19.603555000 +0000
@@ -130,6 +130,7 @@
 <----->Please install an extended getopt version that supports --long, \
 <----->gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
 <----->getopt -o t --long test -- --test | grep '^ *--test *--', \
+<----->/usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
 <----->/usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \

but submitting it is something I can't figure out, although I doubt I would be able to

I looked into how to submit my suggested patch, but seemed overly complicated for such a minor change. I'd appreciate it if someone could submit it on my behalf. It's only the addition of an additional search path for getopt.

patch  <<EOF                                                                                                                                                
--- include/     2023-08-26 09:03:31.437266000 +0100                                                                                        
+++ -                                                                                                                                                      
@@ -149,6 +149,7 @@                                                                                                                                        
        Please install an extended getopt version that supports --long, \\                                                                                  
        gnugetopt -o t --long test -- --test | grep '^ *--test *--', \\                                                                                    
        getopt -o t --long test -- --test | grep '^ *--test *--', \\                                                                                        
+       /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \\                                                                        
        /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \\                                                          
        /opt/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))                                                                          

Thanks in advance.

Just a reminder that the build system says:-


To build your own firmware you need a GNU/Linux, BSD or MacOSX system (case
sensitive filesystem required). Cygwin is unsupported because of the lack of a
case sensitive file system.

And it contains a BSDmakefile.

How do I get the above patch included in include/ ?

there's just no way i'd ever do this unless using a Linux container to build the firmware on, which apparently you can do with FreeBSD though i'm not sure how easy and clean that is ultimately

I've never gotten very familiar with things like docker, systemd-nspawn seems simple and clean enough, if freebsd has a similar way of getting an Arch Linux or Debian linux container up you'd figure that would be the best no brainer way to ultimately build openwrt from a freebsd host