-
Senior Member
registered user
A general method for stopping apt preinst/postinst madness, here: install libc6

Originally Posted by
Capricorny
To fix the problem, we must have access to and patch the offending downloaded .deb packages. This may be accomplished in a number of ways, right now I tend to support the more drastical ones, to be able to stop Debian apt madness on the spot when needed.

Here is a general solution to the problem, found on github:gist, https://gist.github.com/1729559
It amounts to running a script on the troublesome downloaded .deb package, to remove the associated pre/postrm scripts. I think it should be fairly safe to use, and in any case far safer than the default dive-into-it Debian "method", which may leave us with a broken system even if everything is correct, because the scripts are buggy - as they very often tend to be.
The script is called stripdeb.sh, and I installed it in /usr/local/bin:
Code:
#!/bin/bash
# Usage: stripdeb.sh something.deb
# From: https://gist.github.com/1729559
# Patch /etc/apt.conf.d/70debconf: DPkg::Pre-Install-Pkgs {"xargs -rL1 bash /usr/local/bin/stripdeb.sh 2>&1 | logger -t stripdeb"}
# 20120624 tay: This patching didn't seem to work, and using on a regular basis may not be that smart either.
# Safer to run it only on individual packages basis:
# #> sudo stripdeb.sh /var/cache/apt/archives/libc6_2.13-33_i386.deb
# Don't use apt-get afterwards, it may notice something is changed and download the old madness again
# #> dpkg -i /var/cache/apt/archives/libc6_2.13-33_i386.deb
echo "Args: $*"
echo "Stripping $1 of pre/post maintainer scripts"
tmpdir=$(mktemp -d)
[ ! -f $1 ] && exit 1
genldconfigscript() {
# Maybe we should just make the always run 'ldconfig'
cat << EOF
#!/bin/sh
[ "\$1" = "configure" ] && ldconfig
[ "\$1" = "remove" ] && ldconfig
true
EOF
}
# The .deb is an 'ar' archive, grab the control files.
ar -p $1 control.tar.gz | tar -C $tmpdir -zxf -
# Kill the stupid package scripts, but log what we do.
for i in $tmpdir/{post,pre}{rm,inst} ; do
if [ -f $i ] ; then
# Linux sucks, so we have to run ldconfig on any library changes.
# So if the post/pre script includes ldconfig
if grep -q ldconfig $i ; then
echo "$1: Replacing $i with a generic 'ldconfig' script"
genldconfigscript > $i
chmod 755 $i
else
echo "$1: Stripping $(basename $i)"
rm $i
fi
fi
done
# Rebuild the control tarball
tar -C $tmpdir -zcf control.tar.gz .
# And replace the old one with the stripped one back into the .deb
ar -r $1 control.tar.gz
# Clean up
rm control.tar.gz
So, to get around the Debian package bugs, I ran the script before chvt'ing, and used dpkg instead of apt-get after init 2. The modified version of Klaus2008's recipe thus becomes:
Code:
sudo apt-get update
sudo apt-get -d -t unstable install libc-bin libc-dev-bin libc6 libc6-dev
sudo stripdb.sh /var/cache/apt/archives/libc6_2.13-33_i386.deb
sudo chvt 1
init 2
dpkg -i libc-bin libc-dev-bin libc6 libc6-dev
chroot /UNIONFS/
apt-get -t unstable -f install
exit
init 5
chvt 5
sudo apt-get -y -t unstable install gcc-4.6-multilib g++-4.6-multilib
It worked for me, and with due modifications it ought to work more generally.
We must of course be pretty sure that the scripts aren't really needed for the particular package.
-
Hi Capricorny,
Thank you very much for offering a fix proposal. I tried it and I found two problems:

Originally Posted by
Capricorny
sudo stripdb.sh /var/cache/apt/archives/libc6_2.13-33_i386.deb
The first one is a typo in your modified Klaus2008's recipe: stripdb.sh ==> stripdeb.sh
(to match the location of the /usr/local/bin/stripdeb.sh script)

Originally Posted by
Capricorny
dpkg -i libc-bin libc-dev-bin libc6 libc6-dev
The second: dpkg -i complains about not finding the archive, please see the log below:
dpkg -i libc-bin libc-dev-bin libc6 libc6-dev
dpkg: error processing libc-bin (--install):
cannot access archive: No such file or directory
dpkg: error processing libc-dev-bin (--install):
cannot access archive: No such file or directory
dpkg: error processing libc6 (--install):
cannot access archive: No such file or directory
dpkg: error processing libc6-dev (--install):
cannot access archive: No such file or directory
Errors were encountered while processing:
libc-bin
libc-dev-bin
libc6
libc6-dev
Best Regards,
Gilles
Last edited by ruymbeke; 06-24-2012 at 01:27 PM.
-
Senior Member
registered user
Right you are, Gilles!
This reporting was very quickly done, a bit too fast.
What I actually ran was
Code:
sudo apt-get update
sudo apt-get -d -t unstable install libc-bin libc-dev-bin libc6 libc6-dev
sudo stripdeb.sh /var/cache/apt/archives/libc6_2.13-33_i386.deb
sudo chvt 1
init 2
# The other libs were correctly installed already, next line implicit - didn't run it
# sudo apt-get -y -t unstable --reinstall install libc-bin libc-dev-bin libc6-dev
# Give dpkg exact file address
dpkg -i /var/cache/apt/archives/libc6_2.13-33_i386.deb
chroot /UNIONFS/
apt-get -t unstable -f install
exit
init 5
chvt 5
sudo apt-get -y -t unstable install gcc-4.6-multilib g++-4.6-multilib
But I wasn't able to copy from the chvt 1 commands, thus only edited the line from the recipe. apt-get may possibly be used, but told not to download again? It just downloaded the unmodified .deb libc6 over the modified one for me.
The most robust thing to do might be to adjust the dpkg command.
PS: The autoformatting here REALLY SUCKS!
Last edited by Capricorny; 06-24-2012 at 01:47 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

WAVLINK RAID 2 Bay Hard Drive Docking Station SATA 2.5/3.5'' SSD HDD Enclosure
$107.99

Broadcom 9600-24i Tri-Mode RAID Controller 4.0 NVMe SAS SATA NEW 05-50111-01003
$639.69

Intel VROC Premium RAID Controller Card PCIe Add-On Module VROCPREMMOD
$265.00

G-Technology G-SPEED Studio XL 48TB Thunderbolt 2 Storage
$200.00

Broadcom LSI 9305-16i 12Gbps SAS-3 PCIe x8 HBA 16-Ports Raid Controller
$64.99

2-Bay/4-Bay Hard Drive Enclosure for 3.5"/2.5'' SATA HDD/SSD 10Gbps USB-C 3.2
$75.99

Dell 3KDWX PERC H755 12G 8GB Cache Front RAID Controller
$999.99

TerraMaster D5-300C 5-Bay USB-C Hard Drive Enclosure
$115.00

Lacie 2big Quadra RAID 2 x 2 TB 4 TB Only 158 hours
$199.00

EMC VNXe3100 EPE 12-LFF 3.5" NAS Storage Array 12*3TB SAS HDD 2*303-137-000D
$224.99