Autobuilding of trunk - General Discussion and Assistance - CHDK Forum

Autobuilding of trunk

  • 31 Replies
  • 25462 Views
*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Autobuilding of trunk
« on: 21 / March / 2008, 17:18:07 »
Advertisements
I've set up a script on one server, which checks every 15 minutes for the new revision in svn repository and builds it if it's found. The build takes 5 minutes. Then puts zip-files to http://grandag.nm.ru/hdk/autobuild/download.htm. So in the worst case the new build will be available in 20 minutes (in 5 minutes if the check-in was just before the check).

Very experimental feature...  :D

edit by phyrephox:

HERE you can find an autobuild server that not only hosts the autobuilds grand hosts, but the EXTENDED zips as well (including readmes and files etc). Provided by Hacki. Don't ask about the domain name, it's weird german.
So if you need the extended zips - go there. If you got problems connecting to russian domains - go to Hackis place.
Dont just always download the "big" zips though, as the extra files arent updates as often as the binaries - so better check the versions first.
« Last Edit: 25 / September / 2008, 12:16:09 by PhyrePhoX »
CHDK Developer.

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Autobuilding of trunk
« Reply #1 on: 21 / March / 2008, 17:25:34 »
Here is the script in case somebody wish to improve it :D
Code: (tcl) [Select]
#!/bin/sh
# \
exec tclsh $0 $*
 
#-------------------------------------------------------------------
# PATH settings
set BUILD_PATH      "/project/home/grand/chdk/autobuild"
set BUILD_LOCK_FILE "${BUILD_PATH}/.build_lock"
set LAST_REV_FILE   "${BUILD_PATH}/.last_revision"
set LOG_FILE        "${BUILD_PATH}/compile.log"
set COMPILER_PATH   "/project/home/grand/chdk/gcc/arm-elf/bin"
 
#-------------------------------------------------------------------
# List of branches to automatic rebuild
set BRANCHES_TO_BUILD [list "trunk"]
 
#-------------------------------------------------------------------
 
 
 
#-------------------------------------------------------------------
proc run {cmd resVar} {
    upvar $resVar x
    if {[catch {set res [eval exec $cmd 2>@ stdout]} errMsg]} {
        set x $errMsg
        return 0
    } else {
        set x $res
        return 1
    }
}
 
#-------------------------------------------------------------------
proc send {file resVar} {
    upvar $resVar x
    set ok 0
    set USER "**********"
    set PASSWD "***********"

    lappend cmds "user $USER $PASSWD"
    lappend cmds "cd hdk/autobuild"
    lappend cmds "binary"
    lappend cmds "mdelete $file"
    lappend cmds "mput $file"
    lappend cmds "pwd"
    lappend cmds "quit"

    if {![catch {set f [open "|ftp -n -i ftp.newmail.ru 2>@ stdout" "w+"]} res]} {
        puts $f [join $cmds "\n"]
        flush $f
        set res ""
        while {![eof $f]} {
            gets $f ll
            lappend res $ll
        }
        if {![catch {close $f} res2]} {
            foreach ll $res {
                if {[regexp -- {hdk/autobuild} $ll]} {
                    set ok 1
                    break
                }
            }
        } else {
            lappend res $res2
        }
    }
    set x $res
    return $ok
}

#-------------------------------------------------------------------
proc finish {err} {
    global BUILD_PATH BUILD_LOCK_FILE LOG_FILE info log

    # Save last compiled revision
    if {![catch {set f [open $LOG_FILE "w"]}]} {
        if {$err} {
            #errors
            puts $f "Errors occured during build process: $err."
        } else {
            puts $f "Build process finished normally."
        }

        puts $f "================================================\n"
        puts $f [join $log "\n++++++++++++++++++++++++++++++++++++++++++++++++\n"]
        catch {close $f}
        set res ""
        cd $BUILD_PATH
        send [file tail $LOG_FILE] res
    }

    catch {file delete $BUILD_LOCK_FILE}
    exit
}
 
 
 
#-------------------------------------------------------------------
# Check for lock-file and wait until lock is away
while {[file exists $BUILD_LOCK_FILE]} {
    lappend log "Lock is detected. Waiting..."
    catch {exec sleep 1m}
}
 
# Create lock-file
#!!!catch {set f [open $BUILD_LOCK_FILE "w"]; close $f}

set errors 0
set info(last_revision) 0

# Get last compiled revision
if {![catch {set f [open $LAST_REV_FILE "r"]}]} {
    catch {gets $f info(last_revision)}
    catch {close $f}
}

# Get last revision info
lappend log "Getting last revision info:"
set ok [run [list svn log --verbose -r HEAD "http://tools.assembla.com/svn/chdk/"] res]
lappend log $res
if {!$ok} {
    incr errors
    lappend log "***FATAL***: Cannot obtain last revision information."
    finish $errors
}
set res [split $res "\n"]
 
# Parse the revision information
# r243 | grand | 2007-12-07 19:18:54 +0300 (Fri, 07 Dec 2007) | 1 line
set info(info) [lindex $res 1]
set list [split $info(info) "|"]
foreach name {revision person date changes} value $list {
    set info($name) [string trim $value]
}
set info(revision) [string trim $info(revision) "rR"]

if {$info(revision) == $info(last_revision)} {
    exit
}
 
