1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
#! /bin/sh
set -e
# WARNING: This script is in sometimes-works-for-me state. Only use if
# you understand what's going on.
# Setup
: ${chroot_dir:=../chroot}
: ${debmirror:=http://ftp.de.debian.org/debian}
: ${proxy:=http://proxy.galaxy:3128/}
woodytar=$chroot_dir/woody_base.tar.gz
# List our packages
list_packages() {
local p ver
ver=`dpkg-parsechangelog|sed -ne 's/^Version: //p'`
for p in `dh_listpackages`; do
(cd .. && echo ${p}_$ver*deb)
done
}
# Run a command inside the chroot
in_target() {
chroot $chroot_dir/woody "$@"
}
# Set a debconf variable inside the chroot
debconf_set() {
local name=$1
shift
cat >>$chroot_dir/woody/var/cache/debconf/config.dat <<EOF
Name: $name
Template: $name
Flags: seen
Value: $@
EOF
}
# Setup a woody chroot
setup_chroot() {
# Kill an existing chroot
rm -Rf $chroot_dir/woody
# If there is a tar archive with a base system we use it
if [ -e $woodytar ]; then
mkdir $chroot_dir/woody
tar -C $chroot_dir/woody -xzvf $woodytar | \
shtool prop -p "Unpacking system from $woodytar"
# Otherwise we need to create a new base system and save it
# to a tar for the next time
else
debootstrap woody $chroot_dir/woody $debmirror | \
shtool prop -p "Creating base system from $debmirror"
tar -C $chroot_dir/woody -czvf $woodytar . | \
shtool prop -p "Saving system to $woodytar"
fi
# Install a suitable apt configuration
echo "deb $debmirror woody main" \
> $chroot_dir/woody/etc/apt/sources.list
echo "Acquire::HTTP::Proxy \"$proxy\";" \
> $chroot_dir/woody/etc/apt/apt.conf
in_target apt-get update
in_target mount -t proc none /proc
# We don't want any debconf interaction
#debconf_set debconf/frontend Noninteractive
}
# These are our example configurations for testing the upgrade
conf_domain_or_host() {
debconf_set slapd/fill_method auto
debconf_set slapd/suffix_type "domain or host"
debconf_set slapd/domain "some.example.net"
debconf_set slapd/replicate false
debconf_set shared/organization Some Organization
}
check_domain_or_host() {
sleep 2 # wait for slapd to startup
in_target ldapsearch -h localhost -b dc=some,dc=example,dc=net -x \
objectclass=\*
}
conf_location() {
debconf_set slapd/fill_method auto
debconf_set slapd/suffix_type "location"
debconf_set shared/locale/countrycode de
debconf_set shared/organization "Sample Organization"
debconf_set slapd/replicate false
debconf_set shared/organization Some Organization
}
check_location() {
sleep 2 # wait for slapd to startup
in_target ldapsearch -h localhost -b "o=Some Organization, c=de" \
-x objectclass=\*
}
# Install slapd inside the chroot
install_slapd() {
in_target apt-get -y install slapd ldap-utils
}
# Do an upgrade of our packages inside the chroot
upgrade() {
# Link our packages into the chroot
for p in `list_packages`; do
ln ../$p $chroot_dir/woody/root/
done
# Create a packages file
(cd $chroot_dir/woody/root && dpkg-scanpackages . /dev/null >Packages)
# Switch to unstable
echo "deb $debmirror unstable main" \
> $chroot_dir/woody/etc/apt/sources.list
echo "deb file:/root ./" >> $chroot_dir/woody/etc/apt/sources.list
# Update package lists
in_target apt-get update
# Tell our scripts to fix the config
debconf_set slapd/fix_directory true
debconf_set slapd/password1 foobar
# Do an upgrade of our packages
in_target apt-get install -y `dh_listpackages`
}
# Checks if upgrading a woody system with slapd configured with the
# command given works.
check_upgrade() {
setup_chroot
conf_$1
debconf_set slapd/password1 foobar
debconf_set slapd/password2 foobar
install_slapd
check_$1
upgrade
check_$1
in_target /etc/init.d/slapd stop
in_target umount /proc
}
# Try upgrading our example setups
for i in domain_or_host location; do
check_upgrade $i
done
echo "SUCCESS testing upgrading from woody"
|