| 1 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 2 | // FILE : store_history.tol
|
|---|
| 3 | // PURPOSE : Almacena el instalador NSIS de TOLBase NSIS en el directorio
|
|---|
| 4 | // history
|
|---|
| 5 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 6 |
|
|---|
| 7 | //Busca el instalador cuyo nombre es de la forma "tolbase-*-setup.exe"
|
|---|
| 8 | Set installerName =
|
|---|
| 9 | {
|
|---|
| 10 | Set aux1 = GetDir(".")[1];
|
|---|
| 11 | Set aux2 = EvalSet(aux1,ToLower);
|
|---|
| 12 | Set aux3 = Select(aux2, Real(Text fileName)
|
|---|
| 13 | {
|
|---|
| 14 | TextBeginWith(fileName, "tolbase-") &
|
|---|
| 15 | TextEndAt (fileName, "-setup.exe")
|
|---|
| 16 | })
|
|---|
| 17 | };
|
|---|
| 18 |
|
|---|
| 19 | //Si se devuelve 0 es que todo ha ido bien. En caso contario el error es un
|
|---|
| 20 | //número negativo que codifica el error ocurrido.
|
|---|
| 21 | Real errorNumber = Case
|
|---|
| 22 | (
|
|---|
| 23 | //Si no se encuentra ningún instalador se devuelve error
|
|---|
| 24 | Card(installerName)==0,
|
|---|
| 25 | {
|
|---|
| 26 | WriteLn("No se encuentra el instalador de TOLBase","E");
|
|---|
| 27 | -1
|
|---|
| 28 | },
|
|---|
| 29 | //Si hay más de un instalador también se devuelve error
|
|---|
| 30 | Card(installerName)>1,
|
|---|
| 31 | {
|
|---|
| 32 | WriteLn("Hay más de un instalador de TOLBase:\n"<<installerName,"E");
|
|---|
| 33 | -2
|
|---|
| 34 | },
|
|---|
| 35 | //Si se encuentra un solo instalador se intenta procesar
|
|---|
| 36 | Card(installerName)==1,
|
|---|
| 37 | {
|
|---|
| 38 | Text hist = "history";
|
|---|
| 39 | //Se intenta crear el directorio de almacenamiento histórico
|
|---|
| 40 | Real OSDirMake(hist);
|
|---|
| 41 | Real ok1 = OSDirExist(hist);
|
|---|
| 42 | //Si por algún motivo no es posible construirlo se da un error
|
|---|
| 43 | If(!ok1,
|
|---|
| 44 | {
|
|---|
| 45 | WriteLn("No se puede crear el directorio de almacenamiento historico "
|
|---|
| 46 | "de instaladores '"+hist+"'","E");
|
|---|
| 47 | -3
|
|---|
| 48 | },
|
|---|
| 49 | {
|
|---|
| 50 | Text historicName = hist+"\\tolbase-"+ToName(Version)+"-setup.exe";
|
|---|
| 51 | WriteLn("Se va a almacenar el instalador de TOLBase \n "+
|
|---|
| 52 | installerName[1]+"\ncomo\n "+historicName+"\n");
|
|---|
| 53 | //Se borra un eventual fichero almacenado previamente con el mismo nombre
|
|---|
| 54 | Real OSFilRemove(historicName);
|
|---|
| 55 | //Se intenta copiar el fichero en el directorio histórico
|
|---|
| 56 | Real ok2 = OSFilCopy(installerName[1], historicName);
|
|---|
| 57 | If(!ok2,
|
|---|
| 58 | {
|
|---|
| 59 | WriteLn("No se puede copiar el instalador de TOLBase \n "+
|
|---|
| 60 | installerName[1]+"\ncomo\n "+historicName+"\n","E");
|
|---|
| 61 | -4
|
|---|
| 62 | },
|
|---|
| 63 | {
|
|---|
| 64 | //Se intenta borrar el instalador original para limpiar el directorio
|
|---|
| 65 | //NSIS en ulteriores sesiones
|
|---|
| 66 | Real ok3 = OSFilRemove(installerName[1]);
|
|---|
| 67 | If(ok3,
|
|---|
| 68 | {
|
|---|
| 69 | Text order = "plink tdt@cvs.tol-project.org \"cp "
|
|---|
| 70 | "/home/bayes/pub/bin/win/"+installerName[1]+" "+
|
|---|
| 71 | "/home/bayes/pub/bin/win/"+Replace(historicName,"\\","/")+"\"";
|
|---|
| 72 | WriteLn("almacenamiento del histórico en la web tol-project:\n"+order);
|
|---|
| 73 | Real ok4 = OSCmdWait(order);
|
|---|
| 74 | If(ok4, 0,
|
|---|
| 75 | {
|
|---|
| 76 | WriteLn("No se puede almacenar el histórico en la web tol-project","E");
|
|---|
| 77 | -5
|
|---|
| 78 | })
|
|---|
| 79 | },
|
|---|
| 80 | {
|
|---|
| 81 | WriteLn("No se puede borrar el instalador de TOLBase "+
|
|---|
| 82 | installerName[1],"E");
|
|---|
| 83 | -6
|
|---|
| 84 | })
|
|---|
| 85 | })
|
|---|
| 86 | })
|
|---|
| 87 | }
|
|---|
| 88 | );
|
|---|
| 89 |
|
|---|
| 90 | //Real Exit(errorNumber);
|
|---|
| 91 |
|
|---|
| 92 | /* */
|
|---|