[haiku-commits] haiku: hrev43776 - 3rdparty/mmu_man/scripts

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 23 Feb 2012 02:40:57 +0100 (CET)

hrev43776 adds 2 changesets to branch 'master'
old head: 7ee685d20ce9a34a74f42afedede9dd95d6666ea
new head: d4ad358195309bc43d96c70502b0948b3fe3f037

----------------------------------------------------------------------------

9130cab: Cleanup
  
  * separate unrelated code.
  * remove "function" bashism.
  * add a possible update command override variable $DEVUPCMD that is pushed to 
the history.

d4ad358: Added 'devup' function to autoupdate projects
  
  * scans projects for the AUTOUP tag in the .profile script.
  * runs the $DEVUPCMD sequentially with the needed environment.

                                          [ François Revol <revol@xxxxxxx> ]

----------------------------------------------------------------------------

1 files changed, 94 insertions(+), 10 deletions(-)
3rdparty/mmu_man/scripts/dev-perso |  104 ++++++++++++++++++++++++++++---

############################################################################

Commit:      9130cabf87695d0a22c62f90124726673b28821e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9130cab
Author:      François Revol <revol@xxxxxxx>
Date:        Thu Feb 23 00:56:30 2012 UTC

Cleanup

* separate unrelated code.
* remove "function" bashism.
* add a possible update command override variable $DEVUPCMD that is pushed to 
the history.

----------------------------------------------------------------------------

diff --git a/3rdparty/mmu_man/scripts/dev-perso 
b/3rdparty/mmu_man/scripts/dev-perso
index 7d020ce..c63bc27 100755
--- a/3rdparty/mmu_man/scripts/dev-perso
+++ b/3rdparty/mmu_man/scripts/dev-perso
@@ -56,7 +56,7 @@
 if [ -z "$DEVROOT" ]; then
        DRLIST="$HOME/devel /Data /work /Volumes/Data/devel"
        for d in $DRLIST; do
-               test -d $d && DEVROOT=$d && break;
+               test -d "$d" && DEVROOT="$d" && break;
        done
 fi
 export DEVROOT
@@ -64,14 +64,14 @@ export DEVROOT
 # automagically find password files
 PWLIST="/Data /fat32 $HOME"
 for d in $PWLIST; do
-       test -d $d/PASSWDS && PASSWDS=$d/PASSWDS && break;
+       test -d "$d/PASSWDS" && PASSWDS="$d/PASSWDS" && break;
 done
 export PASSWDS
 
 # svn sometimes forgets about vi and wants me to use nano...
 #export EDITOR=vim
 
