Matt Daubneys Blog

packaging

Linux From Scratch

by on Apr.08, 2009, under FOSS, learning, linux, packaging, programming, ubuntu

My knowledge of linux is sadly lacking, but every day I improve on it. Since I had a few days free over the easter holidays I thought I’d try and improve this further by installing Linux From Scratch. This is essentially building up a linux system from it’s base packages and takes a LONG time. This to me seemed like a good idea, it would exponentially increase my knowledge of what makes linux tick, and what depends on what.

I started on Monday night by reading through all of the LFS documentation. As bedtime reading goes, it’s actually quite interesting, and it seemed like a good idea to get an overview of what needs doing before I started.

Luckily for me my laptop has a fairly large HD (320GB) so finding some space on a partition was quite easy. A quick boot into a livecd and resizing my /home partition created a nice little 10GB partition for LFS to go in. That was at 9am in the morning. By 10:00am I had downloaded all the required programs in the mounted partition as directed by the book and started to build them.  In the first day, I managed to build the initial toolchain and got into the chroot and got to chapter 6.15 in the LFS PDF. The longest thing to build was probably either glibc or GCC, which took just over an hour, but did give me time to cook some tortillas from scratch for lunch :)

The second day, it took me from about 10 in the morning till roughly 3 in the afternoon to finish installing everything.  Was a bit quicker than I expected, but also a lot more involved.

I did hit a few roadbumps, I didn’t have gawk installed on the host system, so at one point something didn’t compile properly and freaked out a bit. A simple sudo aptitude install gawk fixed that though. When I was recompiling glibc all of the tests failed, it took me a few minutes to realise that the reason this was happening was because I’d forgotten to run “make”.. oops.

The last major bump was that when I chose which options to compile with the kernel, I forgot to add the drivers for my ethernet card and my wireless card, so when I booted the machine I had no network! A quick scan through the options and a recompile sorted that out (to include the b44 driver)

What have I learnt from this? Two things mainly.

  1. Where everything should live on a linux system and why its there
  2. Package Managers are beyond fantastic. They save so much time and hassle!

Tomorrow I intend to try and make my LFS install useful by installing openssh initially, wget and possible x.org and gnome. That may be a bit ambitious at the moment though!

Leave a Comment :, , , , , , more...

Really Simple Python Distribution

by on May.25, 2008, under linux, packaging, programming

Today I decided to start looking into packaging a few of my python scripts. The first step to this to me looks to be setting up pythons own distribution system. I’ve just known this as a setup.py file, the meaning of the contents of which has confused me. A quick search through google brings me to this document. It’s a bit confusing at first, but makes much more sense once you sit down with it and start hacking away.

The first thing I realise I need to do is sort my programs into some kind of logical directory structure and inside the directory with all the modules place a __init__.py file. I’m not entirely sure what this file does… but it doesn’t work without it! Anyway, moving swiftly on! Once I’d done that I copied across the simple example from the documentation and then started playing. My final setup.py looked like this.

from distutils.core import setup

setup(name=’MattsLibrary’,
version=’0.1′,
author = ‘Matthew Daubney’,
author_email = ‘my@email’,
description = ‘A very short library for recording serial numbers and books’,
package_dir = {‘MattsLibrary’: ‘library’},
scripts=['library/mattslibrary']
)

Let’s examine this line by line. The first line imports the distutils module, this is the module that will do all the work for us.

The second line just calls the setup function, passing it all the stuff we want. Also on this line I set the name of the module/program I’m defining. The next line sets the version number of the program and the next two tell it my name and set my email address to it. The line after that gives a short description of the program.

The next two lines are the important ones here. Package_dir tells the setup function that all my modules are in the library folder. ['MattsLibrary':'library'] is of the format ['ProgramTitle':'folder'] however here (from what I understand) the ProgramTitle bit is not needed, and I’m not entirely sure of it’s purpose. However, this, works. When I have more time I’ll try and understand it a bit more.

The final line tells the setup function that there is a script that needs to be installed. These are installed in /usr/bin/ instead of /usr/lib/python2.5/site-packages/. This is set as a list such as scripts=['library/mattslibrary', 'library/script2', 'library/script3'].

These settings work for my little simple program. But the documentation seems to be fairly thorough, however I recommend you actually do this with a program as you read the docs. It makes more sense that way!

With all this set up I can now install my little program by typing:

python setup.py install

And all is well…

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...