When I add a PPA and I want to install some of its content, it 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?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityyes, apt-get can do that, and can do it in a nice way.
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
}
Append following to ~/.bashrc
if [ -f $HOME/.bash_funcs ]; then
. $HOME/.bash_funcs
fi
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
Then source the files
. ~/.bashrc
. ~/.bash_completion
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.
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
sourceparts
should not be used. See github.com/Debian/apt/blob/master/apt-pkg/sourcelist.cc#L313 . I could be wrong though, couldn't find a proper doc explaining the '-'.
Apr 9, 2019 at 18:00
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.
sudo add-apt-repository ppa:webupd8team/y-ppa-manager
then sudo apt-get update
and finally sudo apt-get install y-ppa-manager
To update a specific repository, use -o
, e.g.:
apt-get update -o Dir::Etc::sourcelist=/path/to/repo.list
Here is a one-liner updating only recently added apt repository
find /etc/apt/sources.list.d -type f -name '*.list' -exec sudo apt-get update -o Dir::Etc::sourcelist="{}" ';'
It's much quicker than updating all repositories, especially during VM provisioning after adding new.
The -u
option was added in 15.10. From 15.10 to 17.10, you could use -u
to automatically update only the specific repo you are adding:
add-apt-repository -u my-ppa
The silly thing is that this option was not added to man
until 18.04 (it was documented in add-apt-repository --help
, however). But in 18.04, this functionality was removed! (Again, not in man
, but you can see in add-apt-repository --help
).
In 18.04, the update functionality was changed to always do a full apt-get update
after add-apt-repository
. The -u
option was effectively removed. It remains there for legacy syntax, but it is always set to options.update = False
. In 18.04, you do have the option of -n, --no-update
, which is like the old behavior. But it's all or nothing, you cannot update a single repo since 18.04.
One can also reduce the available choices to one single repository:
echo "deb http://archive.ubuntu.com/ubuntu/ focal universe" > /etc/apt/sources.list
apt-get update -y && apt-get install -y ncftp
This may be radical, but it saves time and traffic, when running apt-get
in a single-use container.
If you don't know what a single-use container is, please educate yourself before casting a vote...
because this is a correct and functional answer, which serves an actual purpose (saving time).
add-apt-repository -u
-u
on Ubuntu (15.x) Vivid as far as I can tell.add-apt-repository --help
. Please open a bug asking to fix the manpage.-u
functionality was removed since 18.04. See askubuntu.com/questions/65245/…