3 # Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
20 test -e "$UTIL_VSERVER_VARS" || {
21 echo "Can not find util-vserver installation; aborting..." >&2
24 . "$UTIL_VSERVER_VARS"
29 $"Usage: $0 <vserver-name> <tag>
31 Report bugs to <$PACKAGE_BUGREPORT>."
35 function showVersion()
38 pkgmgmt-info $PACKAGE_VERSION -- shows information about packages in vservers
39 This program is part of $PACKAGE_STRING
41 Copyright (C) 2004 Enrico Scholz
42 This program is free software; you may redistribute it under the terms of
43 the GNU General Public License. This program has absolutely no warranty."
49 local vdir=$($_VSERVER_INFO "$1" VDIR) || {
50 echo $"Can not determine vserver-root" >&2
54 if test -e "$vdir"/etc/redhat-release -o -e "$vdir"/etc/fedora-release; then
56 elif test -e "$vdir"/etc/mandrake-release; then
58 elif test -e "$vdir"/etc/debian_version; then
61 echo $"Can not determine packagemanagement style" >&2
66 (--help) showHelp $(basename $0);;
67 (--version) showVersion ;;
70 test "$1" -a "$2" || {
71 echo $"No vserver and/or tag given; use '--help' for more information" >&2
80 get-conffiles|install) ;;
81 *) echo $"Unsupport tag '$tag'" >&2; exit 1;;
84 cfgdir=$($_VSERVER_INFO "$vserver" APPDIR pkgmgmt) || :
85 vdir=$($_VSERVER_INFO "$1" VDIR) || :
89 { read style <"$cfgdir"/style; } 2>/dev/null
90 test "$style" || guessStyle "$vserver"
92 test ! -d "$cfgdir" -o -e "$cfgdir"/internal || is_external=1
102 ## rpm outputs sometimes '(contains no files)', so return
103 ## only the valid output
105 rpm_param=( -qac --pipe "sed '\!^/!p;d'" );;
107 rpm_param=( -Uvh "$@" )
108 apt_param=( install "$@" )
112 if test "$is_external"; then
114 test -d "$cfgdir"/base/apt -o -d "$cfgdir"/aptetc || have_apt=
117 for i in /bin /usr/bin /usr/local/bin; do
118 test ! -x "$vdir$i"/apt-get || { have_apt=1; break; }
122 if test "$is_external"; then
123 if test "$have_apt" -a "$apt_param"; then
124 cmd=( "$_VAPT_GET" "$vserver" -- "${apt_param[@]}" )
126 cmd=( "$_VRPM" "$vserver" -- "${rpm_param[@]}" )
129 if test "$have_apt" -a "$apt_param"; then
130 cmd=( "$_VSERVER" --silent "$vserver" exec apt-get "${apt_param[@]}" )
132 cmd=( "$_VSERVER" --silent "$vserver" exec rpm "${rpm_param[@]}" )
139 cmd=( sh -c "cat /var/lib/dpkg/info/*.conffiles 2>/dev/null" )
142 cmd=( apt-get install "$@" )
146 if test "$is_external"; then
147 echo $"'external' packagemanagement is not supported for Debian" >&2
150 cmd=( "$_VSERVER" --silent "$vserver" exec "${cmd[@]}" )