| 1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/rox.eclass,v 1.35 2011/12/27 17:55:12 fauli Exp $
|
| 4 |
|
| 5 |
# ROX eclass Version 3
|
| 6 |
|
| 7 |
# This eclass was created by Sergey Kuleshov (svyatogor@gentoo.org) and
|
| 8 |
# Alexander Simonov (devil@gentoo.org.ua) to ease installation of ROX desktop
|
| 9 |
# applications. Enhancements and python additions by Peter Hyman.
|
| 10 |
# Small fixes and current maintenance by Jim Ramsay (lack@gentoo.org)
|
| 11 |
|
| 12 |
# These variables are used in the GLOBAL scope to decide on DEPENDs, so they
|
| 13 |
# must be set BEFORE you 'inherit rox':
|
| 14 |
#
|
| 15 |
# ROX_VER - the minimum version of rox filer required. Default is 2.1.0
|
| 16 |
# ROX_LIB_VER - version of rox-lib required if any
|
| 17 |
# ROX_CLIB_VER - version of rox-clib required if any
|
| 18 |
#
|
| 19 |
# These variables are only used inside functions, and so may be set anywhere in
|
| 20 |
# the ebuild:
|
| 21 |
#
|
| 22 |
# APPNAME - the actual name of the application as the app folder is named
|
| 23 |
# WRAPPERNAME - the name of the wrapper installed into /usr/bin
|
| 24 |
# Defaults to 'rox-${PN}', or just ${PN} if it already starts with 'rox'.
|
| 25 |
# This does not normally need to be overridden.
|
| 26 |
# If overridden with the reserved word 'skip' no wrapper will be created.
|
| 27 |
# APPNAME_COLLISION - If not set, the old naming convention for wrappers of
|
| 28 |
# /usr/bin/${APPNAME} will still be around. Needs only be set in packages
|
| 29 |
# with known collisions (such as Pager, which collides with afterstep)
|
| 30 |
# APPCATEGORY - the .desktop categories this application should be placed in.
|
| 31 |
# If unset, no .desktop file will be created. For a list of acceptable
|
| 32 |
# category names, see
|
| 33 |
# http://standards.freedesktop.org/menu-spec/latest/apa.html
|
| 34 |
# APPMIME - the .desktop MimeTypes value to include. This is a
|
| 35 |
# semicolon-delimited list of mime-types. Any characters in [[:space:]] are
|
| 36 |
# ignored. If the supported mime-types are dependent upon USE flags, the new
|
| 37 |
# 'usemime' function may be useful. For example:
|
| 38 |
# APPMIME="a/foo-1;a/foo-2
|
| 39 |
# $(usemime three "a/three")
|
| 40 |
# text/plain"
|
| 41 |
# will be expanded to either "a/foo-1;a/foo-2;a/three;text/plain" if
|
| 42 |
# USE=three or "a/foo-1;a/foo-2;text/plain" if not.
|
| 43 |
# WARNING: the 'usemime' function cannot be used in global scope. You should
|
| 44 |
# set APPMIME (or at least the USE-dependant parts) in your own src_install
|
| 45 |
# before calling rox_src_install. See rox-extra/archive for an example.
|
| 46 |
# KEEP_SRC - this flag, if set, will not remove the source directory
|
| 47 |
# but will do a 'make clean' in it. This is useful if users wish to
|
| 48 |
# preserve the source code for some reason
|
| 49 |
|
| 50 |
# For examples refer to ebuilds in rox-extra/ or rox-base/
|
| 51 |
|
| 52 |
if [[ ${ROX_LIB_VER} ]]; then
|
| 53 |
# Presently all packages which require ROX_LIB also require python2
|
| 54 |
PYTHON_DEPEND="2"
|
| 55 |
fi
|
| 56 |
|
| 57 |
# need python to byte compile modules, if any
|
| 58 |
# need autotools to run autoreconf, if required
|
| 59 |
inherit python autotools eutils multilib
|
| 60 |
|
| 61 |
ROX_VER=${ROX_VER:-"2.1.0"}
|
| 62 |
|
| 63 |
RDEPEND=">=rox-base/rox-${ROX_VER}"
|
| 64 |
|
| 65 |
if [[ ${ROX_LIB_VER} ]]; then
|
| 66 |
RDEPEND="${RDEPEND}
|
| 67 |
>=rox-base/rox-lib-${ROX_LIB_VER}"
|
| 68 |
fi
|
| 69 |
|
| 70 |
if [[ ${ROX_CLIB_VER} ]]; then
|
| 71 |
RDEPEND="${RDEPEND}
|
| 72 |
>=rox-base/rox-clib-${ROX_CLIB_VER}"
|
| 73 |
DEPEND="${DEPEND}
|
| 74 |
>=rox-base/rox-clib-${ROX_CLIB_VER}
|
| 75 |
virtual/pkgconfig"
|
| 76 |
fi
|
| 77 |
|
| 78 |
# This is the new wrapper name (for /usr/bin/)
|
| 79 |
# It is also used for the icon name in /usr/share/pixmaps
|
| 80 |
#
|
| 81 |
# Use rox-${PN} unless ${PN} already starts with 'rox'
|
| 82 |
_a="rox-${PN}"
|
| 83 |
_b=${_a/rox-rox*}
|
| 84 |
WRAPPERNAME=${_b:-${PN}}
|
| 85 |
unset _a _b
|
| 86 |
|
| 87 |
# This is the location where all applications are installed
|
| 88 |
LIBDIR="/usr/$(get_libdir)"
|
| 89 |
APPDIR="${LIBDIR}/rox"
|
| 90 |
|
| 91 |
# External Functions
|
| 92 |
|
| 93 |
# Used for assembling APPMIME with USE-dependent parts
|
| 94 |
# WARNING: Cannot be used in global scope.
|
| 95 |
# Set this in src_install just before you call rox_src_install
|
| 96 |
usemime() {
|
| 97 |
local myuse="$1"; shift
|
| 98 |
use "${myuse}" && echo "$@"
|
| 99 |
}
|
| 100 |
|
| 101 |
# Utility Functions
|
| 102 |
|
| 103 |
# Expands APPMIME properly, removing whitespace, newlines, and putting in ';'
|
| 104 |
# where needed.
|
| 105 |
expandmime() {
|
| 106 |
local old_IFS=$IFS
|
| 107 |
IFS=$'; \t\n'
|
| 108 |
echo "$*"
|
| 109 |
IFS=$old_IFS
|
| 110 |
}
|
| 111 |
|
| 112 |
#
|
| 113 |
# Install the wrapper in /usr/bin for commandline execution
|
| 114 |
#
|
| 115 |
# Environment needed:
|
| 116 |
# WRAPPERNAME, APPDIR, LIBDIR, APPNAME, APPNAME_COLLISION
|
| 117 |
#
|
| 118 |
rox_install_wrapper() {
|
| 119 |
if [[ "${WRAPPERNAME}" != "skip" ]]; then
|
| 120 |
#create a script in bin to run the application from command line
|
| 121 |
dodir /usr/bin/
|
| 122 |
cat >"${D}/usr/bin/${WRAPPERNAME}" <<EOF
|
| 123 |
#!/bin/sh
|
| 124 |
if [ "\${LIBDIRPATH}" ]; then
|
| 125 |
export LIBDIRPATH="\${LIBDIRPATH}:${LIBDIR}"
|
| 126 |
else
|
| 127 |
export LIBDIRPATH="${LIBDIR}"
|
| 128 |
fi
|
| 129 |
|
| 130 |
if [ "\${APPDIRPATH}" ]; then
|
| 131 |
export APPDIRPATH="\${APPDIRPATH}:${APPDIR}"
|
| 132 |
else
|
| 133 |
export APPDIRPATH="${APPDIR}"
|
| 134 |
fi
|
| 135 |
exec "${APPDIR}/${APPNAME}/AppRun" "\$@"
|
| 136 |
EOF
|
| 137 |
chmod 755 "${D}/usr/bin/${WRAPPERNAME}"
|
| 138 |
|
| 139 |
# Old name of cmdline wrapper: /usr/bin/${APPNAME}
|
| 140 |
if [[ ! "${APPNAME_COLLISION}" ]]; then
|
| 141 |
ln -s ${WRAPPERNAME} "${D}/usr/bin/${APPNAME}"
|
| 142 |
# TODO: Migrate this away... eventually
|
| 143 |
else
|
| 144 |
ewarn "The wrapper script /usr/bin/${APPNAME} has been removed"
|
| 145 |
ewarn "due to a name collision. You must run ${APPNAME} as"
|
| 146 |
ewarn "/usr/bin/${WRAPPERNAME} instead."
|
| 147 |
fi
|
| 148 |
fi
|
| 149 |
}
|
| 150 |
|
| 151 |
#
|
| 152 |
# Copy the .DirIcon into the pixmaps dir, and create the .desktop file
|
| 153 |
#
|
| 154 |
rox_install_desktop() {
|
| 155 |
# Create a .desktop file if the proper category is supplied
|
| 156 |
if [[ -n "${APPCATEGORY}" ]]; then
|
| 157 |
# Copy the .DirIcon into /usr/share/pixmaps with the proper extension
|
| 158 |
if [[ -f "${APPNAME}/.DirIcon" ]]; then
|
| 159 |
local APPDIRICON=${APPNAME}/.DirIcon
|
| 160 |
local APPICON
|
| 161 |
case "$(file -b ${APPDIRICON})" in
|
| 162 |
"PNG image"*)
|
| 163 |
APPICON=${WRAPPERNAME}.png
|
| 164 |
;;
|
| 165 |
"XML 1.0 document text"* | \
|
| 166 |
"SVG Scalable Vector Graphics image"*)
|
| 167 |
APPICON=${WRAPPERNAME}.svg
|
| 168 |
;;
|
| 169 |
"X pixmap image text"*)
|
| 170 |
APPICON=${WRAPPERNAME}.xpm
|
| 171 |
;;
|
| 172 |
"symbolic link"*)
|
| 173 |
APPDIRICON=$(dirname ${APPDIRICON})/$(readlink ${APPDIRICON})
|
| 174 |
APPICON=${WRAPPERNAME}.${APPDIRICON##*.}
|
| 175 |
;;
|
| 176 |
*)
|
| 177 |
# Unknown... Remark on it, and just copy without an extension
|
| 178 |
ewarn "Could not detect the file type of the application icon,"
|
| 179 |
ewarn "copying without an extension."
|
| 180 |
APPICON=${WRAPPERNAME}
|
| 181 |
;;
|
| 182 |
esac
|
| 183 |
# Subshell, so as to not pollute the caller's env.
|
| 184 |
(
|
| 185 |
insinto /usr/share/pixmaps
|
| 186 |
newins "${APPDIRICON}" "${APPICON}"
|
| 187 |
)
|
| 188 |
fi
|
| 189 |
|
| 190 |
make_desktop_entry "${WRAPPERNAME}" "${APPNAME}" "${WRAPPERNAME}" \
|
| 191 |
"${APPCATEGORY}" "MimeType=$(expandmime $APPMIME)"
|
| 192 |
fi
|
| 193 |
}
|
| 194 |
|
| 195 |
# Exported functions
|
| 196 |
|
| 197 |
rox_pkg_setup() {
|
| 198 |
if [[ ${PYTHON_DEPEND} ]]; then
|
| 199 |
python_set_active_version 2
|
| 200 |
fi
|
| 201 |
}
|
| 202 |
|
| 203 |
rox_src_compile() {
|
| 204 |
cd "${APPNAME}"
|
| 205 |
# Python packages need their shebangs fixed
|
| 206 |
if [[ ${PYTHON_DEPEND} ]]; then
|
| 207 |
python_convert_shebangs -r 2 .
|
| 208 |
fi
|
| 209 |
#Some packages need to be compiled.
|
| 210 |
chmod 755 AppRun
|
| 211 |
if [[ -d src/ ]]; then
|
| 212 |
# Bug 150303: Check with Rox-Clib will fail if the user has 0install
|
| 213 |
# installed on their system somewhere, so remove the check for it in the
|
| 214 |
# configure script, and adjust the path that the 'libdir' program uses
|
| 215 |
# to search for it:
|
| 216 |
if [[ -f src/configure.in ]]; then
|
| 217 |
cd src
|
| 218 |
sed -i.bak -e 's/ROX_CLIB_0LAUNCH/ROX_CLIB/' configure.in
|
| 219 |
# TODO: This should really be 'eautoreconf', but that breaks
|
| 220 |
# some packages (such as rox-base/pager-1.0.1)
|
| 221 |
eautoconf
|
| 222 |
cd ..
|
| 223 |
fi
|
| 224 |
export LIBDIRPATH="${LIBDIR}"
|
| 225 |
|
| 226 |
# Most rox self-compiles have a 'read' call to wait for the user to
|
| 227 |
# press return if the compile fails.
|
| 228 |
# Find and remove this:
|
| 229 |
sed -i.bak -e 's/\<read\>/#read/' AppRun
|
| 230 |
|
| 231 |
./AppRun --compile || die "Failed to compile the package"
|
| 232 |
if [[ -n "${KEEP_SRC}" ]]; then
|
| 233 |
emake -C src clean
|
| 234 |
else
|
| 235 |
rm -rf src
|
| 236 |
fi
|
| 237 |
if [[ -d build ]]; then
|
| 238 |
rm -rf build
|
| 239 |
fi
|
| 240 |
|
| 241 |
# Restore the original AppRun
|
| 242 |
mv AppRun.bak AppRun
|
| 243 |
fi
|
| 244 |
}
|
| 245 |
|
| 246 |
rox_src_install() {
|
| 247 |
if [[ -d "${APPNAME}/Help/" ]]; then
|
| 248 |
for i in "${APPNAME}"/Help/*; do
|
| 249 |
dodoc "${i}"
|
| 250 |
done
|
| 251 |
fi
|
| 252 |
|
| 253 |
insinto "${APPDIR}"
|
| 254 |
|
| 255 |
# Use 'cp -pPR' and not 'doins -r' here so we don't have to do a flurry of
|
| 256 |
# 'chmod' calls on the executables in the appdir - Just be sure that all the
|
| 257 |
# files in the original appdir prior to this step are correct, as they will
|
| 258 |
# all be preserved.
|
| 259 |
cp -pPR ${APPNAME} "${D}${APPDIR}/${APPNAME}"
|
| 260 |
|
| 261 |
# Install the wrapper in /usr/bin
|
| 262 |
rox_install_wrapper
|
| 263 |
|
| 264 |
# Install the .desktop application file
|
| 265 |
rox_install_desktop
|
| 266 |
}
|
| 267 |
|
| 268 |
rox_pkg_postinst() {
|
| 269 |
if [[ ${PYTHON_DEPEND} ]]; then
|
| 270 |
python_mod_optimize "${APPDIR}/${APPNAME}" >/dev/null 2>&1
|
| 271 |
fi
|
| 272 |
|
| 273 |
einfo "${APPNAME} has been installed into ${APPDIR}"
|
| 274 |
if [[ "${WRAPPERNAME}" != "skip" ]]; then
|
| 275 |
einfo "You can run it by typing ${WRAPPERNAME} at the command line."
|
| 276 |
einfo "Or, you can run it by pointing the ROX file manager to the"
|
| 277 |
else
|
| 278 |
einfo "You can run it by pointing the ROX file manager to the"
|
| 279 |
fi
|
| 280 |
einfo "install location -- ${APPDIR} -- and click"
|
| 281 |
einfo "on ${APPNAME}'s icon, drag it to a panel, desktop, etc."
|
| 282 |
}
|
| 283 |
|
| 284 |
rox_pkg_postrm() {
|
| 285 |
if [[ ${PYTHON_DEPEND} ]]; then
|
| 286 |
python_mod_cleanup "${APPDIR}"
|
| 287 |
fi
|
| 288 |
}
|
| 289 |
|
| 290 |
|
| 291 |
EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst pkg_postrm
|