Solved How to submit (kernel & base) patches?

mjollnir

Active Member

Reaction score: 67
Messages: 232

I have a few patches (kernel & base) that I'd like to submit, but I don't know of how to do that in a decent way.
It might be unfair for innocent users to post the kernel patch here, since although it's fairly small and ran for years on two of my machines, it might have unforseen bad side effects.
Thx in advance.

The base system patch is pretty harmless, esp. since it affects the sh(1) version of man(1) - which is not used by default - and the location in the src tree of the apropos(1) man page changed since I produced the patch.

The patch makes apropos(1) and whatis(1) to respect the MANSECT environment variable - what man(1) does by default only for viewing man pages - so the user sees e.g. developer man pages only when s/he wants it. To be used with the appopiate addition of e.g. "MANSECT=1:8:n:4:5:6:7:l" in /etc/login.conf, then it's "on" by default. 2nd, it updates whatis(1) to answer appropiately to whatis the answer.

They are against FreeBSD 10 or 11, I don't remember exactly. One has to RTFM build(7) and src.conf(5) and find out how to enable it for FBSD 12. Maybe that's even not possible anymore.
Apply with $ patch -F 5 < usr.bin.man.man.sh.patch. The patch for the apropos(1) man page does not succeed on FBSD12, you'll have to manually apply it by editing the source file. For FBSD 10/11 one has to revert the source file name from contrib/mandoc to usr.bin/man (only for the apropos man page patch).
usr.bin.man.man.sh.patch
Code:
--- usr.bin/man/man.sh.orig    2016-01-29 15:19:53.270135762 +0100
+++ usr.bin/man//man.sh        2016-04-01 18:33:26.618283119 +0200
@@ -539,10 +539,19 @@
     unset IFS
 
     pages="$*"
 }
 
+# Usage: man_setup_sections
+# Setup manual sections to search.
+man_setup_sections() {
+    if [ -z "$MANSECT" ]; then
+        MANSECT=$man_default_sections
+    fi
+    decho "Using manual sections: $MANSECT"
+}
+
 # Usage: man_setup
 # Setup various trivial but essential variables.
 man_setup() {
     # Setup machine and architecture variables.
     if [ -n "$mflag" ]; then
@@ -556,17 +565,11 @@
         MACHINE=$($SYSCTL -n hw.machine)
     fi
     decho "Using architecture: $MACHINE_ARCH:$MACHINE"
 
     setup_pager
-
-    # Setup manual sections to search.
-    if [ -z "$MANSECT" ]; then
-        MANSECT=$man_default_sections
-    fi
-    decho "Using manual sections: $MANSECT"
-
+    man_setup_sections
     build_manpath
     man_setup_locale
     man_setup_width
 }
 
@@ -751,20 +754,21 @@
 }
 
 # Usage: search_whatis cmd [arglist]
 # Do the heavy lifting for apropos/whatis
 search_whatis() {
-    local IFS bad cmd f good key keywords loc opt out path rval wlist
+    local IFS bad cmd f good key keywords loc opt out path rval wlist s_re
 
     cmd="$1"
     shift
 
     whatis_parse_args "$@"
 
     build_manpath
     build_manlocales
     setup_pager
+    man_setup_sections
 
     if [ "$cmd" = "whatis" ]; then
         opt="-w"
     fi
 
@@ -795,20 +799,27 @@
         echo "$cmd: no whatis databases in $MANPATH" >&2
         exit 1
     fi
 
     rval=0
+    # Filter appropiate sections (delimited by colon ":")
+    # NOTE: there may be multi-letter sections like
+    # "perl5" or "x11" thus no character class "[]" but "(x|y|..)"
+    s_re="(.+\\(($(echo $MANSECT | sed 's/:/|/g'))\\))+[[:space:]]+-[[:space:]]"
+    decho "Filter sections by re_format(7): $s_re"
     for key in $keywords; do
-        out=$(grep -Ehi $opt -- "$key" $wlist)
+        out=$(grep -Ehi $opt -- "$key" $wlist | grep -Eh "${s_re}")
         if [ -n "$out" ]; then
             good="$good\\n$out"
         else
             bad="$bad\\n$key: nothing appropriate"
             rval=1
         fi
     done
 
+    [ "$cmd" = "whatis" -a "$1" = "the" -a "$2" = "answer" ] && bad="$bad\\n42"
+
     # Strip leading carriage return.
     good=${good#\\n}
     bad=${bad#\\n}
 
     if [ -n "$good" ]; then
@@ -868,13 +879,14 @@
 
 # Usage: whatis_parse_args "$@"
 # Parse commandline args for whatis and apropos.
 whatis_parse_args() {
     local cmd_arg
-    while getopts 'd' cmd_arg; do
+    while getopts 'dS:' cmd_arg; do
         case "${cmd_arg}" in
         d)    debug=$(( $debug + 1 )) ;;
+        S)    MANSECT=$OPTARG ;;
         *)    whatis_usage ;;
         esac
     done >&2
 
     shift $(( $OPTIND - 1 ))
@@ -883,11 +895,11 @@
 }
 
 # Usage: whatis_usage
 # Display usage for the whatis/apropos utility.
 whatis_usage() {
-    echo "usage: $cmd [-d] keyword [...]"
+    echo "usage: $cmd [-d] [-S section[:sect...]] keyword [...]"
     exit 1
 }
