aboutsummaryrefslogtreecommitdiff
blob: 650c35305b5e4c8cadd2a76bcf1ae934e34cbfda (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
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
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Versioning is output of nmrPipe -help

EAPI=8

inherit virtualx

DESCRIPTION="Spectral visualisation, analysis and Fourier processing"
HOMEPAGE="https://www.ibbr.umd.edu/nmrpipe"
#SRC_URI="
#	NMRPipeX.tZ
#	talos.tZ
#	dyn.tZ
#	binval.com
#	install.com"
SRC_URI="
	https://www.ibbr.umd.edu/nmrpipe/install.com -> install-${PV}.com
	https://www.ibbr.umd.edu/nmrpipe/binval.com -> binval-${PV}.com
	https://www.ibbr.umd.edu/nmrpipe/NMRPipeX.tZ -> NMRPipeX-${PV}.tZ
	https://www.ibbr.umd.edu/nmrpipe/plugin.smile.tZ -> plugin.smile-${PV}.tZ
	https://www.ibbr.umd.edu/nmrpipe/talos.tZ -> talos-${PV}.tZ
	https://www.ibbr.umd.edu/nmrpipe/dyn.tZ -> dyn-${PV}.tZ
	"

SLOT="0"
LICENSE="nmrpipe"
# Right now, precompiled executables are only available for Linux on the
# x86 architecture. The maintainer chose to keep the sources closed, but
# says he will gladly provide precompiled executables for other platforms
# if there are such requests.
KEYWORDS="~amd64 ~x86"

RESTRICT="strip bindist mirror !test? ( test )"

DEPEND="app-shells/tcsh"
RDEPEND="${DEPEND}
	app-editors/nedit
	dev-lang/tk
	dev-tcltk/blt
	media-fonts/font-sun-misc
	sys-libs/ncurses-compat:5/5
	x11-apps/xset
	x11-libs/xview-bin
	!prefix? ( >=x11-libs/libX11-1.6.2 )
	prefix? ( dev-util/patchelf )"

S="${WORKDIR}/NMR"

NMRBASE="/opt/${PN}"
ENMRBASE="${EPREFIX}/${NMRBASE}"

QA_PREBUILT="opt/.*"

src_unpack() {
	# The installation script will unpack the package. We just provide symlinks
	# to the archive files, ...
	for i in NMRPipeX-${PV}.tZ plugin.smile-${PV}.tZ talos-${PV}.tZ dyn-${PV}.tZ; do
		ln -sf "${DISTDIR}"/${i} ${i/-${PV}/} || die
	done
	mkdir "${S}" && cd "${S}" || die
	# ... copy the installation scripts ...
	cp -L "${DISTDIR}"/install-${PV}.com install.com || die
	cp -L "${DISTDIR}"/binval-${PV}.com binval.com || die
	# ... and make the installation scripts executable.
	chmod +x *.com || die
	VIRTUALX_COMMAND="csh"
	virtx \
		./install.com \
		+type $(usex x86 linux9 linux212_64) \
		+src "${WORKDIR}" \
		+dest "${S}" \
		+nopost +nocshrc
}

src_prepare() {
	default
	local bin i

	mv nmrbin.$(usex x86 linux9 linux212_64)/nmr{W,w}ish || die

	ebegin "Cleaning installation"

	# Remove some of the bundled applications and libraries; they are provided by Gentoo instead.
	rm -rf nmrbin.linux*/{lib/*.timestamp,*timestamp,xv,gnuplot*,rasmol*,nc,nedit} \
		nmrbin.{linux,mac} nmruser format \
		$(usex x86 nmrbin.linux212_64 nmrbin.linux9) \
		|| die "Failed to remove unnecessary libraries."
	# As long as xview is not fixed for amd64 we do this
	rm nmrbin.linux*/lib/{libxview.so*,libolgx.so*} || die
	# Remove the initialisation script generated during the installation.
	# It contains incorrect hardcoded paths; only the "nmrInit.com" script
	# should be used.
	rm -f com/nmrInit.linux*.com || die "Failed to remove broken init script."
	# Remove installation log files.
	rm -f README_NMRPIPE_USERS *.log install.com binval.com || die "Failed to remove installation log."
	# Remove unused binaries
	rm -f {talos*,spartaplus,promega}/bin/*{linux,mac,sgi6x,winxp} pdb/misc/addSeg || die

	# Some scripts are on the wrong place
	cp -f nmrtxt/*.com com/
	rm -f {acme,com}/{nmrproc,fid,install}.com || die
	eend

	ebegin "Fixing paths in scripts"

	# Set the correct path to NMRPipe in the auxiliary scripts.
	for i in $(find com/ dynamo/surface/misc/ nmrtxt/ talos/misc talosplus/com -type f); do
		sed -e "s%/u/delaglio%${ENMRBASE}%" -i ${i} || die \
			"Failed patching scripts."
	done
	sed -i "s:${WORKDIR}:${ENMRBASE}:g" com/font.com || die

	sed \
		-e "s:!/bin:!${EPREFIX}/bin:g" \
		-e "s:!/usr/bin:!${EPREFIX}/usr/bin:g" \
		-e "s:!/usr/local/bin:!${EPREFIX}/usr/bin:g" \
		-e "s: /bin: ${EPREFIX}/bin:g" \
		-e "s: /usr/bin: ${EPREFIX}/usr/bin:g" \
		-e "s: /usr/local/bin: ${EPREFIX}/usr/bin:g" \
		-i $(find "${S}" \( -name "*.tcl" -o -name "*.com" -o -name "*.ksh" \)) \
			{com/,nmrtxt/*.com,nmrtxt/nt/*.com,dynamo/tcl/,talos*/com/,dynamo/tcl/}* \
			nmrbin.linux*/{nmrDraw,xNotify} || die
	eend

	if use prefix; then
		sed \
			-e "s: sh : \"${EPREFIX}/bin/sh\" :g" \
			-e "s: csh : \"${EPREFIX}/bin/csh\" :g" \
			-e "s: bash : \"${EPREFIX}/bin/bash\" :g" \
			-e "s:appTerm -e:appTerm -e \"${EPREFIX}/bin/csh\":g" \
			-i com/* || die

		ebegin "Setting RPATH in binaries"
		for bin in $(find nmrbin.linux*/ -type f -maxdepth 1); do
			patchelf --set-rpath "${EPREFIX}/usr/lib/" ${bin}
		done
		eend $?
	fi
}

