On print directement la liste
Parce que sinon ça bouffe vraiment beaucoup de mémoire... darcs-hash:20080217235621-af139-2a4c8f0ee726f0bbd98be69a40ba059c36b8874b.gz
This commit is contained in:
parent
61ec58f133
commit
e23d60db29
1 changed files with 14 additions and 31 deletions
|
@ -23,40 +23,11 @@
|
||||||
'''Outil pour générer la liste des paquets avec leurs version pour le
|
'''Outil pour générer la liste des paquets avec leurs version pour le
|
||||||
plugin Rules de bcfg2.'''
|
plugin Rules de bcfg2.'''
|
||||||
|
|
||||||
__all__ = ["gen_rules"]
|
__all__ = []
|
||||||
|
|
||||||
import apt, commands
|
import apt, commands
|
||||||
from xml.dom.minidom import Document
|
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__":
|
if __name__ == "__main__":
|
||||||
import sys, os, time
|
import sys, os, time
|
||||||
|
|
||||||
|
@ -65,4 +36,16 @@ if __name__ == "__main__":
|
||||||
print >>sys.stderr, "Génération du document XML..."
|
print >>sys.stderr, "Génération du document XML..."
|
||||||
print ("<!-- Fichier autogénéré le %s avec %s -->" %
|
print ("<!-- Fichier autogénéré le %s avec %s -->" %
|
||||||
(time.ctime(), os.path.basename(sys.argv[0])))
|
(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>'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue