[GSoC 2015] Setting up MacPorts libsolv branch


Hola Amigos,

Here I am going to show how to setup and install my MacPorts development branch (gsoc15-dependency) and libsolv.

Step 1: Clone my development branch inside ~/Development folder probably so that we do not mess up other folders/files. You are free to do it in your preferred folder too.

If you do not have ~/Development folder you can run:

mkdir ~/Development; cd ~/Development

Now we will clone our svn repository. To do so run:

svn co https://svn.macports.org/repository/macports/branches/gsoc15-dependency
cd base

Note: I will be setting up everything inside ~/Development. If you choose to do it under other folder, do remember to replace ~/Development in the following commands with your folder path.

Step 2: Installing MacPorts Development branch.

As this is a testing branch, we do not want it to install and interfere with our installed MacPorts in ${prefix} i.e. /opt/local (default).

Run the following command to make sure it is installed in ~/Development/mp_libsolv (you can give any name by replacing “mp_libsolv”) and also we will have to –disable-readline (we do not want this development version to be used by default by adding it to our PATH).

PATH=/usr/bin:/bin:/usr/sbin:/sbin ./configure --prefix ~/Development/mp_libsolv

Step 3: Adding alias for this development port.

To run this dev version of port you will have to run using “~/Development/mp_libsolv/bin/port”. So instead we will create a alias in our bash_profile. To do so run the following command.

echo 'alias portgsoc="/Users/JacksonIsaac/Development/mp_libsolv/bin/port"' >> ~/.bash_profile

You can also give some other alias instead of portgsoc and also remember to fix the absolute path i.e. “/Users/JacksonIsaac/Development/mp_libsolv” to your installed folder. You can also get that by running “pwd” inside ~/Development/mp_libsolv folder.

We will have to create a alias for sudo too if we want sudo to recognize this “portgsoc” alias (for installing and updating ports which need root access).

echo 'alias sudo="sudo "' >> ~/.bash_profile

Step 4: Test our development port

Now we will test if our development port is working fine or not. To do so I will be updating the portindex and some port operation.

sudo portgsoc -d selfupdate
portgsoc search libsolv

To add libsolv support to our Development port, we need to build libsolv.

Step 5: Cloning libsolv from upstream.

Libsolv port is available (but the current version is 0.6.10) which does not support Tcl bindings yet. So we will clone the upstream branch for now and build from source against our portgsoc-tclsh.

Under ~/Devlopment run the following commands:

git clone https://github.com/openSUSE/libsolv.git
cd libsolv
mkdir build; cd build

Now we will run cmake inside build/ so that we do not mess up the root folder with make files and if we need to delete this folder and run cmake again if something goes wrong while building.

cmake -DTCL_INCLUDE_PATH=${prefix}/libexec/macports/include -DTCL_LIBRARY=${prefix}/libexec/macports/lib/libtcl8.5.dylib -DTCL_TCLSH=${prefix}/libexec/macports/bin/tclsh8.5 -DENABLE_TCL:BOOL=ON ..

Note: Replace ${prefix} with your installation path i.e. ~/Development/mp_libsolv if you exactly followed the steps above.

Now libsolv is ready to be installed against our portgsoc-tclsh, so run the following make commands (in build/):

make
sudo make install

Okay so now we are set to use the libsolv feature in our MacPorts libsolv branch. You can test libsolv search feature by using -l option.
Example commands are:

portgsoc -l search libsolv
portgsoc -l search --category math
portgsoc -l search --exact --case-sensitive gcc5

and so on. You can also pass -d for debug options.

Let the Windows be open, and feel the Freedom.

[GSoC 2015] Week 1: Create libsolv bindings for Tcl


Hola amigos,

1stWeek: 25stMay, 2015 – 31stMay, 2015
Now we are into the coding phase of GSoC 2015. First we finished going through the pysolv, python bindings of libsolv which helped us a lot to understand what all stuff libsolv can do for us.

We had to find a way for the libsolv to work with Tcl, as MacPorts base is largely written in Tcl. So my mentor mentioned SWIG (a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.) as libsolv was written in C. Then luckily we came across solv.i in the bindings/ folder. solv.i contains the interface file for SWIG which helps SWIG to convert it into the destination language (Tcl for us).

