summaryrefslogtreecommitdiff
blob: de4955b5ad6de12e04fb6ed3701429b83fe0a993 (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
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/rox.eclass,v 1.16 2006/11/15 19:28:33 lack Exp $

# ROX eclass Version 2

# This eclass was created by Sergey Kuleshov (svyatogor@gentoo.org) and
# Alexander Simonov (devil@gentoo.org.ua) to ease installation of ROX desktop
# applications. Enhancements and python additions by Peter Hyman.
# Small fixes and current maintenance by the Rox herd (rox@gentoo.org)

# These variables are used in the GLOBAL scope to decide on DEPENDs, so they
# must be set BEFORE you 'inherit rox':
#
# ROX_VER - the minimum version of rox filer required. Default is 2.1.0
# ROX_LIB_VER - version of rox-lib required if any
# ROX_CLIB_VER - version of rox-clib required if any
#
# These variables are only used in local scopes, and so may be set anywhere in
# the ebuild:
#
# APPNAME - the actual name of the application as the app folder is named
# KEEP_SRC - this flag, if set, will not remove the source directory
#    but will do a make clean in it. This is useful if users wish to
#    preserve the source code for anything

# For examples refer to ebuilds in rox-extra/

# need python to byte compile modules, if any
# need autotools to run autoreconf, if required
inherit python autotools

if [[ -z "${ROX_VER}" ]]; then
	ROX_VER="2.1.0"
fi

RDEPEND=">=rox-base/rox-${ROX_VER}"

if [[ -n "${ROX_LIB_VER}" ]]; then
	RDEPEND="${RDEPEND}
		>=rox-base/rox-lib-${ROX_LIB_VER}"
fi

if [[ -n "${ROX_CLIB_VER}" ]]; then
	RDEPEND="${RDEPEND}
		>=rox-base/rox-clib-${ROX_CLIB_VER}"
	DEPEND="${RDEPEND}
		>=dev-util/pkgconfig-0.20"
fi

rox_src_compile() {
	cd "${APPNAME}"
	#Some packages need to be compiled.
	chmod 755 AppRun
	if [ -d src/ ]; then
		# Bug 150303: Check with Rox-Clib will fail if the user has 0install
		# installed on their system somewhere, so remove the check for it in the
		# configure script, and adjust the path that the 'libdir' program uses
		# to search for it:
		if [ -f src/configure.in ]; then
			cd src
			sed -i.bak -e 's/ROX_CLIB_0LAUNCH/ROX_CLIB/' configure.in
			# TODO: This should really be 'eautoreconf', but that breaks a number
			# of packages (such as pager-1.0.1)
			eautoconf
			cd ..
		fi
		export LIBDIRPATH="/usr/lib/"

		# Most rox self-compiles have a 'read' call to wait for the user to
		# press return if the compile fails.
		# Find and remove this:
		sed -i.bak -e 's/\<read\>/#read/' AppRun

		./AppRun --compile || die "Failed to compile the package"
		if [ -n "${KEEP_SRC}" ]; then
			cd src
			make clean
			cd ..
		else
			rm -rf src
		fi
		# set permissions flag here!
		SET_PERM=true

		# Restore the original AppRun
		mv AppRun.bak AppRun
	fi
}

rox_src_install() {
	if [ -d "${APPNAME}/Help/" ]; then
		for i in "${APPNAME}"/Help/*; do
			dodoc "${i}"
		done
	fi
	insinto /usr/lib/rox
	doins -r ${APPNAME}

	#set correct permissions on files, in case they are wrong
	#include all subdirectories in search, just in case
	find "${D}/usr/lib/rox/${APPNAME}" -name 'AppRun' -print0 | xargs -0 chmod 755 >/dev/null 2>&1
	find "${D}/usr/lib/rox/${APPNAME}" -name 'AppletRun' -print0 | xargs -0 chmod 755 >/dev/null 2>&1

	# set permissions for programs where we have libdir script
	if [ -f "${D}/usr/lib/rox/${APPNAME}/libdir" ]; then
		chmod 755 "${D}/usr/lib/rox/${APPNAME}/libdir"
	fi

	# set permissions for programs where we have rox_run script (all who using rox-clib )
	if [ -f "${D}/usr/lib/rox/${APPNAME}/rox_run" ]; then
		chmod 755 "${D}/usr/lib/rox/${APPNAME}/rox_run"
	fi

	# some programs have choice_install script
	if [ -f "${D}/usr/lib/rox/${APPNAME}/choice_install" ]; then
		chmod 755 "${D}/usr/lib/rox/${APPNAME}/choice_install"
	fi

	# set permissions on all binares files for compiled programs per arch
	if [ -n "${SET_PERM}" ]; then
		ARCH="`uname -m`"
		case ${ARCH} in
			i?86) ARCH=ix86 ;;
		esac
		PLATFORM="`uname -s`-${ARCH}"
		chmod -R 755 "${D}/usr/lib/rox/${APPNAME}/${PLATFORM}"
	fi

	#create a script in bin to run the application from command line
	dodir /usr/bin/
	cat >"${D}/usr/bin/${APPNAME}" <<EOF
#!/bin/sh
exec "/usr/lib/rox/${APPNAME}/AppRun" "\$@"
EOF
	chmod 755 "${D}/usr/bin/${APPNAME}"

	#now compile any and all python files
	python_mod_optimize "${D}/usr/lib/rox/${APPNAME}" >/dev/null 2>&1
}

rox_pkg_postinst() {
	einfo "${APPNAME} has been installed into /usr/lib/rox"
	einfo "You can run it by typing ${APPNAME} at the command line."
	einfo "Or, you can run it by pointing the ROX file manager to the"
	einfo "install location -- /usr/lib/rox/${APPNAME} -- and click"
	einfo "on ${APPNAME}'s icon, drag it to a panel, desktop, etc."
}

EXPORT_FUNCTIONS src_compile src_install pkg_postinst