[erlang-questions] Relocating Erlang installation on Windows?

Scott Lystig Fritchie fritchie@REDACTED
Thu May 29 19:42:12 CEST 2008


Johan Holmberg <johan556@REDACTED> wrote:

jh> I wonder if there is some way of getting the installation "position
jh> independent"?

Not that I'm aware of.  (I'm just catching up on my mailing list reading
and noticed that no one (?) has replied to your query.)

We use a shell script to relocate builds of R11B-5 on Linux, which is
included below.  It mostly works, but since we don't use "escript" and
some of the other scripts, I don't know if it does 100% the right thing
with all the scripts.  It also doesn't do anything with Windows-only
files.  Hope it helps.

-Scott

--- snip --- snip --- snip --- snip --- snip --- snip --- 

#!/bin/sh

##
## For copying when configured via:
## ./configure --prefix=/some/place/that/is/not/the/final/installation/dir
##

TAR_DEL_ARG=""
if [ "X$1" = "X-d" ]; then
	shift
	TAR_DEL_ARG="--remove-files"
fi

if [ $# -ne 3 ]; then
	echo usage: $0 [-d] src-dir dst-dir path-dir
	echo example: $0 /usr/local/gemini/erlang /new/dir /new/dir
	echo "NOTE: In most cases, dst-dir and path-dir will be the same."
	echo "      However, in some weird NFS cases, the dst-dir (where"
	echo "      this script will copy files) may be different from"
	echo "      path-dir (where final users will use/execute files)."
	echo NOTE: Both directories should be absolute paths.
	exit 1
fi

SRCDIR=$1
DSTDIR=$2
NEW_ROOTDIR=$3/lib/erlang

if [ ! -d $SRCDIR ]; then
	echo "Source directory $SRCDIR does not exist, aborting!"
	exit 1
fi
if [ ! -d $DSTDIR ]; then
	echo "Destination directory $DSTDIR does not exist, creating"
	mkdir $DSTDIR
	if [ $? -ne 0 ]; then
		echo "mkdir $DSTDIR failed, aborting!"
		exit 1
	fi
fi

echo -n "Copying files from $SRCDIR to $DSTDIR ... "
(cd $SRCDIR ; tar cf - $TAR_DEL_ARG .) | (cd $DSTDIR ; tar xfp -)
echo "done."

echo -n "Performing relocation steps ... "

cd $DSTDIR/bin
for f in dialyzer epmd erl erlc escript run_erl start to_erl typer
do
	if [ -h $f ]; then
		rm -f $f
		# Use wildcard to be Erlang-version-flexible (hopefully)
		ln -s ../lib/erlang/erts-*/bin/$f ./$f
	fi
done

cd ../lib/erlang/erts-*/bin
for f in erl start start_erl
do
	perl -np -e "s|%FINAL_ROOTDIR%|$NEW_ROOTDIR|" < $f.src > $f
	if [ -f $DSTDIR/lib/erlang/bin/$f ] ; then
		cp $f $DSTDIR/lib/erlang/bin/$f
	fi
done
echo "done."

cd $DSTDIR/lib/erlang/bin
rm epmd
ln -s ../erts-*/bin/epmd ./epmd

echo ""
echo "To use the new runtime environment, add the following directory"
echo "to your shell's PATH variable:"
echo ""
echo "	$DSTDIR/bin"
echo ""

exit 0



More information about the erlang-questions mailing list