Thursday, January 01, 2015

Linux - Installing a Program By Hand

In Windows you download an executable (.exe) or a .msi installer program, double-click it, and sit back and hope. It used to be that Windows' use of .dll files promised a major problem if your new program wrote a new version over a file of the same name that did something else! All of a sudden installing the new anti-virus program killed the accounting program stone-dead! This was known as "DLL Hell" and there's a good Wikipedia article here about it and how it was "cured", if you're interested!

Of course, Windows itself changes from time to time, as service packs and patches are installed, but Microsoft, being just one company, can make sure that if it replaces version 12 with version 13 then they appear to be identical to the program trying to use them.

Linux operates slightly differently. When I write a program I do it in an environment of different programs that it needs, just like I do in Windows. For example, I might require at least Windows 2000 so that I can use an infra-red device (Windows NT didn't support that). Similarly, in Linux, I might require a certain version of some particular other program in order to support my program's functionality. In order to do this I package my program up with all the pieces with which I can supply it, and then add a dependency list of what versions of what other pieces of software my program will need. For example, there's a nice customisable little utility called Docky, which offers a variety of differing launch bars - Windows style, Apple style, etc. - and my little application might need to live with at least a certain version of Docky.

Once I've made sure that I have listed all the required Dependencies that my program has, I can load it up into a Repository and let people have at it!

When you want to install my program you would normally (for Mint) get it from Synaptic Package Manager, as you can see here. You just click on the item you want and ask to mark it for installation, and the Package Manager reads the package, sees what you don't have installed from the list of Dependencies, and tags them for installation too. Once you're done you tell Synaptic to install everything for you and you let it happen.

So simple! But what if what you want isn't on offer? Then you have to do it yourself. Here's an example.


I have a rather nifty little box (a Canopus ADVC-300 - you used to be able to get them from B&H, but maybe now second-hand) that takes in analogue audio/video (like from a videocam) and spits out a digitised version on an IEEE Firewire cable. Happily my PC has a Firewire socket.

To the right you can see the front (over) and back (under). You plug your RCA jacks into the front and your Firewire cable into the far-left socket on the back. Ever so neat and it gives you 1080p - quality pictures!

Anyhow, the best program for pulling in the feed from this is one called dvgrab (Digital Video Grabber). You run it from the command prompt and it just does its thing until you turn it off. For demonstration purposes this is how you go about it:

Open a command prompt and go to the folder in which you want the incoming files to appear. I start in my own folder ("mirwin") here, so I have to go up one (cd ..  just like in DOS!) to "home" and up one again to the root before I can go down to "media", down to B2 (the name of the hard drive I want to put the video on) and down again to the "canopus" folder. I'm sure that there are easier ways of going directly to it, but I remember the tree structure and find my way more easily like this!

mirwin@Bonobo ~ $ cd ..
mirwin@Bonobo /home $ cd ..
mirwin@Bonobo / $ cd media
mirwin@Bonobo /media $ cd mirwin
mirwin@Bonobo /media/mirwin $ cd B2
mirwin@Bonobo /media/mirwin/B2 $ cd canopus
mirwin@Bonobo /media/mirwin/B2/canopus $ ls

The last command above is "ls", standing for "list" (although there is no "list" command!), and I got nothing back because the folder is empty.

So next to run dvgrab, in the (mistaken) belief that it's installed:

mirwin@Bonobo /media/mirwin/B2/canopus $ dvgrab
The program 'dvgrab' is currently not installed. You can install it by typing:
sudo apt-get install dvgrab

So not only does it nicely tell me that I can't run it, but also why not (not installed) and even what to do to go and get it! How friendly!
OK, so I'll type in that weird line and see what happens:

mirwin@Bonobo /media/mirwin/B2/canopus $ sudo apt-get install dvgrab
[sudo] password for mirwin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dvgrab
0 upgraded, 1 newly installed, 0 to remove and 50 not upgraded.
Need to get 129 kB of archives.
After this operation, 340 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/trusty/universe dvgrab amd64 3.5-2 [129 kB]
Fetched 129 kB in 0s (204 kB/s)
Selecting previously unselected package dvgrab.
(Reading database ... 183240 files and directories currently installed.)
Preparing to unpack .../dvgrab_3.5-2_amd64.deb ...
Unpacking dvgrab (3.5-2) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up dvgrab (3.5-2) ...
mirwin@Bonobo /media/mirwin/B2/canopus

As you can see, it's quite verbose, but that's deliberate, so you know what's going on and have some chance of catching it if it goes wrong. As I explained above, and as it tells you as it goes along, it reads the list of everything that the package has and needs, works out what all is needed that isn't actually in the package, and then tells you what has to be installed. In this case just the program itself - dvgrab. Then it tells you how much space it'll use and gets, unpacks, and installs all the bits.

Now to run it:
mirwin@Bonobo /media/mirwin/B2/canopus $ dvgrab
Found AV/C device with GUID 0x0020110113001daa
Waiting for DV...
^C""     0.00 MiB 0 frames
Capture Stopped
Error: no DV

So it ran, found the Canopus box (the AV/C device) and waited for it to send some video. It didn't, of course, because I'd not yet plugged in a videocam to the other end, so the box had nothing to send.

So now I can attach my DVR or camcorder to one side of my Canopus box, using cables with RCA jacks, and feed it analogue audio-video signal. From the other side of the Canopus comes an IEEE 1394 FireWire cable that connects to my laptop. In the laptop dvgrab sucks up the digitised signal and saves it to disc in gigabyte chunks, all ready for me to watch using a program like the VLC Vdeo Player.

So that's how you install a simple Linux program. Not that hard after all!

TTFN

No comments:

Found Food

I have published quite a few recipes here on my blog over the last few years, and I hope that all my readers have tried at least some of the...