[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Contributing with KDE 4
From:       Thiago Macieira <thiago () kde ! org>
Date:       2007-02-14 12:46:42
Message-ID: 200702141346.42685.thiago () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Lorenzo Bettini wrote:
>and could you please share this script?

Attaching mine.
-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

["bash_functions" (text/x-makefile)]

# -*- mode: sh -*-
function cdreplace()
{
    newdir=${PWD/$1/$2}
    command cd "$newdir"
}

function updatedirs()
{
    # initialise variables
    local devhome=${DEVHOME-$HOME}
    local srchome=${SRCHOME-$devhome/src}
    local objhome=${OBJHOME-$devhome/obj}

    # the other ones
    export srcdir=$PWD
    export objdir=$PWD

    # find out if we're in src or obj
    case "$PWD" in
	$srchome*)
	    # we're in a srcdir - try to find the objdir
	    objdir=${PWD/#$srchome/$objhome}
	    ;;
	$objhome*)
	    # we're in an objdir - try to find the srcdir
	    srcdir=${PWD/#$objhome/$srchome}
	    ;;
    esac

    if [ \! -d "$srcdir" ]; then
	srcdir=$PWD
    fi
    if [ \! -d "$objdir" ]; then
	objdir=$PWD
    fi
}

function cd()
{
    if [ $# -eq 2 ]; then
	cdreplace "$1" "$2"
    else
	command cd "$@"
    fi
    updatedirs
}

function pushd()
{
    command pushd "$@"
    updatedirs
}

function popd()
{
    command popd
    updatedirs
}

function src()
{
    cd obj src
}

function obj()
{
    cd src obj
}

function removefrom()
{
    local varname=$1
    local entry="$2"

    unset newvar
    for value in `IFS=: eval echo \\$$varname`; do
	if [ "$value" != "$entry" ]; then
	    newvar="${newvar}${newvar+:}${value}"
	fi
    done

    # Set it again
    eval $varname="$newvar"
    unset newvar
}

function addto()
{
    local varname=$1
    local newvalue=$2
    eval $varname="$newvalue:\${$varname}"
    eval $varname=\${$varname/%:}
}

function kde3()
{
    # Remove the current KDE from variables
    removefrom PATH $KDEDIR/bin
    removefrom LD_LIBRARY_PATH $KDEDIR/lib
    unset QT_PLUGIN_PATH
    unset KDEHOME
    unset KDETMP
    unset KDEVARTMP

    # Add the new ones
    export KDEDIR=/usr/local/kde3
    export KDEDIRS=$KDEDIR:/usr
    export PATH=$KDEDIR/bin:$PATH
    export XDG_CONFIG_DIRS=$KDEDIR/etc/xdg

    echo "Using KDE 3 ($KDEDIR)"
}

function kde4()
{
    # Remove the current KDE from variables
    removefrom PATH $KDEDIR/bin
    removefrom LD_LIBRARY_PATH $KDEDIR/lib

    # Add the new one
    export KDEDIR=$HOME/KDE4
    export KDEDIRS=$KDEDIR
    export KDEHOME=$HOME/.kde4
    export KDETMP=${TMPDIR-/tmp}/kde4-$USER
    export KDEVARTMP=/var/tmp/kde4cache-$USER
    export KDE_DATA_DIRS=$KDEDIR/share
    export PATH=$KDEDIR/bin:$PATH
    export XDG_CONFIG_DIRS=$KDEDIR/etc/xdg
    export QT_PLUGIN_PATH=$KDEDIR/lib/plugins

    # Ensure that they exist
    mkdir -p $KDEDIR $KDETMP $KDEVARTMP

    echo "Using KDE 4 ($KDEDIR)"
}

[Attachment #8 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic