Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Mar 2007 14:03:33 -0600 (CST)
From:      Jason Bacon <bacon@smithers.neuro.mcw.edu>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/110144: New port: Matlab7
Message-ID:  <200703092003.l29K3WI3066709@smithers.neuro.mcw.edu>
Resent-Message-ID: <200703092050.l29Ko3cu064544@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         110144
>Category:       ports
>Synopsis:       New port: Matlab7
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 09 20:50:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Jason Bacon
>Release:        FreeBSD 5.4-RELEASE i386
>Organization:
Medical College of Wisconsin
>Environment:
System: FreeBSD smithers.neuro.mcw.edu 5.4-RELEASE FreeBSD 5.4-RELEASE #2: Wed Aug 24 14:54:53 CDT 2005 bacon@clone.neuro.mcw.edu:/usr/obj/usr/src/sys/clone i386
>Description:
	This is a port framework for installing Linux Matlab 7.3.0 (R2006b).
	Other versions of Matlab have not been tested.  Requires 
	linux_base-fc4.  Java desktop (optional) requires jdk15.
	Users must have a valid Matlab license and media: The port
	serves only to encapsulate the installation process and the
	hacks necessary to make Linux Matlab install and run cleanly 
	on FreeBSD.  This port has undergone basic testing on FreeBSD 5.4 
	with a ports snapshot from March, 2007, and on FreeBSD 6.x with 
	snapshots dating from summer 2006 to March 2007.  There is no 
	guarantee that all Matlab features will work reliably.  Please 
	report any problems (and preferably solutions) to the maintainer.
