Update pi

De Slacam_Wiki
Ir para: navegação, pesquisa

Keeping Your Raspberry Pi Fresh

In order to keep your Raspberry Pi secure, and to get updated functionality, you should get the firmware and the software updated. This post will describe how to keep your Raspberry Pi updated, as well as how to manage the software for the system. 

Updating the Firmware

As described in Getting Sound and Video to Work on Raspberry Pi, the rpi-update tool should be downloaded fromHexxah's Github, copied to /usr/local/bin/, and made executable.

  • Install software needed to perform the update:
  • pi@raspberrypi:~$ sudo apt-get install ca-certificates git-core binutils
  • Download the script:
  • pi@raspberrypi:~$ sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update
  • Copy the script to /usr/local/bin:
  • pi@raspberrypi:~$ sudo cp rpi-update /usr/local/bin/rpi-update
  • Make the script executable:
  • pi@raspberrypi:~$ sudo chmod +x /usr/local/bin/rpi-update
  • Run the script:
  • pi@raspberrypi:~$ sudo rpi-update
  • In the future to check for updates, just execute this last step!

Every time you want to check for firmware updates, then execute:

pi@raspberrypi:~$ sudo rpi-update

<span style="font-family: 'Trebuchet MS', sans-serif;" />
Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Performing self-update
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Autodetecting memory split
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Using ARM/GPU memory split of 192MB/64MB
Updating firmware (this will take a few minutes)
Checking out files: 100% (21/21), done.
Using SoftFP libraries
If no errors appeared, your firmware was successfully updated
A reboot is needed to activate the new firmware
If you have firmware that is already updated, then the output will look like this:
Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS
Performing self-update
Autodetecting memory split
Using ARM/GPU memory split of 192MB/64MB
Updating firmware (this will take a few minutes)
Your firmware is already up to date

Checking Your Firmware Version

If you haven't updated recently, then your output might be something like this:


pi@raspberrypi:~$ /opt/vc/bin/vcgencmd version
Jun 22 2012 19:43:47
Copyright (c) 2012 Broadcom
version 321258 (release)


Today. I ran sudo rpi-update again, and sudo reboot and found that the Raspberry Pi firmware has been updated as recently as June 22, 2012. The update shown to the version did not appear until after I rebooted:


<span style="font-family: 'Trebuchet MS', sans-serif;" />
pi@raspberrypi:~$ /opt/vc/bin/vcgencmd version
Jul  1 2012 12:48:16 
Copyright (c) 2012 Broadcom
version 323014 (release)

Updating Software Packages

As I described in Slicing into the Raspberry Pi, the first thing to do after going through the initial boot and reboot is to update the software for the system:




  • Check for updates: 
  • pi@raspberrypi: ~$ sudo apt-get update 
  • Apply updates: 
  • pi@raspberrypi: ~$ sudo apt-get upgrade

Updating Software Releases

At the time of this writing, Debian is on the Squeeze release for it's stable packages. If you stay on this stable release, then the only updated software that you will be able to get will be software updated for security reasons, and not for added functionality. The most current, but unstable release is always known as Sid. When the current Sid is eventually released it will be called Wheezy. The unstable release always stays with the name Sid. 
If you want to get the most updated, and possibly face broken packages from time to time, then you can edit withsudo nano /etc/apt/sources.list and replace squeeze with sidHere is an example of my updated /etc/apt/sources.list. Notice the original lines that referred to squeeze have been commented out, and lines added where squeeze has been replaced with sid:
pi@raspberrypi:~$ cat /etc/apt/sources.list
# deb http://ftp.uk.debian.org/debian/ squeeze main non-free
deb http://ftp.uk.debian.org/debian/ sid main non-free
<span style="font-family: 'Trebuchet MS', sans-serif;" />
# Nokia Qt5 development</span</div>
deb http://archive.qmh-project.org/rpi/debian/ unstable main</span</div></div>
<span style="font-family: 'Trebuchet MS', sans-serif;" />
After updating the sources.list file, perform the following to update your release:
pi@raspberrypi:~$ apt-get update && apt-get dist-upgrade
Before you try this, be sure you expand your SD card image, as described in A bigger slice of Raspberry Pi. You might also have to do apt-get -f install to finish the upgrade.

