Using a proxy server for apt-get

by richard on Tue, 01/24/2012 - 10:45

Today, whilst simulating an entire network for my project, I found myself needing to use a proxy server for some Debian hosts (for some reason, they won't seem to connect just straight out!).

It's fairly simple to do. I set up squid on my laptop (what I'm virtualising all this on), and then added a single line to my apt.conf


Acquire::http::Proxy "http://proxy-server-or-ip:8080";

Obviously changing the hostname and port to the ones that you actually use.

debootstrap - creating a chroot environment on a Debian system

by richard on Fri, 12/09/2011 - 00:26

Being a software developer, and owning quite a few old computers (x86), I sometimes regret my choice of running a 64-bit operating system on my desktop. Then again, it allows me to use the full potential of my processor (whatever that may be - I'm not convinced that it's all that much better than running it 32-bit, but hohum), so I deal with it.

Having cut my metaphorical linux teeth on Gentoo, from before it had an automated installer, I'm no stranger to chroot. A wonderful command that allows you to isolate different installs of the operating system.

A chroot is by far the easiest way to compile 32-bit software on a 64-bit debian install (I know it's possible to install all the 32-bit libraries, but I've always found it to be a faff!).

Enter our friend debootstrap.

debootstrap allows you to create a minimal debian filesystem within a folder on your current system. If you look closely when installing Debian in the first place, you will notice that the installer uses debootstrap to set up your initial system.

It's really easy to use. You just need to point it at a directory, tell it what architecture and version you want to install, and point it at a mirror.

For example, to install a native chroot environment on a debian amd64 system, you would run

richard@nemo:~$ debootstrap squeeze /srv/chroot/squeeze-chroot http://ftp.uk.debian.org/debian

Thats basically telling it to bootstrap squeeze into the folder /srv/chroot/squeeze-chroot from the mirror http://ftp.uk.debian.org

If, however, you want a 32-bit environment on a 64-bit machine, and you want it from wheezy (testing) rather than squeeze (stable) then you would run

richard@nemo:~$ debootstrap --arch=i386 wheezy/srv/chroot/wheezy-chroot http://ftp.uk.debian.org/debian

You can then chroot into your new environment with

richard@nemo:~$ chroot /srv/chroot/wheezy-chroot /bin/bash

In order to make it usable, you would need to create the /dev layout, and mount the proc and sys filesystems. I'll cover them in another post!

Kernel 3.0

by richard on Fri, 12/09/2011 - 00:06

I'm getting a new laptop for Christmas this year. Well, I say for Christmas, but I've actually already got it, and today I started using it (my Final Year Project was refusing to compile on my old one. No idea why, but it just wouldn't have it!).

So I installed Debian (as I was always going to), and off it goes. All happy, a couple of tweaks to the grub boot command to get the touchpad working, and I'm sorted. Or so I thought.

I was happily sitting at Uni, listening to my music, when I realise that the sound is not only coming through my headphones, but also out of the inbuilt speakers. Thinking that odd, I fiddle around with the headphone jack in case it's a loose connection or something.

No ball.

After a quick google, I realise that this is a common problem with the sound chip I have (I'll have to update this post with the name of it if I remember!). It seems that the speaker cut-out is handled by the driver rather than by the hardware (who knew!).

So, I add squeeze-backports to my apt-sources and upgrade to Kernel 2.6.38 hoping that the ALSA driver in that will have it.

Again, no ball.

Deciding to just see if it'll work (although there's nothing more permanent than a temporary solution) if I upgrade to Kernel 3.0, I grab the associated packages from the wheezy repository. After a bit of faffing with dependencies (and about 10 package downloads, one after the other), I get Kernel 3.0 installed. Which is all well and good, but it refuses to install the nVidia driver I spent oh-so-long installing earlier. Kernel 3.0 is compiled with gcc-4.6 which doesn't appear in squeeze, and as I don't really want to upgrade large swathes of my fresh squeeze install, I refuse to let it install. Still, at least the alsa is now working and it mutes the speakers when I plug headphones in!

Eventually, I debootstrap-ed a chroot of wheezy, and compiled the nVidia dkms module in there, copied it out, and ran depmod. It worked perfectly, and now I have a nice running 3.0 kernel, with full ALSA support for my sound card, and an nVidia binary driver for the display (I would use one of the open source ones, but my video card, a GeForce 410M appears to be a bit new!).

Using get_iplayer to download from iPlayer

by richard on Sun, 09/18/2011 - 14:24

get_iplayer is a nifty little tool that allows you to download iPlayer programmes (either radio or TV) to your computer.

Installation on Debian is very easy. Just fire up a terminal, and use apt-get.
You can, of course, use synaptic or any other package management tool that interfaces with apt, but I use apt-get

richard@eee:~$ sudo apt-get install get-iplayer

apt-get will ask you to confirm that you want to install the dependencies, which is fine.

Once it is installed, you can browse available programmes, download specific programmes, or download any programme that matches a string. Examples are below:

Browse Programmes

richard@eee:~$ get_iplayer torchwood

get_iplayer v2.78, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.

Matches:
704: Torchwood - Miracle Day: Episode 1, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
705: Torchwood - Miracle Day: Episode 2, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
706: Torchwood - Miracle Day: Episode 3, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
707: Torchwood - Miracle Day: Episode 4, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
708: Torchwood - Miracle Day: Episode 5, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
709: Torchwood - Miracle Day: Episode 6, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
710: Torchwood - Miracle Day: Episode 7, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
711: Torchwood - Miracle Day: Episode 8, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
712: Torchwood - Miracle Day: Episode 9, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
713: Torchwood - Miracle Day: Episode 10, BBC HD, Audio Described,Drama,Guidance,Popular,SciFi & Fantasy,TV, default,audiodescribed,

INFO: 10 Matching Programmes

Download Specific Programme

richard@eee:~$ get_iplayer --get 713

get_iplayer v2.78, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.

Matches:
713: Torchwood - Miracle Day: Episode 10, BBC HD, Audio Described,Drama,Guidance,Popular,SciFi & Fantasy,TV, default,audiodescribed,

INFO: 1 Matching Programmes

This will then go on to download the programme.

Download all programmes matching a string

richard@eee:~$ get_iplayer --get Torchwood
get_iplayer v2.78, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.

Matches:
704: Torchwood - Miracle Day: Episode 1, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
705: Torchwood - Miracle Day: Episode 2, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
706: Torchwood - Miracle Day: Episode 3, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
707: Torchwood - Miracle Day: Episode 4, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
708: Torchwood - Miracle Day: Episode 5, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
709: Torchwood - Miracle Day: Episode 6, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
710: Torchwood - Miracle Day: Episode 7, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
711: Torchwood - Miracle Day: Episode 8, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
712: Torchwood - Miracle Day: Episode 9, BBC HD, Audio Described,Drama,Guidance,SciFi & Fantasy,TV, default,audiodescribed
713: Torchwood - Miracle Day: Episode 10, BBC HD, Audio Described,Drama,Guidance,Popular,SciFi & Fantasy,TV, default,audiodescribed,

INFO: 10 Matching Programmes

Downloading a programme from a URL
If you've found the programme you want on the iPlayer website, then you can download from a specific URL. To do this:

richard@eee:~$ get_iplayer --get "http://www.bbc.co.uk/iplayer/episode/b014vy02/Doctor_Who_Series_6_The_God_Complex/"
get_iplayer v2.78, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.

INFO: Trying pid: b014vy02 using type: tv
INFO Trying to stream pid using type tv
INFO: pid found in cache
Matches:
208: Doctor Who: Series 6 - 11. The God Complex, BBC One, Drama,Highlights,Popular,SciFi & Fantasy,TV, default,

INFO: 1 Matching Programmes

Note the quotation marks around the URL. These are required

 

It is worth noting that get_iplayer will default to downloading as an FLV file (which won't play on everything) unless it can find ffmpeg on the system. To install ffmpeg, just run
richard@eee:~$ apt-get install ffmpeg
then get_iplayer will convert it to a nice mp4 for you