Search:  
Gentoo Wiki

Adapt_an_existing_ebuild

Contents

About

This page is a short collection of hints to help people adapting existing ebuilds to work with Gentoo/Solaris. This is mainly a collection of common pieces of code to use in various situations.

Keywords

The whole system relies on a new ARCH keyword, x86-sunos. All the ebuilds should have this keyword added in order to be merged into your system. To do so, simply find in your ebuild the line starting with KEYWORDS and put the x86-sunos keyword at the end (before the hyphens). For example:

KEYWORDS="x86 sparc x86-sunos"

USE Flags

In the path to make the work cleaner, two keywords have been defined and set into the default profile. They are:

Patches

GNU-ization

By using USERLAND

The following code can be use to auto-GNU-ize the package. GNU command should be created in /usr/bin with program-prefix=g and in /usr/gnu/bin/ without program-prefix

Code: Ebuild modifications
 src_compile() {
        ...
        [[ ${USERLAND} == "SunOS" ]] && myconf="${myconf} --program-prefix=g"
        ...
 }
 ...
 src_install() {
         ...
         if use gnulinks ; then
            [[ ! -z ${GNU_PREFIX} ]] || die "Environment variable GNU_PREFIX must be set."
            # create symlinks in /usr/gnu/bin
            dodir ${GNU_PREFIX}/bin
            cd "${D}"
            for d in usr/bin bin; do
                if [ -d ${d} ]; then
                    einfo "Creating links in ${GNU_PREFIX}/bin"
                    local x
                    for x in * ; do
                        if use g-prefix; then
                            einfo "${d}/${x} -> ${GNU_PREFIX}/${d}/${x:1}"
                            dosym /${d}/${x} ${GNU_PREFIX}/${d}/${x:1} #removes leading 'g'
                        else
                            dosym /${d}/${x} ${GNU_PREFIX}/${d}/${x}
                        fi
                    done
                fi
            done
        fi

         ...
 }

By using new USE flags

This is a "GNU" (read it as "new") way to GNU-ize the command. It relies on a couple of USE flags: gnulinks and g-prefix

Code: Ebuild modifications continued
 if use g-prefix ; then
     pprefix="g"
     myconf="${myconf} --program-prefix=${pprefix}"
 fi

        if use gnulinks ; then
                [[ ! -z ${GNU_PREFIX} ]] || die "Environment variable GNU_PREFIX must be set."
                # create symlinks in /usr/gnu/bin
                dodir ${GNU_PREFIX}/bin
                cd "${D}"
                for d in usr/bin bin; do
                        if [ -d ${d} ]; then
                                cd ${d}
                                einfo "Creating links from ${d} in ${GNU_PREFIX}/bin"
                                local x
                                for x in * ; do
                                        if [ -x ${x} ]; then
                                                if use g-prefix; then
                                                        dosym /${d}/${x} ${GNU_PREFIX}/bin/${x:1} #removes leading 'g'
                                                else
                                                        dosym /${d}/${x} ${GNU_PREFIX}/bin/${x}
                                                fi
                                        fi
                                done
                        fi
                done
        fi

Common issues

The following pieces of code can be used to solve common problem that you can encounter the first time you try to emerge an ebuild. Take them and put in a suitable part of the ebuild. Usually in the src_unpack function after the patch part:

Linker: truble with -soname parameter for ld

Problem description: the SUN ld does not understand the -soname parameter. An error occur if you try to use it.

[[ ${USERLAND} == "SunOS" ]] && sed -i 's/-Wl,-soname -Wl,<library name>//' "${S}"/Makefile

Shell scripts: change /bin/sh to /bin/bash

Problem description: under SunOS userland, the /bin/sh is the standard SUN shell. GNU bash is /bin/bash, so a sobstitution is required.

[[ ${USERLAND} == "SunOS" ]] && sed -e 's%#!/bin/sh%#!/bin/bash%' -i <shell script>

Problem with GNU ld scripts

Problem description:

example: see sys-libs/zlib

Problems with i18n packages and nls flag

Solaris has a separate library for i18n support that is called i18n, so each package that has nls spport must link against this library. The solution is to simply add:

 use x86-sunos && append-ldflags -lintl

into the ebuild

Retrieved from "http://www.gentoo-wiki.info/Adapt_an_existing_ebuild"

Last modified: Sat, 23 Aug 2008 10:06:00 +0000 Hits: 2,874