>How-To-Repeat:
>Fix:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	math/Matlab7
#	math/Matlab7/files
#	math/Matlab7/files/pkg-message.in
#	math/Matlab7/files/finish.m
#	math/Matlab7/files/finish.sh
#	math/Matlab7/files/flexlm.sh
#	math/Matlab7/files/install_flexlm.sh
#	math/Matlab7/files/install_matlab-r14
#	math/Matlab7/Makefile
#	math/Matlab7/distinfo
#	math/Matlab7/pkg-descr
#
echo c - math/Matlab7
mkdir -p math/Matlab7 > /dev/null 2>&1
echo c - math/Matlab7/files
mkdir -p math/Matlab7/files > /dev/null 2>&1
echo x - math/Matlab7/files/pkg-message.in
sed 's/^X//' >math/Matlab7/files/pkg-message.in << 'END-of-math/Matlab7/files/pkg-message.in'
X====================================================================
XSince the Matlab installation directory undergoes changes over time,
X"make deinstall" may fail to remove all files, and you will need to
Xmanually remove %%PREFIX%%/matlab.
X
XIf you want to enable flexlm on this host, run
X%%PREFIX%%/matlab/bin/install_flexlm.sh %%PREFIX%%/matlab
X
XIf you did not allow the Matlab installer to create symbolic links 
Xto the Matlab binaries, users will need %%PREFIX%%/matlab/bin 
Xin their PATH to run matlab.
X
XUsers who wish to run mex, mcc, etc. should add the following to their
X.cshrc, or equivalent startup file:
X
X# If shell is a child of Linux Matlab, put Linux bins in front of PATH for
X# the sake of mex compilation, etc.
Xif ( $?MATLAB && -e /compat/linux ) then
X    set path = (/compat/linux/usr/local/bin /compat/linux/usr/bin \
X		/compat/linux/bin $path)
Xendif
X
XSince Matlab runs mex under the user's shell, this ensures that Linux gcc is
Xfirst in the path, and the mex shared objects produced will be compatible 
Xwith Linux Matlab.
X
XPlease report any problems with this port to the maintainer at
X
X    http://www.neuro.mcw.edu/~bacon/FreeBSD_MRI
X====================================================================
END-of-math/Matlab7/files/pkg-message.in
echo x - math/Matlab7/files/finish.m
sed 's/^X//' >math/Matlab7/files/finish.m << 'END-of-math/Matlab7/files/finish.m'
X! $MATLAB/bin/finish.sh
X
END-of-math/Matlab7/files/finish.m
echo x - math/Matlab7/files/finish.sh
sed 's/^X//' >math/Matlab7/files/finish.sh << 'END-of-math/Matlab7/files/finish.sh'
X#!/usr/compat/linux/bin/sh
X
X(sleep 5; killall -1 matlab_helper) &
Xexit 0
X
END-of-math/Matlab7/files/finish.sh
echo x - math/Matlab7/files/flexlm.sh
sed 's/^X//' >math/Matlab7/files/flexlm.sh << 'END-of-math/Matlab7/files/flexlm.sh'
X#!/bin/sh
X
X# Quiet FreeBSD expr -r errors
XPATH=/compat/linux/bin:/compat/linux/usr/bin:$PATH
Xexport PATH
X
Xcase "$1" in
Xstart)
X    if [ -e /usr/local/etc/lmboot_TMW ]; then
X	/usr/local/etc/lmboot_TMW -glnx86 -u matlab && echo 'MATLAB_lmgrd'
X    fi
X    ;;
Xstop)
X    if [ -e /usr/local/etc/lmdown_TMW ]; then
X	/usr/local/etc/lmdown_TMW  > /dev/null 2>&1
X    fi
X    ;;
X*)
X    echo "Usage: $0 {start|stop}"
X    exit 1
X    ;;
Xesac
X
END-of-math/Matlab7/files/flexlm.sh
echo x - math/Matlab7/files/install_flexlm.sh
sed 's/^X//' >math/Matlab7/files/install_flexlm.sh << 'END-of-math/Matlab7/files/install_flexlm.sh'
X#!/bin/sh
X
Xif [ $# != 1 ]; then
X    echo "Usage: $0 <install-dir>"
X    exit 1
Xfi
X
Xinstall_dir=$1
X
X# FLEXLM License Manager, if installed
Xif [ -e ${install_dir}/etc/lmboot ]; then
X    ln -sf ${install_dir}/etc/lmboot /usr/local/etc/lmboot_TMW
X    ln -sf ${install_dir}/etc/lmdown /usr/local/etc/lmdown_TMW
X    install -m 0555 ${install_dir}/etc/flexlm.sh /usr/local/etc/rc.d
X    /usr/local/etc/rc.d/flexlm.sh start
X    echo "The following files or links were installed outside the Matlab"
X    echo "installation tree:"
X    echo ""
X    echo "      /usr/local/etc/lmboot_TMW"
X    echo "      /usr/local/etc/lmdown_TMW"
X    echo "      /usr/local/etc/rc.d/flexlm.sh"
X    echo ""
X    echo "You will need to manually remove them if you decide to deinstall"
X    echo "or deactivate flexlm."
X
X    matlabuser=`awk -F':' '$1 == "matlab"' /etc/passwd`
X    if [ "${matlabuser}" = "" ]; then
X	echo "There is no 'matlab' user on this system.  You must either create"
X	echo "one, or edit /usr/local/etc/rc.d/flexlm.sh to change the username"
X	echo "flexlm will run under.  Note that flexlm cannot be run as root."
X    fi
Xfi
X
END-of-math/Matlab7/files/install_flexlm.sh
echo x - math/Matlab7/files/install_matlab-r14
sed 's/^X//' >math/Matlab7/files/install_matlab-r14 << 'END-of-math/Matlab7/files/install_matlab-r14'
X#!/bin/sh
X
X#########################################################################
X# Matlab 7.3.0 R2006b FreeBSD installation script
X#
X# Author:   Jason W. Bacon
X#           Medical College of Wisconsin
X#
X# Usage:
X#
X#   This script is a wrapper around the Matlab graphical installation
X#   utility.  It installs and updates license files for use with a
X#   FLEXlm license server, and contains workarounds for installing 
X#   Matlab on FreeBSD using Linux compatibility.
X#
X#   Redistribution and use in source and binary forms, with or without
X#   modification, are permitted provided that the following conditions are
X#   met:
X#
X#   Redistributions of source code must retain the above copyright notice,
X#   this list of conditions and the following disclaimer. Redistributions
X#   in binary form must reproduce the above copyright notice, this list of
X#   conditions and the following disclaimer in the documentation and/or
X#   other materials provided with the distribution. 
X#
X#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
X#   IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
X#   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
X#   PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
X#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
X#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
X#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
X#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
X
Xif [ $# != 2 ]; then
X    echo "Usage: $0 <install-directory> <patch-directory>"
X    exit 1
Xfi
X
X# Port PREFIX
Xprefix="$1"
X
X# Install into PREFIX/matlab
Xinstall_dir=${prefix}/matlab
X
X# WRKSRC directory contains patches and install scripts
Xwrksrc="$2"
X
X# Remember where we started
Xport_dir=`pwd`
Xpkg_plist=${port_dir}/pkg-plist
X
X# A little eye candy
Xalias drawline='echo -e "\n====================================================================\n"'
X
X# License file must be copied into install directory before starting
X# Matlab installer.
Xlicense_file=""
Xwhile [ "${license_file}" = "" ]; do
X    drawline
X    echo 'Enter the full pathname of your license.dat file: '
X    read license_file
X    if [ ! -e ${license_file} ]; then
X	echo 'Error: ${license_file} does not exist.  Please try again.'
X	license_file=""
X    fi
Xdone
X
Xdrawline
Xecho "Should this installation fail, please see the Matlab manual"
Xecho "installation instructions in the FreeBSD Handbook."
Xdrawline
X
X# Input installation source.  Offer standard CDROM mount point
X# as a default.
Xdefault_source_dir='/cdrom'
X
Xecho "If you are using a remote license server,"
Xecho "be sure to remove FLEXlm from the Items to"
Xecho "Install list in the Matlab installer."
Xecho ""
Xecho -n "Press return to continue..."
Xread andthrowaway
X
X# Prime loop for 'install another disk' question at end
Xans='y'
X
X# Run installer from within install directory
Xwhile [ "${ans}" = "y" ]; do
X    drawline
X
X    # Disks in multiple CD set can be loaded in any order.
X    echo ""
X    echo "If you are installing from CDs, insert the first CD now."
X    echo "Otherwise, enter the full pathname of the directory"
X    echo "containing the Matlab 'install' script."
X    echo ""
X    echo -n "Location of install sources? [${default_source_dir}] "
X    read source_dir
X    if [ "${source_dir}" = "" ]; then
X	source_dir="${default_source_dir}"
X    else
X	default_source_dir="${source_dir}"
X    fi
X
X    # Try to determine if this is loadable media
X    dev=`awk -v dir=${source_dir} '$2 == dir && $4 ~ "noauto" { print $1 }' /etc/fstab`
X    if [ "${dev}" != '' ]; then
X	mount=1
X	echo "Mounting $dev..."
X	mount ${source_dir}
X    else
X	mount=0
X    fi
X
X    # Run Matlab installer
X    if [ ! -d ${install_dir} ]; then
X	mkdir -p ${install_dir}
X	if [ $? != 0 ]; then
X	    echo "Error creating ${install_dir}, aborting installation..."
X	    echo "Make sure you are logged in as root, or have appropriate"
X	    echo "permissions on the install directory."
X	    exit 1
X	fi
X    fi
X    
X    # License file must be in install directory when Matlab installer starts
X    echo "Installing skeletal license file..."
X    if [ ! -e ${license_file} ]; then
X	echo "Missing license file: ${license_file}"
X    fi
X    cp ${license_file} ${install_dir}
X
X    # Matlab installer installs into current working directory.
X    cd ${install_dir}
X    
X    # Invoke the installer from a Linux shell so that it senses
X    # a valid environment.  Set PATH so that Linux binaries will be
X    # used where possible.  (FreeBSD expr does not
X    # support -r flag, so this will silence errors during install
X    # by using the Linux expr.)
X    savepath="${PATH}"
X    PATH="/compat/linux/bin:/compat/linux/usr/bin:${PATH}"
X    export PATH
X
X    echo "Running Matlab install tool.  Note that pathnames referred to"
X    echo "by the installer are relative to /compat/linux."
X    
X    # Make sure boot.ftp has been unpacked
X    if [ ! -e "${source_dir}/update" ]; then
X        (cd $source_dir; tar xvf boot.ftp)
X    fi
X
X    # Test connection to X server and run graphical install if possible.
X    xhost > /dev/null 2> /dev/null
X    if [ $? = 0 ]; then
X	/compat/linux/bin/sh ${source_dir}/install
X    else
X	echo "Cannot connect to DISPLAY $DISPLAY.  Using text mode install."
X	/compat/linux/bin/sh ${source_dir}/install -t
X    fi
X    
X    # Restore old path without Linux bins so that the rest of the
X    # script runs native FreeBSD commands.
X    PATH="${savepath}"
X    export PATH
X
X    # Unmount disk if necessary
X    if [ $mount = 1 ]; then
X	echo "Unmounting..."
X	umount ${source_dir}
X    fi
X    
X    echo "Done with ${source_dir}."
X    echo -n 'Install another disk? (y/n) '
X    read ans
Xdone
X
X# Create Matlab launch script to set up Linux environment for Matlab.
X# Put Linux bin directories first in the path, so Matlab scripts will
X# use Linux binaries rather than the FreeBSD binaries wherever possible.
X# This will, at minimum, quiet the annoying 'invalid -r flag' errors 
X# produced by the FreeBSD expr command.
X
Xscript=${prefix}/matlab/bin/matlab
X# Rename original "matlab" script so it doesn't get run directly
Xmv -f ${script} ${script}.sh
X
X# Replace "matlab" with wrapper that sets the environment and calls
X# the original as "matlab.sh"
Xecho '#!/bin/sh' > ${script}
Xecho '' >> ${script}
Xecho 'PATH="/compat/linux/bin:/compat/linux/usr/bin:${PATH}"' >> ${script}
Xecho 'export PATH' >> ${script}
Xecho "${install_dir}"'/bin/matlab.sh -glnx86 $*' >> ${script}
Xchmod 555 ${script}
X
X# Flexlm installation scripts for convenience
Xinstall -m 0555 ${wrksrc}/install_flexlm.sh ${install_dir}/bin
Xinstall -m 0555 ${wrksrc}/flexlm.sh ${install_dir}/etc
X
X# Link to working linux jre
Xln -s /usr/local/linux-sun-jdk1.4.2/jre \
X    ${install_dir}/sys/java/jre/glnx86/jre1.4.2
Xmv ${install_dir}/sys/java/jre/glnx86/jre.cfg \
X    ${install_dir}/sys/java/jre/glnx86/jre.cfg.orig
Xecho "1.4.2" > ${install_dir}/sys/java/jre/glnx86/jre.cfg
X
X######################################################################
X# Generate pkg-plist
X
Xrm -f ${pkg_plist}
X(cd ${prefix} && find -d matlab \! -type d) >> ${pkg_plist}
X(cd ${prefix} && find -d matlab -type d) | \
X	sed -e 's#^#@dirrm #' >> ${pkg_plist}
END-of-math/Matlab7/files/install_matlab-r14
echo x - math/Matlab7/Makefile
sed 's/^X//' >math/Matlab7/Makefile << 'END-of-math/Matlab7/Makefile'
X# New ports collection Makefile for:   Linux Matlab 7r14
X# Date created:        20 Feb 2005
X# Whom:                jbacon@mcw.edu
X#
X# $FreeBSD$
X#
X
XPORTNAME=	Matlab
XPORTVERSION=	7.3.0
XCATEGORIES=	math science
XMASTER_SITES=
XPKGNAMEPREFIX=	linux-
XDISTFILES=
X
XMAINTAINER=	bacon@smithers.neuro.mcw.edu
XCOMMENT=	Mathworks(r) Matlab 7
X
X# If no linux_base is present, linux-sun-jdk14 will install linux_base8 as
X# a dependency.  Make sure linux_base-fc4 is installed to prevent this from
X# happening.
XEXTRACT_DEPENDS=${LINUX_BASE_PORT}
XRUN_DEPENDS=	${LOCALBASE}/linux-sun-jdk1.4.2:${PORTSDIR}/java/linux-sun-jdk14 \
X		${LINUXBASE}/usr/bin/gcc:${PORTSDIR}/devel/linux_devtools
X
XUSE_LINUX=	fc4
XUSE_XLIB=	yes
XPREFIX?=	${LINUXBASE}
X
XONLY_FOR_ARCHS=	i386
X
XIS_INTERACTIVE=	yes
X
XNO_BUILD=	yes
X
XSUB_FILES=	pkg-message
X
X# Run installation script under pre-install, so the packing list
X# can be generated AFTER the files are in place.  The installed
X# toolboxes will vary immensely depending on the user's license options
X# and selection.
Xpre-install:
X	${FILESDIR}/install_matlab-r14 ${PREFIX} ${FILESDIR}
X
Xdo-install:
X	@${ECHO_MSG} "Installation complete."
X
Xpost-install:
X	@${CAT} ${WRKDIR}/pkg-message
X
X.include <bsd.port.mk>
END-of-math/Matlab7/Makefile
echo x - math/Matlab7/distinfo
sed 's/^X//' >math/Matlab7/distinfo << 'END-of-math/Matlab7/distinfo'
XMD5 (Matlab-7r14.tar.gz) = 3ff76719a6679603210af0a7086a4665
XSHA256 (Matlab-7r14.tar.gz) = 2d7a1756749a004acf8a9998eee154f7fe4c039cb01965ef68a6eee249edf795
XSIZE (Matlab-7r14.tar.gz) = 4026
END-of-math/Matlab7/distinfo
echo x - math/Matlab7/pkg-descr
sed 's/^X//' >math/Matlab7/pkg-descr << 'END-of-math/Matlab7/pkg-descr'
XThis is Mathworks (r) Matlab 6.5r13 for Linux.  It requires installation
Xmedia and a license file from Mathworks, Inc., and linux_base-8.
END-of-math/Matlab7/pkg-descr
exit

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703092003.l29K3WI3066709>