system/csh: Updated for version 20230828_1.

Signed-off-by: B. Watson <urchlay@slackware.uk>

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
B. Watson 2023-09-19 07:10:50 -04:00 committed by Willy Sudiarto Raharjo
parent 70512eadfd
commit 1699b53da6
No known key found for this signature in database
GPG Key ID: 3F617144D7238786
8 changed files with 215 additions and 110 deletions

View File

@ -35,7 +35,7 @@ bad idea. Remove csh first, install tcsh, then install csh.
As far as I know, nothing in Slackware depends on tcsh, so if you
mess things up, you won't break your OS. You can always put things
back to Slackware's default state by removing both csh and tsch, then
back to Slackware's default state by removing both csh and tcsh, then
reinstalling tcsh.
@ -47,7 +47,7 @@ shipped /etc/csh.login (from the etc package) contains tcsh-specific
code, which prevents the /etc/profile.d/*.csh scripts from running. This
won't prevent you from logging in, but your environment won't be set up
correctly, you'll see "[: No match." errors, and your prompt won't show
your username, hostname, current directory as tsch does.
your username, hostname, current directory as tcsh does.
To fix this, you can replace /etc/csh.login with the /etc/csh.login.new
installed with the csh package. It behaves the same as the original,
@ -59,6 +59,13 @@ for tcsh, and has conditional code to make csh behave correctly.
If you don't want to replace Slackware's csh.login, just rm
/etc/csh.login.new and forget about it.
Unfortunately, some of the /etc/profile.d/*.csh scripts shipped
with Slackware (or various SBo packages) aren't compatible with the
original csh. Specifically, qt5.csh will cause an "Illegal variable
name" error. You can ignore this, or you can fix it by editing
/etc/profile.d/qt5.csh and changing "$?" to "$status" (on line 27, in
Slackware 15.0).
Other notes
-----------
@ -70,10 +77,6 @@ re-read the NEW FEATURES section in tcsh's man page (it describes the
tcsh features you won't find in csh).
NEVER make csh the default shell for the root account! In fact, it's
probably a bad idea to ever change root's default shell on any Linux or
UNIX system, especially a third-party one that isn't shipped with the OS.
The man page for csh states that "Words can be no longer than 1024
characters", but this build of csh increases the limit to 8192 (actually,
BUFSIZ as defined in stdio.h). This was done so Slackware's profile.d
scripts will work correctly (particularly coreutils-dircolor.sh).
probably a bad idea to ever change root's default shell on any Linux
or UNIX system, especially to a third-party one that isn't shipped
with the OS.

View File

@ -1,30 +0,0 @@
diff -Naur csh-20110502.orig/csh.h csh-20110502.patched/csh.h
--- csh-20110502.orig/csh.h 2014-04-25 17:31:52.000000000 -0400
+++ csh-20110502.patched/csh.h 2014-04-25 17:34:08.000000000 -0400
@@ -36,12 +36,10 @@
* Fundamental definitions which may vary from system to system.
*
* BUFSIZ The i/o buffering size; also limits word size
+ * 20140425 bkw: moved below the #include <stdio.h> since
+ * we want to use the system's default BUFSIZ.
* MAILINTVL How often to mailcheck; more often is more expensive
*/
-#ifndef BUFSIZ
-#define BUFSIZ 1024 /* default buffer size */
-#endif /* BUFSIZ */
-
#ifndef MAXPATHLEN
#define MAXPATHLEN BUFSIZ
#endif
@@ -96,6 +94,11 @@
#include <stdio.h>
FILE *cshin, *cshout, *csherr;
+/* 20140425 bkw: moved here so stdio.h is what initially defines BUFSIZ. */
+#ifndef BUFSIZ
+#define BUFSIZ 1024 /* default buffer size */
+#endif /* BUFSIZ */
+
#include <stdio_ext.h>
#define fpurge __fpurge

View File

@ -6,6 +6,15 @@
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# 20230919 bkw:
# - update for v20230828_1 (sync with Debian sid).
# - remove old no-longer-needed bufsiz.diff and glibc-2.32-sys_siglist.diff.
# - add timespec.diff to work around breakage in csh's time builtin.
# - add remove_publib_dep.diff to avoid an external publib dependency.
# - update csh.login a bit (new csh has a different default $prompt).
# - mention bad profile scripts in README_Slackware.txt.
# - fix the man page slightly.
# 20220409 bkw: BUILD=2
# - fix doinst.sh: only create bin/csh symlink if bin exists, which
# fixes installing the package with 'installpkg -root /some/path'.
@ -22,8 +31,8 @@
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=csh
VERSION=${VERSION:-20110502_6}
BUILD=${BUILD:-2}
VERSION=${VERSION:-20230828_1}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
@ -65,38 +74,54 @@ DEBVER="${VERSION#*_}" # 123_4 => 4
# Grr.
TARNAM="${PRGNAM}_${MAINVER}.orig"
DIRNAM="${PRGNAM}-${MAINVER}.orig"
DIRNAM="${PRGNAM}-${MAINVER}"
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $DIRNAM
tar xvf $CWD/$TARNAM.tar.gz
tar xvf $CWD/$TARNAM.tar.xz
cd $DIRNAM
tar xvf $CWD/${PRGNAM}_${MAINVER}-$DEBVER.debian.tar.[xg]z
tar xvf $CWD/${PRGNAM}_${MAINVER}-$DEBVER.debian.tar.xz
chown -R root:root .
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} + -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} +
# Apply all of Debian's patches. Except one...
for diff in debian/patches/*.diff; do
[ "$( basename $diff )" != "09_sys_signame.diff" ] && patch -p1 < $diff
# Apply all of Debian's patches.
for diff in $( cat debian/patches/series ); do
patch -p1 < debian/patches/$diff
done
# My own patch, keeps csh.h from defining its own (tiny) BUFSIZ. Might
# make I/O more efficient, and allows /etc/profile.d/coreutils-dircolors.sh
# to set a giant $LS_OPTIONS value without "Word too long" error.
patch -p1 < $CWD/bufsiz.diff
# 20230919 bkw: My own patch. Provides an implementations of
# xrealloc(), and replaces xfree() with free(), so we don't have
# publib as a dependency.
patch -p1 < $CWD/remove_publib_dep.diff
# 20210827 bkw: my own patch, glibc >= 2.32 no longer exports
# sys_siglist so we have to use sigdescr_np() instead. Ditto
# sys_signame and sigabbrev_np(). See glibc changelog:
# https://sourceware.org/pipermail/libc-announce/2020/000029.html
# This patch replaces Debian's 09_sys_signame.diff.
patch -p1 < $CWD/glibc-2.32-sys_siglist.diff
# 20230919 bkw: My own patch. Fixes the mess caused by debian's
# bsd_time.patch. We need the patch, but it introduces a bug where a
# 'struct timeval' pointer is treated as a 'struct timespec' pointer,
# leading to a broken time builtin.
# This isn't *just* here to fix a compiler warning! Without this
# patch, we get:
# % time sleep 2.3
# 0.0u 0.0s 0:02.99 0.0% 0+0k 0+0io 0pf+0w
# ...it thinks a 2.3 second sleep took 2.99 sec. Sometimes this
# will print as 0:02:00 instead (also wrong). With the patch:
# % time sleep 2.3
# 0.0u 0.0s 0:02.30 0.0% 0+0k 0+0io 0pf+0w
# This wasn't an issue in the previous (20110502_6) version.
patch -p1 < $CWD/timespec.diff
# use Slackware standard flags
sed -i "1iCFLAGS=$SLKCFLAGS -fcommon" Makefile
# 20230919 bkw: Missing prototype for closefrom(). We don't want
# to #include <bsd/unistd.h> to get it, so just prepend it. This
# probably didn't cause a problem anyway.
sed -i '1ivoid closefrom(int lowfd);' misc.c
# use Slackware standard flags.
# 20230919 bkw: _VIS thing just silences a meaningless warning. it's
# meaningless because it only applies to strnvis() and strnunvis(),
# neither of which is called by csh.
sed -i "1iCFLAGS=$SLKCFLAGS -fcommon -DLIBBSD_OPENBSD_VIS" Makefile
# The LIBC= isn't even used, but Slackware64's pmake is broken: it has
# /usr/lib/libc.a hard-coded, and pmake wants to build that (and can't),
@ -108,6 +133,11 @@ cd USD.doc
pmake paper.ps paper.txt
cd -
# 20230919 bkw: word length is BUFSIZ (by default in 20230828_1, no
# patching required). This is 8192 bytes on x86 and x86_64, so fix
# the man page.
sed -i '/Words can be no/s,1024,8192,' csh.1
# I think this is the first time I've ever seen 'make install' gzip the
# man pages and strip the binary! BSD FTW!
mkdir -p $PKG/usr/bin $PKG/usr/man/man1
@ -119,11 +149,11 @@ pmake install DESTDIR=$PKG BINDIR=/usr/bin MANDIR=/usr/man
mkdir -p $PKG/etc
cat $CWD/csh.login > $PKG/etc/csh.login.new
DOCDIR=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $DOCDIR
cp -a USD.doc/paper.* $DOCDIR
cat $CWD/$PRGNAM.SlackBuild > $DOCDIR/$PRGNAM.SlackBuild
cat $CWD/README_Slackware.txt > $DOCDIR/README_Slackware.txt
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a USD.doc/paper.* $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
cat $CWD/README_Slackware.txt > $PKGDOC/README_Slackware.txt
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

View File

@ -1,10 +1,10 @@
PRGNAM="csh"
VERSION="20110502_6"
VERSION="20230828_1"
HOMEPAGE="https://packages.debian.org/sid/csh"
DOWNLOAD="https://deb.debian.org/debian/pool/main/c/csh/csh_20110502.orig.tar.gz \
https://deb.debian.org/debian/pool/main/c/csh/csh_20110502-6.debian.tar.xz"
MD5SUM="578c40bfa54c09c8affbc434e34fb40c \
22bdcfe61cbbc4f8b8fd69176beadfe7"
DOWNLOAD="http://deb.debian.org/debian/pool/main/c/csh/csh_20230828.orig.tar.xz \
http://deb.debian.org/debian/pool/main/c/csh/csh_20230828-1.debian.tar.xz"
MD5SUM="9917fda92d8ea01c7858f59ece134a72 \
f176353bf84fd41a332f3652cc5edbcb"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES="%README% libbsd"

View File

@ -41,7 +41,11 @@ if ("$TERM" == "unknown") setenv TERM linux
if $?tcsh then
set prompt = "%n@%m:%~%# "
else
set _promptchar = $prompt
if ( `whoami` == "root" ) then
set _promptchar = "#"
else
set _promptchar = "%"
endif
# cache the hostname, assume it will never change (usually true)
set _hostname = `hostname`
alias _setprompt 'set prompt="$user@${_hostname}:$cwd$_promptchar "'

View File

@ -1,38 +0,0 @@
diff -Naur csh-20110502.orig/proc.c csh-20110502.orig.patched/proc.c
--- csh-20110502.orig/proc.c 2009-10-27 19:59:21.000000000 -0400
+++ csh-20110502.orig.patched/proc.c 2021-08-27 02:56:08.386981036 -0400
@@ -726,8 +726,7 @@
&& (reason != SIGPIPE
|| (pp->p_flags & PPOU) == 0))) {
(void) fprintf(cshout, format,
- sys_siglist[(unsigned char)
- pp->p_reason]);
+ sigdescr_np(pp->p_reason));
hadnl = 0;
}
break;
@@ -948,10 +947,10 @@
else if (signum == 0)
(void) fputc('0', cshout); /* 0's symbolic name is '0' */
else
- (void) fprintf(cshout, "%s ", sys_signame[signum]);
+ (void) fprintf(cshout, "%s ", sigabbrev_np(signum));
} else {
for (signum = 1; signum < NSIG; signum++) {
- (void) fprintf(cshout, "%s ", sys_signame[signum]);
+ (void) fprintf(cshout, "%s ", sigabbrev_np(signum));
if (signum == NSIG / 2)
(void) fputc('\n', cshout);
}
@@ -978,9 +977,9 @@
}
for (signum = 1; signum < NSIG; signum++)
- if (!strcasecmp(sys_signame[signum], name) ||
+ if (!strcasecmp(sigabbrev_np(signum), name) ||
(strlen(name) > 3 && !strncasecmp("SIG", name, 3) &&
- !strcasecmp(sys_signame[signum], name + 3)))
+ !strcasecmp(sigabbrev_np(signum), name + 3)))
break;
if (signum == NSIG) {

View File

@ -0,0 +1,54 @@
diff -Naur csh-20230828/Makefile csh-20230828.patched/Makefile
--- csh-20230828/Makefile 2023-09-19 03:56:12.687978921 -0400
+++ csh-20230828.patched/Makefile 2023-09-19 04:21:16.198719211 -0400
@@ -8,7 +8,7 @@
SRCS= alloc.c char.c const.c csh.c dir.c dol.c error.c exec.c exp.c file.c \
func.c glob.c hist.c init.c lex.c misc.c parse.c proc.c \
sem.c set.c str.c time.c
-LDADD+= -lbsd -lpub
+LDADD+= -lbsd
CLEANFILES+=error.h const.h
diff -Naur csh-20230828/alloc.c csh-20230828.patched/alloc.c
--- csh-20230828/alloc.c 2023-08-28 05:51:57.000000000 -0400
+++ csh-20230828.patched/alloc.c 2023-09-19 04:21:16.198719211 -0400
@@ -89,3 +89,15 @@
}
return (n);
}
+
+void *
+xrealloc(void *p, size_t n)
+{
+ void *ptr;
+
+ if ((ptr = realloc(p, n)) == NULL) {
+ child++;
+ stderror(ERR_NOMEM);
+ }
+ return (ptr);
+}
diff -Naur csh-20230828/extern.h csh-20230828.patched/extern.h
--- csh-20230828/extern.h 2023-08-28 05:51:57.000000000 -0400
+++ csh-20230828.patched/extern.h 2023-09-19 04:24:42.595566353 -0400
@@ -284,6 +284,7 @@
void *xreallocarray(void *, size_t, size_t);
void *xcalloc(size_t, size_t);
char *xstrdup(const char *);
+void *xrealloc(void *p, size_t n);
/*
* str.c:
diff -Naur csh-20230828/glob.c csh-20230828.patched/glob.c
--- csh-20230828/glob.c 2023-09-19 03:56:12.707979197 -0400
+++ csh-20230828.patched/glob.c 2023-09-19 04:22:08.760444266 -0400
@@ -455,7 +455,7 @@
* Output is empty, or none of the magic patterns matched.
* It's up to the caller to generate a "No match" error.
*/
- xfree(nv);
+ if(nv) free(nv);
return (NULL);
}
*nvp = NULL;

