[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Botched python upgrade mangled my system--- HELP!



Bob Proulx wrote:
Charles Blair wrote:
   I am running debian 6.0.6 on a Toshiba laptop that is
approximately two years old.

You should consider keeping your machine updated with the latest
security upgrades.  Debian 6.0.7 is current for your system.

You should also consider upgrading to Debian 7 "Wheezy" at some
point.  If you were upgraded to Debian 7 Wheezy then you could have
installed "python3" and gotten 3.2.3 from precompiled packages.

The command python --version
reported 2.6.x.  I wanted to upgrade to 3.3.2, so I
did the following things, some of which were apparently
mistakes.

(1) I downloaded the .tgz for 3.3.2. from python.org,
typed ./configure, make, and make install.  This did
not seem to produce any serious warnings.

That isn't unreasonable.  Seems fairly normal.  Note that
/usr/bin/python would be the system python.  If you only did
"./configure" with no options then the "make install" would have
installed your newly compiled program in /usr/local/bin/python and
there would have been no conflict.

(2) python --version said I was still using 2.6.x,

But this is where you may have become confused.  If you are using bash
as your command shell then it would have "hashed" the path to python
at /usr/bin/python.  In that situation it would have continued to use
that path even if a new binary showed up in PATH in /usr/local/bin
ahead of it.  (I think.  IIRC anyway.)  Therefore you may have
installed the new python but continued to use the old one in that
particular shell window.

The bash command to instruct it to forget previous the cache of paths
is 'hash -r'.  After doing this the shell will once again search for
the command and will find it in /usr/local/bin.

  $ hash -r

I am assuming that you have /usr/local/bin in your PATH.

so [probably a Big Mistake] I typed

apt-get remove python

I think I made the further mistake of saying "go ahead"
when there was a warning.

There are a *lot* of desktop packages that depend upon python being
installed.  On a headless server not so many.  (The fail2ban package
is the one very useful headless server package that requires python.)
But on a desktop a lot of whizzy desktop things require python.  When
you remove python then all of those will be removed too.

(3) Then I repeated step (1), expecting this would
simply replace the older python with the newer one.

Nope.  It would install python at /usr/local/bin/python as it should
do to keep your local installation separate from the system version.

Also you don't really want to smash over the top of the system files
in /usr/bin.  That method leads to madness.

Note that if you were in the 'staff' group then you would be able to
run "make install" as yourself, not as root, and it would be able to
install into the /usr/local tree.  I think that is a much safer way of
operating then running "# make install" or "sudo make install" as
root.  As root an error (or attack) in the makefile could crawl out of
/usr/local and smash over your system version.

At this point, python --version was still saying 2.6.x,
but python3 --version said 3.3.2.

Right.  If you had said:

  $ type python
  python is hashed (/usr/bin/python)

Then it would have been obvious.  Then 'hash -r' and repeat.

  $ hash -r
  $ type python
  python is /usr/local/bin/python

   However, after shutting down my machine, it became
clear that Something Bad had happened.

Your machine booted okay though.  So you can fix it.

   (Bad #1) after entering username and password, I
get tty instead of graphics.

Right.  GNOME was removed when you removed python.  I assume that you
were running GNOME 2 before.  (You said you were running Debian 6
"Squeeze".)  Simply install GNOME again.

   (Bad #2) the wireless connection has stopped working.

Oops.  Both NetworkManager and WICD need python.  That will make this
somewhat more interesting.  But you can still recover from it
relatively easily.  Do not despair! :-)

   There are probably other Bad Things as well, but I
decided at this point to ask the experts for help.

Two things I will note first for reference.

* /var/log/dpkg.log is a file that tracks what dpkg does on your
system.  You can work through it and determine exactly what packages
were removed.

* /var/backups/dpkg.status* is a set of backup copies of the status
file.  This is an even better source of info to work through what was
installed so that you can install it again.  I have written about it
before so will just reference a recent message with the details:

  http://lists.debian.org/debian-user/2013/04/msg00263.html

Plan:

  * Get back on the network
  * Re-install your removed desktop

Networking:

To get back on the network the easy thing is to plug into a wired
network connection and then configure it.  The wired interface is
easy.  After you have networking install then you can install your
removed parts and then you will have wireless working again.

  # cp /etc/network/interfaces /root/interfaces.bak

Edit /etc/network/interfaces.  It will probably have commented out
references to eth0.  It probably needs to be set like this:

  auto lo
  iface lo inet loopback

  allow-hotplug eth0
  iface eth0 inet dhcp

Then bring the interface up.  You need root for this.  Either log in,
use 'su', or 'sudo'.

  # ifup eth0

That should get you networking again.  With networking up and online
everything else should be much easier.  Simply install your missing
desktop.

At this point you need to tell us what desktop you were running.  If
you had selected wicd instead of NetworkManager.  Thinks like that.
Until then I will assume a standard installation.

Since you are running a slightly older 6.0.6 instead of the current
6.0.7 there will be other updates too.  I would do this:

  # apt-get update
  # apt-get install gnome-core
  # apt-get upgrade
  # apt-get dist-upgrade

With that you should be able to log into the graphical environment
again.  You may not be 100% back to where you were before yet.  But
you should be in a much more pleasant state of operation.  The next
step would be to figure out what else needs to be installed.  This is
a way to figure out what was installed before and what is installed
now and then generate a list of additional things to install.

  $ grep-dctrl -s Package -n "install ok installed" /var/backups/var/backups/dpkg.status.0 | sort > list.prev

  $ grep-status -s Package -n "install ok installed" | sort > list.now

  $ comm -3 list.prev list.now

That will show what is different between then and now.  I personally
would just install the packages I recognized.  But you can install
everything one by one.

  apt-get install $(comm -3 list.prev list.now)

However that will mark all of those as being manually installed
instead of as a dependency and so those will never be offered as an
autoremove candidate in the future.  I would address that by after
installing everything I would overwrite the dpkg status file with the
one from /var/backups/apt.extended_states.0 or older appropriate file.
I will be vague on details because better that you ask if you don't
understand.  Doing nothing at that point isn't as bad as it sounds but
easy to correct.

At that point you should have everything installed that you had
installed before.  Your wireless networking should work.  You will
need to restore your /etc/network/interfaces file.

  # ifdown eth0
  # cp /root/interfaces.bak /etc/network/interfaces

You will probably need to restart everything.  But if I didn't screw
up the above recipes then you should be in good shape.  Be careful of
any typos I may have made in the above.  It is hard to do all of that
from memory and not make a mistake somewhere.

Ask more if you have questions.


Very complete advice!

Hugo


Reply to: