AliPhysics  b0b429f (b0b429f)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParUtilities.C
Go to the documentation of this file.
1 
11 #ifndef PARHELPER_C
12 #define PARHELPER_C
13 #ifndef __CINT__
14 # include <TString.h>
15 # include <TProof.h>
16 # include <TSystem.h>
17 # include <TError.h>
18 # include <TFile.h>
19 # include <TSystem.h>
20 # include <TROOT.h>
21 # include <fstream>
22 # include <cstdlib>
23 # include "Railway.C"
24 #else
25 class TString;
26 class Railway;
27 class TProof; // Autoload
28 #endif
29 
30 // ===================================================================
37 {
38  static Bool_t DoFind(const TString& what, TString& src)
39  {
40  src = "";
41  if (what.IsNull()) return false;
42 
43  TString aliRoot = gSystem->ExpandPathName("$ALICE_ROOT");
44  TString aliPhys = gSystem->ExpandPathName("$ALICE_PHYSICS");
45  TString search = Form(".:..:%s:%s/PARfiles:%s:%s/PARfiles",
46  aliPhys.Data(), aliPhys.Data(),
47  aliRoot.Data(), aliRoot.Data());
48  char* found = gSystem->Which(search.Data(), what.Data());
49  if (!found || found[0] == '\0') {
50  Error("ParUtilities::Find", "PAR file %s not found in %s",
51  what.Data(), search.Data());
52  return false;
53  }
54  src = found;
55  return true;
56  }
65  static Bool_t Find(const TString& what)
66  {
67  TString parFile(what);
68  if (!parFile.EndsWith(".par")) parFile.Append(".par");
69  TString src;
70  if (!DoFind(parFile, src)) return false;
71 
72  // Copy to current directory
73  // TFile::Copy(aliParFile, parFile);
74  Info("", "Found PAR %s at %s", what.Data(), src.Data());
75  if (gSystem->Exec(Form("ln -s %s %s", src.Data(), parFile.Data())) != 0){
76  if (!gSystem->AccessPathName(parFile.Data())) return true;
77  Error("ParUtilities::Find", "Failed to symlink %s to %s",
78  src.Data(), parFile.Data());
79  return false;
80  }
81  return true;
82  }
90  static Bool_t Load(const TString& name)
91  {
92  if (name.IsNull()) return true;
93  if (!gProof) {
94  Error("ParUtilities::Load", "No connection to a Proof cluster");
95  return false;
96  }
97 
98  // Load par library
99  TString fn(name);
100  Info("ParUtilities::LoadLibrary", "Uploading %s", name.Data());
101 
102  TString parFile(name);
103  if (!parFile.EndsWith(".par")) parFile.Append(".par");
104  TString src;
105  if (!DoFind(parFile, src)) return false;
106 
107  // First check in current directory
108  Int_t ret = gProof->UploadPackage(src, TProof::kRemoveOld);
109 
110  if (ret < 0) {
111  // IF not found, bark
112  Error("ParUtilities::Load",
113  "Could not upload module %s.par", name.Data());
114  return false;
115  }
116 
117  ret = gProof->EnablePackage(name);
118  Info("ParUtilities::Load", "Enabled package %s (from %s)",
119  name.Data(), fn.Data());
120 
121  return true;
122  }
130  static Bool_t Build(const TString& what)
131  {
132  if (what.IsNull()) return false;
133 
134  TString parFile(what);
135  if (!parFile.EndsWith(".par")) parFile.Append(".par");
136 
137  // Extract archive
138  gSystem->Exec(Form("tar xzf %s", parFile.Data()));
139 
140  // Change directory into par archive
141  TString cwd = gSystem->WorkingDirectory();
142 
143  TString dir(what);
144  if (dir.EndsWith(".par")) dir.ReplaceAll(".par", "");
145  if (!gSystem->ChangeDirectory(dir)) {
146  Error("ParUtilities::Setup", "Failed to change directory to %s",
147  dir.Data());
148  return false;
149  }
150 
151  // Test the build
152  if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
153  Info("ParUtilities::Setup", "Building in PAR archive %s", parFile.Data());
154  if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
155  Error("ParUtilities::Setup", "Failed to build in PAR directory %s",
156  dir.Data());
157  gSystem->ChangeDirectory(cwd.Data());
158  return false;
159  }
160  }
161 
162  // We need to make sure the current directory is in the load path
163  gSystem->SetDynamicPath(Form("%s:%s", gSystem->WorkingDirectory(),
164  gSystem->GetDynamicPath()));
165  // Check for setup script
166  if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
167  // Info("ParUtilities::SetupPAR", "Setting up for PAR %s", what);
168  gROOT->Macro("PROOF-INF/SETUP.C");
169  }
170  if (!gSystem->ChangeDirectory(cwd.Data())) return false;
171 
172  return true;
173  }
174  //__________________________________________________________________
202  static Bool_t MakeScriptPAR(Bool_t isLocal,
203  const TString& script,
204  const TString& deps,
205  Railway* helper)
206  {
207  TObjArray* depList = deps.Tokenize(", ");
208 
209  // --- In local mode, just AcLic and load ------------------------
210  if (isLocal) {
211  // Load dependencies
212  TIter next(depList);
213  TObject* dep = 0;
214  while ((dep = next()))
215  helper->LoadLibrary(dep->GetName());
216 
217  // AcLic and load
218  Info("ParUtilities::MakeScriptPAR", "Loading macro %s", script.Data());
219  if (gROOT->LoadMacro(Form("%s++g", script.Data())) < 0) {
220  Error("ParUtilities::MakeScriptPAR",
221  "Failed to build local library %s", script.Data());
222  return false;
223  }
224  return true;
225  }
226 
227  // --- Get the base name -----------------------------------------
228  Info("ParUtilities::MakeScriptPAR", "Making par file for %s",
229  script.Data());
230  TString base(gSystem->BaseName(script));
231  Int_t idx = base.Last('.');
232  if (idx != kNPOS) base.Remove(idx);
233 
234  // --- Check name of script file ---------------------------------
235  TString scr(script);
236  TString ext;
237  if (script.EndsWith(".C")) ext = "C";
238  else if (script.EndsWith(".cxx")) ext = "cxx";
239  else { ext = "C"; scr.Append(".C"); }
240 
241  // --- Check if we can access the file ---------------------------
242  TString path = TString::Format(".:%s", TROOT::GetMacroPath());
243  char* loc = gSystem->Which(path, scr);
244  if (!loc) {
245  Error("ParUtilities::MakeScriptPAR",
246  "Script %s not found in %s", scr.Data(), path.Data());
247  return false;
248  }
249  TString full(loc);
250 
251  // --- Create our temporary directory ----------------------------
252  TString tmpdir(gSystem->TempDirectory());
253  int ltempl = tmpdir.Length() + 1 + 5 + 6 + 1;
254  char* templ = new char[ltempl];
255  snprintf(templ, ltempl, "%s/trainXXXXXX", tmpdir.Data());
256  if (!mkdtemp(templ)) {
257  Error("ParUtilities::MakeScriptPAR",
258  "Failed to generate temporary directory from template %s",
259  templ);
260  return false;
261  }
262  Info("", "Building PAR in %s", templ);
263 
264  Bool_t retVal = false;
265  try {
266  // --- Make directories for package ------------------------------
267  TString dir = TString::Format("%s/%s", templ, base.Data());
268  // Set-up directories
269  if (gSystem->MakeDirectory(dir) < 0)
270  throw TString::Format("Could not make directory '%s'", base.Data());
271  if (gSystem->MakeDirectory(Form("%s/PROOF-INF", dir.Data())))
272  throw TString::Format("Could not make directory %s/PROOF-INF",
273  base.Data());
274  Info("", "Made directory %s", dir.Data());
275 
276  // --- Copy the script to the setup directory --------------------
277  TString dest = TString::Format("%s/%s.%s", dir.Data(),
278  base.Data(), ext.Data());
279  Int_t ret = gSystem->CopyFile(full, dest, true);
280  switch (ret) {
281  case -1: throw TString::Format("Couldn't open %s for copy", scr.Data());
282  case -2: throw TString::Format("File %s exists", dest.Data());
283  case -3: throw TString::Format("Error while copying %s", scr.Data());
284  }
285 
286  // --- Make scripts, etc. ----------------------------------------
287  if (!MakeScriptBuildScript(dir, base))
288  throw TString::Format("Failed to make build script");
289  if (!MakeScriptUtilityScript(dir))
290  throw TString::Format("Failed to make utility script");
291  if (!MakeScriptBuildMacro(dir, base, ext, depList))
292  throw TString::Format("Failed to make build macro");
293  if (!MakeScriptSetupMacro(dir, base, ext, depList))
294  throw TString::Format("Failed to setup macro");
295 
296  // --- Pack up the archive ---------------------------------------
297  ret = gSystem->Exec(Form("(cd %s && tar -czf %s.par %s)",
298  templ, base.Data(),base.Data()));
299  if (ret != 0)
300  throw TString::Format("Failed to create PAR file %s.PAR from %s",
301  base.Data(), dir.Data());
302 
303  Info("", "Made par archive %s/%s.par - moving here",
304  templ, base.Data());
305  // --- Move PAR file to here -------------------------------------
306  ret = gSystem->Exec(Form("mv -f %s/%s.par %s.par", templ, base.Data(),
307  base.Data()));
308  if (ret != 0)
309  throw TString::Format("Failed to rename %s/%s.par to %s.par: %s",
310  templ, base.Data(), base.Data(),
311  gSystem->GetError());
312  retVal = true;
313  }
314  catch (TString& e) {
315  Error("ParUtilities::MakeScriptPAR", "%s", e.Data());
316  retVal = false;
317  }
318 
319  // --- Remove temporary directory --------------------------------
320  gSystem->Exec(Form("rm -rf %s", templ));
321 
322  return retVal;
323  }
333  const TString& base)
334  {
335  // Make our build file
336  std::ofstream out(Form("%s/PROOF-INF/BUILD.sh", dir.Data()));
337  if (!out) {
338  Error("ParUtilities::MakeScriptBuildScript",
339  "Failed to open out shell script");
340  return false;
341  }
342  out << "#!/bin/sh\n"
343  << "if test x$ALICE_ROOT != x ; then\n"
344  << " export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ALICE_ROOT}/lib\n"
345  << "fi\n"
346  << "if test x$ALICE_PHYSICS != x ; then\n"
347  << " export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ALICE_PHYSICS}/lib\n"
348  << "fi\n"
349  << "# printenv | sort -u\n"
350  << "echo BUILD.sh@`hostname`: Building " << base << "\n"
351  << "root.exe -l -out -q PROOF-INF/BUILD.C 2>&1 | tee "
352  << base << ".log\n"
353  << "echo BUILD.sh@`hostname`: done: $?\n"
354  << std::endl;
355  out.close();
356  if (gSystem->Chmod(Form("%s/PROOF-INF/BUILD.sh", dir.Data()), 0755) != 0) {
357  Error("ParUtilities::MakeScriptBuildScript",
358  "Failed to set exectuable flags on %s/PROOF-INF/BUILD.sh",
359  dir.Data());
360  return false;
361  }
362  return true;
363  }
374  static Bool_t MakeScriptBuildMacro(const TString& dir,
375  const TString& base,
376  const TString& ext,
377  const TCollection* deps) {
378  std::ofstream out(Form("%s/PROOF-INF/BUILD.C", dir.Data()));
379  if (!out) {
380  Error("ParUtilities::MakeScriptBuildMacro","Failed to open build script");
381  return false;
382  }
383  out << "void BUILD() {\n"
384  << " gSystem->AddIncludePath(\"-DBUILD_PAR=1\");\n"
385  << " gROOT->LoadMacro(\"PROOF-INF/UTIL.C\");\n"
386  << " LoadROOTLibs();\n"
387  << " AddAliROOT();\n"
388  << " AddAliPhysics();\n";
389  if (deps) {
390  TIter next(deps);
391  TObject* dep = 0;
392  while ((dep = next())) {
393  out << " AddDep(\"" << dep->GetName() << "\");\t"
394  << " LoadDep(\"" << dep->GetName() << "\");\n";
395  }
396  }
397  out << " // gDebug = 5;\n"
398  << " // gSystem->ListLibraries();\n"
399  << " int ret = gROOT->LoadMacro(\""
400  << base << "." << ext << "++g\");\n"
401  << " if (ret != 0) Fatal(\"BUILD\",\"Failed to build\");\n"
402  << " // else Info(\"BUILD\", \"Made " << base << "\");\n"
403  << "}\n"
404  << std::endl;
405  out.close();
406 
407  return true;
408  }
417  {
418  std::ofstream out(Form("%s/PROOF-INF/UTIL.C", dir.Data()));
419  if (!out) {
420  Error("ParUtilities::MakeScriptUtilityScript",
421  "Failed to open utility script");
422  return false;
423  }
424  out << "void LoadROOTLibs() {\n"
425  << " gSystem->Load(\"libVMC\");\n"
426  << " gSystem->Load(\"libNet\");\n"
427  << " gSystem->Load(\"libTree\");\n"
428  << " gSystem->Load(\"libPhysics\");\n"
429  << " gSystem->Load(\"libMinuit\");\n"
430  << "}\n\n";
431  out << "void AddAliROOT() {\n"
432  << " TString val(gSystem->Getenv(\"ALICE_ROOT\"));\n"
433  << " if (val.IsNull())\n"
434  << " Warning(\"Add\",\"ALICE_ROOT not defined\");\n"
435  << " else\n"
436  << " gSystem->AddIncludePath(Form(\"-I%s/include\",val.Data()));\n"
437  << "}\n\n";
438  out << "void AddAliPhysics() {\n"
439  << " TString val(gSystem->Getenv(\"ALICE_PHYSICS\"));\n"
440  << " if (val.IsNull())\n"
441  << " Warning(\"Add\",\"ALICE_PHYSICS not defined\");\n"
442  << " else\n"
443  << " gSystem->AddIncludePath(Form(\"-I%s/include\",val.Data()));\n"
444  << "}\n\n";
445  out << "void AddDep(const char* env) {\n"
446  << " TString val(gSystem->Getenv(Form(\"%s_INCLUDE\",env)));\n"
447  << " if (val.IsNull())\n"
448  << " Warning(\"Add\",\"%s_INCLUDE not defined\", env);\n"
449  << " else {\n"
450  << " // gSystem->AddIncludePath(Form(\"-I../%s\",val.Data()));\n"
451  << " // Prepend to include path\n"
452  << " TString incPath(gSystem->GetIncludePath());\n"
453  << " incPath.Prepend(Form(\"-I../%s \",val.Data()));\n"
454  << " gSystem->SetIncludePath(incPath);\n"
455  << " // Printf(\"Include path: %s\",incPath.Data());\n"
456  << " }\n"
457  << "}\n\n";
458  out << "void LoadDep(const char* name) {\n"
459  << " // Printf(\"Loading dependency \\\"%s\\\" ...\",name);\n"
460  << " // gSystem->AddDynamicPath(Form(\"../%s\",name));\n"
461  << " // Prepend to dynamic path\n"
462  << " TString dynPath(gSystem->GetDynamicPath());\n"
463  << " dynPath.Prepend(Form(\"../%s:\",name));\n"
464  << " gSystem->SetDynamicPath(dynPath);\n"
465  << " // Printf(\"Dynamic path: %s\",dynPath.Data());\n"
466  << " char* full = gSystem->DynamicPathName(name,true);\n"
467  << " if (!full) \n"
468  << " full = gSystem->DynamicPathName(Form(\"lib%s\",name),true);\n"
469  << " if (!full) \n"
470  << " full = gSystem->DynamicPathName(Form(\"lib%s.so\",name),true);\n"
471  << " if (!full) \n"
472  << " full = gSystem->DynamicPathName(Form(\"%s_C.so\",name),true);\n"
473  << " if (!full) \n"
474  << " full = gSystem->DynamicPathName(Form(\"%s_h.so\",name),true);\n"
475  << " if (!full) {\n"
476  << " Warning(\"LoadDep\",\"Module %s not found\", name);\n"
477  << " return;\n"
478  << " }\n"
479  << " Printf(\"Loading \\\"%s\\\" for \\\"%s\\\"\",full,name);\n"
480  << " gSystem->Load(full);\n"
481  << "}\n"
482  << std::endl;
483  out.close();
484  return true;
485  }
496  static Bool_t MakeScriptSetupMacro(const TString& dir,
497  const TString& base,
498  const TString& ext,
499  const TCollection* deps)
500  {
501  // Make our set-up script
502  std::ofstream out(Form("%s/PROOF-INF/SETUP.C", dir.Data()));
503  if (!out) {
504  Error("ParUtilities::MakeScriptSetupMacro",
505  "Failed to open setup script");
506  return false;
507  }
508  out << "void SETUP() {\n"
509  << " gROOT->LoadMacro(\"PROOF-INF/UTIL.C\");\n"
510  << " Printf(\"Loading \\\"" << base << "\\\" ...\");\n"
511  << " LoadROOTLibs();\n"
512  << " // Info(\"SETUP\",\"Loading libraries\");\n";
513  if (deps) {
514  TIter next(deps);
515  TObject* dep = 0;
516  while ((dep = next()))
517  out << " LoadDep(\"" << dep->GetName() << "\");\n";
518  }
519  out << " // gDebug = 5;\n"
520  << " // Info(\"SETUP\",\"Loading " << base <<"_"<< ext << ".so\");\n"
521  << " gSystem->Load(\"" << base << "_" << ext << ".so\");\n"
522  << " // gDebug = 0;\n"
523  << " gROOT->ProcessLine(\".include " << base << "\");\n"
524  << " gSystem->Setenv(\"" << base << "_INCLUDE\",\""
525  << base << "\");\n"
526  << " // Info(\"SETUP\", \"Done\");\n"
527  << "}\n"
528  << std::endl;
529  out.close();
530  return true;
531  }
532  /* @} */
533  //__________________________________________________________________
538  static Bool_t MakeAuxFilePAR(const TList& files,
539  const TString& name,
540  Bool_t verbose=false)
541  {
542  // --- Check input -----------------------------------------------
543  if (files.GetEntries() <= 0) return true;
544 
545  // --- Create our temporary directory ----------------------------
546  Bool_t retval = true;
547  TString tmpdir(gSystem->TempDirectory());
548  int ltempl = tmpdir.Length() + 1 + 5 + 6 + 1;
549  char* templ = new char[ltempl];
550  snprintf(templ, ltempl, "%s/trainXXXXXX", tmpdir.Data());
551  if (!mkdtemp(templ)) {
552  Error("ParUtilities::MakeAuxFilePAR",
553  "Failed to generate temporary directory from template %s",
554  templ);
555  return false;
556  }
557  if (verbose) Printf("Preparing PAR file in %s", templ);
558 
559  try {
560  // --- Make directories for package ------------------------------
561  TString dir = TString::Format("%s/%s", templ, name.Data());
562  // Set-up directories
563  if (gSystem->MakeDirectory(dir) < 0)
564  throw TString::Format("Could not make directory '%s'", name.Data());
565  if (gSystem->MakeDirectory(Form("%s/PROOF-INF", dir.Data())))
566  throw TString::Format("Could not make directory %s/PROOF-INF",
567  name.Data());
568 
569  TIter next(&files);
570  TObject* o = 0;
571  while ((o = next())) {
572  TString fn(o->GetName());
573  if (verbose) Printf("Got %s", fn.Data());
574  if (fn.BeginsWith("/")) {
575  Warning("MakeAuxFilePAR", "Will not include absolute path %s",
576  fn.Data());
577  continue; // absolute path
578  }
579 
580  if (gSystem->AccessPathName(fn.Data())) {
581  Warning("MakeAuxFilePAR", "Cannot access %s", fn.Data());
582  continue; // non-exist
583  }
584  // Loop over path components and make directories as needed
585  TObjArray* comps = fn.Tokenize("/");
586  TString cur = dir;
587  Int_t n = comps->GetEntriesFast();
588  if (verbose) Printf("Got %d path components in %s", n-1, fn.Data());
589  Int_t lvl = 0;
590  for (Int_t i = 0; i < n-1; i++) {
591  TObjString* comp = static_cast<TObjString*>(comps->At(i));
592  TString& c = comp->String();
593  if (c.IsNull()) continue;
594  if (c.EqualTo(".")) continue;
595 
596  Bool_t doMake = true;
597  if (c.EqualTo("..")) { doMake = false; lvl--; }
598 
599  cur = gSystem->ConcatFileName(cur, c);
600  if (lvl < 0) {
601  Warning("MakeAuxFilePAR", "Path %s points outside archive, ignored",
602  cur.Data());
603  break;
604  }
605 
606  if (doMake) {
607  lvl++;
608  if (!gSystem->AccessPathName(cur)) continue;
609  if (verbose) Printf("Making directory %s", cur.Data());
610  gSystem->MakeDirectory(cur);
611  }
612  } // for(i)
613  if (verbose) Printf("cur=%s for %s lvl=%d", cur.Data(), fn.Data(), lvl);
614  comps->Delete();
615  if (lvl < 0) continue;
616 
617  TString dest = TString::Format("%s/%s", cur.Data(),
618  gSystem->BaseName(fn.Data()));
619  if (verbose) Printf("%s -> %s", fn.Data(), dest.Data());
620  // Int_t ret = gSystem->CopyFile(fn, dest, true);
621  Int_t ret = gSystem->Exec(Form("cp -f %s %s", fn.Data(), dest.Data()));
622  switch (ret) {
623  case -1: throw TString::Format("Couldn't open %s for copy", fn.Data());
624  case -2: throw TString::Format("File %s exists", dest.Data());
625  case -3: throw TString::Format("Error while copying %s", fn.Data());
626  }
627  }
628 
629  {
630  // Make our build file
631  if (verbose) Printf("Making build script");
632  std::ofstream out(Form("%s/PROOF-INF/BUILD.sh", dir.Data()));
633  if (!out) {
634  Error("ParUtilities::MakeAuxFilePAR",
635  "Failed to open out shell script");
636  return false;
637  }
638  out << "#!/bin/sh\n\n"
639  << "echo \"Nothing to be done\"\n\n"
640  << "# EOF" << std::endl;
641  out.close();
642  if (gSystem->Chmod(Form("%s/PROOF-INF/BUILD.sh", dir.Data()), 0755)) {
643  Error("ParUtilities::MakeAuxFilePAR",
644  "Failed to set exectuable flags on %s/PROOF-INF/BUILD.sh",
645  dir.Data());
646  return false;
647  }
648  }
649  {
650  if (verbose) Printf("Making setup script");
651  // Make our setup file
652  std::ofstream out(Form("%s/PROOF-INF/SETUP.C", dir.Data()));
653  if (!out) {
654  Error("ParUtilities::MakeAuxFilePAR",
655  "Failed to open out ROOT script");
656  return false;
657  }
658  // The SETUP script is executed in the package's directory in
659  // the package cache - not in the session directory. Hence,
660  // we take special care to get a link to the session directory
661  // from the package cache directory
662  out << "void SETUP()\n"
663  << "{\n"
664  << " TString oldDir(gSystem->WorkingDirectory());\n"
665  << " TSystemDirectory* dir = new TSystemDirectory(\".\",\".\");\n"
666  << " TList* files = dir->GetListOfFiles();\n"
667  << " if (!gSystem->ChangeDirectory(oldDir)) {\n"
668  << " Error(\"SETUP\", \"Failed to go back to %s\",\n"
669  << " oldDir.Data());\n"
670  << " return;\n"
671  << " }\n"
672  << " if (!files) {\n"
673  << " Warning(\"SETUP\", \"No files\");\n"
674  << " gSystem->Exec(\"pwd; ls -al\");\n"
675  << " return;\n"
676  << " }\n"
677  << " files->Sort();\n"
678  << " TString pkgDir = gSystem->WorkingDirectory();\n"
679  << " TString sesDir = gProofServ->GetSessionDir();\n"
680  << " Info(\"\",\"Session dir: %s\",sesDir);\n"
681  << " TIter next(files);\n"
682  << " TSystemFile* file = 0;\n"
683  << " while ((file = static_cast<TSystemFile*>(next()))) {\n"
684  << " TString name(file->GetName());\n"
685  << " if (name == \".\" || name == \"..\") continue;\n"
686  << " TString title(file->GetTitle());\n"
687  << " TString full(gSystem->ConcatFileName(pkgDir.Data(),\n"
688  << " name.Data()));\n"
689  << " TString tgt(gSystem->ConcatFileName(sesDir.Data(),\n"
690  << " name.Data()));\n"
691  << " if (file->IsA()->InheritsFrom(TSystemDirectory::Class())){\n"
692  << " gSystem->mkdir(tgt.Data(), true);\n"
693  << " continue;\n"
694  << " }\n"
695  << " Info(\"\",\"Linking %s to %s\",full.Data(),tgt.Data());\n"
696  << " gSystem->Symlink(full, tgt);\n"
697  << " }\n"
698  << "}\n"
699  << "// EOF " << std::endl;
700  out.close();
701  }
702  if (verbose) Printf("Packing up");
703  Int_t ret = 0;
704  ret = gSystem->Exec(Form("(cd %s && tar -c%szf %s.par %s)",
705  templ, (verbose ? "v" : ""),
706  name.Data(),name.Data()));
707  if (ret != 0)
708  throw TString::Format("Failed to create PAR file %s.PAR from %s",
709  name.Data(), name.Data());
710 
711  // --- Move PAR file to here -------------------------------------
712  if (verbose) Printf("Move here");
713  ret = gSystem->Exec(Form("mv -f %s/%s.par %s.par", templ, name.Data(),
714  name.Data()));
715  if (ret != 0)
716  throw TString::Format("Failed to rename %s/%s.par to %s.par: %s",
717  templ, name.Data(), name.Data(),
718  gSystem->GetError());
719 
720 
721  if (verbose) {
722  Printf("List content");
723  gSystem->Exec(Form("tar tzf %s.par", name.Data()));
724  }
725  retval = true;
726  }
727  catch (TString& e) {
728  Error("ParUtilities::MakeAuxFilePAR", "%s", e.Data());
729  retval = false;
730  }
731 
732  // --- Remove temporary directory --------------------------------
733  gSystem->Exec(Form("rm -rf %s", templ));
734 
735  return retval;
736  }
737 };
738 #endif
739 //
740 // EOF
741 //
static Bool_t MakeScriptPAR(Bool_t isLocal, const TString &script, const TString &deps, Railway *helper)
Definition: ParUtilities.C:202
static Bool_t Load(const TString &name)
Definition: ParUtilities.C:90
TSystem * gSystem
TCanvas * c
Definition: TestFitELoss.C:172
int Int_t
Definition: External.C:63
static Bool_t DoFind(const TString &what, TString &src)
Definition: ParUtilities.C:38
static Bool_t Find(const TString &what)
Definition: ParUtilities.C:65
static Bool_t MakeScriptBuildMacro(const TString &dir, const TString &base, const TString &ext, const TCollection *deps)
Definition: ParUtilities.C:374
static Bool_t MakeScriptUtilityScript(const TString &dir)
Definition: ParUtilities.C:416
Base class for analysis helpers.
bool Bool_t
Definition: External.C:53
static Bool_t MakeScriptSetupMacro(const TString &dir, const TString &base, const TString &ext, const TCollection *deps)
Definition: ParUtilities.C:496
static Bool_t Build(const TString &what)
Definition: ParUtilities.C:130
static Bool_t MakeScriptBuildScript(const TString &dir, const TString &base)
Definition: ParUtilities.C:332
static Bool_t MakeAuxFilePAR(const TList &files, const TString &name, Bool_t verbose=false)
Definition: ParUtilities.C:538
virtual Bool_t LoadLibrary(const TString &name, Bool_t slave=true, Bool_t forcePar=false)=0