Friday, April 14, 2017

Re: news/nn overhaul

I don't currently use OpenBSD on any of my main work machines, so I don't use the NN port right now, but I heartily approve of the overall simplification enumerated below. Thank you!

--
Aaron W. Hsu | arcfide@sacrideo.us | http://www.sacrideo.us
Support my Open Work: http://www.gratipay.com/Co-dfns/

From: Christian Weisgerber
Sent: Friday, April 14, 2017 6:00 PM
To: ports@openbsd.org
Cc: Aaron W. Hsu
Subject: news/nn overhaul

Does anybody still use news/nn? Here's an overhaul of the port:

* Get rid of the MACHINE_ARCH dance and use a single m-openbsd.h
file. We only need to define a few basic types that are the same
on all our archs. NETWORK_BYTE_ORDER could be gotten from
<endian.h>, but it is only used with NETWORK_DATABASE, which we
don't define.

* Simplify the contorted substitutions in Makefile and use SUBST_CMD
where possible.

* clang throws a hissy fit over nested comments. Since fixing those
destroys the diff-ability of s-openbsd.h compared to s-template.h
anyway, I went ahead and compactified the file.

* clang on amd64 with our binutils ld produced a relocation error
for BC in term.c. I think these are globals that are already
defined in libtermlib, and thus should be declared extern.

Very lightly tested on arm64.


Index: Makefile
===================================================================
RCS file: /cvs/ports/news/nn/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- Makefile 1 Sep 2016 10:53:27 -0000 1.15
+++ Makefile 14 Apr 2017 21:26:28 -0000
@@ -1,8 +1,8 @@
# $OpenBSD: Makefile,v 1.15 2016/09/01 10:53:27 jasper Exp $

-COMMENT = No News is Good News (Fast CLI Point & Read Newsreader)
+COMMENT = menu-based Usenet newsreader
DISTNAME = nn-6.7.3
-REVISION = 2
+REVISION = 3
CATEGORIES = news
HOMEPAGE = http://www.nndev.org

@@ -23,36 +23,12 @@ USE_GROFF = Yes
NO_TEST = Yes
MAKE_ENV = CC="${CC}"

-.if "${MACHINE_ARCH}" == "alpha"
-MFILE = m-alpha.h
-.elif "${MACHINE_ARCH}" == "hppa"
-MFILE = m-hp9000.h
-.elif "${MACHINE_ARCH}" == "m88k"
-MFILE = m-m88000.h
-.elif "${MACHINE_ARCH}" == "powerpc"
-MFILE = m-powerpc.h
-.elif "${MACHINE_ARCH}" == "mips64"
-MFILE = m-mips.h
-.elif "${MACHINE_ARCH}" == "sparc64"
-MFILE = m-sparc.h
-.else
-MFILE = m-i80386.h
-.endif
-
pre-configure:
- sed -e "s/OBSD_PREFIX/${PREFIX:S/\//\\\//g}/" \
- -e "s/m-i80386\.h/${MFILE}/" \
- ${FILESDIR}/config.h > ${WRKSRC}/config.h
- cp ${FILESDIR}/s-openbsd.h ${WRKSRC}/conf/s-openbsd.h
-
-pre-install:
- sed -e "s/\/usr\/local/${PREFIX:C/\//\\\//g}/" \
- ${WRKSRC}/inst > ${WRKSRC}/inst.new
- mv ${WRKSRC}/inst ${WRKSRC}/inst.old
- mv ${WRKSRC}/inst.new ${WRKSRC}/inst
- chmod 755 ${WRKSRC}/inst
+ ${SUBST_DATA} ${FILESDIR}/config.h ${WRKSRC}/config.h
+ cp ${FILESDIR}/[ms]-openbsd.h ${WRKSRC}/conf/

do-install:
- cd ${WRKSRC} && echo `pwd` && ./inst n
+ perl -pi.bak -e 's:${TRUEPREFIX}:${PREFIX}:g' ${WRKSRC}/inst
+ cd ${WRKSRC} && ./inst n

