Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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 W. 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 ? –  warl0ck 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 Answers 5

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/

share|improve this answer

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

share|improve this answer

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
share|improve this answer

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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