Forum Feature requests

Add parameter-setting ability to install.sh

joelmeador
I feel like I should be able to set all of these with option switches when doing a cli install:
PRODUCT="Prince"
PROGRAM="prince"
VERSION="8.0"
WEBSITE="http://www.princexml.com"
prefix=/usr/local

Alternately, I should be prompted for each of them during install.

My reasoning for this request:
I can only currently change the prefix. I would like to have multiple copies of prince installed side-by-side, and I want them installed in /usr/local/. Right now that means I'm going to be installing to /usr/local/prince/8.0 and /usr/local/prince/7.1/ as my prefixes, which is going to lead to some ugly-ass directory structure.

Bonus points for detecting previous versions of prince and automatically making new bin files (e.g. prince70, prince71, prince80, etc).
joelmeador
This is what I came up with for an install script for the OSX version that will replace previous prince binaries but install libs/src in its own directory so more versions can be installed without losing 8.0:
#! /bin/sh

PRODUCT="Prince"
PROGRAM="prince"
VERSION="8.0"
PROGRAM_ALIAS="prince80"
WEBSITE="http://www.princexml.com"

prefix=/usr/local

base=`dirname $0`

cd "$base"

echo "$PRODUCT $VERSION"
echo
echo "Install directory"
echo "    This is the directory in which $PRODUCT $VERSION will be installed."
echo "    Press Enter to accept the default directory or enter an alternative."
echo "    [$prefix]: "

read input
if [ ! -z "$input" ] ; then
    prefix="$input"
fi

echo
echo "Installing $PRODUCT $VERSION..."

# Create shell script

cat > $PROGRAM <<EOF
#! /bin/sh

exec $prefix/lib/$PROGRAM-$VERSION/bin/$PROGRAM --prefix="$prefix/lib/$PROGRAM-$VERSION" "\$@"
EOF
cp $PROGRAM $PROGRAM_ALIAS

# Test that we can create directories

install -d "$prefix/bin" 2>/dev/null ||
{
echo "    Unable to create directories in $prefix"
echo "    (You may need to be logged in as root to install programs in system"
echo "    directories. Ask your system administrator, or try installing inside"
echo "    your home directory, such as $HOME/$PROGRAM-$VERSION)."
echo
exit 1
}

# Install shell script
install $PROGRAM "$prefix/bin"
install $PROGRAM_ALIAS "$prefix/bin"

# Install everything else

echo "Creating directories..."

ln -sfF `pwd`/lib/$PROGRAM `pwd`/lib/$PROGRAM-$VERSION

for dir in `find lib/$PROGRAM-$VERSION/ -type d` ; do

    install -d "$prefix/$dir"

done

echo "Installing files..."

for file in `find lib/$PROGRAM-$VERSION/ -type f` ; do

    dir=`dirname $file`

    if [ -x "$file" ] ; then
	      install "$file" "$prefix/$dir"
    else
	      if [ "$file" = "lib/$PROGRAM-$VERSION/license/license.dat" ] ; then
	          if [ ! -f "$prefix/$file" ] ; then
		            install -m 644 "$file" "$prefix/$dir"
	          fi
	      else
	          install -m 644 "$file" "$prefix/$dir"
	      fi
    fi

done

echo
echo "Installation complete."
echo "    Thank you for choosing $PRODUCT $VERSION, we hope you find it useful."
echo "    Please visit $WEBSITE for updates and development news."
echo