#!/usr/bin/python

import re
import os
import string

all_pkg = []
pkg_regex = r"\"\w+[-.\w\d]*\""

with open("/data/core.list") as input_file:
    cmd_arg = input_file.read()

#cmd  = "debtree -q -R --show-all %s" % cmd_arg
cmd  = "debtree -q -R %s" % cmd_arg
data = os.popen(cmd).read()

result = re.findall(r"\"\w+[-.\w\d]*\"", data)
str=''.join(result).replace('\"\"','\n')
#str=''.join(result).replace('\"\"','\n').replace('\"','')
with open("/data/pkg.list","w") as save:
    save.write(str)
