在使用 exec 執行 git clone B2G 的 source code 時,希望可以看到目前的情況,所以:
set B2G_git [list git clone https://github.com/andreasgal/B2G.git B2G >@stdout 2>@stderr]
puts "Using git clone B2G source code..."
exec {*}$B2G_git
整個程式如下,不過我只是急救章的寫一個來用,還沒有完整的測試過:
#!/usr/bin/tclsh
#
# Purpose: Get B2G project source code
# Update date: 2012/06/24
#
# global variable
#
set B2GDir [pwd]
append B2GDir "/B2G"
set B2G_GIT "https://github.com/andreasgal/B2G.git"
#
# get_source procedure: using git clone to get source code
#
proc get_source {} {
puts "########## get start ##########"
set B2G_git [list git clone $::B2G_GIT B2G >@stdout 2>@stderr]
puts "Using git clone B2G source code..."
exec {*}$B2G_git
puts "########## get end ##########"
}
#
# update_source procedure: using git pull to update source code
#
proc update_source {} {
puts "B2G folder exists!!! --- try to update"
set git_pull [list git pull >@stdout 2>@stderr]
puts "########## upate start ##########"
cd $::B2GDir
set fileExist [file exists .git]
if {$fileExist > 0} {
puts "Using git pull to update B2G source code..."
exec {*}$git_pull
} else {
puts "Error!!!"
puts "B2G folder exists but no .get folder!!!"
}
puts "########## upate end ##########"
}
#
# Main procedure, get B2G project source code
#
if {$argc > 0} {
set argv0 [string toupper [lindex $argv 0]]
if { [expr [string compare $argv0 "GET" ] == 0] } {
set fileExist [file exists $B2GDir]
if {!$fileExist} {
get_source
} else {
update_source
}
} elseif { [expr [string compare $argv0 "UPDATE" ] == 0] } {
set fileExist [file exists $B2GDir]
if {!$fileExist} {
puts "B2G folder does not exist!!!"
} else {
update_source
}
}
} elseif {$argc == 0} {
puts "User does not use GET or UPDATE parameter..."
puts "Check B2G folder..."
set fileExist [file exists $B2GDir]
if {!$fileExist} {
get_source
} else {
update_source
}
}
沒有留言:
張貼留言