[rescue] Re: Re: Small serial terminal

Frank Van Damme frank.vandamme at student.kuleuven.ac.be
Wed Feb 19 12:52:12 CST 2003


On Wednesday 19 February 2003 02:03, Joshua D. Boyd wrote:
> On Wed, Feb 19, 2003 at 12:13:46AM +0100, Frank Van Damme wrote:
> > Holy cow, you're nuts. Mandrake and Suse are built to stay with your
> > hands out of every possible text file. Every time you use the config
> > tools it will screw your carefully configured stuff.
>
> Config tools?  I suppose I vaguely remeber hearing something about them
> existing.  Never tried them though.

LOL... well thrust me, mandrake and suse target their product to different 
people :-)

> > Redo the init scripts? ditch the package management system? I can see
> > your point if you run slackware, but on any other distro you just didn't
> > understand what a distro is. The advantage of those is PACKAGE management
> > - it's that little something that *bsd nearly not have, and linux does.
> > dpkg and apt still amaze me every day.
>
> dpkg and apt amaze me less now that I find info on reparing them on my
> debian gnu/linux machine. :(

I suppose if you also nuked /usr, and /lib for instance, restoring everything 
MIGHT be a pain :)

> > Recompile? from tarbals I suppose? Or with apt-get, editing debian/rules
> > (no joke ;) ) and entering other compiletime options or GCC flags?
>
> No, recompile from tarballs.  Editing whatever needs edited,(usually, a
> --prefix= on the ./configure is all that is needed, but sometimes
> tarballs are more broken, especially when on Solaris or Irix.  I don't
> screw around too much with Solaris and Irix configuration.  They scare
> me.  But I screw around with linux and NetBSD configuration a lot.

What do the debian developpers waste their time with? What you need is linux 
from scratch. 

> > Ok now you're going too far! What nonsense. You obviously even didn't
> > bother to read the dpkg man pages didn't you? Just as a test, I hosed my
> > proftpd configuration files. Next step:
> >
> > # dpkg-reconfigure proftpd
> >
> > and THIRTY seconds later I had a working proftpd again. Now tell me what
> > os has a package management system and which has not.
>
> Ahem.  I did.  Now, perhaps you are more of a debian guru and can help me.
>
> root at ecstacy:~# dpkg-reconfigure gcc
> dpkg-query: failed to open package info file `/var/lib/dpkg/status' for
> reading: No such file or directory
> /usr/sbin/dpkg-reconfigure: gcc is not installed

I was thinking about config files of each package. dpkg-reconfigure 
re-generates those files in a given package that is marked as a configuration 
file. 

> root at ecstacy:~# dpkg-reconfigure autoconf
> dpkg-query: failed to open package info file `/var/lib/dpkg/status' for
> reading: No such file or directory
> /usr/sbin/dpkg-reconfigure: autoconf is not installed
> root at ecstacy:~# dpkg-reconfigure binutils
> dpkg-query: failed to open package info file `/var/lib/dpkg/status' for
> reading: No such file or directory
> /usr/sbin/dpkg-reconfigure: binutils is not installed
> root at ecstacy:~#

Wait a sec. Never done this before, but let's think. 

frank at dionysos:/var/lib/dpkg$ file status
status: ISO-8859 English text, with very long lines

Good, debian uses text files for everything. Slower to read and write then the 
binary stuff rpm uses but easier to recover. 

I would try to trick apt into thinking that the package in question is NOT 
installed by touching the file. I'm not going to try this on my system, but 
if that file would just be empty, dpkg would probably think about each 
package that you ask it about, that it is not installed. Consequently, since 
you have no information on your system left about what files belong to what 
package, there is only one way to get that information: re-install the 
package. 

Maybe it's possible to use apt-get at this point. Try apt-get -d install gcc. 
This will download gcc and its dependencies. You will probably have to 
operate on the level of dpkg, not apt except if you're very lucky. If you're 
lucky, it will just download the gcc package (or get it from cdrom), extract 
it and attempt to configure it. Otherwise you will have to fall back to 
installing every package by hand with 

# dpkg -i libc6bla gccbla 

I tested a few things out on my system and apparently, apt normally doesn't 
overwrite files if they're in the database. So you'll have to be careful with 
configuration files. (This might actually make a good feature request... 
anyway). backup /etc. 

Go on like that till you think you installed the packages you had before you 
nuked your system. You might be able to use apt-get once you got the most 
important package installed. The first thing to do before you can install 
packages again is seems to fool dpkg into thinking that dpkg is installed :-)

(Reading database ... 0 files and directories currently installed.)
Unpacking libc6 (from .../libc6_2.2.5-6_i386.deb) ...
dpkg not recorded as installed, cannot check for epoch support !
dpkg: error processing /var/cache/apt/archives/libc6_2.2.5-6_i386.deb 
(--install):
 subprocess pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.2.5-6_i386.deb

 . You can do this by searching through someone elses 'available' file for 
"Package: dpkg" and copy the whole block of text.  

Next to that everything goes smooth... 

 dpkg -i  /var/cache/apt/archives/libc6_2.2.5-6_i386.deb            
(Reading database ... 
dpkg: serious warning: files list file for package `dpkg' missing, assuming 
package 
0 files and directories currently installed.)
Unpacking libc6 (from .../libc6_2.2.5-6_i386.deb) ...
Setting up libc6 (2.2.5-6) ...
Running 'tzconfig' to set this system's timezone.

  [drivel]



a small sample. What I did here is make a chroot jail, put the "base debs" 
from Debian in it, and extracted them all. 

#!/bin/bash
for i in var/cache/apt/archives/*deb
do
    ar x $i
    tar -xzvf data.tar.gz
done

So this system has NO information at all about packages. 

next I've been using nano since vi isn't in this chroot jail.

Let's reinstall it...




dionysos:/# apt-get install nano
Reading Package Lists...
Building Dependency Tree...
You might want to run `apt-get -f install' to correct these:
Sorry, but the following packages have unmet dependencies:
  dpkg: PreDepends: libncurses5 (>= 5.2.20020112a-1) but it is not going to be 
insta
        PreDepends: libstdc++2.10-glibc2.2 (>= 1:2.95.4-0.010810) but it is 
not goin
  nano: Depends: libncurses5 (>= 5.2.20010310-1) but it is not going to be 
installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a 
solut

	Oops, brokeage.  

dionysos:/# apt-get -f install
Reading Package Lists...
Building Dependency Tree...
Correcting dependencies... Done
The following extra packages will be installed:
  libncurses5 libstdc++2.10-glibc2.2 
The following NEW packages will be installed:
  libncurses5 libstdc++2.10-glibc2.2 
0 packages upgraded, 2 newly installed, 0 to remove and 1  not upgraded.
Need to get 142kB/381kB of archives. After unpacking 823kB will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.belnet.be stable/main libstdc++2.10-glibc2.2 
1:2.95.4-11woody1 [142kB]
Fetched 142kB in 2s (59.0kB/s)
Selecting previously deselected package libncurses5.
(Reading database ... 
dpkg: serious warning: files list file for package `dpkg' missing, assuming 
package has no files currently installed.
1954 files and directories currently installed.)
Unpacking libncurses5 (from .../libncurses5_5.2.20020112a-7_i386.deb) ...
Setting up libncurses5 (5.2.20020112a-7) ...

Selecting previously deselected package libstdc++2.10-glibc2.2.
(Reading database ... 
dpkg: serious warning: files list file for package `dpkg' missing, assuming 
package has no files currently installed.
1968 files and directories currently installed.)
Unpacking libstdc++2.10-glibc2.2 (from 
.../libstdc++2.10-glibc2.2_1%3a2.95.4-11woody1_i386.deb) ...
Setting up libstdc++2.10-glibc2.2 (2.95.4-11woody1) ...


So, we got the most-needed part of the system (the text editor :) ) in a clean 
state. 


CLEANING UP

Next, it depends on wether you've recently cleaned out 
/var/cache/apt/archives. If they aren't gone, it's easier to recover, since 
the package there will be just the same as whose files are found all over 
your system... 

also note the output from dpkg about dpkf above. It hasn't got a filelist. 
Install it.

dionysos:/# cd /var/cache/apt/archives/
dionysos:/var/cache/apt/archives# dpkg -i *
Selecting previously deselected package adduser.
(Reading database ... 
dpkg: serious warning: files list file for package `dpkg' missing, assuming 
package has no files currently installed.
1976 files and directories currently installed.)
Unpacking adduser (from adduser_3.47_all.deb) ...
Selecting previously deselected package apt-utils.
Unpacking apt-utils (from apt-utils_0.5.4_i386.deb) ...
Selecting previously deselected package apt.

.....

Tried it, it installed everything but gave lots of errors. Mainly packages 
depending on other packages being installed and configured. It will tell you 
that:

dpkg: dependency problems prevent configuration of modconf:
 modconf depends on modutils (>= 2.1.85-14); however:
  Package modutils is not configured yet.
(and tons of others)

a smart guy will configure debconf, dpkg and apt first. They depend on 
fileutils, so you tackle that first. And so on.

What you can do afterwards, in case your cache wasn't an exact mirror of what 
you had installed, is to do something like

# dpkg -S /usr/bin | grep found
dpkg: /usr/bin/ymessenger not found.

to see if you still got "ghost files" not belonging to any package. 

RESCUING /etc

Back it up, install everything you need, remove every file in /etc newer then 
before you began rescuing your system, untar your /etc backup but don't let 
it overwrite any file. 


Maybe this works for you? It went relatively easy here, given a completely 
distroyed package database. 

-- 
Frank Van Damme
http://www.openstandaarden.be


More information about the rescue mailing list