Commit 7e507b62881919d5f9eeb22c2fd4fa72a2859564

Authored by Göran Krampe
1 parent 3e2f4c14

Fixes discovered while testing on windows XP.

Showing 1 changed file with 23 additions and 15 deletions
blimp.nim
@@ -41,10 +41,10 @@ password = "some-good-rsync-password-for-blimpuser" @@ -41,10 +41,10 @@ password = "some-good-rsync-password-for-blimpuser"
41 # The following three formats should not need editing. 41 # The following three formats should not need editing.
42 # $1 is the blimp filename, $2 is remote location and $3 is the local blimpstore directory set above. 42 # $1 is the blimp filename, $2 is remote location and $3 is the local blimpstore directory set above.
43 # NOTE: The password-file .blimp.pass will be created by blimp on every command, do not remove that option. 43 # NOTE: The password-file .blimp.pass will be created by blimp on every command, do not remove that option.
44 -upload = "rsync --password-file $3/.blimp.pass -avzP $3/$1 $2/"  
45 -download = "rsync --password-file $3/.blimp.pass -avzP $2/$1 $3/" 44 +upload = "rsync --password-file $3/.blimp.pass -azP $3/$1 $2/"
  45 +download = "rsync --password-file $3/.blimp.pass -azP $2/$1 $3/"
46 # This deletes a single file from destination, that is already deleted in source. Yeah... insane! But it works. 46 # This deletes a single file from destination, that is already deleted in source. Yeah... insane! But it works.
47 -delete = "rsync --password-file $3/.blimp.pass -dv --delete --existing --ignore-existing --include '$1' --exclude '*' $3/ $2" 47 +delete = "rsync --password-file $3/.blimp.pass -d --delete --existing --ignore-existing --include '$1' --exclude '*' $3/ $2"
48 48
49 [blimp] 49 [blimp]
50 # Minimal version, otherwise stop 50 # Minimal version, otherwise stop
@@ -53,7 +53,12 @@ delete = "rsync --password-file $3/.blimp.pass -dv --delete --existing --ignore- @@ -53,7 +53,12 @@ delete = "rsync --password-file $3/.blimp.pass -dv --delete --existing --ignore-
53 53
54 proc cmd(cmd: string): string = 54 proc cmd(cmd: string): string =
55 try: 55 try:
56 - let tup = execCmdEx(cmd) 56 + # Otherwise pipes will not work for git commands etc
  57 + when defined(windows):
  58 + let tup = execCmdEx("cmd /c \"" & cmd & "\"")
  59 + else:
  60 + let tup = execCmdEx(cmd)
  61 + #echo "cmd: " & $cmd & "err:" & $tup[1]