82
system/csh/timespec.diff Normal file
View File

@ -0,0 +1,82 @@
diff -Naur csh-20230828/extern.h csh-20230828.patched/extern.h
--- csh-20230828/extern.h 2023-09-19 17:44:07.356219253 -0400
+++ csh-20230828.patched/extern.h 2023-09-19 18:07:32.732605839 -0400
@@ -276,6 +276,7 @@
void settimes(void);
void pcsecs(long);
void psecs(long);
+int timespec_gettimeofday(struct timespec *restrict, struct timezone *restrict);
/*
* alloc.c
diff -Naur csh-20230828/proc.c csh-20230828.patched/proc.c
--- csh-20230828/proc.c 2023-09-19 17:44:07.349219157 -0400
+++ csh-20230828.patched/proc.c 2023-09-19 18:06:05.785406431 -0400
@@ -121,7 +121,7 @@
}
else {
if (pp->p_flags & (PTIME | PPTIME) || adrof(STRtime))
- (void) gettimeofday(&pp->p_etime, NULL);
+ (void) timespec_gettimeofday(&pp->p_etime, NULL);
pp->p_rusage = ru;
@@ -507,7 +507,7 @@
}
pp->p_next = proclist.p_next;
proclist.p_next = pp;
- (void) gettimeofday(&pp->p_btime, NULL);
+ (void) timespec_gettimeofday(&pp->p_btime, NULL);
}
diff -Naur csh-20230828/time.c csh-20230828.patched/time.c
--- csh-20230828/time.c 2023-09-19 17:44:07.350219170 -0400
+++ csh-20230828.patched/time.c 2023-09-19 18:08:07.012078715 -0400
@@ -30,6 +30,7 @@
* SUCH DAMAGE.
*/
+#include <sys/time.h>
#include <sys/types.h>
#include <stdarg.h>
@@ -39,6 +40,20 @@
/*
* C Shell - routines handling process timing and niceing
*/
+
+int
+timespec_gettimeofday(struct timespec *restrict ts, struct timezone *restrict)
+{
+ int rv;
+ struct timeval tv;
+
+ rv = gettimeofday(&tv, NULL);
+ ts->tv_sec = tv.tv_sec;
+ ts->tv_nsec = tv.tv_usec * 1000;
+
+ return rv;
+}
+
static void pdeltat(struct timeval *, struct timeval *);
void
@@ -46,7 +61,7 @@
{
struct rusage ruch;
- (void) gettimeofday(&time0, NULL);
+ (void) timespec_gettimeofday(&time0, NULL);
(void) getrusage(RUSAGE_SELF, &ru0);
(void) getrusage(RUSAGE_CHILDREN, &ruch);
ruadd(&ru0, &ruch);
@@ -65,7 +80,7 @@
(void) getrusage(RUSAGE_SELF, &ru1);
(void) getrusage(RUSAGE_CHILDREN, &ruch);
ruadd(&ru1, &ruch);
- (void) gettimeofday(&timedol, NULL);
+ (void) timespec_gettimeofday(&timedol, NULL);
prusage(&ru0, &ru1, &timedol, &time0);
}