Listing Installed Debian Packages

pi@raspberrypi:~$ dpkg -l
<span style="font-family: 'Trebuchet MS', sans-serif;" />
or to be to page through the listing use:
pi@raspberrypi:~$ 
or
pi@raspberrypi:~$ 
</span</div>
or to send it to a file:
pi@raspberrypi:~$ dpkg -l > ~/

</span</div>

Listing the Contents of a Debian Package

If you know the name of a package, then you can list the files it contains by using dpkg -L package.
pi@raspberrypi:~$ dpkg -L python
/.
/usr
/usr/bin
/usr/bin/dh_python2
/usr/share
/usr/share/apps
/usr/share/apps/konsole
/usr/share/apps/konsole/python.desktop
/usr/share/doc
/usr/share/doc/python2.7
/usr/share/doc/python
/usr/share/doc/python/faq
/usr/share/doc/python/faq/library.html
/usr/share/doc/python/faq/programming.html
/usr/share/doc/python/faq/installed.html
/usr/share/doc/python/faq/gui.html
/usr/share/doc/python/faq/windows.html
/usr/share/doc/python/faq/general.html
/usr/share/doc/python/faq/extending.html
/usr/share/doc/python/python-policy.sgml.gz
/usr/share/doc/python/python-policy.html
/usr/share/doc/python/python-policy.html/ch-module_packages.html
/usr/share/doc/python/python-policy.html/ch-programs.html
/usr/share/doc/python/python-policy.html/ap-packaging_tools.html
/usr/share/doc/python/python-policy.html/ch-embed.html
/usr/share/doc/python/python-policy.html/ch-other.html
/usr/share/doc/python/python-policy.html/ap-build_dependencies.html
/usr/share/doc/python/python-policy.html/ap-upgrade.html
/usr/share/doc/python/python-policy.html/index.html
/usr/share/doc/python/python-policy.html/ch-python.html
/usr/share/doc/python/copyright
/usr/share/doc/python/python-policy.txt.gz
/usr/share/doc/python/changelog.Debian.gz
/usr/share/doc/python/README.Debian
/usr/share/doc/python/FAQ.html
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/python
/usr/share/python
/usr/share/python/runtime.d
/usr/share/python/runtime.d/public_modules.rtremove
/usr/share/python/runtime.d/public_modules.rtinstall
/usr/share/python/dist_fallback
/usr/share/python/python.mk
/usr/share/perl5
/usr/share/perl5/Debian
/usr/share/perl5/Debian/Debhelper
/usr/share/perl5/Debian/Debhelper/Sequence
/usr/share/perl5/Debian/Debhelper/Sequence/python2.pm
/usr/share/debhelper
/usr/share/debhelper/autoscripts
/usr/share/debhelper/autoscripts/prerm-pyclean
/usr/share/debhelper/autoscripts/preinst-pycentral-clean
/usr/share/debhelper/autoscripts/postinst-pycompile
/usr/share/doc-base
/usr/share/doc-base/python-policy
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/dh_python2.1.gz
/usr/share/pixmaps
/usr/lib
/usr/lib/valgrind
/usr/lib/valgrind/python.supp
/usr/bin/pydoc
/usr/bin/pdb
/usr/bin/pygettext
/usr/bin/2to3
/usr/share/doc/python2.7/python-policy.sgml.gz
/usr/share/doc/python2.7/python-policy.html
/usr/share/doc/python2.7/python-policy.txt.gz
/usr/share/man/man1/pydoc.1.gz
/usr/share/man/man1/pdb.1.gz
/usr/share/man/man1/2to3.1.gz
/usr/share/man/man1/pygettext.1.gz
/usr/share/pixmaps/python.xpm

Showing the Information about a Debian Package