57 if tup[1] == 0: 62 if tup[1] == 0:
58 result = strip(tup[0]) 63 result = strip(tup[0])
59 else: 64 else:
@@ -139,7 +144,7 @@ proc run(cmd: string): auto = @@ -139,7 +144,7 @@ proc run(cmd: string): auto =
139 proc rsyncRun(cmd: string): auto = 144 proc rsyncRun(cmd: string): auto =
140 if not rsyncPassword.isNil: 145 if not rsyncPassword.isNil:
141 writeFile(blimpStore / ".blimp.pass", rsyncPassword) 146 writeFile(blimpStore / ".blimp.pass", rsyncPassword)
142 - if execCmd("chmod 600 " & blimpStore / ".blimp.pass") != 0: 147 + if execCmd("chmod 600 \"" & blimpStore / ".blimp.pass\"") != 0:
143 quit("Failed to chmod 600 " & blimpStore / ".blimp.pass") 148 quit("Failed to chmod 600 " & blimpStore / ".blimp.pass")
144 run(cmd) 149 run(cmd)
145 150
@@ -244,14 +249,14 @@ proc deflate(filename: string) = @@ -244,14 +249,14 @@ proc deflate(filename: string) =
244 249
245 # Iterator over all deflated files in the git clone 250 # Iterator over all deflated files in the git clone
246 iterator allDeflated() = 251 iterator allDeflated() =
247 - let filenames = cmd("git ls-files " & gitRootDir).split('\l') 252 + let filenames = cmd("git ls-files " & gitRootDir).split({'\l', '\c'})
248 for fn in filenames: 253 for fn in filenames:
249 if not blimpFilename(fn).isNil: 254 if not blimpFilename(fn).isNil:
250 yield fn 255 yield fn
251 256
252 # Iterator over all files matching the blimp filter in the git clone 257 # Iterator over all files matching the blimp filter in the git clone
253 iterator allFiltered() = 258 iterator allFiltered() =
254 - let lines = cmd("git ls-files | git check-attr --stdin filter").split('\l') 259 + let lines = cmd("git ls-files | git check-attr --stdin filter").split({'\l', '\c'})
255 for line in lines: 260 for line in lines:
256 let status = line.split(':') 261 let status = line.split(':')
257 if strip(status[2]) == "blimp": 262 if strip(status[2]) == "blimp":
@@ -310,11 +315,11 @@ proc `$`(x: string): string = @@ -310,11 +315,11 @@ proc `$`(x: string): string =
310 315
311 proc dumpConfig() = 316 proc dumpConfig() =
312 echo "\nDump of configuration:" 317 echo "\nDump of configuration:"
313 - echo "\tblimpStore: " & blimpStore  
314 - echo "\tremoteBlimpStore: " & remoteBlimpStore  
315 - echo "\tuploadCommandFormat: " & uploadCommandFormat  
316 - echo "\tdownloadCommandFormat: " & downloadCommandFormat  
317 - echo "\tdeleteCommandFormat: " & deleteCommandFormat 318 + echo "\tblimpStore: " & $blimpStore
  319 + echo "\tremoteBlimpStore: " & $remoteBlimpStore
  320 + echo "\tuploadCommandFormat: " & $uploadCommandFormat
  321 + echo "\tdownloadCommandFormat: " & $downloadCommandFormat
  322 + echo "\tdeleteCommandFormat: " & $deleteCommandFormat
318 echo "\trsyncPassword: " & $rsyncPassword 323 echo "\trsyncPassword: " & $rsyncPassword
319 echo "\tblimpVersion: " & $blimpVersion 324 echo "\tblimpVersion: " & $blimpVersion
320 echo "\n" 325 echo "\n"
@@ -418,6 +423,7 @@ homeDir = getHomeDir() @@ -418,6 +423,7 @@ homeDir = getHomeDir()
418 homeDir = homeDir[0.. -2] # Not sure why it keeps a trailing "/" on Linux 423 homeDir = homeDir[0.. -2] # Not sure why it keeps a trailing "/" on Linux
419 currentDir = getCurrentDir() 424 currentDir = getCurrentDir()
420 gitRootDir = gitRoot() 425 gitRootDir = gitRoot()
  426 +echo gitRootDir
421 427
422 # Using lapp to get args, on parsing failure this will show usage automatically 428 # Using lapp to get args, on parsing failure this will show usage automatically
423 var args = parse(synopsis) 429 var args = parse(synopsis)
@@ -442,13 +448,15 @@ parseConfFile(currentDir / ".blimp.conf") @@ -442,13 +448,15 @@ parseConfFile(currentDir / ".blimp.conf")
442 if not gitRootDir.isNil and gitRootDir != currentDir: 448 if not gitRootDir.isNil and gitRootDir != currentDir:
443 parseConfFile(gitRootDir / ".blimp.conf") 449 parseConfFile(gitRootDir / ".blimp.conf")
444 450
  451 +if existsDir(homeDir / "blimpstore"):
  452 + parseConfFile(homeDir / "blimpstore" / ".blimp.conf")
  453 +
  454 +parseConfFile(homeDir / ".blimp.conf")
  455 +
445 # If we haven't gotten a blimpstore yet, we set a default one 456 # If we haven't gotten a blimpstore yet, we set a default one
446 if blimpStore.isNil: 457 if blimpStore.isNil:
447 blimpStore = homeDir / "blimpstore" 458 blimpStore = homeDir / "blimpstore"
448 459
449 -if existsDir(blimpStore):  
450 - parseConfFile(blimpStore / ".blimp.conf")  
451 -parseConfFile(homeDir / ".blimp.conf")  
452 460
453 # Let's just show what we have :) 461 # Let's just show what we have :)
454 if verbose: dumpConfig() 462 if verbose: dumpConfig()