Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e87c8dfb authored by hhakim's avatar hhakim
Browse files

Remove from pkg post-install scripts the matlab userpath startup.m edition to avoid redundancy.

parent e489ae2b
No related branches found
No related tags found
No related merge requests found
Pipeline #833953 skipped
......@@ -8,15 +8,40 @@ function dirname_noerr
function inject_matlab_code_to_update_path
{
# each line must contains the word faust (for filtering of old install lines)
FILE=$1
echo "matfaust_path = which('matfaust.version')" >> "$FILE"
echo "matfaust_path = which('matfaust.version');" >> "$FILE"
echo "if(isempty(matfaust_path))" >> "$FILE"
echo "addpath('"$FAUST_MATLAB_WRAPPER_PATH"')" >> "$FILE"
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/mex'])" >> "$FILE"
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/tools'])" >> "$FILE"
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/data'])" >> "$FILE"
echo "matfaust.enable_gpu_mod('silent', true)" >> "$FILE"
echo end >> "$FILE"
echo "matfaust.enable_gpu_mod('silent', true);end" >> "$FILE"
}
funtion inject_matlab_code_to_update_user_paths
{
# try edit startup.m of all users (only when files exist)
for USER_DIR in /home/*
do
USER=${USER_DIR##*/}
for USR_STARTUP_FILE in $USER_DIR/Documents/MATLAB/startup.m $USER_DIR/matlab/startup.m
do
#if [[ ! "${USR_STARTUP_FILE}" = "${STARTUP_FILE}" ]]
#then
if [[ -r "$USR_STARTUP_FILE" ]]
then
grep -i -v faust "$USR_STARTUP_FILE" > "${USR_STARTUP_FILE}.tmp" 2>/dev/null && mv "${USR_STARTUP_FILE}.tmp" "$USR_STARTUP_FILE"
#echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$USR_STARTUP_FILE"
inject_matlab_code_to_update_path "$USR_STARTUP_FILE"
chown $USER "$USR_STARTUP_FILE"
RET2=$(($?+$RET2))
fi
#fi
done
done
}
MATLAB_ROOT=$(dirname_noerr $(dirname_noerr $(which matlab 2>/dev/null)))
......@@ -42,25 +67,8 @@ else
echo "oldpwd = pwd; startup_path = fullfile(matlabroot, 'toolbox', 'local'); cd(startup_path); startup; cd(oldpwd)" >> $MATLABRC
RET1=$?
RET2=0
# try edit startup.m of all users (only when files exist)
for USER_DIR in /home/*
do
USER=${USER_DIR##*/}
for USR_STARTUP_FILE in $USER_DIR/Documents/MATLAB/startup.m $USER_DIR/matlab/startup.m
do
#if [[ ! "${USR_STARTUP_FILE}" = "${STARTUP_FILE}" ]]
#then
if [[ -r "$USR_STARTUP_FILE" ]]
then
grep -i -v faust "$USR_STARTUP_FILE" > "${USR_STARTUP_FILE}.tmp" 2>/dev/null && mv "${USR_STARTUP_FILE}.tmp" "$USR_STARTUP_FILE"
#echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$USR_STARTUP_FILE"
inject_matlab_code_to_update_path "$USR_STARTUP_FILE"
chown $USER "$USR_STARTUP_FILE"
RET2=$(($?+$RET2))
fi
#fi
done
done
# disable because it's too intrusive and maybe redundant
# inject_matlab_code_to_update_user_paths
[[ $RET1 = 0 && $RET2 = 0 ]] && echo -e "\033[1mNOTICE\033[0m: Faust matlab setup is complete." || echo "ERROR: something went wrong in matlab startup script editing."
else
echo "ERROR: Faust matlab wrapper path isn't valid."
......
......@@ -2,15 +2,42 @@
function inject_matlab_code_to_update_path
{
# each line must contains the word faust (for filtering of old install lines)
FILE=$1
echo "matfaust_path = which('matfaust.version')" >> "$FILE"
echo "matfaust_path = which('matfaust.version');" >> "$FILE"
echo "if(isempty(matfaust_path))" >> "$FILE"
echo "addpath('"$FAUST_MATLAB_WRAPPER_PATH"')" >> "$FILE"
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/mex'])" >> "$FILE"
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/tools'])" >> "$FILE"
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/data'])" >> "$FILE"
echo "matfaust.enable_gpu_mod('silent', true)" >> "$FILE"
echo end >> "$FILE"
echo "matfaust.enable_gpu_mod('silent', true);end" >> "$FILE"
}
function inject_matlab_code_to_update_user_paths
{
# set path in user startup script
#USR_STARTUP_FILE="$($MATLAB_BIN -nojvm -nodisplay -r "which startup;exit" | tail -n 2 | head -n 1)" # doesn't work into install script
# even if it works in a normal script #TODO: debug
# temporary solution (hard-coded paths)
for USR_HOME in /Users/*
do
USER=${USR_HOME##*/}
for USR_STARTUP_FILE in "$USR_HOME"/Documents/MATLAB/startup.m "$USR_HOME"/matlab/startup.m
do
#if [[ ! "${USR_STARTUP_FILE}" = "${STARTUP_FILE}" ]]
#then
if [[ -r "$USR_STARTUP_FILE" ]]
then
grep -i -v faust "$USR_STARTUP_FILE" > "${USR_STARTUP_FILE}.tmp" && mv "${USR_STARTUP_FILE}.tmp" "$USR_STARTUP_FILE"
#echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$USR_STARTUP_FILE"
inject_matlab_code_to_update_path "$USR_STARTUP_FILE"
chown $USER "$USR_STARTUP_FILE"
fi
#fi
done
done
}
# find matlab root path from the accessible matlab in the PATH
......@@ -39,25 +66,6 @@ else
inject_matlab_code_to_update_path $STARTUP_FILE
# add a line to force startup execution into matlabrc
echo "oldpwd = pwd; startup_path = fullfile(matlabroot, 'toolbox', 'local'); cd(startup_path); startup; cd(oldpwd)" >> $MATLABRC
# set path in user startup script
#USR_STARTUP_FILE="$($MATLAB_BIN -nojvm -nodisplay -r "which startup;exit" | tail -n 2 | head -n 1)" # doesn't work into install script
# even if it works in a normal script #TODO: debug
# temporary solution (hard-coded paths)
for USR_HOME in /Users/*
do
USER=${USR_HOME##*/}
for USR_STARTUP_FILE in "$USR_HOME"/Documents/MATLAB/startup.m "$USR_HOME"/matlab/startup.m
do
#if [[ ! "${USR_STARTUP_FILE}" = "${STARTUP_FILE}" ]]
#then
if [[ -r "$USR_STARTUP_FILE" ]]
then
grep -i -v faust "$USR_STARTUP_FILE" > "${USR_STARTUP_FILE}.tmp" && mv "${USR_STARTUP_FILE}.tmp" "$USR_STARTUP_FILE"
#echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$USR_STARTUP_FILE"
inject_matlab_code_to_update_path "$USR_STARTUP_FILE"
chown $USER "$USR_STARTUP_FILE"
fi
#fi
done
done
# disable because it's too intrusive and maybe redundant
# inject_matlab_code_to_update_user_paths
fi
......@@ -244,25 +244,26 @@ Function matlabFoundCb
FileOpen $1 "$R4\toolbox\local\startup.m" a
FileSeek $1 0 END ; do not erase start of file (but risk to add Faust path multiple times)
;FileWrite $1 "$\r$\naddpath(genpath('$INSTDIR\matlab'));$\r$\nmatfaust.enable_gpu_mod('silent', true)"
FileWrite $1 "matfaust_path = which('matfaust.version');$\r$\nif(isempty(matfaust_path))"
FileWrite $1 "matfaust_path = which('matfaust.version');$\r$\nif(isempty(matfaust_path));"
FileWrite $1 "$\r$\naddpath('$INSTDIR\matlab');$\r$\naddpath('$INSTDIR\matlab\mex');$\r$\naddpath('$INSTDIR\matlab\tools');$\r$\naddpath('$INSTDIR\matlab\data')$\r$\nmatfaust.enable_gpu_mod('silent', true)"
FileWrite $1 "$\r$\nend"
FileClose $1
FileOpen $1 "$R4\toolbox\local\matlabrc.m" a
FileSeek $1 0 END ; do not erase start of file (but risk to add Faust path multiple times)
FileWrite $1 "oldpwd = pwd; startup_path = fullfile(matlabroot, 'toolbox', 'local'); cd(startup_path); startup; cd(oldpwd)"
FileWrite $1 "oldpwd = pwd; startup_path = fullfile(matlabroot, 'toolbox', 'local'); cd(startup_path); startup; cd(oldpwd);"
FileClose $1
FileOpen $1 "$DOCUMENTS\MATLAB\startup.m" a
IfErrors done
FileSeek $1 0 END
;FileWrite $1 "$\r$\naddpath(genpath('$INSTDIR\matlab'));$\r$\nmatfaust.enable_gpu_mod('silent', true)"
FileWrite $1 "matfaust_path = which('matfaust.version');$\r$\nif(isempty(matfaust_path))"
FileWrite $1 "$\r$\naddpath('$INSTDIR\matlab');$\r$\naddpath('$INSTDIR\matlab\mex');$\r$\naddpath('$INSTDIR\matlab\tools');$\r$\naddpath('$INSTDIR\matlab\data')$\r$\nmatfaust.enable_gpu_mod('silent', true);"
FileWrite $1 "$\r$\nend"
FileClose $1
done:
# disable because it's redundant
; FileOpen $1 "$DOCUMENTS\MATLAB\startup.m" a
; IfErrors done
; FileSeek $1 0 END
; ;FileWrite $1 "$\r$\naddpath(genpath('$INSTDIR\matlab'));$\r$\nmatfaust.enable_gpu_mod('silent', true)"
; FileWrite $1 "matfaust_path = which('matfaust.version');$\r$\nif(isempty(matfaust_path))"
; FileWrite $1 "$\r$\naddpath('$INSTDIR\matlab');$\r$\naddpath('$INSTDIR\matlab\mex');$\r$\naddpath('$INSTDIR\matlab\tools');$\r$\naddpath('$INSTDIR\matlab\data')$\r$\nmatfaust.enable_gpu_mod('silent', true);"
; FileWrite $1 "$\r$\nend"
; FileClose $1
; done:
;MessageBox MB_OK '$R0$\n$\nFaust bound into $R4.'
;MessageBox MB_YESNO 'Faust installed for $R4. Do you want to continue searching another version of Matlab to install Faust for ?' IDYES +2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment