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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: octaveforge.eclass
# @AUTHOR:
# Rafael G. Martins <rafael@rafaelmartins.eng.br>
# Alessandro Barbieri <lssndrbarbieri@gmail.com>
# @BLURB: octaveforge helper eclass.
# @MAINTAINER:
# Alessandro Barbieri <lssndrbarbieri@gmail.com>
# @SUPPORTED_EAPIS: 8
inherit autotools edo
case ${EAPI} in
8) ;;
*) die "${ECLASS}: EAPI ${EAPI} unsupported."
esac
EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install src_test pkg_postinst pkg_prerm pkg_postrm
# @ECLASS-VARIABLE: REPO_URI
# @DESCRIPTION:
# URI to the sourceforge octave-forge repository
REPO_URI="http://svn.code.sf.net/p/octave/code/trunk/octave-forge"
# defining some paths
# @ECLASS-VARIABLE: OCT_ROOT
# @DESCRIPTION:
# full path to octave share
OCT_ROOT="/usr/share/octave"
# @ECLASS-VARIABLE: OCT_PKGDIR
# @DESCRIPTION:
# path to octave pkgdir
OCT_PKGDIR="${OCT_ROOT}/packages"
# @ECLASS-VARIABLE: OCT_BIN
# @DESCRIPTION:
# octave binary name
OCT_BIN="octave"
SRC_URI="mirror://sourceforge/octave/${P}.tar.gz"
SLOT="0"
# @FUNCTION: octaveforge_src_unpack
# @DESCRIPTION:
# function to unpack and set the correct S
octaveforge_src_unpack() {
default
if [[ ! -d "${WORKDIR}/${P}" ]]; then
S="${WORKDIR}/${PN}"
fi
}
# @FUNCTION: octaveforge_src_prepare
# @DESCRIPTION:
# function to add octaveforge specific makefile and configure and reconfigure if possible
octaveforge_src_prepare() {
default
_generate_configure || die
if [[ -e "${S}/src/configure.ac" ]]; then
pushd "${S}/src" || die
eautoreconf
popd || die
elif [[ -e "${S}/src/autogen.sh" ]]; then
pushd "${S}/src" || die
edo ./autogen.sh
popd || die
fi
if [[ -e "${S}/src/Makefile" ]]; then
sed -i 's/ -s / /g' "${S}/src/Makefile" || die
fi
}
octaveforge_src_compile() {
PKGDIR="$(pwd | sed -e 's|^.*/||' || die)"
export OCT_PACKAGE="${TMPDIR}/${PKGDIR}.tar.gz"
export MKOCTFILE="mkoctfile -v"
cmd="disp(__octave_config_info__('octlibdir'));"
OCTLIBDIR=$(octavecommand "${cmd}" || die)
export LFLAGS="${LFLAGS} -L${OCTLIBDIR}"
export LDFLAGS="${LDFLAGS} -L${OCTLIBDIR}"
if [[ -e src/Makefile ]]; then
emake -C src
fi
if [[ -e src/Makefile ]]; then
mv src/Makefile src/Makefile.disable || die
fi
if [[ -e src/configure ]]; then
mv src/configure src/configure.disable || die
fi
pushd .. || die
tar -czf "${OCT_PACKAGE}" "${PKGDIR}" || die
}
# @FUNCTION: octaveforge_src_install
# @DESCRIPTION:
# function to install the octave package
octaveforge_src_install() {
DESTDIR="${D}" _octaveforge_pkg_install || die
}
octaveforge_src_test() {
DESTDIR="${T}" _octaveforge_pkg_install || die
# cargo culted from Fedora
cmd="
pkg('load','${PN}');
oruntests('${oct_pkgdir}');
unlink(pkg('local_list'));
unlink(pkg('global_list'));
"
octavecommand "${cmd}" || die
}
# @FUNCTION: octaveforge_pkg_postinst
# @DESCRIPTION:
# function that will rebuild the octave package database
octaveforge_pkg_postinst() {
einfo "Registering ${CATEGORY}/${PF} on the Octave package database."
if [[ ! -d "${OCT_PKGDIR}" ]] ; then
mkdir -p "${OCT_PKGDIR}" || die
fi
cmd="pkg('rebuild');"
octavecommand "${cmd}" || die
}
# @FUNCTION: octaveforge_pkg_prerm
# @DESCRIPTION:
# function that will run on_uninstall routines to prepare the package to remove
octaveforge_pkg_prerm() {
einfo 'Running on_uninstall routines to prepare the package to remove.'
cmd="
pkg('rebuild');
l = pkg('list');
disp(l{cellfun(@(x)strcmp(x.name,'${PN}'),l)}.dir);
"
oct_pkgdir=$(octavecommand "${cmd}" || die)
rm -f "${oct_pkgdir}/packinfo/on_uninstall.m" || die
if [[ -e "${oct_pkgdir}/packinfo/on_uninstall.m.orig" ]]; then
mv "$oct_pkgdir"/packinfo/on_uninstall.m{.orig,} || die
pushd "$oct_pkgdir/packinfo" || die
cmd="
l = pkg('list');
on_uninstall(l{cellfun(@(x)strcmp(x.name,'${PN}'), l)});
"
octavecommand "${cmd}" || die
fi
}
# @FUNCTION: octaveforge_pkg_postrm
# @DESCRIPTION:
# function that will rebuild the octave package database
octaveforge_pkg_postrm() {
einfo 'Rebuilding the Octave package database.'
if [[ ! -d "${OCT_PKGDIR}" ]] ; then
mkdir -p "${OCT_PKGDIR}" || die
fi
cmd="pkg('rebuild');"
edo "${OCT_BIN}" -H --silent --no-gui --eval "${cmd}"
}
octavecommand() {
edo "${OCT_BIN}" -H -q --no-site-file --no-gui --eval "$1"
}
_generate_configure() {
cat << EOF > configure || die
#! /bin/sh -f
if [ -e src/configure ]; then
cd src
./configure $*
fi
EOF
chmod 0755 "configure" || die
}
_octaveforge_pkg_install() {
TMPDIR="${T}"
DISTPKG='Gentoo'
pushd ../ || die
if [[ "X${DISTPKG}X" != "XX" ]]; then
stripcmd="
unlink(pkg('local_list'));
unlink(pkg('global_list'));
"
fi
if [[ "X${DESTDIR}X" = "XX" ]]; then
cmd="
warning('off','all');
pkg('install','${OCT_PACKAGE}');
l=pkg('list');
disp(l{cellfun(@(x)strcmp(x.name,'${PN}'),l)}.dir);
${stripcmd}
"
oct_pkgdir=$(octavecommand "${cmd}" || die)
else
cmd="disp(fullfile(__octave_config_info__('datadir'),'octave'));"
shareprefix=${DESTDIR}/$(octavecommand "${cmd}" || die)
cmd="disp(fullfile(__octave_config_info__('libdir'),'octave'));"
libprefix=${DESTDIR}/$(octavecommand "${cmd}" || die)
octprefix="${shareprefix}/packages"
archprefix="${libprefix}/packages"
if [[ ! -e "${octprefix}" ]]; then
mkdir -p "${octprefix}" || die
fi
if [[ ! -e "${archprefix}" ]]; then
mkdir -p "${archprefix}" || die
fi
cmd="
warning('off','all');
pkg('prefix','${octprefix}','${archprefix}');
pkg('global_list',fullfile('${shareprefix}','octave_packages'));
pkg('local_list',fullfile('${shareprefix}','octave_packages'));
pkg('install','-nodeps','-verbose','${OCT_PACKAGE}');
"
octavecommand "${cmd}" || die
cmd="
warning('off','all');
pkg('prefix','${octprefix}','${archprefix}');
pkg('global_list',fullfile('${shareprefix}','octave_packages'));
pkg('local_list',fullfile('${shareprefix}','octave_packages'));
l=pkg('list');
disp(l{cellfun(@(x)strcmp(x.name,'${PN}'),l)}.dir);
${stripcmd}
"
oct_pkgdir=$(octavecommand "${cmd}" || die)
fi
export oct_pkgdir
}
|