On Fri, Dec 22, 2000 at 11:09:34AM -0600, Adam Heath wrote: > Funny, no segfault for me. After adding -o Debug::pkgDPkgPM=true to the > apt-get lines, then, manually running dpkg in the right order, instead of > having apt do it, I get no segfault.
Hmm, I have a similar seeming dpkg segfault bug, that's reproducible, but
goes away if I run dpkg a few times.
Ummm. To duplicate, make a directory somewhere with:
create_chroot.sh (attached)
required/
base/
required/ should contains all the required debs, roughly. Something like:
base-files base-passwd bash bsdutils debianutils diff dpkg
e2fsprogs fileutils findutils grep gzip hostname ldso libc6
libdb2 libgdbmg1 libncurses5 libpam-modules libpam-runtime
libpam0g libreadline4 libstdc++2.10 login makedev mawk mbr
modutils mount ncurses-base ncurses-bin passwd perl-5.005-base
procps sed setserial shellutils slang1 sysklogd sysvinit tar
textutils update util-linux
should do it.
base/ should contain all the base debs, roughly. It doesn't matter too much.
Running
sudo ./create_chroot.sh
should then try to construct a base system in chroot/, and the initial
dpkg unpacking will probably fail a couple of times before succeeding.
The error I get goes something like:
] fetching required packages: done
] unpacking required packages: ./create_chroot.sh: line 160: 15159 Segmentation
fault chroot $C dpkg --unpack --force-depends --force-auto-select
--force-overwrite --recursive /var/cache/apt/archives >>$L 2>&1
] failed, will retry.
] unpacking required packages: ./create_chroot.sh: line 160: 15300 Segmentation
fault chroot $C dpkg --unpack --force-depends --force-auto-select
--force-overwrite --recursive /var/cache/apt/archives >>$L 2>&1
] failed, will retry.
] unpacking required packages: done
ie, running the exact same command three times in a row makes the bug
go away. Using --chroot instead of chrooting in advance works somewhat more
reliably, but still flakes out occassionally iirc.
Cheers,
aj
--
Anthony Towns <[EMAIL PROTECTED]> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. GPG signed mail preferred.
``Thanks to all avid pokers out there''
-- linux.conf.au, 17-20 January 2001
#!/bin/sh -e
R=`pwd`/required
B=`pwd`/base
C=`pwd`/chroot
L=`pwd`/dpkg.log
D=`pwd`/dev.tgz
##### Helper functions
pkg_to_deb () {
for a in $*; do
(ls -d $R/${a}_*.deb $B/${a}_*.deb | head -1) 2>/dev/null
done
}
installcore () {
echo -n "installing core packages: $1"
local coredebs=`pkg_to_deb $1`
#(cd $C && yes '' | dpkg --root=. --install --force-depends --force-auto-select $coredebs >>$L 2>&1) || exit 1
local LDC=0
if [ ! -e $C/sbin/ldconfig ]; then
ln $C/sbin/ldconfig.new $C/sbin/ldconfig
fi
mkdir -p $C/var/cache/apt/archives/
cp $coredebs $C/var/cache/apt/archives/
coredebs=`echo $coredebs | sed 's=[^ ]*/=/var/cache/apt/archives/=g'`
yes '' | chroot $C dpkg --install --force-depends --force-auto-select $coredebs >>$L 2>&1
if [ -e $C/sbin/ldconfig.new ]; then
rm $C/sbin/ldconfig
fi
echo "."
}
#### Actually do it all
if [ -d $C ]; then
echo -n "umounting chrooted /proc /dev/pts: "
chroot $C umount /proc || true
chroot $C umount /dev/pts >/dev/null 2>&1 || true
echo "done"
echo -n "removing old chroot: "
rm -rf $C
echo "done"
fi
echo -n "initializing dpkg.log: "
(date; echo) >$L
echo "done"
echo -n "creating chroot: "
mkdir $C
echo "done"
echo -n "extracting required packages: "
for pkg in $R/*.deb; do
dpkg-deb --extract $pkg $C >>$L 2>&1
done
echo "done"
echo -n "cleaning up:"
echo -n " perl-5.005.dist"
mv $C/usr/bin/perl-5.005.dist $C/usr/bin/perl-5.005
echo -n " perl-symlink"
ln -s perl-5.005 $C/usr/bin/perl
echo -n " status/avail"
echo -n >$C/var/lib/dpkg/status
echo -n >$C/var/lib/dpkg/available
echo "."
if [ -e dev.tgz ]; then
echo -n "unpacking devices: "
(cd $C; tar xzf $D)
echo "done"
else
echo -n "making devices:"
echo -n " generic"
(cd $C/dev && /sbin/MAKEDEV generic-i386) # hde hdf hdg hdh sde sdf sdg sdh scd-all initrd rtc) || exit 1
echo -n " i386"
(cd $C/dev && /sbin/MAKEDEV isdn-io eda edb sonycd mcd mcdx cdu535 lmscd sbpcd aztcd bpcd dac960 ida) || exit 1
echo "."
echo -n "tarring up devices so next time is quicker: "
(cd $C; tar czf $D dev)
echo "done"
fi
echo -n "testing ldconfig.new: "
if (cd $C && chroot `pwd` sbin/ldconfig.new); then
echo "success!"
else
echo "failure!!"
exit 1
fi
echo -n "fstab: "
echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' >$C/etc/fstab
chmod 644 $C/etc/fstab
chown root.root $C/etc/fstab
echo "done"
echo -n "chroot procfs: "
trap "umount $C/proc" 0
chroot $C mount -t proc proc /proc
echo "done"
echo -n "faking dpkg install: "
(
pkg=`pkg_to_deb dpkg`
ver=$(dpkg-deb -I $pkg | grep Version: | sed 's/ *Version: //' | head -1)
cat >$C/var/lib/dpkg/status <<EOF
Package: dpkg
Version: $ver
Essential: yes
Status: install ok installed
EOF
)
echo "done"
installcore "base-files base-passwd ldso" || exit 1
installcore "dpkg" || exit 1
echo -n "Setting UTC timezone: "
echo UTC >$C/etc/timezone
cp $C/usr/share/zoneinfo/Factory $C/etc/localtime
echo "done"
installcore "libc6" || exit 1
echo -n "removing perl symlink: "
rm -f $C/usr/bin/perl
echo "done"
installcore "perl-5.005-base" || exit1
####
echo -n "fetching required packages: "
mkdir -p $C/var/cache/apt/archives
cp $R/* $C/var/cache/apt/archives/ # should rename also
echo "done"
while :; do
echo -n "unpacking required packages: "
if chroot $C dpkg --unpack --force-depends --force-auto-select \
--force-overwrite --recursive /var/cache/apt/archives >>$L 2>&1
then
echo "done"
break;
else
echo "failed, will retry."
fi
done
echo -n "moving ssd out of the way: "
mv $C/sbin/start-stop-daemon $C/sbin/start-stop-daemon.REAL
cp $C/bin/true $C/sbin/start-stop-daemon
echo "done"
echo -n "miscellaneous tidying:"
echo -n " dselect-apt"
echo "apt apt" >$C/var/lib/dpkg/cmethopt
chmod 644 $C/var/lib/dpkg/cmethopt
echo -n " lib-modules"
mkdir $C/lib/modules/`uname -r`
echo "."
echo -n "configuring everything: "
trap "chroot $C umount /dev/pts" 0
chroot $C dpkg --configure --pending --force-configure-any --force-depends >>$L 2>&1
echo "done"
echo -n "fetching base: "
mkdir -p $C/var/cache/apt/archives
cp $B/* $C/var/cache/apt/archives/ # should rename also
echo "done"
while :; do
echo "installing base..."
if chroot $C dpkg --install --force-auto-select --force-overwrite \
--skip-same-version --recursive /var/cache/apt/archives/
then
echo "done"
break;
else
echo "failed, will retry."
fi
done
echo -n "removing fake fstab: "
rm -f $C/etc/fstab
echo "done"
echo -n "restoring ssd: "
mv $C/sbin/start-stop-daemon.REAL $C/sbin/start-stop-daemon
echo "done"
echo -n "umounting chrooted /proc /dev/pts: "
chroot $C umount /proc
chroot $C umount /dev/pts >/dev/null 2>&1 || true
echo "done"
pgpQYRpxg4KOv.pgp
Description: PGP signature

