It’s possible; the difficulty level will depend on how strict you want to be.
Packages in Ubuntu (as in Debian and all Debian derivatives) are fully described by the files in the debian
directory in the corresponding source package. To rebuild a package from source, run
sudo apt-get build-dep <package>
apt-get -b source <package>
(replacing <package>
with the name of the package you want to rebuild). You’ll find the compile options in debian/rules
, based on defaults provided by debhelper
and dpkg-buildflags
(so debian/rules
might not contain much at all).
If you want to rebuild from scratch, starting with a minimal system and working your way up without every installing a binary package, things get more complex. See How to update all Debian packages from source code? for the basics (and reasons why you probably don’t want to do this).
To understand multiarch, I don’t think there’s any need to rebuild Ubuntu. Start by reading the multiarch documentation; then if you need more you can look at the patches which implement multiarch in GCC (they all have “multiarch” in their name), at the support for multiarch in debhelper
, e.g. here for autoconf
, and at the ld.so
configuration in glibc
.