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

PATCH: function installation



This implements Tanaka Akira's suggestion of adding a site-functions
directory, and Andrej's point that we don't need the .old directories for
uninstallation if the functions installed are version-specific anyway.
The site-functions directory goes to the start of the default $fpath and
never gets removed on uninstall.  At the moment, the top-level version
specific data directory (by default /usr/local/share/zsh/$ZSH_VERSION)
doesn't get removed either, since in principle it can have other things
than functions in it.  If anyone feels strongly they can add this for a
full uninstall (only) to the top-level Makefile (only).  (I suppose this
corresponds to Pictures' uninstall's rather vague `some components didn't
get removed' message...)

I haven't checked this with all possible combinations of install options.
I presume that will happen in the general run of things anyway.

Index: INSTALL
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/INSTALL,v
retrieving revision 1.4
diff -u -r1.4 INSTALL
--- INSTALL	2000/01/07 22:46:43	1.4
+++ INSTALL	2000/01/14 18:49:17
@@ -283,16 +283,13 @@
 directory, i.e. `Core/*' files will be installed into `FNDIR/Core', and so
 on. This also initialises $fpath/$FPATH appropriately.
 
-On installation, any completion function which already exists but is
-different from the new version will be moved to a corresponding place in
-FNDIR.old; for example, if a different version of User/_rcs exists when
-installing into /usr/local/share/zsh/functions/User, the old one will be
-moved into /usr/local/share/zsh/functions.old/User.  The installer is
-responsible for recovering or deleting old functions which have been moved
-in this way.  On uninstallation, any newly installed functions (including
-those which existed before but were unchanged) will be deleted and the
-files in the FNDIR.old hierarchy moved back into FNDIR.  To preserve the
-entire old hierarchy, you should move or copy it before installation.
+The option --enable-site-fndir controls whether to create and initialise
+$fpath to include a directory for site-specific functions.  By default this
+is created in the location ${datadir}/zsh/site-functions, i.e. parallel to
+the version-specific functions directory, and inserted at the start of the
+$fpath array on shell startup.  This directory will not be affected by
+`make uninstall' or `make uninstall.fns', although the version-specific
+directory and its contents will be deleted.
 
 Support for large files and integers
 ------------------------------------
@@ -366,6 +363,7 @@
      zprofile=pathname   # the full pathname of the global zprofile script
      zlogout=pathname    # the full pathname of the global zlogout script
      fndir=directory     # the directory where shell functions will go
+     site-fndir=directory# the directory where site-specific functions can go
      function-subdirs    # if functions will be installed into subdirectories
      dynamic             # allow dynamically loaded binary modules
      lfs                 # allow configure check for large files
Index: Makefile.in
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Makefile.in,v
retrieving revision 1.10
diff -u -r1.10 Makefile.in
--- Makefile.in	1999/12/09 23:15:18	1.10
+++ Makefile.in	2000/01/14 13:22:46
@@ -76,7 +76,13 @@
 	@cd Doc && $(MAKE) $(MAKEDEFS) $@
 
 # install/uninstall just the shell functions
-install.fns uninstall.fns:
+install.fns:
+	test x$(sitefndir) != xno && $(sdir_top)/mkinstalldirs $(sitefndir)
+	@cd Completion && $(MAKE) $(MAKEDEFS) $@
+	@cd Functions && $(MAKE) $(MAKEDEFS) $@
+
+uninstall.fns:
+	# never attempt to remove $(sitefndir)
 	@cd Completion && $(MAKE) $(MAKEDEFS) $@
 	@cd Functions && $(MAKE) $(MAKEDEFS) $@
 
Index: configure.in
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/configure.in,v
retrieving revision 1.14
diff -u -r1.14 configure.in
--- configure.in	2000/01/14 12:33:35	1.14
+++ configure.in	2000/01/14 13:18:50
@@ -212,7 +212,7 @@
 
 undefine([fndir])dnl
 AC_ARG_ENABLE(fndir,
-[  --enable-fndir=DIR         where functions go (default DATADIR/zsh/functions)],
+[  --enable-fndir=DIR         where functions go],
 dnl ${VERSION} to be determined at compile time.
 [if test $enableval = yes; then
   fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions
@@ -220,6 +220,15 @@
   fndir="$enableval"
 fi], [fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions])
 
+undefine([sitefndir])dnl
+AC_ARG_ENABLE(sitefndir,
+[  --enable-site-fndir=DIR    where site functions (not version specific) go],
+[if test $enableval = yes; then
+  sitefndir=${datadir}/${tzsh_name}/site-functions
+else
+  sitefndir="$enableval"
+fi], [sitefndir=${datadir}/${tzsh_name}/site-functions])
+
 undefine([function_subdirs])
 AC_ARG_ENABLE(function-subdirs,
 [  --enable-function-subdirs  install functions in subdirectories])
@@ -240,6 +249,7 @@
 fi
 
 AC_SUBST(fndir)dnl
+AC_SUBST(sitefndir)dnl
 AC_SUBST(FUNCTIONS_INSTALL)dnl
 AC_SUBST(FUNCTIONS_SUBDIRS)dnl
 
Index: Config/defs.mk.in
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Config/defs.mk.in,v
retrieving revision 1.4
diff -u -r1.4 defs.mk.in
--- Config/defs.mk.in	1999/12/09 23:15:18	1.4
+++ Config/defs.mk.in	2000/01/14 13:18:39
@@ -41,6 +41,7 @@
 mandir          = @mandir@
 datadir         = @datadir@
 fndir           = @fndir@
+sitefndir       = @sitefndir@
 htmldir         = $(datadir)/$(tzsh)/htmldoc
 
 # compilation
Index: Config/funcinst.mk
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Config/funcinst.mk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 funcinst.mk
--- Config/funcinst.mk	1999/11/28 17:42:27	1.1.1.1
+++ Config/funcinst.mk	2000/01/14 13:10:43
@@ -33,7 +33,7 @@
 	  FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
 	  INSTALL_DATA="$(INSTALL_DATA)" \
-	  DESTDIR="$(DESTDIR)" \
+	  DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
 	  $(SHELL) $(sdir_top)/Config/installfns.sh || exit 1; \
 	fi; \
 	exit 0
@@ -43,7 +43,7 @@
 	  fndir="$(fndir)" sdir="$(sdir)" \
 	  FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
-	  DESTDIR="$(DESTDIR)" \
+	  DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
 	  $(SHELL) $(sdir_top)/Config/uninstallfns.sh || exit 1; \
 	fi; \
 	exit 0
Index: Config/installfns.sh
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Config/installfns.sh,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 installfns.sh
--- Config/installfns.sh	1999/11/28 17:42:27	1.1.1.1
+++ Config/installfns.sh	2000/01/14 13:08:06
@@ -2,10 +2,6 @@
 
 fndir=$DESTDIR$fndir
 
-if test -d $fndir.old; then
-  add_old=1
-fi
-
 $sdir_top/mkinstalldirs $fndir || exit 1;
 
 # If the source directory is somewhere else, we need to force
@@ -24,27 +20,14 @@
     if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
       subfile="$file"
       subdir="`echo $file | sed -e 's%/[^/]*$%%'`"
-      olddir="$fndir.old/$subdir"
       instdir="$fndir/$subdir"
     else
       subfile="`echo $file | sed -e 's%^.*/%%'`"
-      olddir="$fndir.old"
       instdir="$fndir"
     fi
-    if test -f $fndir/$subfile; then
-      if cmp $fndir/$subfile $sdir/$file >/dev/null; then :; else
-	$sdir_top/mkinstalldirs $olddir
-        mv $fndir/$subfile $olddir
-        : ${add_old:=1}
-      fi
-    fi
     $sdir_top/mkinstalldirs $instdir || exit 1
     $INSTALL_DATA $sdir/$file $instdir || exit 1
   fi
 done
-
-if test x$add_old != x1; then
-  rm -rf $fndir.old
-fi
 
 exit 0
Index: Config/uninstallfns.sh
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Config/uninstallfns.sh,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 uninstallfns.sh
--- Config/uninstallfns.sh	1999/11/28 17:42:27	1.1.1.1
+++ Config/uninstallfns.sh	2000/01/14 19:02:11
@@ -14,20 +14,26 @@
 fndir=$DESTDIR$fndir
 
 for file in $install; do
-  if test -f $sdir/$file; then
-    if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
-      rm -f $fndir/$file;
-      if test -f $fndir.old/$file; then
-	mv $fndir.old/$file $fndir/$file
-      fi
-    else
-      bfile="`echo $file | sed -e 's%^.*/%%'`"
-      rm -f "$fndir/$bfile"; \
-      if test -f $fndir.old/$bfile; then
-        mv $fndir.old/$bfile $fndir/$bfile
-      fi
-    fi
-  fi
+  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
+       ;;
+    *)
+       if test -f $sdir/$file; then
+	 if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
+	   rm -f $fndir/$file;
+	 else
+	   bfile="`echo $file | sed -e 's%^.*/%%'`"
+	   rm -f "$fndir/$bfile"; \
+	 fi
+       fi
+       ;;
+  esac
 done
 
 exit 0