-function dev() {
+dev() {
        if [ $# -lt 1 ]; then 
                #ls $DEVROOT/*/.profile | sed 's,.*/\([^/]*\)/.profile,\1,'
                for f in "$DEVROOT/"*; do test -e "$f/.profile" || continue; 
echo ${f##*/}; done
@@ -89,12 +89,16 @@ function dev() {
                mkdir "$DEVROOT/$1" && touch "$DEVROOT/$1/.profile"
                # fallback
        fi
+
        export DEVPROJ="$1"
        if [ ! -d "$DEVROOT/$1" ]; then
                echo "invalid project name '$1'"
                return 1
        fi
+
+       # change to the project root folder
        cd "$DEVROOT/$1"
+
        # use a specific history file
        export HISTFILE="$DEVROOT/$1/.bash_history"
        # and bump up the history limits
@@ -103,6 +107,10 @@ function dev() {
        export HISTCONTROL=ignoreboth
        # and force loading the new histfile
        history -r
+
+       # force default locale so that compiler errors and such are reported in 
english
+       #export LC_ALL=C.UTF-8
+
        # set the prompt
        # cf. http://tldp.org/HOWTO/Bash-Prompt-HOWTO/
        NICEPS1='\[\033[1m\][\u@\h \w]\[\033[0m\]\$ '
@@ -122,6 +130,7 @@ function dev() {
                export PROMPT_COMMAND='echo -en "\033]0;['$1':${PWD##*/}]\a"'
                ;;
        esac
+
        # lower priority so background builds don't slow the GUI too much
        case "$OSTYPE" in
        beos|haiku)
@@ -135,7 +144,9 @@ function dev() {
                #renice 3 $$
                ;;
        esac
-       
+
+       DEVUPCMD=""
+
        # source the specific profile file
        test -f .profile && . .profile
 
@@ -143,12 +154,15 @@ function dev() {
        test -z "$EDITOR" -a -z "$SVN_EDITOR" && export EDITOR=vim
        
        # make sure the update action is the first found in history.
-       test -d .svn && history -s svn up
-       test -d .bzr && history -s bzr update
-       test -d .hg && history -s hg pull
-       test -d .git && history -s git pull
-       test -d CVS && history -s cvs up -d
-       test -n "$P4PORT" && history -s p4 sync
+       if [ -z "$DEVUPCMD" ]; then
+               test -d .svn && DEVUPCMD="svn up"
+               test -d .bzr && DEVUPCMD="bzr update"
+               test -d .hg && DEVUPCMD="hg pull"
+               test -d .git && DEVUPCMD="git pull"
+               test -d CVS && DEVUPCMD="cvs up -d"
+               test -n "$P4PORT" && DEVUPCMD="p4 sync"
+       fi
+       test -n "$DEVUPCMD" && history -s "$DEVUPCMD"
 }
 
 complete -W complete -W "$(dev)" dev

############################################################################

Revision:    hrev43776
Commit:      d4ad358195309bc43d96c70502b0948b3fe3f037
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d4ad358
Author:      François Revol <revol@xxxxxxx>
Date:        Thu Feb 23 01:39:09 2012 UTC

Added 'devup' function to autoupdate projects

* scans projects for the AUTOUP tag in the .profile script.
* runs the $DEVUPCMD sequentially with the needed environment.

----------------------------------------------------------------------------

diff --git a/3rdparty/mmu_man/scripts/dev-perso 
b/3rdparty/mmu_man/scripts/dev-perso
index c63bc27..f1ffea0 100755
--- a/3rdparty/mmu_man/scripts/dev-perso
+++ b/3rdparty/mmu_man/scripts/dev-perso
@@ -167,4 +167,74 @@ dev() {
 
 complete -W complete -W "$(dev)" dev
 
+_devup_notify() {
+       echo "#### $*" >&2
+}
+
+devup() {
+       if [ $# -lt 1 ]; then 
+               #ls $DEVROOT/*/.profile | sed 's,.*/\([^/]*\)/.profile,\1,'
+               for f in "$DEVROOT/"*; do
+                       test -e "$f/.profile" || continue
+                       grep "^# AUTOUP$" "$f/.profile" > /dev/null 2>&1 || 
continue
+                       p="${f##*/}"
+                       _devup_notify "Updating $p..."
+                       devup "$p" && _devup_notify "Updated $p: OK" || 
(_devup_notify "Updating $p: Error: $?"; read)
+               done
+               return 0
+       fi
+
+       # subshell!!!
+       (
+
+       export DEVPROJ="$1"
+       if [ ! -d "$DEVROOT/$1" ]; then
+               echo "invalid project name '$1'"
+               return 1
+       fi
+
+       # change to the project root folder
+       cd "$DEVROOT/$1"
+
+       # lower priority so background builds don't slow the GUI too much
+       case "$OSTYPE" in
+       beos|haiku)
+               prio $$ 1
+               ;;
+       darwin10.*)
+               renice 3 $$
+               ;;
+       linux-*)
+               # linux doesn't really need it much
+               #renice 3 $$
+               ;;
+       esac
+
+       DEVUPCMD=""
+
+       # source the specific profile file
+       test -f .profile && . .profile
+
+       # make sure the update action is the first found in history.
+       if [ -z "$DEVUPCMD" ]; then
+               test -d .svn && DEVUPCMD="svn up"
+               test -d .bzr && DEVUPCMD="bzr update"
+               test -d .hg && DEVUPCMD="hg pull"
+               test -d .git && DEVUPCMD="git pull"
+               test -d CVS && DEVUPCMD="cvs up -d"
+               test -n "$P4PORT" && DEVUPCMD="p4 sync"
+       fi
+
+       test -n "$DEVUPCMD" || return 7
+
+       # run the update command...
+       eval "$DEVUPCMD"
+
+       return $?
+       )
+
+       return $?
+}
+
+complete -W complete -W "$(dev)" devup
 


Other related posts:

  • » [haiku-commits] haiku: hrev43776 - 3rdparty/mmu_man/scripts - revol