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.

96 lines
2.3 KiB

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