Index: Src/init.c
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Src/init.c,v
retrieving revision 1.4
diff -u -r1.4 init.c
--- Src/init.c	2000/01/14 12:33:35	1.4
+++ Src/init.c	2000/01/14 18:53:10
@@ -547,6 +547,18 @@
 #ifdef HAVE_GETRLIMIT
     int i;
 #endif
+#if defined(SITEFPATH_DIR) || defined(FPATH_DIR)
+    char **fpathptr;
+# if defined(FPATH_DIR) && defined(FPATH_SUBDIRS)
+    char *fpath_subdirs[] = FPATH_SUBDIRS;
+    int j;
+# endif
+# ifdef SITEPATH_DIR
+    int fpathlen = 1;
+# else
+    int fpathlen = 0;
+# endif
+#endif
 
     getkeyptr = NULL;
 
@@ -581,23 +593,33 @@
     cdpath   = mkarray(NULL);
     manpath  = mkarray(NULL);
     fignore  = mkarray(NULL);
-#ifdef FPATH_DIR
-# ifdef FPATH_SUBDIRS
-    {
-	char *fpath_subdirs[] = FPATH_SUBDIRS;
-	int len = sizeof(fpath_subdirs)/sizeof(char *), j;
-
-	fpath = zalloc((len+1)*sizeof(char *));
-	for (j = 0; j < len; j++)
-	    fpath[j] = tricat(FPATH_DIR, "/", fpath_subdirs[j]);
-	fpath[len] = NULL;
-    }
-# else
-    fpath    = mkarray(ztrdup(FPATH_DIR));
+
+#if defined(SITEFPATH_DIR) || defined(FPATH_DIR)
+# ifdef FPATH_DIR
+#  ifdef FPATH_SUBDIRS
+    fpathlen += sizeof(fpath_subdirs)/sizeof(char *);
+#  else
+    fpathlen++;
+#  endif
+# endif
+    fpath = fpathptr = (char **)zalloc((fpathlen+1)*sizeof(char *));
+# ifdef SITEFPATH_DIR
+    *fpathptr++ = ztrdup(SITEFPATH_DIR);
+    fpathlen--;
 # endif
