# 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.19 2007/01/30 22:07:49 lack Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/rox.eclass,v 1.20 2007/02/09 17:27:39 lack Exp $
# ROX eclass Version 2
# the ebuild:
#
# APPNAME - the actual name of the application as the app folder is named
+# WRAPPERNAME - the name of the wrapper installed into /usr/bin
+# Defaults to 'rox-${PN}', or just ${PN} if it already starts with 'rox'.
+# This does not normally need to be overridden.
+# APPNAME_COLLISION - If not set, the old naming convention for wrappers of
+# /usr/bin/${APPNAME} will still be around. Needs only be set in packages
+# with known collisions (such as Pager, which collides with afterstep)
# APPCATEGORY - the .desktop categories this application should be placed in.
# If unset, no .desktop file will be created. For a list of acceptable
# category names, see
# http://standards.freedesktop.org/menu-spec/latest/apa.html
# 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
+# preserve the source code for some reason
-# For examples refer to ebuilds in rox-extra/
+# For examples refer to ebuilds in rox-extra/ or rox-base/
# need python to byte compile modules, if any
# need autotools to run autoreconf, if required
>=dev-util/pkgconfig-0.20"
fi
-# Utility functions
+# This is the new wrapper name (for /usr/bin/)
+# It is also used for the icon name in /usr/share/pixmaps
+#
+# Use rox-${PN} unless ${PN} already starts with 'rox'
+a="rox-${PN}"
+b=${a/rox-rox*}
+WRAPPERNAME=${b:-${PN}}
+
+# This is the location where all applications are installed
+APPDIR="/usr/lib/rox"
+LIBDIR="/usr/lib"
+
+# Utility Functions
+
+# Creates a .desktop file for this rox application
+# (Adapted from eutils::make_desktop_entry)
+#
+# rox_desktop_entry <exec> <name> <icon> <type> [<extra> ...]
+# exec - The executable to run
+# name - The name to display
+# icon - The icon file to display
+# Any other arguments will be appended verbatim to the desktop file.
+#
+# The name of the desktop file will be ${exec}.desktop
+#
rox_desktop_entry() {
- # make_desktop_entry(<command>, [name], [icon], [type], [path])
- make_desktop_entry ${APPNAME} ${APPNAME} \
- "${APPICON}" "${APPCATEGORY};ROX"
+ # Coppied from etuils:make_desktop_entry
+ local exec=${1}; shift
+ local name=${1}; shift
+ local icon=${1}; shift
+ local type=${1}; shift
+
+ local desktop="${exec}.desktop"
+
+ cat <<-EOF > "${desktop}"
+ [Desktop Entry]
+ Encoding=UTF-8
+ Version=1.0
+ Name=${name}
+ Type=Application
+ Comment=${DESCRIPTION}
+ Exec=${exec}
+ TryExec=${exec%% *}
+ Icon=${icon}
+ Categories=ROX;Application;${type};
+ EOF
+
+ local extra=${1}; shift
+ while [[ "${extra}" ]]; do
+ echo "${extra}" >> "${desktop}"
+ extra=${1}; shift
+ done
+
+ (
+ # wrap the env here so that the 'insinto' call
+ # doesn't corrupt the env of the caller
+ insinto /usr/share/applications
+ doins "${desktop}"
+ )
}
# Exported functions
eautoconf
cd ..
fi
- export LIBDIRPATH="/usr/lib/"
+ export LIBDIRPATH="${LIBDIR}"
# Most rox self-compiles have a 'read' call to wait for the user to
# press return if the compile fails.
done
fi
- insinto /usr/lib/rox
+ insinto ${APPDIR}
# Use 'cp -pPR' and not 'doins -r' here so we don't have to do a flurry of
# 'chmod' calls on the executables in the appdir - Just be sure that all the
# files in the original appdir prior to this step are correct, as they will
# all be preserved.
- cp -pPR ${APPNAME} ${D}/usr/lib/rox/${APPNAME}
+ cp -pPR ${APPNAME} ${D}${APPDIR}/${APPNAME}
#create a script in bin to run the application from command line
dodir /usr/bin/
- cat >"${D}/usr/bin/${APPNAME}" <<EOF
+ cat >"${D}/usr/bin/${WRAPPERNAME}" <<EOF
#!/bin/sh
-exec "/usr/lib/rox/${APPNAME}/AppRun" "\$@"
+if [[ "\${LIBDIRPATH}" ]]; then
+ export LIBDIRPATH="\${LIBDIRPATH}:${LIBDIR}"
+else
+ export LIBDIRPATH="${LIBDIR}"
+fi
+
+if [[ "\${APPDIRPATH}" ]]; then
+ export APPDIRPATH="\${APPDIRPATH}:${APPDIR}"
+else
+ export APPDIRPATH="${APPDIR}"
+fi
+exec "${APPDIR}/${APPNAME}/AppRun" "\$@"
EOF
- chmod 755 "${D}/usr/bin/${APPNAME}"
-
- # Copy the .DirIcon into /usr/share/pixmaps with the proper extension
- if [[ -f "${APPNAME}/.DirIcon" ]]; then
- local APPDIRICON=${APPNAME}/.DirIcon
- case "$(file -b ${APPDIRICON})" in
- "PNG image data"*)
- export APPICON=${APPNAME}.png
- ;;
- "XML 1.0 document text"*)
- export APPICON=${APPNAME}.svg
- ;;
- "X pixmap image text"*)
- export APPICON=${APPNAME}.xpm
- ;;
- "symbolic link"*)
- APPDIRICON=$(dirname $APPDIRICON)/$(readlink $APPDIRICON)
- export APPICON=${APPNAME}.${APPDIRICON##*.}
- ;;
- *)
- # Unknown... Remark on it, and just copy without an extension
- export APPICON=${APPNAME}
- ;;
- esac
- insinto /usr/share/pixmaps
- newins "${APPDIRICON}" "${APPICON}"
+ chmod 755 "${D}/usr/bin/${WRAPPERNAME}"
+
+ # Old name of cmdline wrapper: /usr/bin/${APPNAME}
+ if [[ ! "${APPNAME_COLLISION}" ]]; then
+ ln -s ${WRAPPERNAME} ${D}/usr/bin/${APPNAME}
+ # TODO: Migrate this away... eventually
+ else
+ ewarn "The wrapper script /usr/bin/${APPNAME} has been removed"
+ ewarn "due to a name collision. You must run ${APPNAME} as"
+ ewarn "/usr/bin/${WRAPPERNAME} instead."
fi
- #now compile any and all python files
- python_mod_optimize "${D}/usr/lib/rox/${APPNAME}" >/dev/null 2>&1
-
# Create a .desktop file if the proper category is supplied
if [[ -n "${APPCATEGORY}" ]]; then
- rox_desktop_entry
+ # Copy the .DirIcon into /usr/share/pixmaps with the proper extension
+ if [[ -f "${APPNAME}/.DirIcon" ]]; then
+ local APPDIRICON=${APPNAME}/.DirIcon
+ case "$(file -b ${APPDIRICON})" in
+ "PNG image data"*)
+ export APPICON=${WRAPPERNAME}.png
+ ;;
+ "XML 1.0 document text"*)
+ export APPICON=${WRAPPERNAME}.svg
+ ;;
+ "X pixmap image text"*)
+ export APPICON=${WRAPPERNAME}.xpm
+ ;;
+ "symbolic link"*)
+ APPDIRICON=$(dirname ${APPDIRICON})/$(readlink ${APPDIRICON})
+ export APPICON=${WRAPPERNAME}.${APPDIRICON##*.}
+ ;;
+ *)
+ # Unknown... Remark on it, and just copy without an extension
+ ewarn "Could not detect the file type of the application icon,"
+ ewarn "copying without an extension."
+ export APPICON=${WRAPPERNAME}
+ ;;
+ esac
+ insinto /usr/share/pixmaps
+ newins "${APPDIRICON}" "${APPICON}"
+ fi
+
+ rox_desktop_entry "${WRAPPERNAME}" "${APPNAME}" "${APPICON}" "${APPCATEGORY}"
fi
+
+ #now compile any and all python files
+ python_mod_optimize "${D}${APPDIR}/${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 "${APPNAME} has been installed into ${APPDIR}"
+ einfo "You can run it by typing ${WRAPPERNAME} 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 "install location -- ${APPDIR} -- and click"
einfo "on ${APPNAME}'s icon, drag it to a panel, desktop, etc."
}