summaryrefslogtreecommitdiff
path: root/gitupdateunit.pas
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2015-10-27 10:52:35 +0100
committerErich Eckner <git@eckner.net>2015-10-27 10:52:35 +0100
commit532d3e60aead3c722805518a20fe347d9abcd7ae (patch)
treeddf309c994364f402de19959a5f55104b2019ec8 /gitupdateunit.pas
parent3ebfdf688593001cdd359d7b374d289a9dcfdbb2 (diff)
downloadunits-532d3e60aead3c722805518a20fe347d9abcd7ae.tar.xz
temporäres Verzeichnis zum Kompilieren für gitupdateunit.pas
Diffstat (limited to 'gitupdateunit.pas')
-rw-r--r--gitupdateunit.pas35
1 files changed, 22 insertions, 13 deletions
diff --git a/gitupdateunit.pas b/gitupdateunit.pas
index 94e0263..64e820e 100644
--- a/gitupdateunit.pas
+++ b/gitupdateunit.pas
@@ -15,7 +15,7 @@ uses
var
updated: boolean;
myDir,baseDir,
- output,tmpFile: string;
+ output,tmpDir: string;
args: array of string;
initialization
@@ -24,7 +24,7 @@ initialization
myDir:=extractFilePath(paramstr(0));
baseDir:=extractFilePath(leftStr(myDir,length(myDir)-1));
- tmpFile:='';
+ tmpDir:='';
output:='';
setlength(args,1);
@@ -48,31 +48,40 @@ initialization
args[10]:='-Fu../units';
args[11]:='-Fu.';
args[12]:='-FUlib/x86_64-linux';
- tmpFile:=myDir+extractFileName(paramstr(0));
- if fileexists(tmpFile+'.lpr') then
- args[13]:=tmpFile+'.lpr'
+ args[13]:=myDir+extractFileName(paramstr(0));
+ if fileexists(args[13]+'.lpr') then
+ args[13]:=args[13]+'.lpr'
else
- args[13]:=tmpFile+'.pas';
- tmpFile:=mkTemp('/tmp/fpc.XXXXXX');
- args[14]:='-o'+tmpFile;
+ args[13]:=args[13]+'.pas';
+ tmpDir:=mkTemp('-d /tmp/fpc.XXXXXX');
+ args[14]:='-o'+tmpDir+'/output';
if runCommandInDir(myDir,'/usr/bin/fpc',args,output) then begin
setlength(args,2);
- args[0]:=tmpFile;
+ args[0]:=tmpDir+'/output';
args[1]:=paramstr(0);
if runCommand('/usr/bin/sha512sum',args,output) then begin
baseDir:=erstesArgument(output,#10);
if erstesArgument(baseDir)<>erstesArgument(output) then begin
deletefile(paramstr(0));
- if runCommand('/usr/bin/mv',args,output) then
- fpExecVe(paramstr(0),argv,envp);
+ if runCommand('/usr/bin/mv',args,output) then begin
+ setlength(args,2);
+ args[0]:='-rf';
+ args[1]:=tmpDir;
+ if runCommand('/usr/bin/rm',args,output) then
+ fpExecVe(paramstr(0),argv,envp);
+ end;
end;
end;
end;
end;
end;
end;
- if (tmpFile<>'') and fileexists(tmpFile) then
- deletefile(tmpFile);
+ if (tmpDir<>'') and directoryexists(tmpDir) then begin
+ setlength(args,2);
+ args[0]:='-rf';
+ args[1]:=tmpDir;
+ runCommand('/usr/bin/rm',args,output);
+ end;
setlength(args,0);
end.