Updating Rasbian from Wheezy to Jessie and Stretch

Before … :-(

$ sudo apt-get update  
Get:1 http://archive.raspberrypi.org wheezy Release.gpg \[488 B\]  
Ign http://mirrordirector.raspbian.org wheezy Release.gpg

Get:2 http://archive.raspberrypi.org wheezy Release \[17.6 kB\]
Ign http://mirrordirector.raspbian.org wheezy Release

Err http://raspberrypi.collabora.com wheezy Release.gpg

  Something wicked happened resolving 'raspberrypi.collabora.com:http'
(-5 - No address associated with hostname)  
Ign http://raspberrypi.collabora.com wheezy Release

Get:3 http://archive.raspberrypi.org wheezy/main armhf Packages [144 kB]
Err http://raspberrypi.collabora.com wheezy/rpi armhf Packages

  Something wicked happened resolving 'raspberrypi.collabora.com:http'
(-5 - No address associated with hostname)  
Err http://raspberrypi.collabora.com wheezy/rpi Translation-en

  Something wicked happened resolving 'raspberrypi.collabora.com:http'
(-5 - No address associated with hostname)  
Ign http://archive.raspberrypi.org wheezy/main Translation-en

$

well, that sucks :-(. Wheezy’s no longer supported at all, you can’t get any of the update files anymore. How do you get it to work?

Following these first steps, I did the following:

  1. To begin updating Raspbian, we need first to edit the /etc/apt/sources.list file to point to Raspbian Jessie instead of Raspbian Wheezy.
    We can begin by running the following command in the terminal.
    sudo nano /etc/apt/sources.list
  2. Within the sources.list file, find and replace all occurrences of Wheezy with Jessie as we have below.
    Find
    deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
    Replace
    deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
    Once you have finished replacing Wheezy with Jessie you can save and quit by pressing Ctrl + X then Y and finally pressing Enter.
  3. Next we have to also modify the /etc/apt/sources.list.d/raspi.list file. This file acts as another way of adding entries to the sources.list file we modified in the previous step.
    Run the following command to begin editing the file.
    sudo nano /etc/apt/sources.list.d/raspi.list
  4. Within the raspi.list file we need to modify the first entry changing Wheezy to Jessie. We also need to add ‚Äúui‚ÄĚ to the end of the line, just like we have shown in our example below.
    Find
    deb http://archive.raspberrypi.org/debian wheezy main
    Replace
    deb http://archive.raspberrypi.org/debian jessie main ui
    Once you have finished modifying the file you can save and quit by pressing Ctrl + X then Y and finally pressing Enter.
  5. Before we begin the update process itself, we need to create a directory. This directory is a requirement for some of the new and updated packages that are in Raspbian Jessie.
    Type the following command into the Raspberry Pi’s terminal to create this directory.
    mkdir /home/pi/.config/autostart
  6. We can now finally begin the update process, and please be prepared for this to take a couple of hours as it is quite an extensive process.
    Run the following two commands on your Raspberry Pi to begin the update process.
    sudo apt-get update
    sudo apt-get dist-upgrade -y

Of course, it didn’t quite work…

...  
Preparing to unpack .../libpam-runtime\_1.1.8-3.1+deb8u2+rpi3\_all.deb
...  
Unpacking libpam-runtime (1.1.8-3.1+deb8u2+rpi3) over (1.1.3-7.1)
...  
Processing triggers for install-info (5.2.0.dfsg.1-6) ...  
Setting up libpam-runtime (1.1.8-3.1+deb8u2+rpi3) ...  
(Reading database ... 93542 files and directories currently
installed.)  
Preparing to unpack .../libalgorithm-diff-perl\_1.19.02-3\_all.deb
...  
Unpacking libalgorithm-diff-perl (1.19.02-3) over (1.19.02-2) ...  
Preparing to unpack .../debconf\_1.5.56+deb8u1\_all.deb ...  
/var/lib/dpkg/info/debconf.prerm: 24:
/var/lib/dpkg/info/debconf.prerm: py3clean: not found  
dpkg: warning: subprocess old pre-removal script returned error exit
status 127  
dpkg: trying script from the new package instead ...  
/var/lib/dpkg/tmp.ci/prerm: 24: /var/lib/dpkg/tmp.ci/prerm: py3clean:
not found  
dpkg: error processing archive
/var/cache/apt/archives/debconf\_1.5.56+deb8u1\_all.deb (--unpack):  
 subprocess new pre-removal script returned error exit status 127  
/var/lib/dpkg/info/debconf.postinst: 82:
/var/lib/dpkg/info/debconf.postinst: py3compile: not found  
dpkg: error while cleaning up:  
 subprocess installed post-installation script returned error exit
status 127  
Errors were encountered while processing:  
 /var/cache/apt/archives/debconf\_1.5.56+deb8u1\_all.deb  
E: Sub-process /usr/bin/dpkg returned an error code (1)  
$

Grrrr. What now?

$ sudo apt-get update  
Hit http://archive.raspberrypi.org jessie Release.gpg  
Hit http://mirrordirector.raspbian.org jessie Release.gpg  
Hit http://archive.raspberrypi.org jessie Release  
Hit http://mirrordirector.raspbian.org jessie Release         
Hit http://archive.raspberrypi.org jessie/main armhf Packages  
Hit http://mirrordirector.raspbian.org jessie/main armhf Packages  
Hit http://archive.raspberrypi.org jessie/ui armhf Packages     
Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages  
Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages 
Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages     
Ign http://archive.raspberrypi.org jessie/main Translation-en         
Ign http://archive.raspberrypi.org jessie/ui Translation-en           
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en 
Ign http://mirrordirector.raspbian.org jessie/main Translation-en  
Ign http://mirrordirector.raspbian.org jessie/non-free
Translation-en  
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en  
Reading package lists... Done                                         
             
W: Ignoring Provides line with DepCompareOp for package pypy-cffi  
W: Ignoring Provides line with DepCompareOp for package
pypy-cffi-backend-api-max  
W: Ignoring Provides line with DepCompareOp for package
pypy-cffi-backend-api-min  
W: You may want to run apt-get update to correct these problems  
$

Ffffff. I just ran “sudo apt-get update” .. why me? Let’s reboot and try again.

$ reboot  
...  
$ sudo apt-get dist-upgrade -y  
Reading package lists... Done  
Building dependency tree       
Reading state information... Done  
You might want to run 'apt-get -f install' to correct these.  
The following packages have unmet dependencies:  
 idle3 : Depends: idle-python3.4 but it is not installed  
 lsof : Depends: libperl4-corelibs-perl but it is not installed or  
                 perl (< 5.12.3-7) but 5.20.2-3+deb8u12 is
installed  
 python3 : Depends: python3.4 (>= 3.4.2-0) but it is not
installed  
           Depends: libpython3-stdlib (= 3.4.2-2) but it is not
installed  
           Depends: dh-python but it is not installed  
 python3-minimal : Depends: python3.4-minimal (>= 3.4.2-0) but it
is not installed  
 python3-numpy : Depends: python3.4 but it is not installed  
E: Unmet dependencies. Try using -f.  
$

Well, that sucks again.

$ sudo apt-get install -f         
Reading package lists... Done  
Building dependency tree       
Reading state information... Done  
Correcting dependencies... Done  
The following packages were automatically installed and are no longer
required:  
 ...  
1 upgraded, 9 newly installed, 0 to remove and 490 not upgraded.  
378 not fully installed or removed.  
Need to get 0 B/4501 kB of archives.  
After this operation, 17.6 MB of additional disk space will be used.  
Do you want to continue \[Y/n\]? y  
Preconfiguring packages ...  
(Reading database ... 93542 files and directories currently
installed.)  
Preparing to unpack .../debconf\_1.5.56+deb8u1\_all.deb ...  
/var/lib/dpkg/info/debconf.prerm: 24:
/var/lib/dpkg/info/debconf.prerm: py3clean: not found  
dpkg: warning: subprocess old pre-removal script returned error exit
status 127  
dpkg: trying script from the new package instead ...  
/var/lib/dpkg/tmp.ci/prerm: 24: /var/lib/dpkg/tmp.ci/prerm: py3clean:
not found  
dpkg: error processing archive
/var/cache/apt/archives/debconf\_1.5.56+deb8u1\_all.deb (--unpack):  
 subprocess new pre-removal script returned error exit status 127  
/var/lib/dpkg/info/debconf.postinst: 82:
/var/lib/dpkg/info/debconf.postinst: py3compile: not found  
dpkg: error while cleaning up:  
 subprocess installed post-installation script returned error exit
status 127  
Errors were encountered while processing:  
 /var/cache/apt/archives/debconf\_1.5.56+deb8u1\_all.deb  
E: Sub-process /usr/bin/dpkg returned an error code (1)  
$

We’re going in circles now.

$ sudo apt-get install --reinstall python3-minimal  
Reading package lists... Done  
Building dependency tree       
Reading state information... Done  
You might want to run 'apt-get -f install' to correct these:  
The following packages have unmet dependencies:  
 idle3 : Depends: idle-python3.4 but it is not going to be installed  
 lsof : Depends: libperl4-corelibs-perl but it is not going to be
installed or  
                 perl (< 5.12.3-7) but 5.20.2-3+deb8u12 is to be
installed  
 python3 : Depends: python3.4 (>= 3.4.2-0) but it is not going to
be installed  
           Depends: libpython3-stdlib (= 3.4.2-2) but it is not going
to be installed  
           Depends: dh-python but it is not going to be installed  
 python3-minimal : Depends: python3.4-minimal (>= 3.4.2-0) but it
is not going to be installed  
 python3-numpy : Depends: python3.4 but it is not going to be
installed  
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or
specify a solution).  
$

… also doesn’t work. Googling around, this question’s answer¬†shows some ideas:

I too experienced this problem - in my case on Raspbian when upgrading
from wheezy to jessie. The python3-minimal package was left in a bad
state, with prerm and postinst hook scripts for debconf failing when
calling the py3clean and py3compile commands.  
Indeed py3clean was broken as seen when running the command
directly:  
-bash: /usr/bin/py3clean: /usr/bin/python3: bad interpreter: No such
file or directory

Yes, that’s me!

Edit the file /var/lib/dpkg/info/debconf.prerm to comment out (add “#” in the beginning of the lines):

if which py3clean >/dev/null 2>&1; then  
       py3clean -p debconf  
fi

and similarly in /var/lib/dpkg/info/debconf.postinst comment out:

if which py3compile >/dev/null 2>&1; then  
       py3compile -p debconf  
fi

Now this works:

$ sudo apt-get -f install

Then uncomment the lines from both of these files, then:

$ sudo apt-get install --reinstall debconf

And … we’re in a good state again.

Back to upgrading …

$ sudo apt-get dist-upgrade  
(...)  
462 upgraded, 254 newly installed, 7 to remove and 1 not upgraded.  
Need to get 0 B/484 MB of archives.  
After this operation, 466 MB of additional disk space will be used.  
Do you want to continue [Y/n]? **Y** 

WARNING: The following packages cannot be authenticated!  
  libfm-extra4 libfm-gtk4 libfm4 libfm-modules lxpanel-data lxpanel
libfm-data libfm-gtk-data gpicview libobt2 libobrender29 openbox
pcmanfm lxinput  
  lxterminal e2fslibs e2fsprogs cmake cmake-data fonts-droid
fonts-roboto libva1 libsdl1.2debian libvdpau1 libbluetooth3
liblightdm-gobject-1-0  
  mesa-va-drivers gstreamer1.0-omx pypy-upstream pypy-lib pypy libss2
bluez bluez-firmware firmware-atheros firmware-brcm80211
firmware-libertas  
  firmware-ralink firmware-realtek fontconfig-infinality gdb gdbserver
gtk2-engines-clearlookspix libbluray1 lightdm pigpio nuscratch
omxplayer  
  raspberrypi-sys-mods pi-bluetooth pi-greeter pimixer pipanel
pishutdown plymouth-themes point-rpi python-pifacecommon
python-pifacedigitalio  
  python-pygame python-rpi.gpio python3-pifacecommon
python3-pifacedigitalio raspi-copies-and-fills rpd-icons
rpd-plym-splash rpd-wallpaper va-driver-all  
  device-tree-compiler libraspberrypi-dev libraspberrypi-doc
libraspberrypi-bin libraspberrypi0 raspberrypi-bootloader
python3-minecraftpi minecraft-pi  
  python-picamera python3-picamera raspberrypi-artwork
raspberrypi-kernel raspberrypi-ui-mods raspi-config sonic-pi  
Install these packages without verification \[y/N\]? **y** 

Extracting templates from packages: 100%  
(...)

Yes, I too, like to live dangerously. Let’s see where this takes us.

… reboot … and it worked!¬†

Now we’re on Jessie. Woohoo, the hard part is complete.

Looking at the official docs, we do:

$ sudo apt update  
(...)  
$ sudo apt-get autoremove  
(... mine was ok, sometimes things get stuck ...)  
$ sudo apt full-upgrade  
(...)

Then we modify the files again, like above, just from “jessie” to “stretch”:

/etc/apt/sources.list

/etc/apt/sources.list.d/raspi.list

  • use sudo to edit, change the mention from “jessie” to “stretch”, save.
$ sudo apt update  
(...)  
$ sudo apt -y dist-upgrade  
(...)  
$ sudo reboot  
(...)  
$ cat /etc/os-release  
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"  
NAME="Raspbian GNU/Linux"  
VERSION_ID="9"  
VERSION="9 (stretch)"  
VERSION_CODENAME=stretch  
ID=raspbian  
ID_LIKE=debian  
HOME_URL="http://www.raspbian.org/"  
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"  
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Woohoo, look, we made it! Eat! Drink! Be Mary! Wait, don’t be Mary unless you’re Mary or you want to be Mary.

Comments / questions

There's currently no commenting functionality here. If you'd like to comment, please use Twitter and @me there. Thanks!

Tweet about this - and/or - search for latest comments / top comments