2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # T2 SDE: misc/vserver/install
6 # Copyright (C) 2006 Juergen "George" Sawinski
7 # Copyright (C) 2006 The T2 SDE Project
9 # More information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; version 2 of the License. A copy of the
14 # GNU General Public License can be found in the file COPYING.
15 # --- T2-COPYRIGHT-NOTE-END ---
19 # - implement "update" mode
21 # - implement $admdir outside $root
22 # - post-installation methods
23 # - add rootfs alike copy_and_parse functionality
25 # root directory defaults
27 vdirbase
=/etc
/vservers
/.defaults
/vdirbase
30 # files (selections) to install
47 templatedir
=.
/${0%/*}/templates
#FIXME /etc/vserver/.distributions/t2/templates
48 patterndir
=.
/${0%/*}/patterns
#FIXME /etc/vserver/.distributions/t2/patterns
50 #############################################################################
53 vserver-guest-install [options] [packages]
57 -i,-install Install packages (default)
58 -u,-update Update packages
59 -r,-remove Remove packages
60 -c,-check Check packages
63 -g,-guest <name of guest> Name of the vserver guest
64 -R,-root <root> Root installation directory (./test)
67 -t,-template <template> Template name or file
70 -v Increase verbosity level
71 -pkgdir Package directory
72 -admdir Set alternate /var/adm directory
73 (a link into the install root is created)
80 -i|
-install) method
=install ;;
81 -u|
-update) method
=update
;;
82 -r|
-remove) method
=remove
;;
84 -g|
-guest) guest
=$2 ; root
=$vdirbase/$2 ; shift ;;
85 -R|
-root) root
=$2 ; shift ;;
87 -t|
-template) templates
="$templates $2" ; shift ;;
89 -v) verbose
=$
(( $verbose + 1 )) ;;
90 -vv) verbose
=$
(( $verbose + 2 )) ;;
91 -vvv) verbose
=$
(( $verbose + 3 )) ;;
92 -pkgdir) pkgdir
=$2 ; shift ;;
93 -admdir) admdir
=$2 ; shift ;;
102 #############################################################################
105 [ $1 -le $verbose ] ||
return
113 head) echo "=== $*" 1>&2 ;;
114 status
) echo "-> $*" 1>&2 ;;
115 warn
) echo "!!! $*" 1>&2 ;;
116 error
) echo "*** $*" 1>&2 ;;
117 info
) lvl
=$1; shift ; echo "[$lvl] $*" 1>&2 ;;
121 #############################################################################
126 dbg
2 " Parsing template \`$1'"
129 if [[ $line = .include
* ]]; then
130 parse_template
${line/.include/}
134 done < <(egrep -v '(#.*|^)$' $templatedir/$1)
137 dbg
1 "Assembling templates...."
140 for tmpl
in $templates; do
141 parse_template
$tmpl >> $tmpfile
143 echo $pkgs >> $tmpfile
144 sort -u < $tmpfile > $pfile
145 pkgs
=" `cat $pfile` "
146 rm -f $tmpfile $pfile
150 #############################################################################
152 pkgdb
=$pkgdir/packages.db
159 zcat
$pkgdb |
egrep "^$1$" -A 10000 |
grep "$block_end" -m 1 -B 10000
162 # extract_package_node <package> <dir>
167 _pkgdb_node
$1 |
while read line
; do
168 if [ "$line" = "$entry_end" -o "$line" = "$block_end" ]; then
169 state
=$
(( $state + 1 ))
172 1) echo $line >> $2/$1.desc
;;
173 2) echo $line >> $2/$1.deps
;;
174 3) echo $line >> $2/$1.md5
;;
180 #############################################################################
187 for f
in default $
*; do
188 [ -f $patterndir/$f ] && egrep -v "(^|#.*)$" $patterndir/$f
190 ) |
while read pat
; do
192 mine
) echo -n "-x '$pat' " ;;
197 #############################################################################
205 for ext
in tar.bz2
; do # FIXME list of extensions!!!
206 if [ -f $pkgdir/$1.
$ext ]; then
210 ver
="`_pkgdb_node $1 | fgrep '[V]'`" ; ver
=${ver##* }
211 if [ -f $pkgdir/$1-$ver.
$ext ]; then
212 echo $pkgdir/$1-$ver.
$ext
218 msg error
"Package archive of \`$1' not found."
221 #############################################################################
222 # install, update, remove packages
224 msg
head "Installing..."
229 [ $verbose -gt 2 ] && v
="-v"
234 dbg
2 mine
-i -R $root $
( pattern
$p ) $
( archive
$pkg )
235 eval mine
-i $v -R $root $
( pattern
$p ) $
( archive
$pkg )
245 echo mine
-r -R $vdirbase/$guest $pkg
251 echo "Not implemented: $method"