usr.bin.man.apropos.1.patch
Code:
--- contrib/mandoc/apropos.1.orig    2016-01-29 15:19:53.248134285 +0100
+++ contrib/mandoc/apropos.1        2016-04-01 18:17:41.863333747 +0200
@@ -23,23 +23,26 @@
 .\"  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\"  SUCH DAMAGE.
 .\"
 .\" $FreeBSD: releng/10.2/usr.bin/man/apropos.1 213317 2010-10-01 03:59:18Z gordon $
 .\"
-.Dd September 1, 2010
+.Dd April 1, 2016
 .Dt APROPOS 1
 .Os
 .Sh NAME
 .Nm apropos ,
 .Nm whatis
 .Nd keyword search whatis documentation databases
 .Sh SYNOPSIS
 .Nm
 .Op Fl d
+.Op Fl S Ar section Ns Op : Ns Ar section ...
 .Ar keyword ...
+.Pp
 .Nm whatis
 .Op Fl d
+.Op Fl S Ar section Ns Op : Ns Ar section ...
 .Ar keyword ...
 .Sh DESCRIPTION
 The
 .Nm
 utility searches a set of databases looking for documentation matching each
@@ -50,27 +53,44 @@
 utility does the same search but only on complete words.
 .Bl -tag -width ".Fl d"
 .It Fl d
 Print extra debugging information.
 .El
+.Bl -tag -width ".Fl S"
+.It Fl S Ar section Ns Op : Ns Ar section ...
+Limit the results to the given manual
+.Ar section .
+.Pp
+Note that this is a colon (':') separated list of extended regular expressions.
+You can use ".+" to search in all sections.
+.El
 .Pp
 The
 .Ar keyword
 is simply passed to
 .Xr grep 1
 allowing for extended regular expression matches.
 .Sh ENVIRONMENT
 The following environment variables affect the execution of
-.Nm :
+.Nm
+and
+.Nm whatis
+:
 .Bl -tag -width ".Ev PAGER"
 .It Ev MANLOCALES , MANPATH , PATH
 Used to find the location of the
 .Nm whatis
 database files. See
 .Xr manpath 1
 for additional information.
-.It Ev PAGER
+.It Ev MANSECT
+The manual sections to search in.  If unset, uses the same default as
+.Xr man 1
+(
+.Ic "1:8:2:3:n:4:5:6:7:9:l"
+).
+.It Ev MANPAGER , PAGER
 Program used to display files.
 If unset,
 .Ic "more -s"
 is used.
 .El
@@ -79,10 +99,11 @@
 .Nm
 utility exits 0 if a keyword matched and 1 if no keywords are matched or no
 .Nm whatis
 databases are found.
 .Sh SEE ALSO
+.Xr re_format 7 ,
 .Xr grep 1 ,
 .Xr makewhatis 1 ,
 .Xr man 1 ,
 .Xr manpath 1 ,
 .Xr man.conf 5
 
Top