On Thu, Oct 23, 2003, Matthias Kurz wrote:
> On Thu, Oct 23, 2003 at 04:41:12PM +0200, Matthias Kurz wrote:
> [...]
> > nn
> > --
> > Uses 'uname' to get hostname. This does not work, when the result
> > of 'uname' is not a fully qualified domain name.
> > hostname=baerlap, You need a fully qualified domain name
> > This will probably not work for Solaris-x86:
> > + M=sparc
> > + /opkg/lib/openpkg/shtool install -c -m 644 -e 's;s-sunos5.h;s-sunos5.h;' -e 's
> > ;m-sparc.h;m-sparc.h;' -e 's;/usr/local/bin;/opkg/bin;' -e 's;/usr/local/lib/nn;
>
Hi.
I changed nn so that it looks at $prefix/etc/nn/hostname when it
exists. When this file does not exist, it tries to find out the
hostname like before. BTW. 'shtool echo -e "%h%d"' did not work
for me, either.
I also added an option "force_nntp".
See attached nn.spec and nn.patch.
Well, it would probably not too bad to put a README.OpenPKG in the
packages that holds non-redundant infos about OpenPKG specific
changes. This could go to $prefix/share/<pkg>/doc/. I have this idea
from the people who make the Sun Companion CD. With non-redundant i
mean only infos one cannot extract from the .spec-file. What do
others think about this ?
(mk)
--
Matthias Kurz; Fuldastr. 3; D-28199 Bremen; VOICE +49 421 53 600 47
>> Im pr�motorischen Cortex kann jeder ein Held sein. (bdw) <<
##
## nn.spec -- OpenPKG RPM Specification
## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
## Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
## Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.com/>
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
# package information
Name: nn
Summary: No News Is Good News
URL: http://www.nndev.org/
Vendor: Kim Fabricius Storm
Packager: The OpenPKG Project
Distribution: OpenPKG [BASE]
Group: News
License: BSD-style
Version: 6.6.5
Release: 20031027
# package options
%option force_nntp yes
# list of sources
Source0: ftp://ftp.nndev.org/pub/nn-6.6/nn-%{version}.tar.Z
Patch0: nn.patch
# build information
Prefix: %{l_prefix}
BuildRoot: %{l_buildroot}
BuildPreReq: OpenPKG, openpkg >= 20030909, gcc
PreReq: OpenPKG, openpkg >= 20030909, MTA
AutoReq: no
AutoReqProv: no
%description
NN ("No News is Good News") is one of the oldest and most popular
Usenet News clients.
options:
nn::force_nntp : Use the nntp protocol to read/post news even when the
nntp-server is the local host.
%prep
%setup -q
%patch0 -p0
%build
S="template"; M="template"
case "%{l_platform -t}" in
i?86-freebsd* ) S="freebsd"; M="i80386" ;;
i?86-linux* ) S="linux"; M="i80386" ;;
sun4*-sunos5* ) S="sunos5"; M="sparc" ;;
i?86*-sunos5* ) S="sunos5"; M="i80386" ;;
* ) echo "Platform \"%{l_platform -t}\" not supported" 1>&2; exit 1 ;;
esac
%{l_shtool} install -c -m 644 \
-e "s;s-sunos5.h;s-${S}.h;" \
-e "s;m-sparc.h;m-${M}.h;" \
-e 's;/usr/local/bin;%{l_prefix}/bin;' \
-e 's;/usr/local/lib/nntp_server;%{l_prefix}/etc/nn/nntp_server;' \
-e 's;/usr/local/lib/nn;%{l_prefix}/libexec/nn;' \
-e 's;/usr/local/man/man1;%{l_prefix}/man/man1;' \
-e 's;/usr/local/man/man8;%{l_prefix}/man/man8;' \
-e 's;/usr/lib/sendmail;%{l_prefix}/sbin/sendmail;' \
-e 's;\(OWNER[^"]*"\)news\("\);\1%{l_rusr}\2;' \
-e 's;\(GROUP[^"]*"\)news\("\);\1%{l_rgrp}\2;' \
config.h-dist config.h
echo '#define OPKG_HOSTNAME_FILE "%{l_prefix}/etc/nn/hostname"' >>config.h
%if "%{force_nntp}" == "yes"
echo "#define FORCE_NNTP" >>config.h
%else
echo "#undef FORCE_NNTP" >>config.h
%endif
%{l_make} %{l_mflags} \
CC="%{l_cc}" all
%install
rm -rf $RPM_BUILD_ROOT
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/bin \
$RPM_BUILD_ROOT%{l_prefix}/etc/nn \
$RPM_BUILD_ROOT%{l_prefix}/libexec/nn \
$RPM_BUILD_ROOT%{l_prefix}/man/man1 \
$RPM_BUILD_ROOT%{l_prefix}/man/man8
%{l_shtool} subst \
-e 's;%{l_prefix}/sbin/sendmail -t;/bin/sh;' \
-e "s;=\"%{l_prefix};=\"$RPM_BUILD_ROOT%{l_prefix};g" \
-e "s;=%{l_prefix};=$RPM_BUILD_ROOT%{l_prefix};g" \
-e "s;) *&;);" \
inst
echo "n" | sh ./inst
strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
%files -f files
%clean
rm -rf $RPM_BUILD_ROOT
? .glimpse_filenames
? .glimpse_filenames_index
? .glimpse_filetimes
? .glimpse_index
? .glimpse_messages
? .glimpse_partitions
? .glimpse_statistics
? .glimpse_turbo
Index: Makefile
===================================================================
RCS file: /cvs/opkg/vendor_stuff/nn/Makefile,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 Makefile
--- Makefile 8 Feb 2002 04:14:41 -0000 1.1.1.1
+++ Makefile 27 Oct 2003 02:38:22 -0000
@@ -24,7 +24,7 @@
#CPP = /lib/cpp
#CPP = /usr/bin/cpp -no-cpp-precomp # for MacOS X
-CFLAGS = -O # -g -Wall -ansi -pedantic
+CFLAGS = -O -g # -g -Wall -ansi -pedantic
#CFLAGS = -O # -w0 -g3 # for DEC
MAKE = make
Index: global.h
===================================================================
RCS file: /cvs/opkg/vendor_stuff/nn/global.h,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 global.h
--- global.h 4 Feb 2002 03:53:13 -0000 1.1.1.1
+++ global.h 27 Oct 2003 02:38:22 -0000
@@ -482,6 +482,7 @@
/* hostname.c */
+extern char *nn_hostname;
void nn_gethostname __APROTO((char *name, int length));
/* init.c */
Index: hostname.c
===================================================================
RCS file: /cvs/opkg/vendor_stuff/nn/hostname.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 hostname.c
--- hostname.c 29 Apr 1995 05:34:44 -0000 1.1.1.1
+++ hostname.c 27 Oct 2003 02:38:22 -0000
@@ -21,8 +21,8 @@
/*
* Easy -- we already got it
*/
-void
-nn_gethostname(name, length)
+static void
+my_nn_gethostname(name, length)
char *name;
int length;
{
@@ -39,8 +39,8 @@
#include <sys/utsname.h>
-void
-nn_gethostname(name, length)
+static void
+my_nn_gethostname(name, length)
char *name;
int length;
{
@@ -61,8 +61,8 @@
* This is not intended to fail (or exit would have been via nn_exit)
*/
-void
-nn_gethostname(name, length)
+static void
+my_nn_gethostname(name, length)
char *name;
int length;
{
@@ -90,8 +90,8 @@
* Hostname is found in whoami.h
*/
-void
-nn_gethostname(name, length)
+static void
+my_nn_gethostname(name, length)
char *name;
int length;
{
@@ -124,8 +124,8 @@
#ifndef DONE
#ifdef HOSTNAME
-void
-nn_gethostname(name, length)
+static void
+my_nn_gethostname(name, length)
char *name;
int length;
{
@@ -138,3 +138,33 @@
#ifndef DONE
YOU LOSE ON GETHOSTNAME -- DEFINE HOSTNAME IN CONFIG.H
#endif
+
+
+void
+nn_gethostname(name, length)
+char *name;
+int length;
+{
+ FILE *f;
+ char *p;
+
+ if (access(OPKG_HOSTNAME_FILE, F_OK) == 0) {
+ *name = NUL;
+ f = fopen(OPKG_HOSTNAME_FILE, "r");
+ if (f != NULL) {
+ if (fgets(name, length, f) != NULL) {
+ if ((p = strchr(name, NL)) != NULL) *p = NUL;
+ } else {
+ *name = NUL;
+ }
+ fclose(f);
+ }
+ if (*name == NUL) {
+ fprintf(stderr, "could not get hostname from '%s'\n",
+ OPKG_HOSTNAME_FILE);
+ exit(77);
+ }
+ } else {
+ my_nn_gethostname(name, length);
+ }
+}
Index: nntp.c
===================================================================
RCS file: /cvs/opkg/vendor_stuff/nn/nntp.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 nntp.c
--- nntp.c 25 Jan 2003 06:10:39 -0000 1.1.1.1
+++ nntp.c 27 Oct 2003 02:38:22 -0000
@@ -832,7 +832,12 @@
server_real_name = hp->h_name;
else
nn_exitmsg(1, "NNTPSERVER is invalid");
+ #ifndef FORCE_NNTP
use_nntp = (strcmp(host_name, server_real_name) != 0);
+ #else
+ /* use NNTP even when the server is the local host */
+ use_nntp = 1;
+ #endif
if (use_nntp) {
freeobj(news_active);