src_install() {
	cat >> "${T}"/nmrWish <<- EOF
	#!${EPREFIX}/bin/csh -f
	setenv NMRBIN \${NMRBASE}/bin/
	setenv NMRLIB \${NMRBIN}/lib
	setenv AUXLIB \${NMRBIN}/openwin/lib
	setenv TCLPATH \${NMRBASE}/com
	setenv TCL_LIBRARY \${NMRBASE}/nmrtcl/tcl8.4
	setenv TK_LIBRARY \${NMRBASE}/nmrtcl/tk8.4
	setenv BLT_LIBRARY \${NMRBASE}/nmrtcl/blt2.4
	setenv NMRPIPE_TCL_LIB \${NMRBASE}/nmrtcl/tcl8.4
	setenv NMRPIPE_TK_LIB \${NMRBASE}/nmrtcl/tk8.4
	setenv NMRPIPE_BLT_LIB \${NMRBASE}/nmrtcl/blt2.4

	if (!(\$?LD_LIBRARY_PATH)) then
		setenv LD_LIBRARY_PATH \${NMRLIB}:\${AUXLIB}
	else
		setenv LD_LIBRARY_PATH \${NMRLIB}:\${LD_LIBRARY_PATH}:\${AUXLIB}
	endif

	nmrwish \$*
	EOF

	sed \
		-e "s:/opt/nmrpipe:${EPREFIX}/opt/nmrpipe:g" \
		-e "s:@BINTYPE@:$(usex x86 linux9 linux212_64):g" \
		"${FILESDIR}"/env-${PN} \
		> "${T}"/env-${PN} || die
	newenvd "${T}"/env-${PN} 40${PN}

	insinto ${NMRBASE}
	doins -r *

	dosym nmrbin.linux* ${NMRBASE}/bin

	ebegin "Fixing permissions"
	chmod 775 "${ED}"/${NMRBASE}/{talos*/bin/,sparta*/bin/,nmrbin.linux*/,com/,dynamo/tcl/,nmrtxt/*.com,talos*/com/,promega/bin/}* || die
	eend

	exeinto ${NMRBASE}/nmrbin.$(usex x86 linux9 linux212_64)
	doexe "${T}"/nmrWish

	insinto ${NMRBASE}/nmrtxt
	doins "${FILESDIR}"/extract.M
}