Sunday 28 December 2014

Installing (proper) unrar on Raspberry Pi

Today i was trying to download and decompress some files on my Raspberry Pi and came across a problem. When I tried to unrar the file, i  got this msg:
pi@raspberrypi ~/ $ unrar -x download.rar

unrar 0.0.1  Copyright (C) 2004  Ben Asselstine, Jeroen Dekkers

Extracting from /home/pi/download.rar

Extracting  howto.txt           Failed   
1 Failed


After digging up a bit online i understood that the free unrar utility doesn't recognize WinRAR 3.x or later versions archives.
To fix this I had to install the non free version using the following steps.

Add deb-src to the sources.list

root@raspberrypi:/home/pi/rar# vim /etc/apt/sources.list

Add the deb-src if not present:

deb-src http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

Update apt-get

root@raspberrypi:/home/pi# apt-get update

Build dependencies

root@raspberrypi:/home/pi# apt-get build-dep unrar-nonfree

Download source archive and build it

root@raspberrypi:/home/pi# apt-get source -b unrar-nonfree

This creates a .deb file on your current dir:

root@raspberrypi:/home/pi# ll unrar*.deb
-rw-r--r-- 1 root root 103758 Dec 27 19:30 unrar_4.1.4-1_armhf.deb


Install the built package with dpkg

root@raspberrypi:/home/pi# dpkg -i unrar_4.1.4-1_armhf.deb
Selecting previously unselected package unrar.
(Reading database ... 79214 files and directories currently installed.)
Unpacking unrar (from unrar_4.1.4-1_armhf.deb) ...
Setting up unrar (1:4.1.4-1) ...
update-alternatives: using /usr/bin/unrar-nonfree to provide /usr/bin/unrar (unrar) in auto mode
Processing triggers for man-db ...
root@raspberrypi:/home/pi#


Test it

root@raspberrypi:/home/pi# unrar
UNRAR 4.10 freeware      Copyright (c) 1993-2012 Alexander Roshal

Usage:     unrar <command> -<switch 1> -<switch N> <archive> <files...>
               <@listfiles...> <path_to_extract\>

(...)

2 comments: