head	1.6;
access;
symbols
	VER_0_3:1.6
	VER_0_2:1.5;
locks; strict;
comment	@# @;


1.6
date	95.03.24.11.43.35;	author coulter;	state Exp;
branches;
next	1.5;

1.5
date	95.03.10.02.42.22;	author coulter;	state Exp;
branches;
next	1.4;

1.4
date	95.02.19.17.13.08;	author coulter;	state Exp;
branches;
next	1.3;

1.3
date	95.02.19.16.06.41;	author coulter;	state Exp;
branches;
next	1.2;

1.2
date	95.02.18.08.36.38;	author coulter;	state Exp;
branches;
next	1.1;

1.1
date	95.02.12.18.21.15;	author coulter;	state Exp;
branches;
next	;


desc
@Install the files in the list produced by process_list.
@


1.6
log
@Checkin version for 0.3 distribution.
@
text
@#! /bin/ksh
USAGE='USAGE: install_list [ -d config_prefix ] list_file mount_path map_to_path
	Each line of list_file has an inode number followed by two tabs and
	a file path.  Each file path starts with the string passed in 
	the mount_path argument.  The file or directory is installed
	at the path formed by replacing mount_path with map_to_path.

	If a file or directory is listed and its parent directory needs
	to be installed, the parent directory must be in list_file also.
'
# (C) Copyright 1995 by Michael Coulter.  All rights reserved.

# define functions

# Process parameters

   ##echo "install_list: command: $0 $*"
   CONFIG_PREFIX=""
   if [ $# -ge 2 -a "$1" = "-d" ]
   then
      shift  # done with -d
      CONFIG_PREFIX="$1"; shift
   fi
   if [ $# -ne 3 ]
   then
      echo "$USAGE" >&2
      echo "$0 Expected 3 arguments, got $#" >&2
      exit 1
   fi
   LIST_FILE="$1"; shift
   if [ ! -r "$LIST_FILE" ] 
   then
      echo "$USAGE" >&2
      echo "Unable to read list_file, $LIST_FILE" >&2
      exit 1
   fi
   MOUNT_PATH="$1"; shift
   if [ ! -d "$MOUNT_PATH" ] 
   then
      echo "$USAGE" >&2
      echo "No directory at MOUNT_PATH, $MOUNT_PATH" >&2
      exit 1
   fi
   MAP_TO_PATH="$1"; shift
   if [ ! -d "$MAP_TO_PATH" ] 
   then
      echo "$USAGE" >&2
      echo "No directory at MAP_TO_PATH, $MAP_TO_PATH" >&2
      exit 1
   fi

# Do it


   ##echo "install_list: MOUNT_PATH is $MOUNT_PATH MAP_TO_PATH $MAP_TO_PATH"
   cut -f3 "$LIST_FILE" | sort | while read FILE_PATH
   do
      echo "$FILE_PATH"
      if [ "$FILE_PATH" = "${FILE_PATH#$MOUNT_PATH}" ]
      then
         if [ "$FILE_PATH" != '.' ]
         then
	    echo "$FILE_PATH is not below $MOUNT_PATH" >&2
         fi
         continue
      fi
      if [ "$FILE_PATH" = "$MOUNT_PATH" ]
      then
         continue # can't install at this level
      fi
      if [ -d "$FILE_PATH" ]
      then
	 FILE_DIR="$FILE_PATH"
      else
	 FILE_DIR="$(dirname "$FILE_PATH")"
      fi
      if [ "$MAP_TO_PATH" = "/" ]
      then
	 DEST_FILE="${FILE_PATH#$MOUNT_PATH}"
      else
	 DEST_FILE="${MAP_TO_PATH}/${FILE_PATH#$MOUNT_PATH}"
      fi

      ##echo "install_list: DEST_FILE is $DEST_FILE"
      ##echo install_list: install_dir -d "$CONFIG_PREFIX" "$(dirname "$DEST_FILE")" "$MOUNT_PATH" "$MAP_TO_PATH"
      install_dir -d "$CONFIG_PREFIX" "$(dirname "$DEST_FILE")" "$MOUNT_PATH" "$MAP_TO_PATH"
      if [ -f "$FILE_PATH" ]
      then
         if [ -L "$DEST_FILE" ]
         then
	    rm "$DEST_FILE"
         fi
         if [ -f "$DEST_FILE" ]
         then
            echo "$DEST_FILE is already a file"
         else
	    cp "${FILE_PATH}" "$DEST_FILE"

	    # Kludge, map in a .el when .elc is mapped in.
	    ##echo "install_list: FILE_PATH is '$FILE_PATH'"
	    if [ "$FILE_PATH" != "${FILE_PATH%.elc}" ]
	    then
	       EL_FILE="${FILE_PATH%.elc}.el"
	       ##echo "install_list: EL_FILE is '$EL_FILE'"
	       if [ -f "$EL_FILE" -a -L "${DEST_FILE%.elc}.el" ]
	       then
	          rm "${DEST_FILE%.elc}.el"
	          cp "$EL_FILE" "${DEST_FILE%.elc}.el"
	       fi
	    fi
         fi
      else
         if [ ! -d "$FILE_PATH" ]
         then
	    echo "$FILE_PATH is not a file or directory!" >&2
	    continue
         fi
         if [ -L "$DEST_FILE" ]
         then
	    install_dir -d "$CONFIG_PREFIX" "$DEST_FILE" "$MOUNT_PATH" "$MAP_TO_PATH"
         fi
      fi
   done
@


1.5
log
@Checkin files modified to make version 0.2
@
text
@d11 1
@


1.4
log
@Add kludge for .el files.
@
text
@d2 1
a2 1
USAGE='USAGE: install_list list_file mount_path map_to_path
d16 7
d54 1
d83 3
a85 1
      install_dir "$(dirname "$DEST_FILE")" "$MOUNT_PATH" "$MAP_TO_PATH"
d99 1
d102 7
a108 5
	      EL_FILE="${FILE_PATH%.elc}.el"
	      if [ -f "$EL_FILE" -a -L "$EL_FILE" ]
	      then
	         install_list "$EL_FILE" "$MOUNT_PATH" "$MAP_TO_PATH"
	      fi
d119 1
a119 1
	    install_dir "$DEST_FILE" "$MOUNT_PATH" "$MAP_TO_PATH"
@


1.3
log
@Checkpoint version 0.1
@
text
@d87 10
@


1.2
log
@Checkpoint version before fixing /usr/bin install
@
text
@d58 4
d74 1
@


1.1
log
@Initial revision
@
text
@d49 1
a49 1
      echo "install_list: $FILE_PATH"
d52 4
a55 1
         echo "$FILE_PATH is not below $MOUNT_PATH" >&2
d82 10
@
