Take the 2-minute tour ×

I want to analyze the APT source code. I have downloaded it and also installed a source code browser for Gedit. But still I have no clue where to begin.

I have only read "sl"'s source code before. I want to mainly study the part where, the software reads the control file of the deb package, and makes an n'ary tree of the dependencies.

If some one has already read the APT source code please help me with where to begin. And also if someone can guide me on some kind of tutorial on how to read source code that would be great.

share|improve this question
Reading the source code depends on your ability to understand the language it was written in. Then pretty much you could start with any file, start reading it, see if it includes other source files, go to them, rinse and repeat. –  NlightNFotis Aug 11 '12 at 8:08
Working on the Keryx Project, I read some of APT's source code. I'm not familiar with C, so it didn't do me a lot of good. I did learn that dependency calculationis VERY complicated. Why are you trying to learn dependency calculation? I may be able to help or point you in the right direction. –  mac9416 Aug 11 '12 at 13:17
Thank you for your reply. I am making a re mastering software for Ubuntu for scratch and doing something different. I wanted to know what data structure was used, and also how they fetched the control file and analyzed the dependencies. I am well versed in C and C++ so I have no problems understanding source code. But since there are so many files, I am having a little difficulty finding the right one. –  mihirk Aug 11 '12 at 18:14

1 Answer 1

I think I would start in the source directory and try fgrep -ir depends * | less, and copy down the filenames I think look interesting. This goes through the entire source tree doing a case-insensitive search for "depends".

Sometimes it helps to look at debian/changelog to see what changes were made in the area you are studying; it sometimes references the names of files affected.

With a fast look I'd say apt-pkg/orderlist.cc, apt-pkg/algorithms, and apt-pkg/packagemanager.cc look interesting.

Sometimes I find a string with fgrep, find a routine where it is used, and then use fgrep again to find where the first routine was called, ad nauseum.

Here you can find a class in algorithms used in Ubuntu that covers graphs and how they can be used to process dependencies, for example (just in case that may be useful to you). The class begins at 17:00 UTC and is taught by tomek204.

share|improve this answer
Thank you for your reply, I will check those files out, and the IRC log is very helpful, it might be exactly what I am looking for. I will also study those listed files and using fgrep is a nice idea, specially with the awesomely commented code. –  mihirk Aug 12 '12 at 7:10

Your Answer


