1 -- --- T2-COPYRIGHT-NOTE-BEGIN ---
2 -- This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 -- T2 SDE: misc/lua/parse-db.lua
5 -- Copyright (C) 2005 - 2006 The T2 SDE Project
7 -- More information can be found in the files COPYING and README.
9 -- This program is free software; you can redistribute it and/or modify
10 -- it under the terms of the GNU General Public License as published by
11 -- the Free Software Foundation; version 2 of the License. A copy of the
12 -- GNU General Public License can be found in the file COPYING.
13 -- --- T2-COPYRIGHT-NOTE-END ---
15 -- parse all packages.db information into tables
16 -- filelist saving commented out (eats another 30M)
21 function block_lines()
23 if (line
== nil) or (line
=="\023") then
31 for line
in block_lines
do
32 _
,_
,dependency
= string.find(line
, "[^ ]* (.*)");
33 table.insert (deps
, dependency
);
43 for line
in block_lines
do
44 _
,_
,cksum
,size
,file
= string.find(line
, "^([0-9]+) ([0-9]+) (.*)");
45 -- uncomment theese lines if you want to save complete file list
46 -- table.insert (files, file);
47 -- table.insert (cksums, 1 * cksum);
48 -- table.insert (sizes, 1 * size);
51 return usage
,files
,cksums
,sizes
;
55 zf
,error = lzlib
.open("./packages.db", "r");
56 if not zf
then -- failed to open file, print error
59 lines
= zf
:lines(); -- obtain line iterator
63 repeat -- parse packages
69 if lines() ~= "\023" then -- separator line
70 print ("terminating line missing\n");
73 pkg_data
.desc
=t2_desc
.parse (block_lines
);
74 pkg_data
.deps
=read_deps ();
75 pkg_data
.usage
= read_flist ();
76 if lines() ~= "\004" then -- separator line
77 print ("terminating line missing\n");
80 packages
[pkgname
] = pkg_data
;
84 _
,normal_eof
,error = zf
:eof ();
85 if not normal_eof
then -- check if stream ended because of error
86 print ("-- abnormal end of stream: ", error);
89 ok
,error = zf
:close();
91 print ("could not close stream: ", error);
94 print(x
, "kb dynamic memory used.");