Fix apt-get “cannot copy extracted data for ‘…’ to ‘…’: unexpected end of file or stream”
I was doing an apt-get upgrade
and got this error:
Preparing to replace liborc-0.4-0:armhf 1:0.4.16-2 (using .../liborc-0.4-0_1%3a0.4.18-1rpi1rpi2_armhf.deb) ...
Unpacking replacement liborc-0.4-0:armhf ...
dpkg-deb (subprocess): decompressing archive member: internal gzip read error: ': incorrect data check'
dpkg-deb: error: subprocess returned error exit status 2
dpkg: error processing /var/cache/apt/archives/liborc-0.4-0_1%3a0.4.18-1rpi1rpi2_armhf.deb (--unpack):
cannot copy extracted data for './usr/lib/arm-linux-gnueabihf/liborc-0.4.so.0.18.0' to '/usr/lib/arm-linux-gnueabihf/liborc-0.4.so.0.18.0.dpkg-new': unexpected end of file or stream
I tried deleting the faulty deb file:
sudo rm /var/cache/apt/archives/liborc-0.4-0_1%3a0.4.18-1rpi1rpi2_armhf.deb
And upgrade again:
sudo apt-get upgrade
But it failed complaining with unresolved dependencies and said to force the process with the -f
parameter:
sudo apt-get -f upgrade
Then it failed again with the first error. Then I figured that cleaning all the deb cache could fix it and it did. Just had to run:
sudo apt-get clean
And then the upgrade process worked fine.