summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/utils/prepup.pp
blob: 2f5480a42c8af1b782f4bbb12c9978308809a110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{
    This file is part of the Free Pascal test suite.
    Copyright (c) 2006 by the Free Pascal development team.

    This program collects the results of a testsuite run
    and prepares things for an upload of the results to the
    database

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

program prepup;

uses
  sysutils,libtar,zstream;

var
  tarwriter : ttarwriter;
  c : tgzfilestream;

procedure dosearch(const dir : string);

  procedure domask(const s : string);
    Var
      Info : TSearchRec;
      hs : string;
      i : integer;
    begin
      If FindFirst (dir+DirectorySeparator+s,faAnyFile,Info)=0 then
        begin
        Repeat
          With Info do
            begin
              hs:=dir+DirectorySeparator+Name;
              { strip leading ./ }
              delete(hs,1,2);
              tarwriter.addfile(hs);
            end;
        Until FindNext(info)<>0;
        end;
      FindClose(Info);
   end;

Var Info : TSearchRec;

Begin
  If FindFirst (dir+DirectorySeparator+'*',faDirectory,Info)=0 then
    begin
      Repeat
        With Info do
          begin
            If ((Attr and faDirectory) = faDirectory) and (name<>'.') and (name<>'..') then
              dosearch(dir+DirectorySeparator+name);
          end;
      Until FindNext(info)<>0;
    end;
  FindClose(Info);
  domask('*.elg');
  domask('*.log');
End;

begin
  if paramcount<>1 then
    begin
      writeln('Usage: prepup <name of .tar.gz>');
      halt(1);
    end;
    C:=TGZFileStream.Create(paramstr(1),gzOpenWrite);
    TarWriter := TTarWriter.Create (C);
  dosearch('.');
  TarWriter.AddFile('dbdigest.cfg');
  TarWriter.AddFile('log');

  TarWriter.free;
  c.free;
end.