Making helpers

From Hamara Wiki
Revision as of 13:07, 13 June 2018 by Unixia (talk | contribs) (Compiling the new source)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

An interesting way to contribute to Hamara can be writing helpers for different packages.

What are Helpers?

Helpers are the scripts that let you make a customized version of a package exclusively for Hamara Linux. Since the base for Hamara Linux is Debian, you'll see all the changes being made around it.

Pre-requisites

  • A debian based distro to see the changes that'll be made in the package and to ensure smooth functioning of helper scripts.
  • BASH scripting
  • Git
  • Access to our development repo for Hamara helpers.

How do helpers work?

In order to demonstrate the functioning of helper scripts, let us take up an example of an already existing helper, apache2. Check it out here. Looking closely at the script, you can see it is quite self-explanatory. We set the version of the script and go about making some changes in some files and compile everything. Easy-peasy!

But, did you miss . ./config?

And what is changelog?

We've all compiled things on Linux but never seen a command like compile before. Have you?

Let's explore the important parts of the script.

config file

You can find the file at the root of helpers repo which happens to be big enough but you shouldn't worry if you know BASH, you'll get along. It does the following.

                                  ----------------------------------------------------------------
                                  |  Set environment variables for building packages against CI  |
                                  ----------------------------------------------------------------
                                                                 |
                                              -------------------------------------
                                              |   Set release versions and info   |
                                              -------------------------------------
                                                                 |
                                                    ----------------------------
                                                    |   Set upstream mirrors   |
                                                    ----------------------------
                                                                 |
                                                       ----------------------
                                                       |   Update machine   |
                                                       ----------------------
                                                                 |
                                                       ------------------------
                                                       |   Build the source   |
                                                       ------------------------

+ Some other auxiliary functions that will be used by helper scripts (You can now see what changelog and compile would do)

Why is this all in a separate file?

Because this process is common to all helper scripts and config file needs to be sourced before running any other tasks in any helper script.

What does . ./config mean?

It means sourcing the file config in current directory. If you'd like to know more about what does this mean and when should it be used, check this out.

Result

After running the config file, your greeting message should look like the following.

Welcome to Hamara Sugam 2.0 (GNU/Linux 4.4.0-104-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
Linux devel.hamaralinux.org 4.4.0-104-generic #127-Ubuntu

Creating new files and replacing the old ones

The next few lines in the helper do a job of removing some files and patterns and replacing them with the new ones in the DATA directory at the root of the project. While it is easy to understand the files and patterns being replaced, sometimes it might become tough to figure out where the changes should be made.

What files to change?

Run the service on the debian distro you're using, look up its result and logs, also look into the files of the package for anything related to Debian. Redo all these files and replace Debian with Hamara. Any pictures, hashes should also be taken care of.

Compiling the new source

Compilation of the new source takes some time and varies from package to package. After the compilation is done, you should see a PACKAGES directory where you compiled it. If you observe this directory, you'll find all the changes you did for the package inside it. For example, for apache2, index.html was customized, you can see it in ./PACKAGES/apache2-amd64/source/debian/ directory. And when you try to open it in your browser, you'll see,

Index.png


Congratulations on compiling your first helper to Hamara Linux!

Possible bumps

1. If your apt is broken or there are some unmet dependencies, your config operation might get stuck.

2. It may not be very evident which files need to be changed so, a good lookup and testing will be required.

3. If you're doing this on your local system, the process will get stuck looking for CI files, use a little wit to figure out how to skip that part.

Footnotes

If you still have any trouble, consider asking the existing developers on community channels.