Moving the OTP top level dir, was: Stuff that breaks when you move it
Scott Lystig Fritchie
fritchie@REDACTED
Wed Aug 5 00:46:40 CEST 2009
Mazen Harake <mazen.harake@REDACTED> wrote:
mh> Should I be able to move the erlang directory? [...]
For those who are interested in doing exactly that, it isn't too hard.
We've got a build system which builds various apps from scratch,
including Erlang/OTP, using something like:
(cd /path/to/otp/src &&
./configure --prefix=/funky/path/with/time-of-day/embedded/in/it)
... which means that "make install" will put the build artifacts into a
different directory each time.
This script might work, but I've edited it slightly to remove some
cruft, so it might not.
-Scott
--- snip --- 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/third-party/erlang /tmp/R13B01 /tmp/R13B01
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