diff options
author | Jim Ramsay <lack@gentoo.org> | 2007-11-28 14:20:58 +0000 |
---|---|---|
committer | Jim Ramsay <lack@gentoo.org> | 2007-11-28 14:20:58 +0000 |
commit | 6d47d8bfde681ceb3497917af4222589e07c0d39 (patch) | |
tree | e6d9990240cb4cc20c41dd3de59507b4e63e0cbe /eclass/rox.eclass | |
parent | * bump (diff) | |
download | gentoo-2-6d47d8bfde681ceb3497917af4222589e07c0d39.tar.gz gentoo-2-6d47d8bfde681ceb3497917af4222589e07c0d39.tar.bz2 gentoo-2-6d47d8bfde681ceb3497917af4222589e07c0d39.zip |
Minor reorganization, also added support for APPMIME variable in ebuilds to set
the MimeType of the created .desktop files.
Diffstat (limited to 'eclass/rox.eclass')
-rw-r--r-- | eclass/rox.eclass | 187 |
1 files changed, 117 insertions, 70 deletions
diff --git a/eclass/rox.eclass b/eclass/rox.eclass index b22cf75b8c2f..fce433b2fd1f 100644 --- a/eclass/rox.eclass +++ b/eclass/rox.eclass @@ -1,13 +1,13 @@ # 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.22 2007/06/12 20:15:22 lack Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/rox.eclass,v 1.23 2007/11/28 14:20:58 lack Exp $ -# ROX eclass Version 2 +# ROX eclass Version 3 # 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) +# Small fixes and current maintenance by Jim Ramsay (lack@gentoo.org) # These variables are used in the GLOBAL scope to decide on DEPENDs, so they # must be set BEFORE you 'inherit rox': @@ -16,7 +16,7 @@ # 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 +# These variables are only used inside functions, and so may be set anywhere in # the ebuild: # # APPNAME - the actual name of the application as the app folder is named @@ -31,8 +31,17 @@ # 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 +# APPMIME - the .desktop MimeTypes value to include. This is a +# semicolon-delimited list of mime-types. Any characters in [[:space:]] are +# ignored. If the supported mime-types are dependent upon USE flags, the new +# 'usemime' function may be useful. For example: +# APPMIME="a/foo-1;a/foo-2 +# $(usemime three "a/three") +# text/plain" +# will be expanded to either "a/foo-1;a/foo-2;a/three;text/plain" if USE=three +# or "a/foo-1;a/foo-2;text/plain" if not. # 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 +# but will do a 'make clean' in it. This is useful if users wish to # preserve the source code for some reason # For examples refer to ebuilds in rox-extra/ or rox-base/ @@ -63,16 +72,34 @@ fi # 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}} +_a="rox-${PN}" +_b=${_a/rox-rox*} +WRAPPERNAME=${_b:-${PN}} +unset _a _b # This is the location where all applications are installed APPDIR="/usr/$(get_libdir)/rox" LIBDIR="/usr/$(get_libdir)" +# External Functions + +# Used for assembling APPMIME with USE-dependent parts +usemime() { + local myuse=$1; shift + useq $myuse && echo "$@" +} + # Utility Functions +# Expands APPMIME properly, removing whitespace, newlines, and putting in ';' +# where needed. +expandmime() { + local old_IFS=$IFS + IFS=";$' \t\n'" + echo "$*" + IFS=$old_IFS +} + # Creates a .desktop file for this rox application # (Adapted from eutils::make_desktop_entry) # @@ -112,71 +139,20 @@ rox_desktop_entry() { extra=${1}; shift done + # Subshell, so as to not pollute the caller's env. ( - # 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 -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="${LIBDIR}" - - # 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 - if [[ -d build ]]; then - rm -rf build - fi - - # 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 ${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}${APPDIR}/${APPNAME} - +# +# Install the wrapper in /usr/bin for commandline execution +# +# Environment needed: +# WRAPPERNAME, APPDIR, LIBDIR, APPNAME, APPNAME_COLLISION +# +rox_install_wrapper() { if [[ "${WRAPPERNAME}" != "skip" ]]; then #create a script in bin to run the application from command line dodir /usr/bin/ @@ -199,7 +175,7 @@ EOF # Old name of cmdline wrapper: /usr/bin/${APPNAME} if [[ ! "${APPNAME_COLLISION}" ]]; then - ln -s ${WRAPPERNAME} ${D}/usr/bin/${APPNAME} + ln -s ${WRAPPERNAME} "${D}/usr/bin/${APPNAME}" # TODO: Migrate this away... eventually else ewarn "The wrapper script /usr/bin/${APPNAME} has been removed" @@ -207,7 +183,12 @@ EOF ewarn "/usr/bin/${WRAPPERNAME} instead." fi fi +} +# +# Copy the .DirIcon into the pixmaps dir, and create the .desktop file +# +rox_install_desktop() { # Create a .desktop file if the proper category is supplied if [[ -n "${APPCATEGORY}" ]]; then # Copy the .DirIcon into /usr/share/pixmaps with the proper extension @@ -234,14 +215,80 @@ EOF export APPICON=${WRAPPERNAME} ;; esac + # Subshell, so as to not pollute the caller's env. + ( insinto /usr/share/pixmaps newins "${APPDIRICON}" "${APPICON}" + ) fi - rox_desktop_entry "${WRAPPERNAME}" "${APPNAME}" "${APPICON}" "${APPCATEGORY}" + rox_desktop_entry "${WRAPPERNAME}" "${APPNAME}" "${APPICON}" \ + "${APPCATEGORY}" "MimeType=$(expandmime $APPMIME)" fi +} + +# Exported functions +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 + # some packages (such as rox-base/pager-1.0.1) + eautoconf + cd .. + fi + export LIBDIRPATH="${LIBDIR}" + + # 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 + emake -C src clean + else + rm -rf src + fi + if [[ -d build ]]; then + rm -rf build + fi + + # 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 ${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}${APPDIR}/${APPNAME}" + + # Install the wrapper in /usr/bin + rox_install_wrapper + + # Install the .desktop application file + rox_install_desktop - #now compile any and all python files + # Finally, optimize any python files python_mod_optimize "${D}${APPDIR}/${APPNAME}" >/dev/null 2>&1 } |