20 de janeiro de 2017

Arranjar o apt-get quando os pacotes estão corrompidos

Hoje tentei instalar um terminal no rpi para fazer interface serial com um contador de Geiger (#PhysicsStuff), mas ele recusou-se, dizendo que havia um problema em alguns pacotes. Sintomas abaixo:


pi@raspberrypi:~ $ sudo apt-get install minicom
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libboost-atomic1.55.0 libboost-filesystem1.55.0 libboost-program-options1.55.0 libboost-regex1.55.0 libboost-thread1.55.0 libjs-prettify libqscintilla2-11 libqscintilla2-l10n
  libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1 libruby1.9.1-dbg libscsynth1 libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 ri1.9.1 ruby ruby1.9.1 ruby1.9.1-dev ruby1.9.1-examples
  ruby1.9.1-full ruby1.9.3 ruby2.1 rubygems-integration supercollider supercollider-common supercollider-ide supercollider-language supercollider-server supercollider-supernova tcl8.5
  tk8.5
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  lrzsz
The following NEW packages will be installed:
  lrzsz minicom
0 upgraded, 2 newly installed, 0 to remove and 208 not upgraded.
Need to get 0 B/330 kB of archives.
After this operation, 986 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package lrzsz.
dpkg: warning: files list file for package 'libvorbisfile3:armhf' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libvisual-0.4-plugins:armhf' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libvo-amrwbenc0:armhf' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libvisual-0.4-0:armhf' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libvte9' missing; assuming package has no files currently installed
dpkg: unrecoverable fatal error, aborting:
 files list file for package 'libvorbis0a:armhf' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)

Imagino que a causa tenha sido um poweroff abrupto quando me desligaram a extensão aqui em casa na qual liguei temporariamente o RPi. Os computadores não gostam nada de serem desligados "à bruta", mas o RPi é mesmo sensível. Seria já a 4ª ou 5ª vez que teria que fazer a reinstalação do sistema do zero, mas já estava farto disso, pelo que pesquisei um bocado e percebi que os pacotes que faltam deviam ser reinstalados.

Para resolver este problema é preciso primeiro baixar os .deb's em questão. No meu caso o pacote corrompido tem o nome libvorbis0a:armhf. Nesse caso o que fiz foi:

sudo apt-get install --reinstall --download-only libvdpau1:armhf

De seguida:

sudo su
dpkg-deb -c /var/cache/apt/archives/libvdpau1_1.1.1-1~bpo8+1_armhf.deb | awk {'print $6'} | cut -f2- -d. | sed 's|^/$|/.|' | sed 's|/$||' > /var/lib/dpkg/info/libvdpau1\:armhf.list

E quando tentei instalar o minicom de novo já se queixou de outro pacote. Repeti o processo sempre com a mesma sintaxe:

sudo apt-get install --reinstall --download-only PACOTE
sudo su
dpkg-deb -c /var/cache/apt/archives/NOMEDOPACOTECORRESPONDENTE.deb | awk {'print $6'} | cut -f2- -d. | sed 's|^/$|/.|' | sed 's|/$||' > /var/lib/dpkg/info/PACOTE.list

Fiz isto com mais 2 pacotes para além do que está documentado, mas o seguimento foi este.

Uma vez que continuei a ter problemas (apesar de virem em forma de warnings apenas), fiz também a mesma coisa com os pacotes:

libvorbisfile3:armhf , libvisual-0.4-plugins:armhf , libvo-amrwbenc0:armhf , libvisual-0.4-0:armhf e libvte9

No fim tinha tudo limpinho como antes, sem bloqueios nem warnings. Podia ter sido pior! :D

Sem comentários: