When I first noticed Dave Jones' post on Fedora master branch statistics, I thought it would be really cool to have an online query interface to this data (132GB, 2B lines, 11K packages).
[Update: Jul 2013. I see the debian equivalent is now available at codesearch.debian.net.]

Then I noticed searchco.de, which provided a functional and fast code searching interface to various online repos.

So I suggested to the searchco.de creator Benjamin Boyter, that the Fedora source would be a very useful and cohesive source base to add, and be to able to filter on. Luckily he agreed and has put in the work to make this happen.

Search syntax

Here are a few example queries you can perform on the Fedora source code. Notice how url:fedora is used to restrict the search to Fedora git. You can further filter to specific packages using the repo: keyword.

Preparing the source

Since searchco.de is currently debian based, we worked through a scheme to index the Fedora code. You could prepare the source for a particular Fedora release using Debian's rpm tools like:
wget $base/$rel/Fedora/source/iso/Fedora-$rel-source-DVD.iso
mkdir loop
sudo mount Fedora-$rel-source-DVD.iso loop
(cd loop
 find -name "*.src.rpm" |
 while read srpm; do
   name=$(rpm -qp $srpm --qf="%{name}")
   rpm -i $srpm
   rpmbuild -bp ~/rpmbuild/SPECS/$name.spec
umount loop
When going from git though, you'd need to run fedpkg prep to prepare the source. Benjamin used a Fedora 17 vM for this, that wrote to shared storage accessible from his Debian system. The fedpkg prep script was something like the following that Dave Jones uses (which can be run subsequently to update the source archive):
while read pkg; do
  echo -n "Package: $pkg : "

  if [ -d $pkg ]; then
    echo Updating.
    pushd $pkg
    fedpkg clean
    fedpkg pull
    echo Checkout.
    fedpkg clone -a $pkg

  pushd $pkg
  fedpkg prep < /dev/null
  chmod -R +r .

done < pkgs.list
Unfortunately some %prep scripts require BuildRequires installed. That could be done automatically by mock, with something like the following untested script:
find -name "*.src.rpm" |
while read srpm; do
  mock --init
  mock --installdeps  $srpm
  mock --copyin $srpm /srpm
  mock --shell /usr/bin/rpmbuild -bp /srpm
© Nov 30 2012