Skip to content

Linux Daily

Daily usage of linux, raw style

Category Archives: software

Step two in The Odyssey – From Nothing to the Ubuntu Software Center.

At this point the VM is all set up and ready to go. All we need is an application.

Linux has several toolkits and frameworks to program graphical applications. Some are bad, some are beyond shit, but at least one of them is top notch – Qt.

Qt is a C++ framework created by vikings from the grim and frostbitten lands of Norway, so you know that shit is for real. It is the only Linux GUI framework that packs an IDE, and a fantastic one for that matter. If you’re interested in python, java or any other garbage collected non-sense I advise you to skip this step and jump to packaging. C++ is for high-octane engineers with a firm grasp of memory management and pure virtual classes. Consider yourself warned.

Now, developing applications isn’t just about frameworks and programming languages. Oh no. There’s source control, source documentation, debugging, unit testing, memory debugging, etc. Yeah, and I mean it: etc! Hopefully we’ll cover most of these concepts till the end of the series. For starters we’ll cover creating a basic project in Qt, using Git for source control, publishing code to Github and licensing.

With me steering the ship, what’s to worry? On with it!

1. Set Up Git

Alright, VM ready to go, all is good but we ain’t going anywhere without Git installed. Don’t know what Git is? Take the crash course and you’ll be up to speed within the hour. If you don’t feel like it don’t worry, I’ll cover the basics.

Install

Git is in the officials reps, so installing is just a matter of:

sudo apt-get install git-core

Configure

Git has some basic configurations you need to setup before you start source controlling like a pro. Still at the terminal, this is my preferred configuration

git config --global user.name "Anonymous Bloke"
git config --global user.email anonymous@bloke.com
git config --global core.editor vim
git config --global merge.tool vimdiff
#List these configurations
git config --list

Git is now officially ready to go.

2. Start a new Qt Project

Install

Qt’s IDE is called Qt Creator, and it’s also in the official reps:

sudo apt-get install qtcreator

The Qt Creator interface. You'll be looking at this for a while.

This should install QtCreator 2.4.0 and pull Qt 4.7.4 as a dependency. Start it and you should see a window much like the one in the screenshot.

What are we looking at?

Well, there’s the sidebar on the left. This is the major anchor in the interface. From here we can access the code in Edit,  we can design a UI by dragging and dropping elements in Design, GDB can be used in debug, projects list recent projects, Analyze is new so I’m not sure what it does to be honest, and finally, Help is for other people.

On the lower left, we have a couple of icons. First one is to configure the current build, the play button runs the program, bellow it is the button to debug a program, and the hammer thing is to just build and not run.

Humpf, all done. Got that? Ok, now let’s create a new project in fil…

Oh no you don’t! Decide on licensing first!

Nope, not kidding! The first thing we do when creating a new project is think about licensing. Each source file should have a header with the copyright declaration, where you, the copyright holder, inform the reader about the deadly consequences of stealing your code. I recommend you use the GPL V3 because although I find Richard Stallman to be quite a weird character, I do not doubt for a single second that he’s doing his best to protect our freedoms.

All code released under the GPLV3 should have a short notice on every source file. My template notice is available here, and I’d like to call your attention to the first 3 lines:

