7

How can I search through the source code used in Ubuntu?

There is a notification message that I'd like to modify to include more data, but it's not obvious which package it's a part of. But it includes a pretty specific string that would be easy to search on. I know there are a large number of projects included in ubuntu, but I'm hoping there's a good way to find the source when it's not apparent what program is responsible.

  • what notification message? – Rinzwind Feb 16 '12 at 15:31
  • What specifically are you trying to add? What notification message to what part of the OS? – Thomas Ward Feb 16 '12 at 16:30
  • 1
    The notification message is irrelevant. I'm not looking for this particular piece of source code. I'm looking for a general solution this problem in any case. The details are there just to make clear what type of situations I would want to do this in. – Rob Mosher Feb 16 '12 at 16:52
  • notify-send doesn't work for you ? – daisy Jun 10 '12 at 1:14
  • 1
    @warl0ck how would I use notify-send in this case? It seems it creates a notification message, rather than tracking down the source of a message. – Rob Mosher Jun 11 '12 at 15:37
5

If it's that specific, Google should be able to help you -- it has indexed tons of publicly available source code. I'd be very surprised if it didn't find something.

Failing that (or any other sort of web search), strings is a pretty handy little application. It reads all the strings out of a file, even if it's binary. I've been hacking around and you can use this to find a phrase anywhere on your computer. This version is looking for "bad" in /usr/bin

find /usr/bin -exec bash -c 'if [[ $(strings {} | grep -i bad) ]]; then echo "{}"; fi' \;

That's obviously a pretty hardcore way of doing things. But wait, there's more. You can find the package for each result as you go:

find /usr/bin -exec bash -c 'if [[ $(strings {} | grep -i bad) ]]; then dpkg -S "{}"; fi' \;

Now that's what I call awesome. Here's it in action, looking for "No such device"

oli@bert:/var/log$ find /usr/bin -exec bash -c 'if [[ $(strings {} | grep -i "No such device") ]]; then dpkg -S "{}"; fi' \;
handbrake-gtk: /usr/bin/ghb
usbutils: /usr/bin/usbhid-dump
3

There's an Ubuntu Code Search website that lets you search the source code of all packages in the Ubuntu repositories: http://ubuntu-codesearch.surgut.co.uk/

The above site appears to have been down for a while now. I'll try to get in contact with the maintainer.

Edit: I spoke to the maintainer, and this project isn't much of a priority at the moment. I'd recommend using the Debian Code Search instead, as we share a lot of packages/code with them: https://codesearch.debian.net/

0

The answer I know you've been dreading:

Download all the source packages and search them locally. It's about 40 GB, gzipped. I'd start by setting up apt-mirror with only deb-src entries.

0

I know am late but still , the package name is libnotify and the source code for it is here http://libnotify.sourcearchive.com/documentation/0.4.4/notify-send_8c-source.html

-1

Ubuntu uses the Debian Linux source code. But, you have to know that linux is a kernel (http://www.kernel.org/), and a distribution is the software (http://www.gnu.org/) bundled with it. You can get the Ubuntu Source repository from archive.ubuntu.com. You can also refer to https://code.launchpad.net/ubuntu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.