Date: Tue, 3 Apr 2007 18:20:10 GMT From: Jason Bacon <bacon@smithers.neuro.mcw.edu> To: freebsd-ports-bugs@FreeBSD.org Subject: Re: ports/110144: New port: math/Matlab7 Message-ID: <200704031820.l33IKAi9095418@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR ports/110144; it has been noted by GNATS. From: Jason Bacon <bacon@smithers.neuro.mcw.edu> To: bug-followup@freebsd.org, bacon@smithers.neuro.mcw.edu Cc: Subject: Re: ports/110144: New port: math/Matlab7 Date: Tue, 3 Apr 2007 12:39:01 -0500 Not quite sure of the best way to submit this update. There were too many changes for a diff to be practical in my opinion, so I'm including a whole new shar file below. If resubmitting it with send-pr would make life easier for the committers, please let me know. Cheers, JB # 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/files/gcc-wrapper.c # 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 Matlab bin in front of PATH X# so the MEX compilations use the gcc wrapper for linux_dist-gentoo. Xif ( $?MATLAB && -e %%PREFIX%% ) then X set path = (%%PREFIX%%/matlab/bin $path) Xendif 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 # Remove old links, if present X for file in matlab mex mcc mbuild X do X rm -f /compat/linux/usr/local/bin/${file} X rm -f /usr/local/bin/${file} X done 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# Set default browser Xecho "Please select a WEB browser for use by Matlab. You must ensure" Xecho "that the browser is installed and in each Matlab user's PATH." Xecho "Examples are firefox, konqueror, mozilla..." Xecho "Just press <Enter> to accept the default [firefox]: " Xread browser Xif [ x${browser} = "x" ]; then X browser="firefox" Xfi Xecho "Setting ${browser} as the default browser for Matlab..." Xsed -e "s|netscape|${browser}|g" ${install_dir}/toolbox/local/docopt.m > /tmp/docopt.m Xmv -f /tmp/docopt.m ${install_dir}/toolbox/local 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} X END-of-math/Matlab7/files/install_matlab-r14 echo x - math/Matlab7/files/gcc-wrapper.c sed 's/^X//' >math/Matlab7/files/gcc-wrapper.c << 'END-of-math/Matlab7/files/gcc-wrapper.c' X#include <stdio.h> X#include <stdlib.h> X#include <string.h> X#include <errno.h> X#include <unistd.h> X X#define DEBUG 0 X#define MAX_ARG_SIZE 1024 X#define PREFIX "/usr/local/gentoo-stage3" X Xint main(int argc,char *argv[]) X X{ X extern int errno; X int c; X char *p, X *temp; X X /* X * Gentoo gcc contains hard-coded paths to files such as X * /usr/bin/gcc-config, which will not be found in the FreeBSD root X * tree. We must chroot() to /usr/local/gentoo-stage3 in order for X * gcc to function. X */ X if ( chroot("/usr/local/gentoo-stage3") != 0 ) X { X fprintf(stderr,"Error: chroot() failed: %s\n",strerror(errno)); X return 1; X } X X /* Relinquish root euid after chroot() */ X seteuid(getuid()); X X#if DEBUG == 1 X printf("UID = %d EUID = %d\n",getuid(),geteuid()); X#endif X X /* Update paths in gcc arguments to reflect chroot to gentoo-base3 */ X for (c=0; argv[c] != NULL; ++c) X { X p = strstr(argv[c],PREFIX); X if ( p != NULL ) X { X /* Null-terminate string preceding PREFIX in original arg */ X *p = '\0'; X X /* Build new arg with / replacing PREFIX */ X temp = malloc(MAX_ARG_SIZE+1); X snprintf(temp,MAX_ARG_SIZE,"%s%s", X argv[c], /* Points to string before PREFIX */ X p+strlen(PREFIX) /* Points to string after PREFIX */ X ); X X /* Replace old arg with new in argv[] */ X argv[c] = temp; X } X } X X /* Check arguments */ X#if DEBUG == 1 X putchar('\n'); X for (c=0; argv[c] != NULL; ++c) X puts(argv[c]); X#endif X X execvp("/usr/bin/gcc",argv); X return 0; X} X END-of-math/Matlab7/files/gcc-wrapper.c echo x - math/Matlab7/Makefile sed 's/^X//' >math/Matlab7/Makefile << 'END-of-math/Matlab7/Makefile' X# New ports collection Makefile for: Linux Matlab 7.3.0 R2006b X# Date created: 20 Mar 2007 X# Whom: bacon@smithers.neuro.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.3.0 R2006b X X# Install linux_base-fc4 before any dependencies install a different one. X# Matlab7 won't work under linux_base8, and is untested under others. XEXTRACT_DEPENDS=${LINUX_BASE_PORT}:${PORTSDIR}/emulators/linux_base-fc4 XRUN_DEPENDS= ${LOCALBASE}/linux-sun-jdk1.4.2:${PORTSDIR}/java/linux-sun-jdk14 X XUSE_LINUX= fc4 XUSE_XLIB= yes X XOPTIONS= MEX "Requires linux_dist-gentoo-stage3" off X XONLY_FOR_ARCHS= i386 X XIS_INTERACTIVE= yes X X.include <bsd.port.pre.mk> X X.if defined(WITH_MEX) XPREFIX= ${LOCALBASE}/gentoo-stage3 XEXTRACT_DEPENDS+= ${LOCALBASE}/gentoo-stage3: ${PORTSDIR}/emulators/linux_dist-gentoo-stage3 X.else XPREFIX= ${LINUXBASE} X.endif X XSUB_FILES= pkg-message X Xpost-extract: X.if defined(WITH_MEX) X ${CP} ${FILESDIR}/gcc-wrapper.c ${WRKDIR}/gcc.c X ${REINPLACE_CMD} -e "s|/usr/local/gentoo-stage3|${PREFIX}|g" \ X ${WRKDIR}/gcc.c X.endif X Xdo-build: X.if defined(WITH_MEX) X (cd ${WRKDIR}; ${CC} -O gcc.c -o gcc) X.endif 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.if defined(WITH_MEX) X ${INSTALL_PROGRAM} ${WRKDIR}/gcc ${PREFIX}/matlab/bin X ${CHMOD} 4555 ${PREFIX}/matlab/bin/gcc X.endif X Xdo-install: X @${ECHO_MSG} "Installation complete." X Xpost-install: X @${CAT} ${WRKDIR}/pkg-message X X.include <bsd.port.post.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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704031820.l33IKAi9095418>