+# ifdef FPATH_DIR
+#  ifdef FPATH_SUBDIRS
+    for (j = 0; j < fpathlen; j++)
+	*fpathptr++ = tricat(FPATH_DIR, "/", fpath_subdirs[j]);
+#  else
+    *fpathptr++ = ztrdup(FPATH_DIR);
+#  endif
+# endif
+    *fpathptr = NULL;
 #else
     fpath    = mkarray(NULL);
 #endif
+
     mailpath = mkarray(NULL);
     watch    = mkarray(NULL);
     psvar    = mkarray(NULL);
Index: Src/zsh.mdd
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Src/zsh.mdd,v
retrieving revision 1.4
diff -u -r1.4 zsh.mdd
--- Src/zsh.mdd	1999/12/22 23:17:29	1.4
+++ Src/zsh.mdd	2000/01/14 18:56:45
@@ -34,6 +34,9 @@
 
 zshpaths.h: Makemod $(CONFIG_INCS)
 	@echo '#define MODULE_DIR "'$(MODDIR)'"' > zshpaths.h.tmp
+	@if test x$(sitefndir) != xno; then \
+	  echo '#define SITEFPATH_DIR "'$(sitefndir)'"' >> zshpaths.h.tmp; \
+	fi
 	@if test x$(fndir) != xno; then \
 	  echo '#define FPATH_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \
 	  if test x$(FUNCTIONS_SUBDIRS) != x -a \

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>



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