2019-02-11 13:54:20 +00:00
|
|
|
#!/usr/bin/python3
|
2010-10-26 12:02:47 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
import sys
|
2010-10-26 12:02:47 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
import apt_pkg
|
|
|
|
|
|
|
|
if len(sys.argv) != 2:
|
|
|
|
sys.exit(1)
|
2010-10-26 12:02:47 +01:00
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
apt_pkg.init()
|
|
|
|
cache = apt_pkg.Cache()
|
|
|
|
package_records = apt_pkg.PackageRecords(cache)
|
|
|
|
known_packages = set()
|
|
|
|
with open(sys.argv[1], "w") as f:
|
|
|
|
for pkg in cache.packages:
|
|
|
|
if pkg.selected_state or not pkg.version_list or pkg.name in known_packages:
|
|
|
|
continue
|
2010-10-26 12:02:47 +01:00
|
|
|
name = pkg.name
|
2019-02-11 13:54:20 +00:00
|
|
|
package_records.lookup(pkg.version_list.pop(0).translated_description.file_list.pop(0))
|
|
|
|
summary = package_records.short_desc
|
|
|
|
description = package_records.long_desc.replace(summary + "\n ", "").replace("\n .\n ", "~~~").replace("\n", "")
|
|
|
|
f.write("CACHE###%s###%s###%s\n" % (name, summary, description))
|
|
|
|
known_packages.add(name)
|
|
|
|
except Exception as e:
|
|
|
|
print("ERROR###ERROR###ERROR###ERROR")
|
|
|
|
print(e)
|
2010-10-26 12:02:47 +01:00
|
|
|
sys.exit(1)
|