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.

When I add a ppa and I want to install some of its content is quite annoying to re-update all my apt list using apt-get update

Is it instead possible to only sync the content of a given repository?

share|improve this question

5 Answers 5

up vote 32 down vote accepted

yes, apt-get can do that, and can do it in a nice way.

  1. Append following to ~/.bash_funcs

    update-repo() {
        for source in "$@"; do
            sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/${source}" \
            -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"    
        done
    }
    
  2. Append following to ~/.bashrc

    if [ -f $HOME/.bash_funcs ]; then
    .  $HOME/.bash_funcs
    fi
    
  3. Append following to ~/.bash_completion

    # Debian user-defined completion                             -*- shell-script -*-
    
    _ppa_lists(){
        local cur
        _init_completion || return
    
        COMPREPLY=( $( find /etc/apt/sources.list.d/ -name "*$cur*.list" \
    -exec basename {} \; 2> /dev/null ) )
        return 0
    } &&
    complete -F _ppa_lists update-repo
    
  4. Then source the files

    . ~/.bashrc
    . ~/.bash_completion
    
  5. Done and start to fire it

    update-repo <tab> <tab>
    

You can update a single ppa repository without having to update whole apt source, with implement of bash-completion.

share|improve this answer
    
Is it possible to use two sourcelist files in one apt-get update run? –  krlmlr Sep 17 '13 at 11:01
1  
+1 For Reminding me I know nothing about bash. –  Behrooz Sep 21 '13 at 16:21
    
In Ubuntu, ~/.bash_completion resides in /etc/.bash_completion which points to /usr/share/bash-completion/bash_completion and ~/.bash_funcs resides in /usr/share/bash-completion/completions/function. –  WitchCraft Nov 29 '13 at 17:06
4  
You should package this. –  PyRulez Apr 24 at 19:44
1  
Are you sure the autocompletion script is working? –  qed Jun 5 at 15:33

If the repository is configured in a specific file in the directory /etc/apt/sources.list.d/, say myrepo.list, you can update that single repository with the command:

sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/myrepo.list" \
    -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"

Nevertheless this is not very convenient.
This can be simplified defining a bash function

update_repo() {
    sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/$1.list" \
        -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
}

so that you can simply run

update_repo myrepo
share|improve this answer
    
I've checked this again, but it doesn't work if then you want to install a package that has some unresolved dependency on another repository (also in the main archive) –  Treviño Nov 13 '11 at 19:25

No, you need to update the entire database in order to ensure that you don't get into problems. Packages can depend on packages in other archives, so you really need to know the status of all archives. However, if no changes have been made to the archive since you last updated it, then it'll know that and it won't update it again.

share|improve this answer
    
we already have the database, we can check the dependency in existing database(re update will not change packages information, if packages in server does not change ). Why should we need to recheck the web server which we had already checked a couple of hours ago? There should be an option. –  shantanu Apr 10 '12 at 18:08
    
Web caching prevents double checks. You do not have the database if your copy of it is obsolete. Because though you do have a list of packages, those packages are no longer available, so you can't install them… That's what it's checking to see. The database is either obsolete or current. If it is obsolete, then that's all you know. You can't know what about it is current. Hence it is updated. If it is current, it moves on to the next repo. Yes, there are improvements to be made. Apt is not perfect. It was designed in different times, for different purposes. Are you volunteering? :) –  Jo-Erlend Schinstad Apr 10 '12 at 23:26
    
Web caching is good, but to update a single source list is obviously faster then 300 sources lists. The problem is, I do have 300 sources lists and I have to move some of them between a "tmpdir" each time before sudo apt-get update. –  Xiè Jìléi Nov 20 '12 at 3:07

Y PPA Manager comes with a command line tool called "update-ppa" that lets you update a single PPA.

For example: "sudo update-ppa ppa:nilarimogard/webupd8"

Also, when adding a PPA through Y PPA Manager, the PPA source is automatically updated (only for that PPA). In a future version, there's going to be a GUI to manually update single PPAs as well.

More information about Y PPA Manager, HERE.

share|improve this answer
    
sudo add-apt-repository ppa:webupd8team/y-ppa-manager then sudo apt-get update and finally sudo apt-get install y-ppa-manager –  mchid Nov 8 at 5:16

I had this problem also and found no program or way to do this as flexibly as I wanted. So I wrote a program using libapt's python binding. It ended up being very similar to enzotib's solution but allowing for arbitrary files and specifying repository lines on the command line.

See my blog post at: http://archimedesden.wordpress.com/2012/08/06/updating-selected-debianubuntu-repositories/

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.