# Search for branch names
foreach str [lrange $res 3 end] {
    if {[regexp -- " \/(\[^\/ \]+)\[\/ \]" $str dummy branch]} {
        if {$branch == "branches"} {
            if {[regexp -- " \/(\[^\/\]+\/\[^\/ \]+)\[\/ \]" $str dummy branch]} {
                set branches($branch) ""
            }
        } else {
            set branches($branch) ""
        }
    }
}
 
set env(PATH) "${COMPILER_PATH}:/bin:/usr/bin:$env(PATH)"
#set env(HOME) "/var/www"
 
# Build only required branches
foreach branch $BRANCHES_TO_BUILD {
    if {[info exists branches($branch)]} {
        lappend log "\n"
        lappend log "Removing old sources of branch: '${branch}'"
        catch {cd $BUILD_PATH}
        catch {file delete -force -- "${BUILD_PATH}/${branch}"}
        # Get sources
        lappend log "Getting the sources for branch: '${branch}', revision: $info(revision)"
        set ok [run [list svn export -r $info(revision) "[url=http://tools.assembla.com/svn/chdk/]Revision 338: /[/url]${branch}"] res]
        lappend log $res
        if {!$ok} {
            incr errors
            lappend log "***FATAL***: Cannot get sources."
            continue
        }
       
        lappend log "Compiling branch '${branch}'..."
        if {[catch {cd "${BUILD_PATH}/${branch}"}]} {
            incr errors
            lappend log "***ERROR***: cannot change the current directory to '${branch}'."
            continue
        }
 
        set ok [run [list make NO_INC_BUILD=1 batch-zip] res]
        lappend log $res
        if {!$ok} {
            incr errors
            lappend log "***FATAL***: Error occured during compilation."
            continue
        }
 
        lappend log "Uploading files..."
        if {[catch {cd "${BUILD_PATH}/${branch}/bin"}]} {
            incr errors
            lappend log "***ERROR***: cannot change the current directory to '${branch}/bin'."
            continue
        }
        set ok [send "*.zip" res]
        lappend log $res
        if {!$ok} {
            incr errors
            lappend log "***FATAL***: Cannot upload files for branch '${branch}'."
            continue
        }
    }
}
 
# Save last compiled revision
if {![catch {set f [open $LAST_REV_FILE "w"]}]} {
    catch {puts $f $info(revision)}
    catch {close $f}
}

finish $errors
CHDK Developer.

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Autobuilding of trunk
« Reply #2 on: 21 / March / 2008, 17:39:37 »
It is possible to supress warnings:
Warning: File `******' has modification time #### s in the future 
warning:  Clock skew detected.  Your build may be incomplete.
?



*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Autobuilding of trunk
« Reply #3 on: 21 / March / 2008, 17:44:12 »
It is possible to supress warnings:
Warning: File `******' has modification time #### s in the future 
warning:  Clock skew detected.  Your build may be incomplete.
?

Possible. That "server" just do not sync its time...
CHDK Developer.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Autobuilding of trunk
« Reply #4 on: 21 / March / 2008, 18:20:36 »
hey, thats a good birthday present. but hey, it's YOUR birthday, we should be giving YOU something.
here's my present for you:



other then that, very good idea, with the autobuilds.

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Autobuilding of trunk
« Reply #5 on: 22 / March / 2008, 03:18:49 »
@PhyrePhoX
Thank you for your present. I like it. :)
CHDK Developer.

Re: Autobuilding of trunk
« Reply #6 on: 23 / March / 2008, 00:43:31 »
Deleted
« Last Edit: 22 / April / 2008, 14:42:21 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Autobuilding of trunk
« Reply #7 on: 24 / March / 2008, 04:52:37 »
Windows GUI is discussing here - Windows GUI for trunk building
CHDK Developer.

*

Offline adcz

  • ***
  • 151
  • Canon S5 | Before Thou Smiteth Me, Readeth Sig
    • OSFlower
Re: Autobuilding of trunk
« Reply #8 on: 07 / June / 2008, 21:56:07 »
I've set up a script on one server, which checks every 15 minutes for the new revision in svn repository and builds it if it's found. The build takes 5 minutes. Then puts zip-files to http://grandag.nm.ru/hdk/autobuild/download.htm. So in the worst case the new build will be available in 20 minutes (in 5 minutes if the check-in was just before the check).

Very experimental feature...  :D



Oooooh! Now I get it!!! All this time I was thinking...what in the world do they mean by auto-build? Almost asked...then bumped into this thread :) That is so cool :D Can you email/pm/post the script you used? Might come in useful sometime for me :)

Edit: oh woops! never mind :D found it (I really should read before I post more :P)! By the way...what language is this in? Doesn't look like php...is this a cron job?
« Last Edit: 07 / June / 2008, 22:00:02 by adcz »
Email me at adz@jewc.org for questions/comments/etc or aim me at adzempire!
---
STOP!! Before thou smiteth me, please PM me the reason! . Criticism = bad, constructive criticism = good.

If you wanna applaud, no reason necessary, I know I'm wonderful :P

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Autobuilding of trunk
« Reply #9 on: 08 / June / 2008, 00:12:03 »
By the way...what language is this in? Doesn't look like php...is this a cron job?

Tcl. Yes, it's executed as a cron job.
CHDK Developer.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal