Commit e23d60db authored by Jeremie Dimino's avatar Jeremie Dimino

On print directement la liste

Parce que sinon ça bouffe vraiment beaucoup de mémoire...

darcs-hash:20080217235621-af139-2a4c8f0ee726f0bbd98be69a40ba059c36b8874b.gz
parent 61ec58f1
......@@ -23,40 +23,11 @@
'''Outil pour générer la liste des paquets avec leurs version pour le
plugin Rules de bcfg2.'''
__all__ = ["gen_rules"]
__all__ = []
import apt, commands
from xml.dom.minidom import Document
def gen_rules(cache):
'''Création des règles'''
doc = Document()
root = doc.createElement("Rule")
root.setAttribute("priority", "20")
if "sid" in file("/etc/debian_version").read():
distribution = doc.createElement("Group")
distribution.setAttribute("name", "debian-testing")
else:
distribution = doc.createElement("Group")
distribution.setAttribute("name", "debian-testing")
distribution.setAttribute("negate", "true")
group = doc.createElement("Group")
group.setAttribute("name", commands.getoutput("uname -m"))
root.appendChild(distribution)
distribution.appendChild(group)
pkgs = []
for pkg in cache:
if pkg.candidateVersion:
pkgs.append((pkg.name, pkg.candidateVersion))
pkgs.sort()
for (name, version) in pkgs:
pkginfo = doc.createElement("Package")
pkginfo.setAttribute("name", name)
pkginfo.setAttribute("version", version)
group.appendChild(pkginfo)
return root
if __name__ == "__main__":
import sys, os, time
......@@ -65,4 +36,16 @@ if __name__ == "__main__":
print >>sys.stderr, "Génération du document XML..."
print ("<!-- Fichier autogénéré le %s avec %s -->" %
(time.ctime(), os.path.basename(sys.argv[0])))
sys.stdout.write(gen_rules(cache).toprettyxml())
print '<Rule priority="20">'
if "sid" in file("/etc/debian_version").read():
print '<Group name="debian-testing">'
else:
print '<Group name="debian-testing" negate="true">'
print '<Group name="%s">' % commands.getoutput("uname -m")
for pkg in cache:
if pkg.candidateVersion:
print ('<Package name="%s" version="%s"/>' %
(pkg.name, pkg.candidateVersion))
print '</Group></Group></Rule>'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment