Commit c42796ee authored by Jeremie Dimino's avatar Jeremie Dimino

Géeneration automatique des listes de paquets pour bcfg2

darcs-hash:20080319233101-af139-5519d4ba2df29dfc00711f815adce99d93984343.gz
parent 8c318510
......@@ -4,7 +4,7 @@
# create-versions-index.py
# ------------------------
#
# Copyright (C) 2008 Jeremie Dimino <jeremie@dimino.org>
# Copyright (C) 2008 Jeremie Dimino <dimino@crans.org>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -25,27 +25,32 @@ plugin Rules de bcfg2.'''
__all__ = []
import apt, commands
from xml.dom.minidom import Document
if __name__ == "__main__":
import sys, os, time
print >>sys.stderr, "Chargement du cache..."
cache = apt.Cache()
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])))
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>'
import apt_pkg, sys, os, time
apt_pkg.init()
ver = {}
for line in sys.stdin:
[name, new_ver] = line.split()
old_ver = ver.get(name, None)
if not old_ver or apt_pkg.VersionCompare(new_ver, old_ver) == 1:
ver[name] = new_ver
list = ver.items()
list.sort()
print ("<!-- Fichier autogénéré le %s avec %s -->" %
(time.ctime(), os.path.basename(sys.argv[0])))
print '<Rule priority="20">'
if sys.argv[2] == "testing":
print '<Group name="debian-testing">'
else:
print '<Group name="debian-testing" negate="true">'
print '<Group name="%s">' % sys.argv[1]
for (name,ver) in list:
print '<Package name="%s" version="%s"/>' % (name, ver)
print '</Group></Group></Rule>'
#!/bin/bash
# Outil pour générer la liste des paquets pour bcfg2
generate () {
# $1 = distribution (etch, lenny, ...)
distrib=$1
arch=$2
arch2=$3
cat $(locate -r "/$distrib/.*/binary-$arch/Packages$") /mirror/custom/Packages | \
awk '$1 == "Package:" {printf "%s ", $2} $1 == "Version:" {print $2}' | \
/usr/scripts/bcfg2/create-versions-index.py $arch2 $distrib > /usr/scripts/var/bcfg2/packages-generated-$distrib-$arch2.xml
}
generate etch i386 i686
generate etch amd64 x86_64
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