3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 # based on distrib-info by Jacques Gelinas
5 # Debian support shoe-horned in by Matthew Lavy <mml@mupsych.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 # This scripts knows about every possible distribution (well, it should)
23 # It is passed a vserver name and a key (a command). The key represent a task.
24 # It executes the command and output on stdout.
26 # distrib-info vserver1 pkgversion
27 # If vserver1 is a redhat system, it executes
28 # rpm -qa --queryformat "%{name}=%{version}-%{release}
29 : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
30 test -e "$UTIL_VSERVER_VARS" || {
31 echo "Can not find util-vserver installation; aborting..."
34 . "$UTIL_VSERVER_VARS"
36 if [ "$1" = "" ] ; then
37 echo distrib-info vserver-name command [ args ... ] >&2
38 echo Commands are: >&2
39 echo dumpfiles: Shows all files owned by a package >&2
40 echo pkgversion: reports all packages and their version/release >&2
41 echo unifiles: reports all unify-able file of a package >&2
44 if [ "$1" = "/" ] ; then
47 elif [ -d "$1" ] ; then
49 CHROOTCMD="$SBINDIR/chroot $DISTDIR"
52 CHROOTCMD="$SBINDIR/chroot $DISTDIR"
57 if [ -f $DIRDIR/etc/redhat-release -o -f $DISTDIR/etc/mandrake-release ] ; then
60 $CHROOTCMD /bin/rpm -qa --queryformat "%{name}=%{version}-%{release}\n"
63 # We remove /etc and /var/log to make sure no special file
64 # there will be unified
65 $CHROOTCMD /bin/rpm -ql --dump $* \
66 | $PKGLIBDIR/parserpmdump /etc/
69 $CHROOTCMD /bin/rpm -ql $*
72 echo unknown request $KEY >&2
75 elif [ -f $DISTDIR/etc/debian_version ] ; then
78 $CHROOTCMD /usr/bin/dpkg-query -W \
79 --showformat='${Package}=${Version}#${Status}\n' \
80 | perl -pe 's/(.+)-.*/$1/' \
81 | grep "install ok installed" | cut -d"#" -f1
84 echo $* | perl -pe 's/(.+)-.*/$1/' \
85 | xargs $CHROOTCMD /usr/bin/dpkg -L \
86 | grep -v "^/etc\|^/var"
89 echo $* | perl -pe 's/(.+)-.*/$1/' \
90 | xargs $CHROOTCMD /usr/bin/dpkg -L
93 echo unknown request $KEY >&2
97 echo Distribution not supported yet >&2