Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Re: Implementation of simple newuser module (how to start?)



Here's a basic newuser script to be installed and the outline of the
function that will be doing the work.  The function zsh-install-newuser
is the file to edit to do the work; everything else should work as it is.

We don't want to distribute the shell with this default version of
zsh-install-newuser, which will simply make it harder to fix things
later on; it would be better to have it do nothing.  However, I assume
it will be doing something by then.

I've created a separate Scripts directory for files which will be run
directly by the shell (actually sourced in this case) and adapted the
function installation system to install them.

Index: Makefile.in
===================================================================
RCS file: /cvsroot/zsh/zsh/Makefile.in,v
retrieving revision 1.13
diff -u -r1.13 Makefile.in
--- Makefile.in	3 Mar 2004 19:37:53 -0000	1.13
+++ Makefile.in	20 Jul 2005 17:59:57 -0000
@@ -84,6 +84,7 @@
 	  test x$(sitefndir) != xno && \
 	    $(SHELL) $(sdir_top)/mkinstalldirs $(DESTDIR)$(sitefndir); \
 	  sdir_top="$(sdir_top)" fndir="$(fndir)" dir_top="$(dir_top)" \
+	  scriptdir="$(scriptdir)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
 	  INSTALL_DATA="$(INSTALL_DATA)" \
 	  DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
@@ -94,6 +95,7 @@
 uninstall.fns:
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
 	  fndir="$(fndir)" dir_top="$(dir_top)" \
+	  scriptdir="$(scriptdir)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
 	  DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
 	  $(SHELL) $(sdir_top)/Config/uninstallfns.sh || exit 1; \
Index: Config/installfns.sh
===================================================================
RCS file: /cvsroot/zsh/zsh/Config/installfns.sh,v
retrieving revision 1.10
diff -u -r1.10 installfns.sh
--- Config/installfns.sh	13 Feb 2003 16:34:36 -0000	1.10
+++ Config/installfns.sh	20 Jul 2005 17:59:57 -0000
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 fndir=$DESTDIR$fndir
+scriptdir=$DESTDIR$scriptdir
 
 /bin/sh $sdir_top/mkinstalldirs $fndir || exit 1;
 
@@ -25,13 +26,23 @@
       Completion/*)
         instdir="$fndir/Completion"
         ;;
+      Scripts/*)
+        instdir="$scriptdir"
+	;;
       *)
         subdir="`echo $file | sed -e 's%/[^/]*$%%' -e 's%^Functions/%%'`"
         instdir="$fndir/$subdir"
         ;;
       esac
     else
-      instdir="$fndir"
+      case "$file" in
+      Scripts/*)
+        instdir="$scriptdir"
+	;;
+      *)
+        instdir="$fndir"
+        ;;
+      esac
     fi
     test -d $instdir || /bin/sh $sdir_top/mkinstalldirs $instdir || exit 1
     $INSTALL_DATA $sdir_top/$file $instdir || exit 1
Index: Config/uninstallfns.sh
===================================================================
RCS file: /cvsroot/zsh/zsh/Config/uninstallfns.sh,v
retrieving revision 1.3
diff -u -r1.3 uninstallfns.sh
--- Config/uninstallfns.sh	4 Dec 2000 19:21:07 -0000	1.3
+++ Config/uninstallfns.sh	20 Jul 2005 17:59:57 -0000
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 fndir=$DESTDIR$fndir
+scriptdir=$DESTDIR$scriptdir
 
 allfuncs="`grep ' functions=' ${dir_top}/config.modules |
   sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`"
@@ -10,10 +11,6 @@
 case $fndir in
   *$VERSION*)
      # Version specific function directory, safe to remove completely.
-     # However, we don't remove the top-level version directory since
-     # it could have other things than functions in it.  We could
-     # do that instead in the top-level Makefile on a full uninstall,
-     # if we wanted.
      rm -rf $fndir
      ;;
   *) # The following will only apply with a custom install directory
@@ -22,15 +19,39 @@
      # We now have a list of files, but we need to use `test -f' to check
      # (1) the glob got expanded (2) we are not looking at directories.
      for file in $allfuncs; do
-       if test -f $sdir_top/$file; then
-	 if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
-	   file=`echo $file | sed -e 's%%^Functions/%'`
-	   rm -f $fndir/$file;
-	 else
-	   bfile="`echo $file | sed -e 's%^.*/%%'`"
-	   rm -f "$fndir/$bfile"; \
-	 fi
-       fi
+       case $file in
+       Scripts/*)
+	 ;;
+       *)
+         if test -f $sdir_top/$file; then
+	   if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
+	     file=`echo $file | sed -e 's%%^(Functions|Completion)/%'`
+	     rm -f $fndir/$file
+	   else
+	     bfile="`echo $file | sed -e 's%^.*/%%'`"
+	     rm -f "$fndir/$bfile"
+	   fi
+         fi
+	 ;;
+       esac
+     done
+     ;;
+esac
+
+case $scriptdir in
+  *$VERSION*)
+     # $scriptdir might be the parent of fndir.
+     rm -rf $scriptdir
+     ;;
+  *) for file in $allfuncs; do
+	case $file in
+	Scripts/*)
+	  if test -f $sdir_top/$file; then
+	    bfile="`echo $file | sed -e 's%^.*/%%'`"
+	    rm -f "$scriptdir/$bfile"
+	  fi
+	  ;;
+	esac
      done
      ;;
 esac
Index: Functions/Newuser/zsh-install-newuser
===================================================================
RCS file: Functions/Newuser/zsh-install-newuser
diff -N Functions/Newuser/zsh-install-newuser
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Functions/Newuser/zsh-install-newuser	20 Jul 2005 17:59:57 -0000
@@ -0,0 +1,11 @@
+# Function to install startup files for a new user.
+# This dummy version simply creates a new .zshrc with a comment.
+# FIXME: we don't want to distribute a file that does that, it
+# would be preferable to do nothing at all.
+
+# Sanitize environment.
+emulate -L zsh
+
+echo "# Created by newuser for $ZSH_VERSION" >${ZDOTDIR:-$HOME}/.zshrc
+
+unfunction zsh-install-newuser
Index: Scripts/newuser
===================================================================
RCS file: Scripts/newuser
diff -N Scripts/newuser
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Scripts/newuser	20 Jul 2005 17:59:57 -0000
@@ -0,0 +1,6 @@
+# zsh script sourced at startup when a user is found to have
+# no startup files.  See the documentation for the zsh/newuser
+# module in zshmodules(1).
+
+autoload -U zsh-install-newuser
+zsh-install-newuser
Index: Src/Modules/newuser.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/newuser.mdd,v
retrieving revision 1.1
diff -u -r1.1 newuser.mdd
--- Src/Modules/newuser.mdd	20 Jul 2005 16:08:23 -0000	1.1
+++ Src/Modules/newuser.mdd	20 Jul 2005 17:59:57 -0000
@@ -1,8 +1,9 @@
 name=zsh/newuser
 link=dynamic
-# We will always try to load newuser, but there is
-# no error if it fails.
+# We will always try to load newuser, but there should
+# be no error if it fails, so don't use the standard mechanism.
 load=no
+functions='Scripts/newuser Functions/Newuser/*'
 
 objects="newuser.o"
 
-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author