summaryrefslogtreecommitdiff
blob: 360d2594f43543687ebf426d910912b09fb659a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# By eroen, 2014
# Distributed under the terms of the ISC licence
# $Header: $

EAPI=5

inherit cdrom

MY_PV=R${PV}

DESCRIPTION="High-level language and interactive environment"
HOMEPAGE="http://www.mathworks.com/products/matlab/"
SRC_URI=""

LICENSE="MATLAB"
RESTRICT="bindist"
SLOT=${MY_PV}
KEYWORDS="-* ~amd64"
IUSE=""

HDEPEND="app-admin/chrpath"
LIBDEPEND=""
DEPEND="${LIBDEPEND}"
RDEPEND="${LIBDEPEND}"
[[ ${EAPI} == *-hdepend ]] || DEPEND+=" ${HDEPEND}"

S=${WORKDIR}
BINDIR=/opt/bin
MY_PREFIX=/opt/${PN}/${MY_PV}
MY_EXE=${PN}-${PV}
INSTALL_KEY_VAR=MATLAB_${MY_PV}_FILE_INSTALLATION_KEY

QA_PRESTRIPPED="${MY_PREFIX#/}/.*"
QA_TEXTRELS="${MY_PREFIX#/}/bin/glnxa64/*"
QA_FLAGS_IGNORED="${MY_PREFIX#/}/.*"

pkg_pretend() {
	if [[ $MERGE_TYPE != binary ]] && [[ -z ${!INSTALL_KEY_VAR} ]]; then
		eerror "You need to set ${INSTALL_KEY_VAR} to your MATLAB ${MY_PV}"
		eerror "File Installation Key, eg. by adding"
		eerror "    ${INSTALL_KEY_VAR}=\"12345-67890-12345-67890\""
		eerror "to your make.conf ."
		eerror
		die
	fi
}

src_unpack() {
	CDROM_NAME="MATLAB ${MY_PV}_UNIX dvd" cdrom_get_cds version.txt

	# I can't find any version-specific filenames at all :(
	local DISK_PV=$(head -n 1 "${CDROM_ROOT}"/version.txt)
	if [[ ${DISK_PV} != ${MY_PV} ]]; then
		eerror "Incorrect disk found at ${CDROM_ROOT}."
		eerror "Expected version: ${MY_PV}"
		eerror "Found version:    ${DISK_PV}"
		eerror
		die
	fi
}

src_configure() {
	sed -e '/^# destinationFolder=/a destinationFolder='"${ED%/}${MY_PREFIX}" \
		-e '/^# fileInstallationKey=/afileInstallationKey='"${!INSTALL_KEY_VAR}" \
		-e '/^# agreeToLicense=/a agreeToLicense=yes' \
		-e '/^# mode=/a mode=silent' \
		-e '/^# automatedModeTimeout=/a automatedModeTimeout=0' \
		-e '/^#product.MATLAB$/a product.MATLAB' \
		< "${CDROM_ROOT}"/installer_input.txt \
		> "${T}"/installer_input.txt \
		|| die
}

src_install() {
	"${CDROM_ROOT}"/install \
		-inputFile "${T}"/installer_input.txt \
		-tmpdir "${T}" \
		-verbose \
		|| die
	rm "${ED%/}${MY_PREFIX}"/license.txt

	einfo "Stripping RPATH from binaries ..."
	find "${ED%/}${MY_PREFIX}"/bin/glnxa64 -type f -name '*.so*' -execdir chrpath -d {} + || die
	einfo "Fixing broken png files ..."
	cp "${FILESDIR}"/MatlabIcon.png "${ED%/}${MY_PREFIX}"/toolbox/shared/dastudio/resources/MatlabIcon.png || die

	# User should be able to add a licence.
	dodir "${MY_PREFIX}"/licenses
	fperms 1777 "${MY_PREFIX}"/licenses

	dosym "${MY_PREFIX}"/bin/matlab "${BINDIR}"/matlab-${PV}
	dosym "${MY_PREFIX}"/bin/mex "${BINDIR}"/mex-${PV}
}

pkg_postinst() {
	elog "On first startup, you will be asked to provide a MATLAB ${MY_PV} licence"
	elog "file. Alternatively, you can save your licence file as one of"
	elog "    ~/.matlab/${MY_PV}_licenses/*.lic"
	elog "    ${EPREFIX}${MY_PREFIX}/licenses/license.dat"
	elog "    ${EPREFIX}${MY_PREFIX}/licenses/network.lic"
	elog
	elog "If you experience blank windows after launching ${MY_EXE}, try"
	elog "installing x11-misc/wmname and running"
	elog "    wmname LG3D"
	elog "before launching ${MY_EXE} again."
}