OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.3 KiB

  1. -- --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. -- This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. --
  4. -- T2 SDE: misc/lua/sde/pkgdb.lua
  5. -- Copyright (C) 2005 - 2006 The T2 SDE Project
  6. -- Copyright (C) 2005 - 2006 Valentin Ziegler, Juergen "George" Sawinski
  7. --
  8. -- More information can be found in the files COPYING and README.
  9. --
  10. -- This program is free software; you can redistribute it and/or modify
  11. -- it under the terms of the GNU General Public License as published by
  12. -- the Free Software Foundation; version 2 of the License. A copy of the
  13. -- GNU General Public License can be found in the file COPYING.
  14. -- --- T2-COPYRIGHT-NOTE-END ---
  15. -- TODO:
  16. -- - add "update-priority" (like "urgent,security,normal" etc)
  17. -- (also needs to go into create_package_db and other places)
  18. -- DESCRIPTION:
  19. -- p = pkgdb.parse(line-iterator)
  20. -- Parse the package.db (takes a line iterator as input)
  21. require "sde/desc"
  22. -- parse all packages.db information into tables
  23. -- filelist saving commented out (eats another 30M)
  24. local function block_lines()
  25. local line = lines()
  26. if (line == nil) or (line=="\023") then
  27. return nil
  28. end
  29. return line
  30. end
  31. local function read_deps()
  32. local deps={}
  33. for line in block_lines do
  34. _,_,dependency = string.find(line, "[^ ]* (.*)")
  35. table.insert (deps, dependency)
  36. end
  37. return deps
  38. end
  39. local function read_flist()
  40. local files={}
  41. local cksums={}
  42. local sizes={}
  43. local usage=0
  44. for line in block_lines do
  45. _,_,cksum,size,file = string.find(line, "^([0-9]+) ([0-9]+) (.*)")
  46. -- uncomment these lines if you want to save complete file list
  47. -- table.insert (files, file);
  48. -- table.insert (cksums, 1 * cksum);
  49. -- table.insert (sizes, 1 * size);
  50. usage = usage + size
  51. end
  52. return usage,files,cksums,sizes
  53. end
  54. local function parse(lines)
  55. packages = {}
  56. repeat -- parse packages
  57. pkgname = lines()
  58. if pkgname then
  59. print(pkgname)
  60. local pkg_data = {}
  61. if lines() ~= "\023" then -- separator line
  62. print ("terminating line missing\n")
  63. end
  64. pkg_data.desc = desc.parse (block_lines)
  65. pkg_data.deps = read_deps ()
  66. pkg_data.usage = read_flist ()
  67. if lines() ~= "\004" then -- separator line
  68. print ("terminating line missing\n")
  69. end
  70. packages[pkgname] = pkg_data
  71. end
  72. until pkgname == nil
  73. return packages
  74. end