You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.2 KiB

6 years ago
11 years ago
  1. <?php
  2. // DEPRECATED : ne sert plus
  3. // l'url du repo en premier argument
  4. if (!isset($argv[1]) OR !($user = $argv[1])){
  5. echo "Vous devez indiquer en premier argument repertoire du repository\n";
  6. die();
  7. }
  8. define('_TRACE',true);
  9. define('_SLEEP_BETWEEN',200000);
  10. define('_DIR_REPOSITORY',$argv[1]);
  11. chdir(_DIR_REPOSITORY);
  12. $k = 2;
  13. $dirs = array();
  14. $op = "";
  15. while (isset($argv[$k]) AND $subdir=$argv[$k]){
  16. if (!in_array($subdir,array('A','U','D'))) {
  17. $subdir = rtrim($subdir,'/');
  18. while ($subdir
  19. AND $subdir!==dirname($subdir)
  20. AND !in_array($subdir,$dirs)
  21. ) {
  22. $dirs[] = $subdir;
  23. // si c'est deja un dir, on fait un up non recursif
  24. if (is_dir($subdir) AND $op!=='D')
  25. $out = exec_trace("svn up -N $subdir");
  26. // sinon, si le fichier/dossier n'existe pas mais son parent oui
  27. // on up
  28. elseif(($op=='D' OR !file_exists($subdir)) AND is_dir(dirname($subdir))) {
  29. $op = "";
  30. $out = exec_trace("svn up $subdir");
  31. }
  32. // sinon il sera up en meme temps que son parent
  33. if (strpos($out,'cleanup')!==FALSE) {
  34. $headers = "From: updateur@rezo.net\r\n";
  35. mail("files@spip-contrib.net","updateur","$subdir :\n $out",$headers);
  36. }
  37. if (strpos($out,'chec de')!==FALSE) {
  38. $headers = "From: updateur@rezo.net\r\n";
  39. mail("files@spip-contrib.net","updateur","$subdir :\n $out",$headers);
  40. }
  41. $subdir = dirname($subdir);
  42. }
  43. if ($subdir AND !in_array($subdir,$dirs)) {
  44. $out = exec_trace("svn up -N $subdir");
  45. $dirs[] = $subdir;
  46. }
  47. }
  48. else $op = $subdir;
  49. $k++;
  50. }
  51. $dirs = implode("\n",$dirs)."\n";
  52. file_put_contents("dirs-changed.txt",$dirs,FILE_APPEND);
  53. /**
  54. * Echo avec un horodatage
  55. */
  56. function echo_trace($out){
  57. $outh = date("[Y-m-d H:i:s] ",time()).$out."\n";
  58. if (_TRACE) echo $outh;
  59. if (strncmp($out,"Erreur :",8)==0)
  60. $GLOBALS['erreurs'][]=$outh;
  61. return $outh;
  62. }
  63. /**
  64. * exec avec une trace de la commande et de son resultat
  65. */
  66. function exec_trace($commande){
  67. $output = "";
  68. $return_var="";
  69. echo_trace($commande);
  70. $commande = "$commande 2>&1";
  71. $out = exec($commande,$output,$return_var);
  72. if ($output!==null) {
  73. $out = end($output);
  74. }
  75. if (strlen(trim($out)))
  76. array_map('echo_trace',$output);
  77. return $out;
  78. }
  79. ?>