Newer
Older
tmkproject / tmkproject.sh
@tundra tundra on 1 Jun 2012 4 KB Initialize revision number
#!/bin/sh
# mkproject.sh - Create A New Project Skeleton
#
# Copyright (c) 2012, TundraWare Inc., Des Plaines, IL 60018 USA
# All Rights Reserved. For Terms Of Use, See: mkproject-license.txt
# $Id: tmkproject.sh,v 1.100 2012/06/01 20:56:46 tundra Exp $

CVSID='$Id: tmkproject.sh,v 1.100 2012/06/01 20:56:46 tundra Exp $'

# Make sure we have a valid command line

if [ $# -ne 4 ]
    then
	echo "usage: mkproject.sh name type cost 'Brief Description'"
	exit 1
fi

# Get the command line args into normal form

PROJECTNAME=$1
TYPE=$2
COST=$3
DESCRIPTION=$4

# Find out where we're installed

FULL=`readlink -f $0`
BASE=`dirname ${FULL}`

# Where do temporary files go?

TMDIR=/tmp

# Readin site-specific information

. ${BASE}/.mkprojectrc

# Make sure requested language is supported and
# setup language-specific literals

# Note that the interpreter strings must
# escape all '/' characters because they
# will be used by 'sed' in substituion commands

case ${TYPE}
in

  "pl")
    INTERPRETER="\/usr\/bin\/env perl"
    LANGUAGE="perl"
  ;;

  "py")
    INTERPRETER="\/usr\/bin\/env python"
    LANGUAGE="python"
  ;;

  "sh")
    INTERPRETER="\/bin\/sh"
    LANGUAGE="the shell interpreter"
  ;;

  *)
    echo "'${TYPE}' Programs Not Supported (Yet)"
    exit 1
  ;;

esac

# Additional replacement strings

COPYDATE=`date +%Y`
COPYRIGHT="Copyright (c) ${COPYDATE} ${COPYOWNER}"
LICENSE="${PROJECTNAME}-license.txt"
RESERVED="All Rights Reserved. For Terms Of Use See: ${LICENSE}"
UPDATES="For Program Updates See: ${WEBSITE}"

# Make relevant directories and go to the working directory

RELEASES="Releases"
WRKDIR=${TMPDIR}/${PROJECTNAME}
mkdir -p  ${WRKDIR}/${RELEASES}
cd ${WRKDIR}

# Copy project files, preserving permissions
# Substitute template tokens with actual values

for F in `find -H ${BASE}/common ${BASE}/${TYPE} -maxdepth 1 -type f `
do
  echo "Processing: ${F}"
  cp -p $F .
  sed                                               \
      -e s/__AUTHOR__/"${AUTHOR}"/g                 \
      -e s/__COPYRIGHT__/"${COPYRIGHT}"/g           \
      -e s/__COST__/"${COST}"/g                     \
      -e s/__DESCRIPTION__/"${DESCRIPTION}"/g       \
      -e s/__EDITOR__/"${EDITOR}"/g                 \
      -e s/__EDITARGS__/"${EDITARGS}"/g             \
      -e s/__EMAILSUPPORT__/"${EMAILSUPPORT}"/g     \
      -e s/__ID__/\$Id\$/                           \
      -e s/__INTERPRETER__/"${INTERPRETER}"/g       \
      -e s/__LANGUAGE__/"${LANGUAGE}"/g             \
      -e s/__LICENSE__/"${LICENSE}"/g               \
      -e s/__PROJECTNAME__/"${PROJECTNAME}"/g       \
      -e s/__RESERVED__/"${RESERVED}"/g             \
      -e s/__TYPE__/"${TYPE}"/g                     \
      -e s/__UPDATES__/"${UPDATES}"/g               \
      -e s/__VENDORNAME__/"${VENDORNAME}"/g         \
      -e s/__WEBSITE__/"${WEBSITE}"/g               \
      <$F >`basename $F`
done


# Combine the generic program template and the
# language-specific program template

cat program_header program.${TYPE} >tmpfile
cat tmpfile >program.${TYPE}
rm tmpfile program_header

# Set the project file names correctly

tren.py -r program=${PROJECTNAME} -r license=${PROJECTNAME}-license -r manpage=${PROJECTNAME} *

# Get everything under CVS control

cvs import -m "${DESCRIPTION}" ${PROJECTNAME} ${VENDORTAG} start 
cd ..
rm -rf ${PROJECTNAME}

# Instantiate the project in the projects directory

cd ${PROJECTSDIR}
cvs co ${PROJECTNAME}
cd ${PROJECTNAME}
cvs commit -r1.100 -m 'Initial CVS checkin to initialize version number'

# Get rid of sticky tags

for f in `find ./ -type f | grep -v CVS`
do
  cvs update -A $f
done

# Reminders

echo
echo
echo
echo
echo
echo "------------------------------------------------------------------------"
echo "Don't Forget To Manually Add Any Additional Files And Update makefile!!!"
echo "------------------------------------------------------------------------"
echo
echo
echo "--------------------------------------------------------------------"
echo "Don't Forget To Setup The Mail Alias: ${EMAILSUPPORT}!!!"
echo "--------------------------------------------------------------------"