/*
 * %FILENAME% - Math Machine
 * Copyright (C) %YEAR% Anonymous Bloke

So, the project is gonna be called Math Machine and the copyright is for Anonymous Bloke, which you should change to your own name. Qt Creator will do all the work and automatically append this notice to your source files. The %FILENAME% and %YEAR% keywords will be interpreted by Creator and changed accordingly (you can see some more of these here if you need a more elaborate copyright notice).

To make use of this notice, define the file as the license template in Tools/Options/C++/File Naming/License template.

With the license template in place, we can finally create our project by hitting File/New File or Project. There, select Qt Widget Project/Qt Gui Application.

In the wizard there’s a couple of things you need to check.

First off, our project is gonna be called “MathMachine” and I suggest you put it in a new folder called developer in Documents. Just to keep shit organized.

No math in the machine just yet, but hey, it's a start!

Second, we’re gonna be brutal and uncheck Generate form in Class Information. In this example we won’t need it.

Lastly, in Project Management be sure to add this project to git instead of the default <None>.

Boom! We have a project. Standard Qt boilerplate, nothing fancy. You can even run it by pressing Ctrl-R. The result looks something like the picture to the right – an empty window called MainWindow. Sweet.

Your first commit

Awesome.

First things first, we commit! In Tools/Git/Commit. you should do something like in the screenshot.

Now, there’s a couple of things we need to do to push our source control all the way up to 11. First, right-click in main.cpp and choose “Open Terminal Here”. Then run

git status

Which should say

# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    MathMachine.pro.user
nothing added to commit but untracked files present (use "git add" to track)

There’s a leftover file. Could be better. These .user files are Qt Creator instance specific – we should flat out ignore them. Let’s create and source control a .gitignore file – we don’t want anybody dealing with this .user business.

echo "*.user" > .gitignore
git add .gitignore
git commit

Your default editor will show up. There’s an unwritten rule that commits should have a short title and a brief description of the commit separated by a blank line. Like this.

Ignore *.user

Added .gitignore with QtCreator *.user files.

Save and exit. Now, if we run git status we’ll see

# On branch master
nothing to commit (working directory clean)

Which is much nicer. No MOM I don’t have OCD, don’t embarrass me in front of my friends!, I HATE IT when you do that, I just like things need und tidy, what’s wrong wit-

3. Prepare for public debut

Oh my! Who said anything about going public?! Don’t you just love surprises?! We’re gonna release the software as is!

According to the GNU standard, free software releases should come with a bunch of all caps files.

COPYING

All GPL code should have, in addition to the copyright header, a COPYING file with a transcript of the GPL. It says so right here. So, open a terminal in the project root folder once more (right click on main.cpp, open terminal here) and

wget http://www.gnu.org/licenses/gpl.txt
mv gpl.txt COPYING

Now, this is just a personal preference of mine, but I like to see this file in the project tree. You can right click on your project (the top level of the tree) and choose Add existing file to add the COPYING file and say Yes to add it to git. You know, just to keep shit organized.

README

A classic. Instead of add existing file, this time select ADD NEW and then General/Text file. Qt will insist upon the .txt, and you shall insist in renaming it by right-click on the file and selecting rename.

There’s a good standard for writing README files. It’s called AsciiDoc and it’s a good idea to use it. By following the syntax, we can convert our README to a webpage, a pdf, etc. Here’s a nice README for our program

Math Machine README
===================
Anonymous Bloke <anonymous@bloke.com>
:website: https://linuxd.wordpress.com

Math Machine
------------

Math Machine is part of "The Odyssey", a series of guides on how to
properly distribute a free software application. It does two things
and two things only:

- Start.
- Exit.

I know.

=== Installation

Please refer to the INSTALL file

Simple.

INSTALL

We’ll do exactly the same thing with the INSTALL file. Just to keep shit organized.

Math Machine INSTALL
===================
Anonymous Bloke <anonymous@bloke.com>
:website: https://linuxd.wordpress.com

Math Machine cannot be installed. Yet.
However, it can compile to a binary by doing

qmake
make

🙂

Done. Now commit like before, and we’re golden!

4. Set up GitHub

That’s right, we’re gonna go with the latest trend. GitHub is DOPE.

Register

Head over to www.github.com and register an account. Do remember to register with the same e-mail  from your git configuration (“anonymous@bloke.com” in this example)

Create an SSH Key

GitHub forces you to use a sweet SSH setup. In order to have write access to the repo, and hence be able to push, a local ssh key has to be created and registered with the website. Each machine should have a different ssh key, so you might want to repeat this process from the Ubuntu 10.04 VM.

Head over to the terminal. Again, mind the e-mail address.

ssh-keygen -t rsa -C "anonymous@bloke.com"

Add your SSH Key to GitHub

On the GitHub site click Account Settings>SSH Public Keys>Add another public key. The public key is

cat ~/.ssh/id_rsa.pub

Holler!

ssh -T git@github.com

Which should reply

The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
Hi bloke! You've successfully authenticated, but GitHub does not provide shell access.

Totally not a calculator.

Create a new repository

For our example, create a new repository called MATH MACHINE. GitHub will present instructions on how to add this new repo.

5. Now, Push!

You could add the repo to the local git like in the GitHub instructions

git remote add origin git@github.com:bloke/Math-Machine.git

Or use QtCreator’s GUI Tools/Git/Remotes

Name: origin
URL: git@github.com:bloke/Math-Machine.git

Choose one, but you have to go to the terminal anyway for the FINAL PUSH.

git push origin master

Really! It’s done! Click continue on the instructions page on GitHub. And see your baby.

Notice that now, everytime we hit Tools/Git/Push in Qt Creator it will push the master to origin (meaning our code changes to GitHub). Do it in the terminal, via menus, you decide.

You probably noticed the README doesn’t look too good on the GitHub repo page. If you rename it to README.asciidoc it will render great. If you’ve reached this far, you probably know how to do this right? In QtCreator

  1. Rename README to README.ascii by right clicking on the file and selecting RENAME
  2. Commit!
  3. Push!

Alright, first change! Pretty sweet, hum?

The end

Dude, what a ride! Next up:

  • Find out what Math Machine is actually supposed to do! Is it a calculator? Does it do math? Is it even a machine? Who knows! not me!
  • Source documentation with Doxygen
  • Unit Testing with QtTest
  • Memory debugging with valgrind
  • … And more!

If you’re considering serious software development, you should consider doing your development in a virtualized environment. When dealing with Linux, this is by far the best approach. Agility with virtualization will allow you to test your code in a multitude of different distros and scenarios, easily check for package dependencies, etc etc. The source code of your programmatic ramblings should be stored in a public server, instead of being kept local, trapped inside the virtual machine. This is why using version control software such as git or svn is crucial. But that’s for another talk, this one is about virtualization.

1. Get VirtualBox

VirtualBox is a full-feature free software virtualization suite that runs Linux like a charm. Download it from www.virtualbox.org or hit

sudo apt-get install virtualbox

on your console if you’re pro and are already running Linux. Super!

2. Get Ubuntu

Ubuntu can be freely downloaded from www.ubuntu.com. I recommend checking the Ubuntu Releases page to access the currently supported versions from a mirror near you.

Let’s talk about Ubuntu versions. As you may or may not know, Ubuntu releases a new version every 6 months. Every 2 years, in April, a long-term support version is released which is usually referred to as the LTS. LTS versions are supported for 3 years (5 years for servers) instead of the usual 1.5 years. The latest LTS versions are 8.04, 10.04 and the upcoming 12.04.

That’s a lot of versions. How do users choose what version to install? Well, regular users just stick with the latest version. We’ll call them general population or gen pop for short. This is to allude to the fact that they live  in a sort of computing prison, constantly reinstalling their OS. So gen pop always upgrades to the latest version and doesn’t give a shit about the LTSs. Who uses the LTS? We’ll call them the saners, since they don’t live in a self-inflicted prison. They normally only upgrade from an LTS to an LTS.

Here’s a quick overview of the last 2 years of Ubuntu versions:

  • 10.04 called the Lucid Lynx is the pinacle of a generation. It runs Gnome 2 and is taken seriously by professionals in computing-related fields. This where the saners are.
  • 10.10-11.10 are a series of beta-level editions whose main objective is to develop and test the new Unity desktop. Only Gen pop and Ubuntu developers ride this wave.
  • 12.04 called the Precise Pangolin is the first generation LTS running Unity. Everyone is a bit suspicious of what’s gonna happen. It’s due in 3 months. People in the professional area are especially suspicious of what the hell is gonna happen.

So, what’s the deal? As soon as 12.04 is released gen pop will adopt it immediately, so the 10.10-11.10 versions are irrelevant. Saners will only upgrade if Unity isn’t a disaster. Either way, what makes sense today if we intend our software to reach a high number of people is to support both Ubuntu 10.04 and 12.04. You can get the latest daily build of 12.04 here.

3. Create the machine

This is dead simple. Some basic configurations on the new machine:

  • 1536MB RAM is a good base.
  • 8GB dynamically allocated is enough for light development, adapt accordingly. Remember that dynamically allocated means the size of the disk file is proportional to the amount of disk used. So you can setup a 32GB disk, and the file that supports it is only 1GB in size, and as you use Ubuntu, the disk will start to grow.

4. Install Ubuntu

Installation

Start your VM and choose the Ubuntu iso you downloaded when the First Run Wizard asks you for an installation media.

Heads up! Boot into the live session first and install by double clicking the shortcut in the desktop. Choosing install Ubuntu from the boot menu will fail!

The rest of the installation is just a matter of clicking next next next as fast as you can.

Drivers

VirtualBox provides a custom set of kernel modules to make Ubuntu run super-smooth. To install them go to Devices->Install Guest Additions in the VM’s menu. This will mount a CD with the required software. Now it’s just a matter of running the executable in the terminal. Open a terminal and hit

cd /media/VBOXADDITIONS/*
sudo ./VBoxLinuxAdditions.run

Restart and boom, all done.

Useful configurations

Here’s a couple of tricks and tips that will make your life easier as a developer.

Open terminal nautilus plugin-in
sudo apt-get install nautilus-open-terminal

Open-terminal

Opens a terminal in the current nautilus folder. Super convenient. Just logout and log back in to see the new option in the context menu.

Go down you lousy paragraph! Down I say! DOWN!

Terminator
sudo apt-get install terminator

Terminator

Terminator ia a terminal that opens several windows and this way you can either control several machines through ssh, or be at several folders at the same time.
Useful for programs that have makefiles all over the place.

Have some tips of your own? Please leave a comment and I’ll add it to the post, we’re trying to look like a team here : -)

The end

The Virgin Virtual Machines

Alright, ready for development! At the end of this step you should have both versions running  inside their own little VMs like in the pretty picture – PreciseVirgin and LucidVirgin. You’re ready to proceed to step two in this series.

Ladies and gentleman, boys and girls, reports of this blog’s death have been greatly exaggerated. Towards clearing this blog’s bad name, this is the first post and anchor point in what shall henceforth be know as the Odyssey – going from absolutely nothing, to an application rolling in Ubuntu Software Center. And by nothing, I mean nothing, not even Ubuntu itself. The main purpose of this undertaking will be to serve as a guide to anyone, young or old, n00b or pro, interested in developing software for Ubuntu.

Let’s start this thing, shall we?
Step One – Spare yourself the trouble, go virtual.
Step Two – Programming, Motherfucker (Part 1).
Step Three – Programming, Motherfucker (Part 2).

People say Linux is fast. People say Ubuntu is fast. What are these people talking about exactly?

Well, it’s not the browser performance. Have a look at the performance results from Peacekeeper.

Side by side - Peacekeeper results for Ubuntu 10.04 and Windows XP

I ran these on a 6 year old laptop, an old centrino 1.7Ghz with a shitty ATI. Just for completeness sake, since it doesn’t really matter. I’m willing to assert that you will have similar results on any machine.

Add to this the shitty graphics drivers to slow the rendering down, and the ubber-shitty flash for the ultimate cherry on top of the cake.

So you see gentlemen, when you say linux is “faster” … well, it’s really not that simple. On the server? sure. On the desktop, on the applications that matter to the desktop user… it’s not faster. At all.

No wonder Ubuntu drains my battery much faster. Not only isn’t powersaving optimal for all my hardware because of inexistent manufacturer support, but the applications themselves burn much more cpu.

BONUS POINTS: Notice the font rendering in XP. Now Ubuntu. Now XP. Holy shit.

PS – A real post in what? Over a year? Holy shitz!

Tags: , , , , , , , , , , , ,

Here’s a question. You know what happens when you try to push a release 20 days earlier just to be released on a date with some special geek significance?

Allow me to answer in the form of screenshots.

 

Design team. Idiots? Visually impaired? You decide!

 

 

A striking resemblance, I dare say!

 

 

They don't call it Maverick for nothing!

 

 

Seriously, this thing is unruly!

 

 

Comes with built-in trolling mechanism, sweet!

 

More lulz to be added as they show up, stay tuned! Excitment! Exclamation points!

If you were on the internet around august-september last year, you might have heard some of the buzz surrounding Ubuntu 9.10 “Karmic “Koala”. Since ubuntu and windows 7 came out on more or less the same time, comparing both operating systems was quite fashionable. And, wow, what do you know, ubuntu always won. If you ask me, linux fanboys have used linux for so long they must’ve forgot what a fully working operating system looks like.

Well, you know what they say, the higher you fly the bigger the fall, or something of the like, and the fall of Karmic Koala was quite severe. Here’s a couple of notes of some the worst of Ubuntu’s latest edition.

1- PulseAudio is still broken

The PulseAudio rush started in late 2007. If I remember correctly, it was Fedora that first shipped with it. Then all the major distros rushed in as well and Ubuntu 8.04 LTS was the first release to include it. And that was the end of linux audio being close to working.

Since then, every ubuntu version suffers from some audio problem or another. In 8.04, flash didn’t work. In 8.10, sound clipped. In 9.04, skype broke. In 9.10 it’s just a mess. Audio in all  the emulators don’t work properly: GensGS, PSCX-R, Mupen64, and even Dosbox . Audio in wine will desynchronize periodically, click, hiss etc. Sound clipping in banshee was solved by defaulting the volume to 80% instead of 100% like it should be.  etc etc ad absurdum.

2- The radeon driver is broken

I had posted before that ATI dropped support for RV300 chips. I was happy that linux enabled me to use the latest software with my aging hardware. But that’s not really the case. The radeon driver suffers from an infinite number of regressions, bugs, performance issues that make Ubuntu 9.10 unusable with these cards. I’m not even talking about compositing performance, or the 3D acceleration that can’t really be called acceleration, it’s with video, 2D desktop performance and, of course, flash and scrolling performance.

I remember a somewhat old interview of Mark Shuttleworth that finished with mark saying to the interviewer “If you have an old laptop around the house, try the ubuntu live cd”. If this was ever true, it definitely is not true anymore.

3- The update-apt-xapian-index bug

Synaptic Package Manager has a quick search function that works very nicely. It has an optimized database of some sort, and it is populated by this process called update-apt-xapian-index which is scheduled to run weekly. Now, everytime this process decides to run, which obeying the fundamentals of moore’s laws is always on the worst possible time, the OS just freezes. If you have a recent computer, this is barely noticeable. If you have an older computer or say a netbook, this is unbelievably annoying. Some people don’t think it’s a bug, these people are wrong. It is a bug.

4- The system log bug

I only noticed this with my netbook, but I’m willing to infer that it happens on all computers that use the Intel Atom processor or one a line of motherboards that support it. On a completely random basis, the system will start logging hundreds of time per second the reported temperature of operation of the processor. In a couple of minutes your log files can shoot up to the GB numbers, which depending on your machine can be either an enormous disaster, or a gigantic disaster. Take your pick.

5- Probably the most unreliable release ever

There are so many little bugs and issues that this release of Ubuntu is just unreliable. It’s the gnome-do package that provides a broken gnome-do. It’s the doubt that any packaged program that uses audio will work at all. It’s the gnome keyring that requires authentication on every operation if you choose to enable automatic login. It’s the new boot process that hides some messages, but doesn’t hide others. It’s the two finger scrolling emulation that the driver supports, but the ubuntu menu to activate it doesn’t work. It’s firefox 3.5 that doesn’t scroll properly in google reader, and still has that bug that if some element has absolute positioning scrolling is horribly slow.  I say no more.

In conclusion

More and more ubuntu has converged into this notion: everything kind of works, but at the same time, it doesn’t. A few years back, installing ubuntu was a pain in the ass but in the end you had a reliable system. Today, the installation procedure is easier, but the bar has been raised. Even if your hardware is 100% supported with the best drivers, the system will not be 100% reliable. Be it the bad packaging or the pulseaudio mess, ubuntu has reached a point where it can’t be trusted. So the obvious question is: why use it at all?

All eyes on lucid lynx.

P.S. I haven’t written anything on this blog for quite some time. I’ve just been busy, and honestly, my motto for creating this blog was “because it’s relevant”. With every ubuntu release, I feel like it’s becoming progressively less true. And I still use ubuntu on all my computers. Go figure.

Tags: , , , , , , , , , , , , , ,

I’ve been trying a lot of distros on the aa1 recently, I’ve tried all Ubuntus from 8.04 till 9.04, sidux, slitaz, madbox, and now Kuki Linux.

Kuki linux is made specifically for the AA1, so I was expecting something nice. I only tried it live from usb, so this is what I got.

On hardware performance and recognition, everything kinda works. Webcam, audio, baterry recognition, wireless (good performance btw) no problem whatsoever. Wired I didn’ try but it should be working.
In terms of graphics I was initially very disappointed with the streaming flash video performance. Then I read the release announcement more closely and it seems they have a “special” xorg configuration that boosts the performance tremendously. I was skeptical, but stupidily so. The xorg configuration they made is great, I mean it’s as good as it gets. I had just tried Ubuntu 9.04 before and flash video was terrible. With their conf you can get daily show with no problem whatsoever, facebook videos with normal quality rolling beautifully, youtube not even worth mentioning. Fullscreen works great too. Glxgears outputs ~570fps. Gentlemen, they did it, hat’s off!
Card recognition depends on which one you’re looking at. The left one works great. Hot plugging working by default, and it’s really fast, wait where’s the bold, oh, really fast. You plug the card in and dare I say in less than one second Thunar pops up. My balls dropped. The right one isn’t working out of the box, but according to this post on the forums they have a solution, so it’s just a matter of making it to the distro. Strange bug though, after I tried the right card reader and then put the card back in the left reader, it stopped working. Not too worried honestly.

Software wise, you get the general assortment of xfce (4.6) apps. You know, mousepad, the ex xarchiver and shit. Then I think they made weird choices on programs. Ok, I take that back, it just comes with programs I don’t like. Audacious for audio playing, Mplayer for video. Ever heard of vlc? Bah. Also comes with this thing called “Zim Desktop Wiki” I have no idea why. A lame looking ebook reader. No office apps as of yet, not even abi word. But I’ll confess my ignorance, i don’t know what are the plans for the future on this end and I didn’t bother to look up. Either way, if you install this, you’re on your own, but this is ubuntu running underneath so installing anything I’m sure is dead basic.
Oh, almost forgot. Networking done by wicd which is awesome. I fucking hate network manager and this was really good to see. Works wonders.

Now the visuals. I was really happy when I saw that the login screen. I don’t have a screenshot but it looks really nice. The color looks really good on the screen, the fonts are beautifull. Then you login, and the background doesn’t flicker or anything, it goes straight to the desktop in this really awesome integrated experience. Sad part is, you walk beautifull to reach this sad thing

Holy shit. Why so sad?

Holy shit. Why so sad?

No I don’t know if it’s just me, but I hate xfce. Seriously. Thunar (the file manager) aside, it’s horrible. Look at the font on the clock. Doesn’t it break your heart? Virtual desktops are vertical instead of horizontal, no option to change it. Bah. The icons on the desktop have no reason to be uncool, but for some reason they just look terrible. Maybe it’s because of the color background behind the name of the file. Maybe it’s because they look realistic and the rest of the desktop looks like ugly cartoons. Now look at this

Please stop, I can't take it anymore

Please stop, I can't take it anymore

Window border is horrific. Default gray makes me so sad I wanna cry. It’s this kind of prison gray, innit? Oh man it’s just awfull. You know, after coming from Ubuntu 9.04 using the awesome dust theme I look at this and just make a sad face. And really after trying madbox my standards in terms of looks just exploded thru the roof, just look at this

Now this is what Im talking about

Now this is what I'm talking about

So ok, let’s make a conclusion. I couldn’t test suspend and hibernation, but I think that’s working out of the box in Ubuntu 9.04 so I guess it’s working, but anyway. In terms of what really matters, kuki wins big time. Performance is great, hardware recognition getting very close to perfect, boot time is good too. I didn’t try it, but I used the same kernel in ubuntu and it was good then, since kuki uses even less services and shit it can only be faster. Where it loses is in using xfce which i hate, they should have sticked to lxde godamnit!, and on the desktop appearance. But this can be worked out, although I never saw any good looking xfce desktop to be honest. It’s one of those things you can leave for last, but guys, aim for the top, for the ubber distro, and do something about it. After that you can all demand preferential treatment from us, the idiots, because you godamn deserve it. Gentlemen, it took a long time but we’re getting very close. Hat’s off!

Ps: I wonder what happens if I stick that xorg conf on ubuntu 9.04 running lxde or something.hm

Tags: , , , , , , , , , , , , , , , , , , , ,