Linux kernel tutorial – Second part

Anuncios

Linux Kernel tutorial for Outreachy

I’m so interested in contributing for the linux kernel, so I’m going to follow the instructions to submit a first patch.

Actually I’m running in my laptop Fedora 27, the tutorial was made for ubuntu but with a little changes we can do it for fedora.

1 – Install some packages

The first thing we are going to do is to run this command

sudo dnf install vim libncurses5-devel gcc make git ctags openssl-devel

let it download the packages.

2 – Setup your Linux kernel code repository

Create a directory and a subdirectory in our user’s home 1.png

enter to this subdirectory and we are going to clone there the tree Greg Kroah-Hartman’s staging tree repository3.png

then we enter to the directory staging.

4.png

3 – Setting up your kernel configuration

When we download the source tree, it doesn’t have a .config file. We have to generate a .config file which determines which drivers are built. In order to do that duplicate your current config.

That config file is stored somewhere in /boot/. And we need to copy that file in our current directory just running this command

9.png

And as we can see, the file was copied, now we have to change it name

10.png

6.png

4 – Building the kernel

I couln’t run the command make at first, because before that I had to install the packages bison and flex, also installed libelf-dev, libelf-devel or elfutils-libelf-devel, on my laptop worked with elfutils-libelf-devel

7-e1519103002434.png

Now, I can run make, takes a long time, but finally it works without errors

2

finally we can see that make add to our current directory 6 files (built-in.o, modules.order, modules.builtin, Moule.symvers, System.map, vmlinux.o) and 2 directories (net, vmlinux)

1

5- Installing the kernel

Once we have the .ko files, we have to install the kernel running this command

3

4

And that’s all, when you boot your computer in the grub will appear the kernel that you have installed.

Example Faculty – Python Gtk

We wanted to create a program that can do something like take an entry and select an option to choose a faculty where you study  and finally return the name and the faculty where belongs instead of message

1

we enter the name of the student(alumno) “fiorella effio saldivar” and then select the faculty(facultad) “Facultad Ciencias Matematicas”, finally press send(enviar) and we will have “name of the student” + of(de la) + “faculty”

2

Now we are going to see the taxonomy of this program

3

The first part of the code

4.png

Here we set the title for the window in line 8 (UNMSM), in line 11 create a Gtk.Box called box_outer to contain all the items(select_message, listbox, button, final_label), in line 12 we add this box_outer to our main window,  in line 13 we create a Gtk.Label called select_message and then in line 14 add it to our box_outer.

Now in line 16 we create a Gtk.ListBoxRow called listbox to contain the row1 and row2, in line we set the selection mode to NONE, in line 19 we create row1 to contain hbox11, in line 20 create hbox11 to contain label1 and entry1.

In line 28 we create row2 to contain hbox21, in line 29 create hbox21 to contain label2 and combo.

The second part5.pngin line 32 we create a Gtk.ComboBoxText called combo, then in line 33, 34, 35, 36 we define the options for  combo, in line 41 we create a Gtk.Button called button and in line 42 create a Gtk.Label called final_label to show the result for our program.

In line 44 we are going to called for button when it is clicked the function on_clicked_me, we add the button and final_label to box_outer.

Finally we define the function on_clicked_me that ask us for 5 parameters (self, button, entry, label,combo), first we get the text written in a variable text, then in text2 we get the string for our combo option selected, in text3 we combine text and text2, and finally we set the text for final_label 🙂

You can check the code here.

Session 6 – Testing integration with circle CI

Today is the final session for #PeruRoadtoGSoC2018 and we are going to test integration with CircleCI in order to contribute with the documentation of Fedora (automatize the proccess of deploying), first you have to create an account in CircleCI (link), to create it please sign up with your github account, once you do that you can see in the Projects tab that you don’t have any project building on CircleCI

2

Now we have to create our repository so create a directory called integration_Fedora containing another directory called src there create the file index.html with this code

1.png

and creating it in our github we can initiliaze our repo now ir order to push all the commits, now in the CircleCI page check the tab Projects and you can see our project integration_Fedora now click on Setup project

3.png

We have to read this guide and the first step is create a folder name .circleci and add a file config.yml there, the second step is to copy on the file the sample .yml below, now push this change up to your Github and press Start building once you did that

4.png

6.png

5.png

Just actualize the page and you have this

7

Now, we are going to do our second commit

8

9

And we see that we put an octocat when you enter the name of the commit

10

Now we are going to edit our config.yml file changing for fedora:latest

1.png

2.png

Now we are going to create a ssh-keygen, please what I did in my terminal

4

Then in the github page we can check in settings the ssh keys and we add our ssh key with the part in white selected, once you’ve done that it will be there our ssh-key

5

6.png

Now in the CircleCI page we have to authorize in permissions checkout SSH keys

7

Then just authorize

8

After creating the key we start to commit with a icon (fire)

9

Icon (rat and raise_hand)

11.png

Finally we are going to edit our config.yml file in this way

12.png

And edit our index.html file like this

13.png

Now we are going to upload it to our repository

20.png

Here you can get the link to your page

21.png

And finally we see here how it works! 🙂

22

You can check my repo here.

Session 5 – Part 1 – Gtk with Python

Today we are going to use Gtk with Python and for that we can check our version of Python just type python

2

Then I’m going to install pygobject3-devel

1.png

this code just create an empty window that close the program when you close the window

3.png

and then we run it with python

5.png

Now, if you want to set the title, you have to add the line win.set_title(“The Text”) like this

1.png

And finally you can run it

2

Now we are going to create another file that have to allow us lo go to the web page of 4 languages, there we are going to add a label and gtk.listbox that contains 4 gtklistboxrow in order to create some like this

5.png

We create a Gtk.Box that will contain all (our first label and gtklistbox and so on)

Here is how it works

  1. box_outer contain label and gtklistbox
  2. gtklistbox contain gtklistboxrow and hbox
  3. hbox contain button

3.png

All that we did was to create the same 4 rows and just change the link for each one using gtklinbutton also to create the link and open it in Chrome.

You can check the code here.

Finally we were seeing how to search bugs in gnome here.

In the next picture we are able to see the nautilus bugs clicking in Issues

6

There we can grep bugs for people who are Newcomers like me

7

Also we saw the projects for Fedora in this link

9

we saw one project called system_config_language that wants to create something like a button for example that change the language configuration for all the system including apps browser keyword etc

22.png

Session 4 – Gtk with C

First we have to install gtk dependencies to compile the file and also run the file. So you have to install with this comand

sudo dnf install gtk3-devel gstreamer-devel clutter-devel libgda-devel gobject-introspection-devel

then we are going to install webkit dependencies to compile our file

7.png

At the moment of compile we had an error

1.png

That’s because the name of the package is not the same as the package that we download before, so we have to find it in /usr/lib64

2

And here at the end we have the webkit2gtk-4.0

3.png

So we have to do a modification to compile it replace  webkit3.0 for wetkit2gtk-4.0

4.png

But there is another error because we have to do a modification in the file that contains our code, so open the file to modificate it

5

just add 2 at the final of webkit, like this

6.png

now we can compile it without errors 😀

7.png

finally we can run the code 🙂8.png

You can check the code here.