It's possible, but it's very difficult. If you really want to rebuild everything from source, you'll end up running into dependency loops which you will have to break. But if you want to persevere, instead of using apt-get build-dep
you should look inside each source package's debian/control
, and rebuild all the packages listed in Build-Depends
and Build-Depends-Indep
. Ideally you should also rebuild all the "essential" packages and all the packages which build-essential
depends upon (packages don't need to declare their dependencies on these).
Others have worked on this (and still are); you can read up on the on-going efforts to bootstrap Debian on the Debian wiki.
As goldilocks points out though this is rather a waste of time. In fact there are people in Debian working to make it completely pointless by ensuring that binary packages are reproducible, i.e. that you can get the same binary as is in the archive by rebuilding on your own machine, thus proving that the claimed source code is really what was used to build the binaries; as a result, unless you want to make changes to the source code or the build configuration, there would then be no point in rebuilding from source on your own computer. You can read up on this effort on the Debian wiki as well; over 80% of the archive is already reproducible.
If you want to do this as a learning exercise, then bdowning's suggestion is very good: take a look at Linux from scratch instead. You could also check out distributions which are more source-oriented (as in, compiling from source locally), such as Gentoo Linux.
You mean so they are exactly the same as the normal pre-compiled binaries
No, not necessarily. Just to make sure they are built from source rather than using per-compiled ones.