We concluded our discussion on libsolv bindings and decided to have a extra meeting on 29stMay, 2015 for adding Tcl related interface code in solv.i. Till then I went through SWIG tutorials and also tried my hand on creating python bindings for MacPorts code (src/machista1.0/machista.i). While doing so I came across a bug, #include was missing from the interface file which was then committed by my mentor with the updated machista_wrap.c file. This wrap file is used to compile against the destination languages library to get the bindings for the destination language.

Tutorials and more information on SWIG can be found SWIG.

In our extra meeting, I wrote the remaining SWIG interface Tcl code and then committed it to neverpanic (my mentors) branch. Which he merged and combined those multiple commits into one and then PR’ed (Pull Request) to the upstream libsolv branch (OpenSuSE/libsolv). Then we compiled everything and run cmake and make on the current build.

Now we had a solv.dylib which can be loaded in the correct Tclsh. We built it against out port-tclsh (A symlink to MacPorts’ copy of Tclsh) by passing some options to cmake, so we can use solv.dylib against that tclsh only as different versions/variants of Tcl would build the SWIG differently and might give errors.

To clone libsolv repository run the following command:

git clone https://github.com/openSUSE/libsolv.git

Now, it is recommended to create a build/ directory and run cmake inside build folder rather than libsolv/ itself as lot of files will be created by cmake which we would have to delete if we run into troubles or need to change the path of Tclsh against which it is built.

You can do so by running the following command in your terminal:

mkdir build; cd build

If you wish to create libsolv bindings against port-tclsh run the following cmake command (Inside libsolv/build):

cmake -DTCL_INCLUDE_PATH=${prefix}/libexec/macports/include -DTCL_LIBRARY=${prefix}/libexec/macports/lib/libtcl8.5.dylib -DTCL_TCLSH=${prefix}/libexec/macports/bin/tclsh8.5 -DENABLE_TCL:BOOL=ON ..
make
sudo make install

Note: Replace ${prefix} with your MacPorts installation path. By Default it would be /opt/local/. You may want to use a development prefix intended for testing purposes e.g. ~/Development/macports.

Then copy the solv.dylib to the directory where you want to use libsolv bindings for Tcl.

Initially we copied solv.dylib to macports1.0/ and the created a file libsolv.tcl which loads this bindings using “load abosulte/path/to/solv.dylib” and the “package require solv” in macports_libsolv.tcl

Note: The current upstream of libsolv is fixed and improvised for “Implementing Tcl Bindings” in this commit and now we just need to use “package require solv”. The bindings is automatically found by Tclsh in the path.

Let the Windows be open, and feel the Freedom.

[GSoC 2015] Community Bonding


Hola amigos,

Google Summer of Code results were announced on 27th April, 2015 and I was one of the selected students. After the results the “Community Bonding” period starts till 25th May, 2015.


What is Community Bonding?

In Community Bonding, we get to know more about the project, mentor(s), other developers, etc. It is a one month period where you get enough time to go through and understand the codebase, set up your accounts and local repositories, discuss about the project plan and strategy, look into similar implementations and get to know the awesome people working to make the project better. You are now one of them too ;)

As soon as the results were out it was something different feeling altogether. For my organization “The MacPorts Project” there were 3 students selected, including me. My Mentor, Clemens Lang, sent out official emails (Google sends official selection mail too) to us about being selected and what we will be doing ahead in community bonding period. I went through the links and what was planned ahead and took no time (excitement level was off the charts) to thank him and the community for helping us out during the pre-application period to better understand the project ideas.


First Meeting: 29th April, 2015

We (My Mentor, Clemens and I) had our first official project meeting on FaceTime the next day itself, it was something new that we had tried having meetings on FaceTime. In this meeting, we got to know each other and we discussed a tiny bit about our project and scheduled weekly meetings. At first FaceTime was lightning fast for discussions, but from the second meeting onwards we stuck to the same old IRC :). Well IRC since, it was easy to go through the previous logs and others can also participate in the discussions.


Second Meeting: 4th May, 2015

In this meeting, we went through the MacPorts (MP) codebase. neverpanic (My Mentor, Clemens) walked me through the complete macports codebase. We discussed which file provides and does what and which were the files we would have to look into and discussed about them in detail. We did skip a few files as they weren’t required at the moment and we would go though them when required. Going through the code yourself and having someone guide you with experience makes a huge difference. I tried to go through the codebase and could actually understand small portion but with the help of a mentor this process was completed in around 2-3 hours (~70-80% of codebase).

Then we also discussed where we would add the libsolv along with MP. Ideally, it would be under vendor/ directory. But then libsolv depends on cmake (a cross platform build system) and cmake isn’t distributed along OS X, Xcode CLT (Command line tools) or MacPorts. So have kept that for future discussion, whether cmake would be a pre-requisite for MP (this would mean more dependencies for MP – curl, expat, zlib, bzip2, libarchive) or should we convert it to autoconf build system or pre-generate cmake-based build system along with MP.

We went through the MP codebase following the path of the command “port install foo”. MacPorts is written in Tcl (pronounced “tickle”) and there exists some part of C. First we looked into port/ folder which contain the files port.tcl, portindex.tcl and portmirror.tcl. port.tcl is the file that is basically executed when we do something like “port install foo” or in general “port “. For the users convenience we run port without the .tcl extension i.e. “port install foo” and not “port.tcl install foo”. Files under port/ mostly deals with the front-end presentation, command line parsing and resolving expressions.

Then we moved to the core of MP i.e macports1.0 folder. Inside this macports.tcl takes care of everything and is the most important and also the largest file in MP base. This is also the file where the dependency calculation happens, hence the main file to work on since we need to work on “dependency calculation” and we will probably call libsolv functions from here. As it is already a huge file, we might probably move the new functionalities to another file, probably dependency.tcl or similar.

To install a port there exists a Portfile which defines a set of rules and metadata describing the package and how to build it. MP create a new Tcl interpreter and runs the portfile. Inside this sub-interpreter the files inside port1.0/ are executed during the respective phases like fetch, verify checksum, extract, patch, configure, build, destroot, test, archive and install. This makes the life of a Portfile maintainer easy as they would only have to configure the URL and filename to download, other things are taken care of by the port1.0/ files.

package1.0 deals with if there exists a pre-built binary archive on our mirrors and how to fetch and use these instead of building the port on the users system.

To keep track of the installed ports, etc MP uses a SQLite DB. The code that deals with handling this DB is under cregistry/ and registry2.0/, where the latter is more object oriented and east to use.

pextlib1.0/ contains the extensions for MP’s Tcl. E.g. MP’s Tcl comes with a “curl” command which internally uses the libcurl to fetch files. Various Hashing algorithms are also found under pextlib1.0/ which is used by MP to verify the checksum of the fetched files by running the checksum on the file and compare with the checksum given in the Portfile by the Portfile maintainer.

Then we had a Q&A session and we cleared some doubts regarding cmake and build system and some parts of Portfile.

We were waiting for other students to respond before we move forward with creating macports.org account for using svn. I started trying out svn on assembla.com. We also discussed about svn (C-VCS) and git (D-VCS) and concluded our second meeting.


Third Meeting: 11th May, 2015

Software Engineering exam tomorrow, but anyways the paper will be as usual difficult so moving to some Open Source :)

I went through the libsolv code and as neverpanic had also sent some links over mail to look into. I couldn’t cover the whole thing but still I got a brief idea of what the libsolv does.

In this meeting, we tried to compile and build libsolv on Mac OS X. As expected there were errors, in linker to be precise. neverpanic created a port with patches to be made to the CMakeLists.txt which is somewhat similar to ‘Makefile’. We also pushed the patch upstream and then moved to vimrc. As I was having some problems using vim so we set up a clean vimrc and then concluded the meeting.


Fourth Meeting: 18th May, 2015

The other students had replied regarding their handle for macports.org ID and neverpanic had mailed the MacOSForge admins requesting for the account creation. We actually rescheduled this meeting the next day i.e. 19th May, 2015.

Now, I had gone through the libsolv and understood the different data structures used and what the functions do and how they work. Thanks to neverpanic’s libsolv Port, man pages libsolv-bindings, libsolv-pool came handy and were very helpful. We also went through the pysolv (Python bindings for libsolv) example as it was easier to understand what the modules do and how.

At the end of meeting, we had covered almost 650 line of code, many lines were skipped too as they were not necessary at the moment.

