You are not logged in.

- Topics: Active | Unanswered

**Lemanr****Member**- Registered: 2020-03-22
- Posts: 19

Hello everyone,

As I am new I would especially like guidance rather than problem solving if you think this will make me a better Arch Linux user. I am a novice at C++ and decent with using R so this is my programing background so I can sort of read my PKGBUILD file however I do not have direct experience with the coding language used in my PKGBUILD.

So I installed Arch Linux yesterday. I am trying to install MATLAB for the first time and I'm using the method found on "https://wiki.archlinux.org/index.php/MATLAB"

I am on the step of modifying PKGBUILD and running "makepkg -s -i --skipinteg" when I get an error in package(){ as shown below. I read through my PKGBUILD as shown below but I do not see any obvious errors. Perhaps this is just due to inexperience and there is an obvious error. So my question, what is my next move so that I can install MATLAB?

```
[ryan@archlinux matlab]$ makepkg -s -i --skipinteg
/home/ryan/code/matlab/matlab.fik: line 1: 58846-26905-64130-31138-25088-31083-28864-61429-59127-63235-04957-61501-03170-61160-43584-27854-10290-35687-49413-14797-61894-04142-21195: command not found
==> Making package: matlab 9.8.0.1323502-1 (Mon 23 Mar 2020 07:26:11 PM MDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Found matlab.tar
==> WARNING: Skipping all source file integrity checks.
==> Extracting sources...
-> Extracting matlab.tar with bsdtar
==> Starting prepare()...
-> Generating .desktop launcher file
[matlab] Generating desktop file... ok
-> Reading file installation key from matlab.fik
-> Modifying the installer settings
==> Removing existing $pkgdir/ directory...
==> Entering fakeroot environment...
/home/ryan/code/matlab/matlab.fik: line 1: 58846-26905-64130-31138-25088-31083-28864-61429-59127-63235-04957-61501-03170-61160-43584-27854-10290-35687-49413-14797-61894-04142-21195: command not found
==> Starting package()...
-> Starting MATLAB installer
==> ERROR: A failure occurred in package().
Aborting...
[ryan@archlinux matlab]$
```

PKGBUILD:

```
# Maintainer: Grey Christoforo <first name at last name dot net>
## This PKGBUILD creates an Arch Linux package for the proprietary MATLAB application.
## In order to build the package, the user must supply:
## 1) a plain text file installation key as file `matlab.fik`
## and
## 2) the software tarball as `matlab.tar` from MATLAB ISO image or as downloaded by the installer
## A typical matlab tarball structure looks like this:
#matlab.tar
#├── activate.ini*
#├── archives/
#│ ├── common/
#│ └── glnxa64/
#│ ├── matlab/
#│ ├── matlab_code_analyzer/
#│ ├── matlabconnector/
#│ ├── matlabdata/
#│ ├── matlab_desktop_glnxa64_1535004605.enc*
#│ ├── matlab_desktop_glnxa64_1535004605.xml*
#│ ├── ... other toolbox/product files & folders go here
#├── bin/
#├── help/
#├── install*
#├── installer_input.txt*
#├── install_guide.pdf*
#├── java/
#├── license_agreement.txt*
#├── patents.txt*
#├── readme.txt*
#├── sys/
#├── trademarks.txt*
#├── ui/
#└── VersionInfo.xml*
## Maybe you'd create this archive like this:
## 1) download the matlab installer form themathworks, let's imagine that file is ~/Downloads/matlab_R2019b_glnxa64.zip
## 2) extract it: unzip ~/Downloads/matlab_R2019b_glnxa64.zip -d ~/matlab
## 3) run the installer almost completely through manually: ~/matlab/install -downloadFolder ${HOME}/matlab/dl -destinationFolder ${HOME}/matlab/deleteme
## you must enter all your proper license info here, the purpose of this is to get the toolbox files you'll need for the offline install later
## when you see that the installer has finished downloading everything, press the Cancel button in the gui and end the installer early
## you don't really want the installer to extract/decrypt the files it has downloaded
## 4) delete anything that might have started to be installed in the above step: rm -rf ~/matlab/deleteme
## 5) now you can create the tarball you'll need here: tar -cvf matlab.tar -C ~/matlab/ .
## You can get your file installation key (that you must manually put into matlab.fik) from https://mathworks.com/licensecenter
## Then maybe you could make the matlab.fik file you need for this package like this:
## echo "xxxxx-xxxxx-xxxxx-xxxxx-..." > matlab.fik
## This PKGBUILD no longer attempts to activate the product.
## The user will be prompted to undertake their activation method of choice when the GUI is first run.
## Activation could be automated by running /opt/matlab/bin/activate_matlab.sh after this package is installed.
## Activation could be further automated in matlab.install (a file that doesn't exist at this time)
## This package will conflict with /usr/bin/mex from texlive-bin
## You could fix that by installing it with the pacman option --overwrite /usr/bin/mex
## /ust/bin/mex from texlive-bin is just a symlink
# partial install
_partialinstall=false
pkgname=matlab
_install_dir="/opt/${pkgname}"
# as of R2020a Update 4, MATLAB's version number is:
pkgver=9.8.0.1323502
pkgrel=1
pkgdesc='A high-level language for numerical computation and visualization'
arch=('x86_64')
url='http://www.mathworks.com'
license=("/home/ryan/code/matlab/matlab.lic")
makedepends=('gendesk')
depends=('gconf'
'glu'
'gstreamer0.10-base'
'gtk2'
'libunwind'
'libxp'
'libxpm'
'libxtst'
'nss'
'portaudio'
'python'
'qt5-svg'
'qt5-webkit'
'qt5-websockets'
'qt5-x11extras'
'xerces-c')
optdepends=('gcc6: For MEX support')
source=("/home/ryan/code/matlab/matlab.tar")
("/home/ryan/code/matlab/matlab.fik")
md5sums=("SKIP" "SKIP")
#PKGEXT='.pkg.tar'
OPTIONS=(!strip staticlibs)
prepare() {
msg2 'Generating .desktop launcher file'
gendesk -f -n --pkgname "${pkgname}" \
--pkgdesc "${pkgdesc}" \
--categories "Development;Education;Science;Mathematics;IDE" \
--exec "${_install_dir}/bin/matlab -desktop"
msg2 'Reading file installation key from matlab.fik'
_fik=$(grep -o [0-9-]* /home/ryan/code/matlab/matlab.fik)
msg2 'Modifying the installer settings'
sed -i "s,^# destinationFolder=,destinationFolder=${pkgdir}${_install_dir}," installer_input.txt
sed -i "s,^# agreeToLicense=,agreeToLicense=yes," installer_input.txt
sed -i "s,^# mode=,mode=silent," installer_input.txt
sed -i "s,^# outputFile=,outputFile=${srcdir}/installer_output.txt," installer_input.txt
sed -i "s,^# fileInstallationKey=,fileInstallationKey=${_fik}," installer_input.txt
if [ ! -z ${_products+isSet} ]; then
msg2 'Building a package with a subset of the licensed products.'
for _product in "${_products[@]}"; do
sed -i "/^#product.${_product}$/ s/^#//" installer_input.txt
done
fi
}
package() {
msg2 'Starting MATLAB installer'
## I assume it's a bad idea, but I had to unset a few vars to prevent
## fakeroot from slowing the matlab installer to a crawl (commented out by default)
LDLP=${LD_LIBRARY_PATH}
LDP=${LD_PRELOAD}
unset LD_LIBRARY_PATH
unset LD_PRELOAD
./install -t -inputFile "${srcdir}/installer_input.txt"
if [ $? -eq 0 ]; then
msg2 'Matlab installer done without error'
else
meg2 'Error encountered while running matlab installer'
fi
export LD_LIBRARY_PATH="$LDLP"
export LD_PRELOAD="$LDP"
msg2 'Installing license agreement file'
install -D -m644 "${pkgdir}${_install_dir}/license_agreement.txt" "${pkgdir}/usr/share/licenses/tmw/${pkgname}/LICENSE"
msg2 'Creating links for license.dat'
mv "${pkgdir}${_install_dir}/licenses" "${pkgdir}${_install_dir}/licenses.bak"
ln -s "/etc/matlab/licenses/" "${pkgdir}${_install_dir}/licenses"
msg2 'Creating links for executables'
install -d -m755 "${pkgdir}/usr/bin/"
for _executable in deploytool matlab mbuild mcc mex; do
ln -s "${_install_dir}/bin/${_executable}" "${pkgdir}/usr/bin/${_executable}"
done
msg2 'Installing .desktop launcher files'
install -D -m644 "${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
install -D -m644 "${pkgdir}${_install_dir}/help/matlab/matlab_env/matlab_desktop_icon.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
}
if ${_partialinstall} && [ -z ${_products+isSet} ]; then
_products=(
"MATLAB"
"MATLAB_Coder"
"MATLAB_Compiler"
"MATLAB_Compiler_SDK"
"MATLAB_Parallel_Server"
"MATLAB_Production_Server"
"MATLAB_Report_Generator"
"MATLAB_Web_App_Server"
)
fi
```

Also I did use chmod 754 on each file & directory associated with my matlab directory so I don't think the error is due to any lack of permission or access to any of the relevent files.

*Last edited by Lemanr (2020-03-24 21:00:44)*

Warning recovering help-vampire:

Do not feed me help (July, 8th 2020)

Offline

**loqs****Member**- Registered: 2014-03-06
- Posts: 11,047

```
source=("/home/ryan/code/matlab/matlab.tar")
("/home/ryan/code/matlab/matlab.fik")
md5sums=("SKIP" "SKIP")
```

produces

```
/tmp/matlab/PKGBUILD: line 90: /home/ryan/code/matlab/matlab.fik: No such file or directory
....
==> ERROR: Integrity checks (md5) differ in size from the source array.
==> ERROR: Could not download sources.
```

The original source array had two elements. It now has one element and the following line is executed as a command.

wiki wrote:

tar -cvf matlab.tar -C matlab/ .

Then download the .lic file: Go in your MathWorks account and click on the license number you want to use. Then, go to the Install and Activate tab and select "Activate to Retrieve License File". Follow the instructions and download the license file needed for the installation and name the file matlab.lic. Also, the File Installation Key (FIK) is displayed: copy-paste it in a empty file and name it matlab.fik.

Copy the above files to the folder containing the PKGBUILD file.

If you had followed the wiki no changes would have been needed to the source array.

`license=("/home/ryan/code/matlab/matlab.lic")`

See https://wiki.archlinux.org/index.php/PKGBUILD#license it was correct as custom

` _fik=$(grep -o [0-9-]* /home/ryan/code/matlab/matlab.fik)`

Even if it works you should not reference files outside the build environment.

If you revert all the changes you made to the PKGBUILD does makepkg and place the sources in the same directory as the PKGBUILD does makepkg still produce?

`==> ERROR: A failure occurred in package().`

Offline

**Lemanr****Member**- Registered: 2020-03-22
- Posts: 19

Yes, after reverting all changes and ensuring the .lic and .fik files are in the same directory as PKGBUILD I still get:

```
[ryan@archlinux matlab]$ makepkg -s -i
==> Making package: matlab 9.7.0.1296695-1 (Tue 24 Mar 2020 03:18:24 PM MDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Found matlab.tar
-> Found matlab.fik
==> Validating source files with md5sums...
matlab.tar ... Skipped
matlab.fik ... Skipped
==> Extracting sources...
-> Extracting matlab.tar with bsdtar
==> Starting prepare()...
-> Generating .desktop launcher file
[matlab] Generating desktop file... ok
-> Reading file installation key from matlab.fik
-> Modifying the installer settings
==> Entering fakeroot environment...
==> Starting package()...
-> Starting MATLAB installer
==> ERROR: A failure occurred in package().
```

PKGBUILD as is.

```
# Maintainer: Grey Christoforo <first name at last name dot net>
## This PKGBUILD creates an Arch Linux package for the proprietary MATLAB application.
## In order to build the package, the user must supply:
## 1) a plain text file installation key as file `matlab.fik`
## and
## 2) the software tarball as `matlab.tar` from MATLAB ISO image or as downloaded by the installer
## A typical matlab tarball structure looks like this:
#matlab.tar
#├── activate.ini*
#├── archives/
#│ ├── common/
#│ └── glnxa64/
#│ ├── matlab/
#│ ├── matlab_code_analyzer/
#│ ├── matlabconnector/
#│ ├── matlabdata/
#│ ├── matlab_desktop_glnxa64_1535004605.enc*
#│ ├── matlab_desktop_glnxa64_1535004605.xml*
#│ ├── ... other toolbox/product files & folders go here
#├── bin/
#├── help/
#├── install*
#├── installer_input.txt*
#├── install_guide.pdf*
#├── java/
#├── license_agreement.txt*
#├── patents.txt*
#├── readme.txt*
#├── sys/
#├── trademarks.txt*
#├── ui/
#└── VersionInfo.xml*
## Maybe you'd create this archive like this:
## 1) download the matlab installer form themathworks, let's imagine that file is ~/Downloads/matlab_R2019b_glnxa64.zip
## 2) extract it: unzip ~/Downloads/matlab_R2019b_glnxa64.zip -d ~/matlab
## 3) run the installer almost completely through manually: ~/matlab/install -downloadFolder ${HOME}/matlab/dl -destinationFolder ${HOME}/matlab/deleteme
## you must enter all your proper license info here, the purpose of this is to get the toolbox files you'll need for the offline install later
## when you see that the installer has finished downloading everything, press the Cancel button in the gui and end the installer early
## you don't really want the installer to extract/decrypt the files it has downloaded
## 4) delete anything that might have started to be installed in the above step: rm -rf ~/matlab/deleteme
## 5) now you can create the tarball you'll need here: tar -cvf matlab.tar -C ~/matlab/ .
## You can get your file installation key (that you must manually put into matlab.fik) from https://mathworks.com/licensecenter
## Then maybe you could make the matlab.fik file you need for this package like this:
## echo "xxxxx-xxxxx-xxxxx-xxxxx-..." > matlab.fik
## This PKGBUILD no longer attempts to activate the product.
## The user will be prompted to undertake their activation method of choice when the GUI is first run.
## Activation could be automated by running /opt/matlab/bin/activate_matlab.sh after this package is installed.
## Activation could be further automated in matlab.install (a file that doesn't exist at this time)
## This package will conflict with /usr/bin/mex from texlive-bin
## You could fix that by installing it with the pacman option --overwrite /usr/bin/mex
## /ust/bin/mex from texlive-bin is just a symlink
# partial install
_partialinstall=false
pkgname=matlab
_install_dir="/opt/${pkgname}"
# as of R2019b Update 4, MATLAB's version number is:
pkgver=9.7.0.1296695
pkgrel=1
pkgdesc='A high-level language for numerical computation and visualization'
arch=('x86_64')
url='http://www.mathworks.com'
license=(custom)
makedepends=('gendesk')
depends=('gconf'
'glu'
'gstreamer0.10-base'
'gtk2'
'libunwind'
'libxp'
'libxpm'
'libxtst'
'nss'
'portaudio'
'python'
'qt5-svg'
'qt5-webkit'
'qt5-websockets'
'qt5-x11extras'
'xerces-c')
optdepends=('gcc6: For MEX support')
source=("local:///matlab.tar"
"local:///matlab.fik")
md5sums=("SKIP" "SKIP")
#PKGEXT='.pkg.tar'
OPTIONS=(!strip staticlibs)
prepare() {
msg2 'Generating .desktop launcher file'
gendesk -f -n --pkgname "${pkgname}" \
--pkgdesc "${pkgdesc}" \
--categories "Development;Education;Science;Mathematics;IDE" \
--exec "${_install_dir}/bin/matlab -desktop"
msg2 'Reading file installation key from matlab.fik'
_fik=$(grep -o [0-9-]* matlab.fik)
msg2 'Modifying the installer settings'
sed -i "s,^# destinationFolder=,destinationFolder=${pkgdir}${_install_dir}," installer_input.txt
sed -i "s,^# agreeToLicense=,agreeToLicense=yes," installer_input.txt
sed -i "s,^# mode=,mode=silent," installer_input.txt
sed -i "s,^# outputFile=,outputFile=${srcdir}/installer_output.txt," installer_input.txt
sed -i "s,^# fileInstallationKey=,fileInstallationKey=${_fik}," installer_input.txt
if [ ! -z ${_products+isSet} ]; then
msg2 'Building a package with a subset of the licensed products.'
for _product in "${_products[@]}"; do
sed -i "/^#product.${_product}$/ s/^#//" installer_input.txt
done
fi
}
package() {
msg2 'Starting MATLAB installer'
## I assume it's a bad idea, but I had to unset a few vars to prevent
## fakeroot from slowing the matlab installer to a crawl (commented out by default)
LDLP=${LD_LIBRARY_PATH}
LDP=${LD_PRELOAD}
unset LD_LIBRARY_PATH
unset LD_PRELOAD
./install -t -inputFile "${srcdir}/installer_input.txt"
if [ $? -eq 0 ]; then
msg2 'Matlab installer done without error'
else
meg2 'Error encountered while running matlab installer'
fi
export LD_LIBRARY_PATH="$LDLP"
export LD_PRELOAD="$LDP"
msg2 'Installing license agreement file'
install -D -m644 "${pkgdir}${_install_dir}/license_agreement.txt" "${pkgdir}/usr/share/licenses/tmw/${pkgname}/LICENSE"
#msg2 'Creating links for license.dat'
#mv "${pkgdir}${_install_dir}/licenses" "${pkgdir}${_install_dir}/licenses.bak"
#ln -s "/etc/matlab/licenses/" "${pkgdir}${_install_dir}/licenses"
msg2 'Creating links for executables'
install -d -m755 "${pkgdir}/usr/bin/"
for _executable in deploytool matlab mbuild mcc mex; do
ln -s "${_install_dir}/bin/${_executable}" "${pkgdir}/usr/bin/${_executable}"
done
msg2 'Installing .desktop launcher files'
install -D -m644 "${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
install -D -m644 "${pkgdir}${_install_dir}/help/matlab/matlab_env/matlab_desktop_icon.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
}
if ${_partialinstall} && [ -z ${_products+isSet} ]; then
_products=(
"MATLAB"
#"Curve_Fitting_Toolbox"
# fill in toolboxes/products here as needed for a partial install
# hint: look in your installer_input.txt file for names to use here
)
fi
```

my original thinking was that I had to replace the provided path files with the path files associated with my computer. I did save my edited PKGfile in a different directory incase I wanted to back to the one I tried originally.

*Last edited by Lemanr (2020-03-24 21:33:29)*

Warning recovering help-vampire:

Do not feed me help (July, 8th 2020)

Offline

**loqs****Member**- Registered: 2014-03-06
- Posts: 11,047

If following code is reached it always report success because if the previous call fails makepkg would terminate.

```
if [ $? -eq 0 ]; then
msg2 'Matlab installer done without error'
else
meg2 'Error encountered while running matlab installer'
fi
```

As there is not output from the package function before it fails the failing line should be

` ./install -t -inputFile "${srcdir}/installer_input.txt"`

As I do not use matlab I do not know why the provided install binary would fail. Possibly an issue with the contents of installer_input.txt?

You could try asking on https://aur.archlinux.org/packages/matlab/

Offline

**Lemanr****Member**- Registered: 2020-03-22
- Posts: 19

This topic can be closed and this is just a final update because I forgot to provide one:

Just letting you all know that I have MATLAB working now. Sorry for not posting solution and unfortunately I had forgotten how I accomplished this. I think there was a step in the instructions that I didn't understand but after giving each detail my undivided attention I was able to get it working. I also know that previously I was trying to download MATLAB 2020 but I had decided to follow the exact instructions thus I ended up installing MATLAB 2019a. If anyone else has issues they might want to consider just downloading the 2019a version so they can follow the wiki instructions directly.

Thanks for the help everyone! btw I am getting much better at using Arch now.

Warning recovering help-vampire:

Do not feed me help (July, 8th 2020)

Offline