From 93c5d62ddcc86bae5b84cc38a1c5bfa08b56a2c0 Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Thu, 7 Jun 2007 19:35:32 +0000 Subject: Commiting initial overlay: multilib changes and preliminary zeroinstall support svn path=/trunk/overlay/; revision=2 --- eclass/0install.eclass | 137 ++++++++++++++++++++++++ eclass/rox.eclass | 282 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 419 insertions(+) create mode 100644 eclass/0install.eclass create mode 100644 eclass/rox.eclass (limited to 'eclass') diff --git a/eclass/0install.eclass b/eclass/0install.eclass new file mode 100644 index 0000000..303371a --- /dev/null +++ b/eclass/0install.eclass @@ -0,0 +1,137 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# +# Original Author: Jim Ramsay +# Purpose: Utility functions for 0install compatibility +# + +# TODO: Install this all the time? +RDEPEND="rox-base/zeroinstall-injector" + +# Environment: +LOCAL_FEED_DIR="/etc/xdg/0install.net/local_feeds" +ZEROINSTALL_STRIP_REQUIRES="" + +# Escapes a http-style URI into a 0install-compatible filename +# +# 0install_escape_uri +# uri - The URI to escape +0install_escape_uri() { + local uri=${1} + uri=${uri//:/%3a} + uri=${uri//\//%2f} + echo $uri +} + +# Parses an implementation, returning the interface URI +# +# 0install_parse_uri +# src - The XML document to parse +0install_parse_uri() { + local src="${1}" + + [ -f "${src}" ] || die "Source file not found" + local feed_for=$(grep '} + echo $feed_for +} + +# Edits a feed, replacing stability and id +# +# 0install_edit_feed +# input - The file to edit +# output - The final install location (relative to ${D}) +0install_edit_feed() { + local input="${1}"; shift + local output="${1}"; shift + + [ -f "${input}" ] || die "No input file" + + # Basic editing: + # - Remove stability="*" + # - Remove uri="*" + # - Replace id="*" with id=".", add in stability="packaged" + # - Force main="AppRun" + sed -e 's/stability="[^"]*"//' \ + -e "s/stability='[^']*'//" \ + -e 's/uri="[^"]*"//' \ + -e "s/uri='[^']*'//" \ + -e 's/id="[^"]*"/id="." stability="packaged"/' \ + -e "s/id='[^']*'/id=\".\" stability=\"packaged\"/" \ + -e 's/main="[^"]*"/main="AppRun"/' \ + -e "s/main='[^']*'/main=\"AppRun\"/" \ + ${input} > tmp.local_feed + + if [[ -n "${ZEROINSTALL_STRIP_REQUIRES}" ]]; then + # Strip out all 'requires' sections + sed -i -e '//d' \ + -e '//,/<\/requires>/d' tmp.local_feed + fi + + ( + insinto $(dirname ${output}) + newins tmp.local_feed $(basename ${output}) + ) +} + +# Installs an ebuild-provided feed +# +# 0install_install_feed +# src - The XML file we will install and point at +# path - The path where the implementation will be installed +# IE, the final xml will be at / +0install_install_feed() { + local src="${1}"; shift + local path="${1}"; shift + local feedfile=$(basename "${src}") + local dest="${path}/$feedfile" + + # Step 1: Find the URI + local uri=$(0install_parse_uri "${src}") + + # Step 2: Install the feed in the proper location + ( + insinto $(dirname "${dest}") + newins "${src}" $(basename "${dest}") + ) + + # Step 3: Install the symlink so 0install can find it + local feedname=$(0install_escape_uri ${uri}) + dosym "${dest}" "${LOCAL_FEED_DIR}/${feedname}" +} + +# Does all the local feed magic you could want: +# - Parses the input file to get the interface URI +# - Edits the input file and installs it to the final location +# - Installs a local feed pointer +# +# Environment variables: +# ZEROINSTALL_STRIP_REQUIRES - If set, strips all 'requires' sections from the XML +# on editing. Default: Not set +# +# 0install_local_feed +# src - The XML file we will edit, install, and point at +# path - The path where the implementation will be installed +# IE, the final edited xml will be at / +0install_local_feed() { + local src="${1}"; shift + local path="${1}"; shift + local feedfile=$(basename "${src}") + local dest="${path}/$feedfile" + + # Step 1: Find the URI + local uri=$(0install_parse_uri "${src}") + + # Step 2: Edit the input and install it in the proper location + 0install_edit_feed "${src}" "${dest}" + + # Step 3: Install the symlink so 0install can find it + local feedname=$(0install_escape_uri ${uri}) + dosym "${dest}" "${LOCAL_FEED_DIR}/${feedname}" +} + + diff --git a/eclass/rox.eclass b/eclass/rox.eclass new file mode 100644 index 0000000..0b5cc50 --- /dev/null +++ b/eclass/rox.eclass @@ -0,0 +1,282 @@ +# 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.20 2007/02/09 17:27:39 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 +# 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 some reason. + +# TODO: Not used yet +# FEED_FILES - The list of files te check for a 0install feed. If found, this +# feed will be edited, and installed such that 0install can see it. If you set +# 'ZEROINSTALL_STRIP_REQUIRES' this editing will also strip any 3rd-party +# requirements from the feed as well. +# Default: "${APPNAME}/${APPNAME}.xml ${APPNAME}.xml" +# LOCAL_FEED_SRC - If set, will install the ebuild-supplied feed file so 0install +# can see it. This feed will not be edited, but installed as-is. +# Default: Not set + +# 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 +inherit multilib python autotools eutils # 0install + +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 + +# 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}} + +# Default for LOCAL_FEED_SRC +LOCAL_FEED_SRC="" + +# This is the location where all applications are installed +APPDIR="/usr/$(get_libdir)/rox" +LIBDIR="/usr/$(get_libdir)" + +# Utility Functions + +# Creates a .desktop file for this rox application +# (Adapted from eutils::make_desktop_entry) +# +# rox_desktop_entry [ ...] +# 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() { + # 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 +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: + # TODO: Use 0compile instead, maybe? + 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/' 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} + + #create a script in bin to run the application from command line + dodir /usr/bin/ + cat >"${D}/usr/bin/${WRAPPERNAME}" </dev/null 2>&1 +} + +rox_pkg_postinst() { + 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 -- ${APPDIR} -- and click" + einfo "on ${APPNAME}'s icon, drag it to a panel, desktop, etc." +} + +EXPORT_FUNCTIONS src_compile src_install pkg_postinst -- cgit v1.2.3-65-gdbad