41 const char*
const kRM =
"/bin/rm -rf";
42 const char*
const kLS =
"/bin/ls -l";
43 const char*
const kUNTAR =
"%s -c %s/%s | (cd %s; tar xf -)";
44 const char*
const kUNTAR3 =
"%s -c %s | (tar xf -)";
47 const char*
const kCP =
"copy";
48 const char*
const kRM =
"delete";
49 const char*
const kLS =
"dir";
50 const char*
const kUNTAR =
"...";
51 const char*
const kUNTAR2 =
"...";
52 const char*
const kUNTAR3 =
"...";
53 const char*
const kGUNZIP =
"gunzip";
64 : fLogger(
DefaultLogger), fName(key), fDir(dir), fLock(dir), fEnabledPackages(0)
108 Info(
"Build",
"building package %s ...", pack);
124 FILE *
f = fopen(
"PROOF-INF/proofvers.txt",
"r");
131 if (!f || !goodver) {
135 " (current: %s, build: %s): cleaning ... ",
149 cmd.
Form(kUNTAR3, gunzip, par.
Data());
152 Error(
"Build",
"failure executing: %s", cmd.
Data());
157 TString md5f = pdir +
"/PROOF-INF/md5.txt";
164 Warning(
"Build",
"failure calculating/saving MD5sum for '%s'", par.
Data());
169 Error(
"Build",
"%s not found", kGUNZIP);
174 " directory not writable: cannot re-build!!! ",
188 cmd.
Form(
"export ROOTINCLUDEPATH=\"%s\" ; PROOF-INF/BUILD.sh", ipath.Data());
191 Error(
"Build",
"failure executing: %s", cmd.
Data());
195 f = fopen(
"PROOF-INF/proofvers.txt",
"w");
197 fputs(
gROOT->GetVersion(),
f);
207 Info(
"Build",
"no PROOF-INF/BUILD.sh found for package %s", pack);
255 return packmgr->
Load(pack, optls);
266 Log(
TString::Format(
"info: TPackMgr::Load: checking dependencies for package %s ...", pack));
271 if (
Load(os->GetName(), optls) < 0) {
273 Log(
TString::Format(
"error: TPackMgr::Load: failure loading dep %s ...", os->GetName()));
286 chkveropt = pcv->
GetVal();
291 if (
Build(pack, chkveropt) < 0) {
309 TMacro setupmc(
"PROOF-INF/SETUP.C");
317 Log(
TString::Format(
"warning: macro '%s/PROOF-INF/SETUP.C' does not contain a SETUP()" 322 if (!setupmc.
Load()) {
325 " cannot continue", pack));
332 Log(
TString::Format(
"error: function SETUP() not found in macro '%s/PROOF-INF/SETUP.C':" 333 " cannot continue", pack));
341 if (optls && optls->
GetSize() > 0) {
343 " the specified argument will be ignored", pack));
351 if (argsig.BeginsWith(
"TList")) {
354 }
else if (argsig.BeginsWith(
"const char")) {
360 if (optls && optls->
First()) {
362 " SETUP expects 'const char *': ignoring",
370 " cannot continue", arg->
GetTitle()));
375 Log(
"error: cannot get information about the SETUP() argument:" 381 Log(
"error: function SETUP() can have at most a 'TList *' argument:" 386 Long_t setuprc = (rc == 0) ? 0 : -1;
389 if (setuprc < 0) rc = -1;
431 if (pack && strlen(pack) > 0) {
457 while ((ppack = (
TPair *) nxp())) {
505 if (strstr(pack,
".par")) pn.
Remove(pn.
Last(
'.'));
522 while ((pck = (
TPair *)nxp())) {
523 if (packlist.
Length() <= 0)
538 const char *fm = (strstr(pack,
".par")) ?
"%s/%s" :
"%s/%s.par";
574 if (title && strlen(title) > 0)
575 printf(
"%s\n", title);
595 if (pack && strlen(pack)) {
611 Int_t rc1 = 0, rc2 = 0, rc3 = 0;
612 if (pack && strlen(pack)) {
628 return (rc1 + rc2 + rc3);
641 while (pac.Length() > 0) {
642 if (pac.EndsWith(
".par")) {
660 TList *epl =
nullptr;
665 while ((o = nxp())) {
690 if (title && strlen(title) > 0)
691 printf(
"%s\n", title);
698 printf(
"%s\n", pck->GetName());
711 const char *fm = (strstr(pack,
".par")) ?
"%s/%s" :
"%s/%s.par";
741 if (!fn.EndsWith(
".par")) fn +=
".par";
752 Error(
"Unpack",
"failure executing: %s (rc: %d)", cmd.
Data(), rc);
755 Error(
"Unpack",
"%s not found", kGUNZIP);
762 Error(
"Unpack",
"package %s did not unpack into %s", fn.Data(), pn.
Data());
784 Info(
"Install",
"installing %s ...", parpath);
789 Error(
"Install",
"%s is invalid", par);
796 TMD5 *sums = 0, *md5 = 0, *md5d = 0;
803 Error(
"Install",
"could not create/get download directory");
814 Warning(
"Install",
"could not retrieve %s", parsum.
Data());
830 Error(
"Install",
"could not remove existing version of '%s'", pack.
Data());
838 psrc.Form(
"%s/%s", dldir.
Data(), parname.
Data());
840 Error(
"Install",
"could not retrieve %s", par);
849 if (*sums != *md5) install =
kTRUE;
852 if (sums)
delete sums;
857 Error(
"Install",
"could not copy %s to %s", psrc.Data(), dest.Data());
863 if (md5 && *md5 != *md5d)
864 Warning(
"Install",
"checksums do not match:\n\tdownloaded:\t%s\n\texpected:\t%s",
865 md5d->AsString(), md5->AsString());
866 if (
Unpack(pack, md5d) != 0) {
867 Error(
"Install",
"could not unpack %s", dest.Data());
887 if (globpack.
Length() > 0) {
890 while (globpack.
Tokenize(ldir, from,
":")) {
892 ::Warning(
"TPackMgr::RegisterGlobalPath",
893 "directory for global packages %s does not" 894 " exist or is not readable", ldir.
Data());
898 key.
Form(
"G%d", ng++);
906 ::Info(
"TPackMgr::RegisterGlobalPath",
907 "manager for global packages directory %s added to the list",
924 if (packmgr && packmgr->
Has(pack))
return packmgr;
931 if (pm->
Has(pack))
return pm;
947 if (packmgr && packmgr->
GetParPath(pack, par) == 0)
return 1;
961 if (par.
Length() > 0)
return 0;
static Int_t FindParPath(TPackMgr *packmgr, const char *pack, TString &par)
Get the full path to PAR, looking also in the global dirs.
static THashList * fgGlobalPackMgrList
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
TList * GetListOfLines() const
Bool_t IsPackageEnabled(const char *pack)
TMD5 * ReadMD5(const char *pack)
Read MD5 checksum of the PAR file from the PROOF-INF/md5.txt file.
The PROOF package manager contains tools to manage packages.
static long int sum(long int i)
void GetEnabledPackages(TString &packlist)
Method to get a semi-colon separated list with the names of the enabled packages. ...
Int_t Unlock()
Unlock the directory.
virtual int GetPid()
Get process id.
Int_t Lock(Bool_t shared=kFALSE)
static Bool_t IsEnabled(const char *pack, TPackMgr *packmgr=nullptr)
Check if the package is enabled; priority is given to packmgr, if defined.
const char * GetName() const
Returns name of object.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual const char * WorkingDirectory()
Return working directory.
static TMD5 * FileChecksum(const char *file)
Returns checksum of specified file.
Collectable string class.
virtual ~TPackMgr()
Destroy a TPackMgr instance.
TString & ReplaceAll(const TString &s1, const TString &s2)
const char *const kUNTAR3
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Int_t Unload(const char *pack)
Method to unload a package.
Int_t GetParPath(const char *pack, TString &path)
Method to get the path of the PAR file for package 'pack'.
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
static TPackMgr * GetPackMgr(const char *pack, TPackMgr *packmgr=nullptr)
Get the package manager having 'pack'; priority is given to packmgr, if defined.
Class supporting a collection of lines with C++ code.
Int_t Clean(const char *pack)
Clean dir for package 'pack' Return -1 in case of error, 0 otherwise.
Int_t GetPackDir(const char *pack, TString &pdir)
Method to get the path of the dir for package 'pack'.
Int_t Load(const char *pack, TList *optls=0)
Method to load a package taking an option list Return -1 on error, 0 otherwise.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Each ROOT method (see TMethod) has a linked list of its arguments.
TPackMgr(const TPackMgr &)
void Show(const char *title=0)
Show available packages.
Int_t Unpack(const char *pack, TMD5 *sum=0)
Read MD5 checksum of the PAR file from the PROOF-INF/md5.txt file.
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
const char *const kGUNZIP
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t buffersize=1000000)
Allows to copy this file to the dst URL.
Int_t Install(const char *par, Bool_t rmold=kFALSE)
Install package from par (unpack the file in the directory); par can be an URL for remote retrieval...
TList * GetListOfEnabled() const
Get list of enabled packages Returns a pointer to a TList object, transferring ownership to the calle...
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual TObjString * GetLineWith(const char *text) const
Search the first line containing text.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
This code implements the MD5 message-digest algorithm.
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=0)
Resolve the file type as a function of the protocol field in 'name'.
void SetName(const char *name)
Set the name of the TNamed.
void ShowEnabled(const char *title=0)
Show enabled packages.
void Init(const TFunction *func)
Initialize the method invocation environment based on the TFunction object.
virtual const char * Getenv(const char *env)
Get environment variable.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Method or function calling interface.
const char * GetTitle() const
Returns title of object.
virtual Bool_t Load() const
Load the macro into the interpreter.
TList * GetList() const
Get list of available packages Returns a pointer to a TList object, transferring ownership to the cal...
const char * GetName() const
Returns name of object.
Named parameter, streamable and storable.
Int_t Build(const char *pack, Int_t opt=TPackMgr::kCheckROOT)
Method to build a package.
Bool_t IsInDir(const char *path)
Method to check if 'path' is in the managed directory Return kTRUE or kFALSE.
Int_t GetNargs() const
Number of function arguments.
void SetName(const char *path)
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
R__EXTERN TSystem * gSystem
static Int_t WriteChecksum(const char *file, const TMD5 *md5)
Writes checksum in ASCII format to specified file.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the , or until EOF.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * GetName() const
Returns name of object.
virtual Int_t ReadFile(const char *filename)
Read lines in filename in this macro.
const char *const kUNTAR2
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual void FreeDirectory(void *dirp)
Free a directory.
TString GetString() const
TString & Remove(Ssiz_t pos)
Class used by TMap to store (key,value) pairs.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
virtual const char * GetIncludePath()
Get the list of include path.
void ResetParam()
Reset parameter list. To be used before the first call the SetParam().
TList * GetListOfMethodArgs()
Return list containing the TMethodArgs of a TFunction.
virtual const char * HostName()
Return the system's host name.
virtual int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
static Int_t RegisterGlobalPath(const char *paths)
Parse one or more paths as possible sources of packages Returns number of paths added; or -1 in case ...
Bool_t Has(const char *pack)
Method to check if this package manager has package 'pack'.
Mother of all ROOT objects.
Global functions class (global functions are obtained from CINT).
Int_t GetDownloadDir(TString &dldir)
Method to get the download dir; create if not existing Return -1 in case of error (not found; not cre...
virtual void Add(TObject *obj)
void Execute(const char *, const char *, int *=0)
Execute method on this object with the given parameter string, e.g.
#define dest(otri, vertexptr)
void SetParam(Long_t l)
Add a long method parameter.
void Log(const char *msg)
Wrapper to notofuer / logger.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Int_t Remove(const char *pack=0, Bool_t dolock=kTRUE)
Remove package 'pack' If 'pack' is null or empty all packages are cleared.
virtual void AddIncludePath(const char *includePath)
Add includePath to the already set include path.
const AParamType & GetVal() const
TMD5 * GetMD5(const char *pack)
Get MD5 checksum of the PAR file corresponding to given package Returns a pointer to a TMD5 object...
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual const char * GetName() const
Returns name of object.
virtual Int_t GetSize() const
static TMD5 * ReadChecksum(const char *file)
Returns checksum stored in ASCII in specified file.
void SetString(const char *s)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
static void DefaultLogger(const char *msg)
virtual void SetIncludePath(const char *includePath)
IncludePath should contain the list of compiler flags to indicate where to find user defined header f...
virtual const char * GetTitle() const
Returns title of object.
const char * Data() const