.include <bsd.port.mk>
Index: files/config.h
===================================================================
RCS file: /cvs/ports/news/nn/files/config.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 config.h
--- files/config.h 17 Nov 2008 08:42:13 -0000 1.1.1.1
+++ files/config.h 14 Apr 2017 21:26:28 -0000
@@ -122,7 +122,7 @@
* conf/m-template.h as a starting point for writing you own.
*/

-#include "m-i80386.h"
+#include "m-openbsd.h"


/***************************** OWNERSHIP ***************************
@@ -173,10 +173,10 @@
* (= LIB_DIRECTORY/Log if undefined).
*/

-#define BIN_DIRECTORY "OBSD_PREFIX/bin"
-#define LIB_DIRECTORY "OBSD_PREFIX/lib/nn"
-#define CLIENT_DIRECTORY "OBSD_PREFIX/libexec/nn"
-#define HELP_DIRECTORY "OBSD_PREFIX/share/doc/nn"
+#define BIN_DIRECTORY "${PREFIX}/bin"
+#define LIB_DIRECTORY "${PREFIX}/lib/nn"
+#define CLIENT_DIRECTORY "${PREFIX}/libexec/nn"
+#define HELP_DIRECTORY "${PREFIX}/share/doc/nn"
#define TMP_DIRECTORY "/tmp"
#define LOG_FILE "/var/log/nn"

@@ -240,13 +240,13 @@
* DAEMON_MAN - nnmaster
*/

-#define USER_MAN_DIR "OBSD_PREFIX/man/man1"
+#define USER_MAN_DIR "${PREFIX}/man/man1"
#define USER_MAN_SECTION "1"

-#define SYS_MAN_DIR "OBSD_PREFIX/man/man1"
+#define SYS_MAN_DIR "${PREFIX}/man/man1"
#define SYS_MAN_SECTION "1m"

-#define DAEMON_MAN_DIR "OBSD_PREFIX/man/man8"
+#define DAEMON_MAN_DIR "${PREFIX}/man/man8"
#define DAEMON_MAN_SECTION "8"


Index: files/m-openbsd.h
===================================================================
RCS file: files/m-openbsd.h
diff -N files/m-openbsd.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/m-openbsd.h 14 Apr 2017 21:26:28 -0000
@@ -0,0 +1,8 @@
+/* $OpenBSD */
+
+/* MACHINE TYPE DEFINED TYPE VALUE RANGE */
+
+typedef unsigned char int8; /* 0 .. 255 */
+typedef short int16; /* -10,000 .. 10,000 */
+typedef int int32; /* -100,000 .. 100,000 */
+typedef unsigned int uint32; /* 0 .. 2^31-1 */
Index: files/s-openbsd.h
===================================================================
RCS file: /cvs/ports/news/nn/files/s-openbsd.h,v
retrieving revision 1.2
diff -u -p -r1.2 s-openbsd.h
--- files/s-openbsd.h 14 Mar 2016 06:43:09 -0000 1.2
+++ files/s-openbsd.h 14 Apr 2017 21:26:28 -0000
@@ -1,258 +1,22 @@
-/*
- * Use this file as a template for new s- files
- */
-
-
-/*
- * Include header files containing the following definitions:
- *
- * off_t, time_t, struct stat
- */
+/* $OpenBSD$ */

#include <sys/types.h>
#include <sys/stat.h>
-
-
-/*
- * Define if your system doesn't have memmove()
- */
-
-/* #define NO_MEMMOVE /* */
-
-/*
- * Define if your system has system V like ioctls
- * and <termio.h>
- */
-
-/* #define HAVE_TERMIO_H /* */
-
-/*
- * Define if your system instead has <termios.h>
- */
-
-#define HAVE_TERMIOS_H /* */
-
-/*
- * Define to use terminfo database.
- * Otherwise, termcap is used
- */
-
-/* #define USE_TERMINFO /* */
-
-/*
- * Specify the library (or libraries) containing the termcap/terminfo
- * routines.
- *
- * Notice: nn only uses the low-level terminal access routines
- * (i.e. it does not use curses).
- */
-
+#define HAVE_TERMIOS_H
#define TERMLIB -ltermlib
-
-/*
- * Define HAVE_STRCHR if strchr() and strrchr() are available
- */
-
-#define HAVE_STRCHR /* */
-
-/*
- * Define if a signal handler has type void (see signal.h)
- */
-
-#define SIGNAL_HANDLERS_ARE_VOID /* */
-
-/*
- * Define if signals must be set again after they are caught
- */
-
-/* #define RESET_SIGNAL_WHEN_CAUGHT /* */
-
-/*
- * Define FAKE_INTERRUPT if a keyboard interrupt (^C) cannot interrupt
- * a read() system call. This happens on a few BSD based systems
- * which don't have SV_INTERRUPT defined in <signal.h> and no
- * siginterrupt() call to make systems call interruptable.
- * However, if siginterrupt() is available, but SV_INTERRUPT isn't
- * defined, then simply define that instead of FAKE_INTERRUPT!
- */
-
-/* #define FAKE_INTERRUPT /* */
-
-/*
- * Define HAVE_HARD_SLEEP if sending a SIGALRM isn't enough to
- * interrupt a sleep() call - typical symptom is that nnadmin W
- * doesn't wakeup the nnmaster.
- */
-
-/* #define HAVE_HARD_SLEEP /* BSD ? */
-
-/*
- * Define HAVE_UALARM if your system has a 4.3 BSD like ualarm() call.
- * Else define MICRO_ALARM(n) to timeout in n/10 seconds if possible.
- * Don't define either if system only has the standard alarm() call.
- */
-
-#define HAVE_UALARM /* BSD 4.3 */
-/* #define MICRO_ALARM(n) xxxx(n) /* */
-
-/*
- * Define if your system has BSD like job control (SIGTSTP works)
- */
-
-#define HAVE_JOBCONTROL /* */
-
-
-/*
- * Define if your system has a 4.3BSD like syslog library.
- */
-
+#define HAVE_STRCHR
+#define SIGNAL_HANDLERS_ARE_VOID
+#define HAVE_UALARM
+#define HAVE_JOBCONTROL
#define HAVE_SYSLOG
-
-/*
- * Define if your system provides the "directory(3X)" access routines
- *
- * If true, include the header file(s) required by the package below
- * (remember that <sys/types.h> or equivalent is included above)
- * Also typedef Direntry to the proper struct type.
- */
-
-#define HAVE_DIRECTORY /* */
-
-#include <dirent.h> /* System V */
-/* #include <sys/dir.h> /* BSD */
-
-typedef struct dirent Direntry; /* System V */
-/* typedef struct direct Direntry; /* BSD */
-
-/*
- * Define if your system has a mkdir() library routine
- */
-
-#define HAVE_MKDIR /* */
-
-/*
- * Pick one:
- * Define HAVE_GETHOSTNAME if you have a BSD like gethostname routine.
- * Define HAVE_UNAME if a system V compatible uname() is available.
- * Define HOSTNAME_FILE "...." to a file containing the hostname.
- * Define HOSTNAME_WHOAMI if sysname is defined in <whoami.h>.
- *
- * As a final resort, define HOSTNAME to the name of your system
- * (in config.h).
- */
-
-#define HAVE_GETHOSTNAME /* BSD systems */
-/* #define HAVE_UNAME /* System V */
-/* #define HOSTNAME_FILE "/etc/uucpname" /* or another file */
-/* #define HOSTNAME_WHOAMI /* in <whoami.h> */
-
-/*
- * Define HAVE_MULTIGROUP if system has simultaneous multiple group
- * membership capability (BSD style).
- * Also define NGROUPS or include the proper .h file if NGROUPS is
- * not defined in <sys/param.h>.
- */
-
-#define HAVE_MULTIGROUP /* BSD */
-
-/*
- * Define DETACH_TERMINAL to be a command sequence which
- * will detatch a process from the control terminal
- * Also include system files needed to perform this HERE.
- * If not possible, just define it (empty)
- */
-
-/* #include "...." */
-
-#define DETACH_TERMINAL setpgrp();
-
-
-/*
- * Specify where the Bourne Shell is.
- */
-
+#define HAVE_DIRECTORY
+#include <dirent.h>
+typedef struct dirent Direntry;
+#define HAVE_MKDIR
+#define HAVE_GETHOSTNAME
+#define HAVE_MULTIGROUP
+#define DETACH_TERMINAL setpgrp();
#define SHELL "/bin/sh"
-
-/*
- * Define OLD_AWK to the name of the "old awk" program if your
- * standard 'awk' is 'nawk' (new awk). Use full path if necessary.
- * (This is a temporary hack until I get time to fix the scripts
- * which breaks nawk).
- */
-
-/* #define OLD_AWK "oawk" /* */
-
-/*
- * Define AVOID_SHELL_EXEC if the system gets confused by
- * #!/bin/sh
- * lines in shell scripts, e.g. only reads #! and thinks it
- * is a csh script.
- */
-
-/* #define AVOID_SHELL_EXEC /* */
-
-/*
- * Specify the default mailer
- */
-
-#define MAILX "/usr/bin/mailx" /* SV */
-/* #define MAILX "/usr/ucb/Mail" /* BSD */
-
-/*
- * Define the maximum length of any pathname that may occur
- */
-
-#define FILENAME 256
-
-/*
- * Define USE_MALLOC_H if the faster malloc() in -lmalloc should be used.
- * This requires that -lmalloc is added to EXTRA_LIB below.
- *
- * You can tune the malloc package through the following definitions
- * according to the descriptions in malloc(3X):
- */
-
-/* #define USE_MALLOC_H /* */
-
-/* #define MALLOC_GRAIN sizeof(double) /* M_GRAIN */
-/* #define MALLOC_MAXFAST (MALLOC_GRAIN*4) /* M_MXFAST */
-/* #define MALLOC_FASTBLOCKS 100 /* M_NLBLKS */
-
-/*
- * NNTP support requires tcp/ip with socket interface.
- *
- * Define NO_RENAME if the rename() system call is not available.
- * Define EXCELAN if the tcp/ip package is EXCELAN based.
- * Define NNTP_EXTRA_LIB to any libraries required only for nntp.
- */
-
-/* #define NO_RENAME /* */
-/* #define EXCELAN /* */
-/* #define NNTP_EXTRA_LIB -lsocket /* */
-
-/*
- * Define RESIZING to make nn understand dynamic window-resizing.
- * (It uses the TIOCGWINSZ ioctl found on most 4.3BSD systems)
- * This should be defined in the conf/s-xxxxx.h file.
- */
-
-#define RESIZING /* */
-
-/*
- * Define standard compiler flags here:
- */
-
-#define COMPILER_FLAGS
-
-/*
- * Define standard loader flags here:
- */
-
-#define LOADER_FLAGS
-
-/*
- * If your system requires other libraries when linking nn
- * specify them here:
- */
-
-#define EXTRA_LIB
+#define MAILX "/usr/bin/mailx"
+#define FILENAME 256
+#define RESIZING
Index: patches/patch-term_c
===================================================================
RCS file: /cvs/ports/news/nn/patches/patch-term_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-term_c
--- patches/patch-term_c 7 Dec 2013 23:47:18 -0000 1.2
+++ patches/patch-term_c 14 Apr 2017 21:26:28 -0000
@@ -1,6 +1,6 @@
$OpenBSD: patch-term_c,v 1.2 2013/12/07 23:47:18 jca Exp $
--- term.c.orig Wed Jun 29 23:40:27 2005
-+++ term.c Sat Dec 7 23:50:52 2013
++++ term.c Fri Apr 14 23:16:01 2017
@@ -25,7 +25,7 @@
#include "regexp.h"
#include "nn_term.h"
@@ -22,3 +22,14 @@ $OpenBSD: patch-term_c,v 1.2 2013/12/07

No comments:

Post a Comment