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 check dependency list for a deb package. I am running Ubuntu 11.10 and I have backed up all deb packages from var/cache/apt/archives. I want to format my pc and re-install selected applications only. Also how can I get the list of installed packages and dependencies.

share|improve this question
    
For your second question see askubuntu.com/questions/17823/… –  htorque Nov 19 '11 at 9:15

3 Answers 3

up vote 13 down vote accepted

In addition to the dpkg method, you can check the dependencies of packages in the repository:

apt-cache showpkg package-name
share|improve this answer

This will show you all the information about the package:

dpkg -I package.deb
share|improve this answer

Here is some sloppy, and probably not very encompassing post-processing you can do to dpkg -I output to get dependency items as a list:

Condensed for computers

# dpkg -I package.deb | python -c "import sys, re; t=re.split(r'\n(?= ?[\w]+:)|:', sys.stdin.read()); print '\n'.join([i.strip() for i in {key.strip(): value.strip() for key, value in zip(t[::2], t[1::2])}['Depends'].split(',')])"
#

Expanded for humans:

dpkg -I package.deb | python -c "
    import sys, re;
    # Split keys and values into pairs (zipped together later)
    t=re.split(
        r'\n(?= ?[\w]+:)|:', 
        sys.stdin.read()
    ); 
    # Newline separate each dependency
    print '\n'.join([
        # Trim each dependency value
        i.strip() for i in {
            # Build assoc array from package metadata
            key.strip(): value.strip() 
            for key, value in zip(t[::2], t[1::2])
        }['Depends'].split(',')
    ])
"
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.