]> git.wh0rd.org Git - home.git/commitdiff
more profile updates
authorMike Frysinger <vapier@gentoo.org>
Mon, 31 Oct 2011 18:53:10 +0000 (14:53 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Apr 2012 19:36:40 +0000 (15:36 -0400)
.bashrc
.profile.d/.post.sh [new file with mode: 0644]
.profile.d/.pre.sh [new file with mode: 0644]
.profile.d/ROOT-bashrc
.profile.d/bfin-alias.sh [new file with mode: 0644]
.profile.d/google.sh

diff --git a/.bashrc b/.bashrc
index 7293877205e9c411b08ee55a2a4c103f10d075a9..ad9468a90328d2a80fb6c8d84260ba1a42f9af03 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -1,15 +1,13 @@
 umask 0022
 
-for sh in ~/.profile.d/*.sh ; do
+for sh in ~/.profile.d/{.pre,*}.sh ; do
        . "$sh"
 done
 unset sh
 
-for p in /sbin /usr/sbin /usr/games/bin /usr/lib*/ccache /usr/lib*/ccache/*/ ~/.bin ; do
-       case :$PATH: in *:$p:*) continue;; esac
-       [ -d "${p}" ] && PATH=${p}:$PATH
-done
-unset p
+path_prepend /sbin /usr/sbin /usr/games/bin /usr/lib*/ccache /usr/lib*/ccache/*/ ~/.bin
+
+. ~/.profile.d/.post.sh
 
 s=$'\001' e=$'\002'
 export JTAG_PROMPT=$s'\e[30;1m\e[34;1m'$e'jtag'$s'\e[30;1m'$e'>'$s'\e[0m'$e' '
diff --git a/.profile.d/.post.sh b/.profile.d/.post.sh
new file mode 100644 (file)
index 0000000..573a690
--- /dev/null
@@ -0,0 +1 @@
+unset path_prepend path_append
diff --git a/.profile.d/.pre.sh b/.profile.d/.pre.sh
new file mode 100644 (file)
index 0000000..f96e3e9
--- /dev/null
@@ -0,0 +1,16 @@
+path_prepend() {
+       local p
+       for p in "$@" ; do
+               if [[ :${PATH}: != *:${p}:* ]] && [[ -d ${p} ]] ; then
+                       PATH="${p}:${PATH}"
+               fi
+       done
+}
+path_append() {
+       local p
+       for p in "$@" ; do
+               if [[ :${PATH}: != *:${p}:* ]] && [[ -d ${p} ]] ; then
+                       PATH+=":${p}"
+               fi
+       done
+}
index 771bfd36a0afdcbe1b12bf363cd5ecdf1a07087e..240b10ae30385aabb29694a656b41c35ed9f164c 100644 (file)
@@ -1,4 +1,4 @@
-for sh in /home/vapier/.profile.d/*.sh ; do
+for sh in /home/vapier/.profile.d/{.pre,*,.post}.sh ; do
        . "$sh"
 done
 unset sh
diff --git a/.profile.d/bfin-alias.sh b/.profile.d/bfin-alias.sh
new file mode 100644 (file)
index 0000000..8c4edf8
--- /dev/null
@@ -0,0 +1,232 @@
+bfin_path() {
+       (
+               set -C
+               rm -f /tmp/bfin-reset-PATH.$$
+               echo "${PATH}" > /tmp/bfin-reset-PATH.$$
+       )
+       trap "rm -f /tmp/bfin-reset-PATH.$$" EXIT
+
+       eval $(
+       local p
+       local quiet=false use_ccache=true
+       [[ $1 == -q || $1 == --quiet ]] && quiet=true && shift
+       [[ $1 == -nc ]] && use_ccache=false && shift
+       if [[ -z $* ]] ; then
+               if [[ -d /usr/local/src/blackfin/toolchains/current ]] ; then
+                       set -- $(eval echo /usr/local/src/blackfin/toolchains/current/{linux-uclibc,uclinux,elf})
+               else
+                       for d in /opt/uClinux /opt/uClinux-svn ; do
+                               [ -d "$d" ] && set -- $d
+                       done
+               fi
+       fi
+       if [[ $# -eq 0 ]] ; then
+               echo "bfin_path: unable to locate a good toolchain" 1>&2
+               echo return 1
+               exit 1
+       elif [[ $# -eq 1 ]] ; then
+               p=""
+               local pp ppp
+               for pp in elf uclinux linux-uclibc ; do
+                       if [[ -e $1/out-${pp}/bin ]] ; then
+                               p="out-"
+                       elif [[ -e $1/bfin-${pp}/bin ]] ; then
+                               p="bfin-"
+                       else
+                               continue
+                       fi
+                       ppp="${ppp},${pp}"
+               done
+               set -- $(eval echo $1/${p}{${ppp:1}}/bin)
+       fi
+       echo export _BFIN_PATH=\'$*\'
+       for p in "$@" ; do
+               p=$(readlink -f ${p})
+               pushd ${p} > /dev/null || return 1
+               local ccache=$(type -P ccache)
+               ${use_ccache} || ccache=""
+               if [[ -n ${ccache} ]] && [[ ! -d ccache ]] ; then
+                       if ! mkdir -p ccache >& /dev/null ; then
+                               (
+                               echo ""
+                               echo "FAIL: ccache creation with $p; please do:"
+                               echo " sudo mkdir '${p}/ccache'"
+                               echo " sudo chown ${USER}:users '${p}/ccache'"
+                               ) 1>&2
+                       fi
+               fi
+               if [[ -n ${ccache} ]] && [[ -d ccache ]] ; then
+                       if [[ ! -d ccache/scripts ]] ; then
+                               mkdir -p ccache/{output,scripts,symlinks}
+                               cd ccache
+                               local x xx
+
+                               cat <<-EOF > scripts/.wrapper
+                                       #!/bin/bash
+                                       x=\${0##*/}
+                                       p=\${0%/*}
+                                       p=\${p%/ccache/scripts}
+                                       export CCACHE_DIR=\${p}/ccache/output
+                                       export PATH=\${p}:\${PATH}
+                                       exec \${p}/ccache/symlinks/\${x} "\$@"
+                               EOF
+                               chmod a+rx scripts/.wrapper
+
+                               x=$(find .. -maxdepth 1 -name '*-gcc' -printf '%P')
+                               xx=${x%-gcc}-ccache
+                               cat <<-EOF > scripts/${xx}
+                                       #!/bin/bash
+                                       p=\${0%/*}
+                                       p=\${p%/ccache/scripts}
+                                       export CCACHE_DIR=\${p}/ccache/output
+                                       export PATH=\${p}:\${PATH}
+                                       exec ccache "\$@"
+                               EOF
+                               chmod a+rx scripts/${xx}
+
+                               for x in gcc c++ g++ ; do
+                                       for xx in $(find .. -maxdepth 1 '(' -name "*-${x}" -o -name "*-${x}-*" ')' -printf '%P ') ; do
+                                               ln scripts/.wrapper scripts/${xx}
+                                               ln -fs ${ccache} symlinks/${xx}
+                                       done
+                               done
+                       fi
+                       echo export UCLINUX_USE_CCACHE=no # we handle it ourself
+                       ${quiet} || echo "Adding ${p} (w/ccache)" 1>&2
+                       export PATH=${PATH}:${p}/ccache/scripts:${p}
+                       echo export PATH=\"${PATH}\"
+               else
+                       ${quiet} || echo "Adding ${p} to PATH" 1>&2
+                       export PATH=${PATH}:${p}
+                       echo export PATH=\"${PATH}\"
+               fi
+               popd > /dev/null
+       done
+       )
+       unset -f bfin_path
+
+       local g
+       for g in bfin-{{linux-uclibc,uclinux,elf}-gdb{,tui},gdbproxy,jtag} ; do
+               type -P ${g} >& /dev/null && alias ${g}="${g} --quiet"
+               type -P ${g} >& /dev/null && alias ${g}="${g} --quiet"
+       done
+
+       bfin-reset() {
+               export PATH=$(</tmp/bfin-reset-PATH.$$)
+               rm -f /tmp/bfin-reset-PATH.$$
+               source /usr/local/src/blackfin/git/toolchain/distribution/snapshots/bfin-alias
+               local g
+               for g in $(alias 2>&1 | sed -n '/^alias bfin-/{s:^alias ::;s:=.*::;p}') ; do
+                       unalias ${g}
+               done
+               for g in $(declare 2>&1 | awk '$0 ~ /^bfin-/ { print $1 }') ; do
+                       unset -f ${g}
+               done
+       }
+
+       bfin-set-gcc-ver() {
+               local ver=$1
+               if [[ -z ${ver} || -n $2 ]] ; then
+                       echo "Usage: bfin-set-gcc-ver <gcc ver>"
+                       return 1
+               fi
+
+               local b bb
+               for b in ${_BFIN_PATH} ; do
+                       for bb in $(echo ${b}/*-${ver}) ; do
+                               b=${bb%-${ver}}
+                               if [[ ! -x ${bb} ]] ; then
+                                       echo "Not found: ${bb}"
+                                       continue
+                               fi
+                               rm -f "${b}"
+                               cp -a "${b}-${ver}" "${b}"
+                               echo "${b##*/} -> ${bb##*/}"
+                       done
+               done
+       }
+
+       bfin-cpu-reset() {
+               bfin-jtag <<-EOF
+               cable probe
+               detect
+               bfin emulation enter
+               bfin reset
+               bfin emulation exit
+               quit
+               EOF
+       }
+
+       bfin-cpu-uboot() {
+               local init=$1 elf=$2
+               [[ -z $elf ]] && echo "Usage: bfin-cpu-uboot <init> <elf>" && return 1
+               killall -q bfin-gdbproxy
+               bfin-gdbproxy -q bfin --reset &
+               local pid=$!
+               sleep 3s
+               bfin-elf-gdb -q -batch \
+                       --ex "target remote localhost:2000" \
+                       --ex "load $init" \
+                       --ex c \
+                       --ex load \
+                       --ex "call memset(&_bss_start, 0, &_bss_end - &_bss_start)" \
+                       --ex c \
+                       "$elf"
+               kill ${pid}
+       }
+}
+
+switch_svn() {
+       local localserv=$(</usr/local/src/blackfin/.svn.local)
+       local remotserv="svn+ssh://${USER}@firewall-sources.blackfin.uclinux.org"
+       [[ -z ${localserv} ]] && return 1
+
+       normalize_svn_trail() {
+               local var=$1
+               local val=${!var}
+               while [[ ${val} == */svn ]] || [[ ${val} == */ ]] ; do
+                       val=${val%/svn}
+                       val=${val%/}
+               done
+               eval ${var}="${val}"
+       }
+       normalize_svn_lead() {
+               local var=$1
+               local val=${!var}
+               while [[ ${val} == svn/* ]] || [[ ${val} == /* ]] ; do
+                       val=${val#svn/}
+                       val=${val#/}
+               done
+               eval ${var}="${val}"
+       }
+
+       normalize_svn_trail localserv
+       normalize_svn_trail remotserv
+
+       local newurl url=$(svn info | grep ^URL:) oldurl
+       [[ -z ${url} ]] && return 1
+       url=${url#URL: }
+       oldurl=${url}
+       case ${url} in
+               ${remotserv}*)
+                       url=${url#${remotserv}}
+                       normalize_svn_lead url
+                       newurl=${localserv}/svn/${url}
+                       ;;
+               ${localserv}*)
+                       url=${url#${localserv}}
+                       normalize_svn_lead url
+                       newurl=${remotserv}/svn/${url}
+                       ;;
+               *)
+                       echo "Unknown url: ${url}; switching to local"
+                       remotserv=${url##*//}
+                       remotserv=${remotserv#*/}
+                       newurl="${localserv}/svn/${remotserv##svn/}"
+                       ;;
+       esac
+       (set -x; svn switch --relocate ${oldurl} ${newurl} "$@")
+
+       unset normalize_svn_trail
+       unset normalize_svn_lead
+}
index 9b37d72d7acb58b0de742370de1646a7addfc821..b00413a2288cf018e0cd2e65a8b0346b158b56e5 100644 (file)
@@ -1,3 +1,5 @@
-if [ -d ~/chromiumos/depot_tools ] ; then
-       PATH="${PATH}:`echo ~`/chromiumos/depot_tools"
+path_prepend "`echo ~`/chromiumos/depot_tools"
+if [ -d ~/gentoo ] ; then
+       export EPREFIX="$HOME/gentoo"
+       path_append "$EPREFIX/usr/bin"
 fi