To display status information about a package use: dpkg -s package.
pi@raspberrypi:~$ dpkg -s python
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Package: python
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Status: install ok installed
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Priority: standard
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Section: python
Installed-Size: 655
Maintainer: Matthias Klose
Architecture: all
Source: python-defaults
Version: 2.7.3~rc2-1
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.3~rc2-1~), python-minimal (= 2.7.3~rc2-1)
Suggests: python-doc (= 2.7.3~rc2-1), python-tk (= 2.7.3~rc2-1)
Breaks: python-bz2 (<< 1.1-8), python-csv (<< 1.0-4), python-email (<< 2.5.5-3), update-manager-core (<< 0.200.5-2)
Conflicts: python-central (<< 0.5.5)
Description: interactive high-level object-oriented language (default version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python version (currently v2.7).
<div style="margin: 0px; outline: none; padding: 0px;" </div

Searching for Debian Software

</div>
In order to have the most recent results, be sure to follow the previous steps to Update Software Packages. If you want to install software, but are not sure which package name to use, then try apt-cache search keyword. For example I wanted to install Python 3, so I used the following. What is listed, is just a partial listing of the packages found, and I have omitted all the listings after the actual one that is needed to install Python 3. If you are logged in directly on terminal without scroll back, then you may want to pipe the output or more, or less, or redirect the output to a file:
pi@raspberrypi:~$ apt-cache search python3
pi@raspberrypi:~$ apt-cache search python3 | less # allows scrolling back and forth results hide on q
pi@raspberrypi:~$ apt-cache search python3 | more # allows scrolling forward only results seen on q
pi@raspberrypi:~$ apt-cache search python3 > python3.search # file can be viewed for results
python-apipkg - namespace control and lazy-import mechanism for Python
python3-authres - RFC 5451 Authentication Results Header manipulation for Python3
...
diveintopython3 - Book for learning Python 3
...
ipython3 - enhanced interactive Python 3 shell
...
python3 - interactive high-level object-oriented language (default python3 version)
<span style="font-family: 'Trebuchet MS', sans-serif;" />

Installing Debian Software Packages

Once you know the name of the Debian software package, then using sudo apt-get install package... is used to install one of more software packages. For example, in order to install python3 and diveintopython3 I used:
pi@raspberrypi:~$ sudo apt-get install python3 '
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Don't walk away too quickly, as you need to confirm by pressing Enter sometimes. When apt-get it needs to install other packages as dependencies, it will require confirmation. Another reason to watch the output is it will show the extra packages that are installed as dependencies, suggested packages, and recommended packages:
<span style="font-family: 'Trebuchet MS', sans-serif;" />
<span style="font-family: 'Trebuchet MS', sans-serif;" />
<span style="font-family: 'Trebuchet MS', sans-serif;" />
The following extra packages will be installed:
<span style="font-family: 'Trebuchet MS', sans-serif;" />
  libexpat1-dev libpython3.2 libssl-dev libssl-doc python-pkg-resources python-setuptools python3-dev python3-pkg-resources python3-setuptools python3.2-dev
<span style="font-family: 'Trebuchet MS', sans-serif;" />
  zlib1g-dev
Suggested packages:
  python-distribute python-distribute-doc
Recommended packages:
  python-dev-all

Removing Debian Software Packages

If you have installed packages, and you realize that they are either defective (audacious), or using space you don't want for something that doesn't work that well (totem). Then, using apt-get remove package... will remove the packages that you specify, and any packages that depend upon it. Packages that were installed as dependencies, however, are not removed when this is done. If this occurs, then apt-get will suggest using apt-get autoremove. When I wanted to remove totem, I used:
pi@raspberrypi:~$ sudo apt-get remove python3
The following packages were automatically installed and are no longer required:
  libexpat1-dev libpython3.2 libssl-dev libssl-doc python3.2-dev zlib1g-dev
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  python3 python3-dev python3-pkg-resources python3-setuptools
...
<span style="font-family: 'Trebuchet MS', sans-serif;" />
Do you want to continue [Y/n]? 
<span style="font-family: 'Trebuchet MS', sans-serif;" />
<span style="font-family: 'Trebuchet MS', sans-serif;" />
The partial output of the command above shows that python3 and packages that depend it on will be removed. However, the packages that were shown as "packages were automatically installed and are no longer required" will not be removed unless apt-get autoremove is used to remove them.
<span style="font-family: 'Trebuchet MS', sans-serif;" />
So, to complete the process, I would have used the following. However, since I didn't really get rid of Python 3, I didn't need to do it. There is a really fun Easter Egg to check out in Python 3!
pi@raspberrypi:~$ apt-get autoremove.