Community Bonding period ends on 25th May, 2015 and Coding period starts but we had another meeting planned on 25th May, 2015, where we finished off with the pysolv example and moved to further planning of the project. This will be covered in the coming posts. :)

P.S: I was lazy to re-check the above. So please feel free to point out the mistakes and I’ll look into it and make sure to correct them.

Let the Windows be open, and feel the Freedom.

GSoC 2015: The MacPorts Project


Hola amigos,

I am happy to announce that I have been selected for GSoC 2015 as a student developer with ‘The MacPorts Project’. My project is titled “MacPorts: Improve Dependency Calculation using SAT solver.“.

GSoC 2015 - The MacPorts Project

GSoC 2015 – The MacPorts Project

The proposal can be found here.

I will be posting all the weekly updates over here, and also document everything. So watch out this space for more about the project.

Let the Windows be open, and feel the Freedom.

PAC-MAN on Google Maps


Hola Amigos,

I am going to show you how you can too play PAC-MAN on your browser through Google-Maps. I have also known PAC-MAN by another name, Gob-Man.*Feels Nostalgic*

Are you Ready?

Are you Ready?

So, here it goes:
Step 1: Open up Google Maps.
Step 2: Navigate to some place with lot of roads, crossroads and streets. I played it near my University :P :)

Easter egg on Bottom-left corner

Easter egg on Bottom-left corner

Note: Don’t worry if you can’t find a street. Maps will do it for you, you just need to click ‘I’m Feeling Lucky’

I'm Feeling Lucky

I’m Feeling Lucky

PAC-MAN Ready to Play

PAC-MAN Ready to Play

PAC-MAN, Gob and Run!!!

PAC-MAN, Gob and Run!!!

Step 3: Now click on the PAC-MAN icon on bottom-left corner.

Enjoy PAC-MAN on your browser :)

Let the Windows be open, and feel the Freedom.

/etc/apt/sources.list, GNOME 3.16 release and Jessie RC2


Jackson Isaac:

Hola Amigos,

Sharing an awesome and informative blog post about Debian sources.list, Debian-GNOME and newest release of Debian flavor – Jessie.

Originally posted on Experiences in the community:

This would be a longish post about lot of topics starting from documenting my /etc/apt/sources.list, going to various goings on with GNOME 3.16 release and Debian Jessie RC2 release.

View original 2,377 more words

[How To]: Installing MacPorts on Mac OS X


Hola Amigos,

I have blogged about installing brew package manager previously. Today I am going to show how to install MacPorts.

What is MacPorts?

MacPorts is an open source package manager for Mac OS X. It makes fetching, compiling and installing open source packages on Mac OS X easy.

It is recommended that you use only one package manager as there can be package conflicts. But I have been using MacPorts along with brew without any problems, unless you purposefully try to break the system.

Also MacPorts depends on Xcode and xcode command line tools. You can download these from App Store or from the Apple Developers website.

You can either download xcode command line tools from Apple Developer website itself or run the following command after install Xcode:

xcode-select --install

Installing MacPorts via Installer:

To install MacPorts (stable version), you can download the dmg from here.

Users having older version of Mac OS X can visit their Download page for detailed steps.

Installing MacPorts from source:

1) Clone the MacPorts source via svn (Subversion):

Run the following command in your Terminal.App:

svn checkout https://svn.macports.org/repository/macports/trunk macports-trunk

This will fetch the source of MacPorts into a folder named ‘macports-trunk’.

You can fetch the source in another folder by running in Terminal.App:

svn checkout https://svn.macports.org/repository/macports/trunk FOLDER_NAME

Note: Replace FOLDER_NAME with your desired folder name.

Considering that our MacPorts source is cloned in macports-trunk folder

If you have already cloned the source code then run the following code inside the macports-trunk directory (in Terminal.App):

svn up

Now to compile and install MacPorts, run the following sequence of commands in Terminal.App:

./configure --enable-readline
make
sudo make install

Run the following command to update your ports (MacPorts base sources)

sudo port -d selfupdate

You can use MacPorts (interactive mode of MacPorts) by running

port

To install a package using MacPorts you can run

sudo port install package_name

Hope this helps you installing open source packages on your Mac.

Let the Windows be open, and feel the Freedom.