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.]
[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.- Search for 'mbsalign' in Fedora
mbsalign url:fedora - Search for 'mbsalign' in coreutils in Fedora
mbsalign url:fedora repo:coreutils - Search for 'mbsalign' in coreutils C files in Fedora mbsalign url:fedora repo:coreutils lang:c
- Regular expression search for 'install.*--context' in Fedora
/install.*--context/ url:fedora
Note regular expression searching currently seems to ignore the url: filter, but will be fixed soon
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:
rel=17
base=http://dl.fedoraproject.org/pub/fedora/linux/releases
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
done
)
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
popd
else
echo Checkout.
fedpkg clone -a $pkg
fi
pushd $pkg
fedpkg prep < /dev/null
chmod -R +r .
popd
echo
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 done
© Nov 30 2012