I'm new to linux and my teacher asked me to learn about how to build Raspbian from the source code.

From what read in other questions, I need to download the Raspbian source code first. In some questions the link http://archive.raspbian.org/raspbian/pool/main/ and https://github.com/raspberrypi/linux appears to be the place where I can get the source code for the OS and kernel.

The thing is, I'm not sure of what to download.

I need the source code of the Raspbian OS and then try to build it as is for academic reason. And I'm quite sure I was asked to compile Raspbian OS, not Raspbian Kernel. I finished compiling Raspbian Kernel yesterday and today I was asked to build Raspbian OS itself.

After I managed to build the OS, I am required to create a module to make Raspberry work with a certain sensor device (currently undecided).

PS: I think this is building a linux distro without added customisation. Is it right?

  • 1
    Raspbian is a lot of code, you probably will do better with something like linux from scratch. Especially if you have never built a full OS from source before.
    – grochmal
    Commented Oct 10, 2016 at 8:28
  • Thank you for the suggestion. LFS will definitely good for me down the way. As for the Raspbian OS building it was an assignment. It required me to build Raspbian OS from source code without further modification. I've read on the building steps, but I need enlightenment on how & what to get from the repository. Commented Oct 10, 2016 at 8:42
  • 2
    Are you sure this is what you were asked, exactly? Raspbian itself doesn't have "source code"... It has a kernel and loads of packages, and compiling it all into a distribution image isn't a simple assignment... Commented Oct 10, 2016 at 8:43
  • 1
    That are my thoughts exactly. I'm confident than an assignment would be something like: compile the raspbian kernel, not the whole OS.
    – grochmal
    Commented Oct 10, 2016 at 8:46
  • Yes, I was asked to build the OS from it's source code. I'm sure of that. In addition I too was asked to share my experience building Raspbian to other students in my lab. Commented Oct 10, 2016 at 8:49

1 Answer 1


Raspbian itself contains 22,544 source packages in its main repository, with 67,417 files to download (as of 2016, Raspbian Jessie) if you want all the source code. Rebuilding all that isn't something I'd consider doing manually...

If you really want to download all the source code for Raspbian, you should start by downloading the source repository index, and process that to construct the download URLs. Something like the following script should get you started:

#!/usr/bin/awk -f

/^$/ {
    for (i = 0; i < nbfiles; i++) {
    print "http://archive.raspbian.org/raspbian/" directory "/" files[i]

/^Files: *$/ {
    infiles = 1
    nbfiles = 0

infiles == 1 && /^ / {
    files[nbfiles] = $3

infiles == 1 && /^[^ ]/ {
    infiles = 0

/^Directory: / {
    directory = $2
  • Thank you. I'll get into this later. I'm currently contacting my teacher to talk about suggestions from @grochmal and will definitely ask whether I really need to build the OS from source code or not. Whatever it will be, your answer and the others suggestions put my mind at ease for now. :) Commented Oct 10, 2016 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .