Géeneration automatique des listes de paquets pour bcfg2
darcs-hash:20080319233101-af139-5519d4ba2df29dfc00711f815adce99d93984343.gz
This commit is contained in:
parent
8c31851006
commit
c42796ee67
2 changed files with 42 additions and 21 deletions
|
@ -4,7 +4,7 @@
|
||||||
# create-versions-index.py
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,27 +25,32 @@ plugin Rules de bcfg2.'''
|
||||||
|
|
||||||
__all__ = []
|
__all__ = []
|
||||||
|
|
||||||
import apt, commands
|
import apt_pkg, sys, os, time
|
||||||
from xml.dom.minidom import Document
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
apt_pkg.init()
|
||||||
import sys, os, time
|
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
|
||||||
|
|
||||||
print >>sys.stderr, "Chargement du cache..."
|
list = ver.items()
|
||||||
cache = apt.Cache()
|
list.sort()
|
||||||
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])))
|
||||||
|
|
||||||
print '<Rule priority="20">'
|
|
||||||
if "sid" in file("/etc/debian_version").read():
|
print '<Rule priority="20">'
|
||||||
print '<Group name="debian-testing">'
|
if sys.argv[2] == "testing":
|
||||||
else:
|
print '<Group name="debian-testing">'
|
||||||
print '<Group name="debian-testing" negate="true">'
|
else:
|
||||||
print '<Group name="%s">' % commands.getoutput("uname -m")
|
print '<Group name="debian-testing" negate="true">'
|
||||||
for pkg in cache:
|
print '<Group name="%s">' % sys.argv[1]
|
||||||
if pkg.candidateVersion:
|
|
||||||
print ('<Package name="%s" version="%s"/>' %
|
for (name,ver) in list:
|
||||||
(pkg.name, pkg.candidateVersion))
|
print '<Package name="%s" version="%s"/>' % (name, ver)
|
||||||
print '</Group></Group></Rule>'
|
|
||||||
|
print '</Group></Group></Rule>'
|
||||||
|
|
||||||
|
|
16
bcfg2/create-versions-index.sh
Executable file
16
bcfg2/create-versions-index.sh
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/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
|
Loading…
Add table
Add a link
Reference in a new issue