DEV Community

Cover image for Contributing to Ubuntu β€” Day 1: When I Met the β€˜sl’ Train Command πŸš‚
Meet Gandhi
Meet Gandhi

Posted on

Contributing to Ubuntu β€” Day 1: When I Met the β€˜sl’ Train Command πŸš‚

Hello reader! I know this is my first blog and you don't know me, but you will eventually (trust me on this one 😁).
But I am just another developer curious about how I can contribute to Ubuntu without any prior experience with open source.

The Background:

I always felt very curious on how Operating systems like Windows work but as luck may have it, Windows is closed source and I cannot dig deep into it. But as my interest in system design grew deeper, I got to know of Linux. And about a month later (to my surprise), having Ubuntu 22.04 on either a VM or on dual boot became a must in the Operating Systems course at my University. That's when I first met Ubuntu, then I explored its command line (which is till date a maze for me). Slowly we were introduced to a ton of OS concepts like scheduling and memory management which just sank into my brain β€” but I wanted to see them in action. Now, I could make an OS myself using QEMU but then I decided why not tinker with Ubuntu first? After all, I have it up and running and it is open source. Hence I started my blog series on Contributing to Ubuntu, here I show my journey of how much I learn while trying to figure my way out. Plus, I could not find something which can really help me do what I want hence this could also act as a "mini guide" (atleast sort of...) for any other beginner who has a passion similar to mine and wants to start as well.

The goal:

My goal at the end of this series is to develop a good solution for the boring emoji picker in Ubuntu. This is because I use a ton of emoji's in a single sentence (though i have controlled myself too much here) I need something better than this to keep using Ubuntu πŸ₯΄

The installation headaches:

So i had Ubuntu 22.04 which after a headache got upgraded to 24.04 (glad ChatGPT is a thing right now)
After upgrading I first installed the build tools which are seemingly necessary to proceed ahead

sudo apt update
sudo apt install build-essential devscripts fakeroot git
Enter fullscreen mode Exit fullscreen mode

Then I did what a great programmer does β€” I asked ChatGPT what I should start with as a noob 😁
So after some spiraling talks, I got to the conclusion of tinkering the sl package since it does not do anything (yep, that is the actual reason 🫠)

sudo apt install sl
apt source sl
cd sl-*
Enter fullscreen mode Exit fullscreen mode

But as the saying goes Bugs follow programmers everywhere (which I created a minute ago), I encountered a bug!

meet@Genius:~$ apt source sl
Reading package lists... Done
E: You must put some 'deb-src' URIs in your sources.list
Enter fullscreen mode Exit fullscreen mode

Then I edited the sources.list file in /etc/apt

  • Previous file content:
deb http://archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
Enter fullscreen mode Exit fullscreen mode
  • Updated file content:
deb http://archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
Enter fullscreen mode Exit fullscreen mode

This finally allowed me to get the source code of sl

sudo apt update
apt source sl
Enter fullscreen mode Exit fullscreen mode

Now I opened the /home/meet/sl-5.02 folder in VSCode. And while VSCode was opening the folder (yes, my laptop is not as fast as your pcs folks!), I typed sl in my terminal in a new desktop and I was flabbergasted! I cannot describe my first time experience but I would recommend anyone reading this Just Try It!.

The code exploration:

After having everything setup (finally!), I started exploring the source code. there were 2 main files I found sl.c and sl.h. the c file seemed normal enough until I opened the header file 🀯
This file had all the train parts hardcoded into it!
After getting amazed the second time I came back to the c file and started dry running the main function. I found that the sl command accepted not just 3 options (I think I read it in the docs), but 4 options, (-a, -c, -F, -l) out of which I loved option -F since it requires a good understanding of what you are doing in order to do such amazing tricks in the terminal. And for 10-20 minutes, I was a bit confused too since I could not figure out what is the use of the constants with the 'C' prefix in the headers, but after seeing this option function I did get clarity on where it is used (it is used in the -c option, which anyone with some common sense could figure out β€” except me, I had to try it once πŸ˜‚)

headers

The conclusion:

So thanks a lot dear reader, you have reached till here, I respect you for giving your time here! After exploring the source code I cannot wait to just tinker it, but college assignments demand time hence the tinkering part goes on to day 2 (I hope my Day 2 comes around quickly) where I plan to tinker this code a bit to see how it works internally, maybe even create my own mini walking robot some days later? πŸ€– But until then, Sayonara Amigos (I hope i said it right πŸ˜…).
If you enjoyed this, drop a 🐧 in the comments β€” it’ll help me know someone’s reading these and Stay Tuned!

Top comments (2)

Collapse
 
drumil_bhati_2aa75996322c profile image
Drumil Bhati

🐧

Collapse
 
shayan_pariyal_74a18330a6 profile image
Shayan Pariyal

A great exploration indeed! And an interesting buildup as well😁