Summary
How can I make apt-get prefer local repository packages instead of downloading again the same package version from official repositories? The local repository is signed and trusted. We've already tried apt preferences priority.
Original question was : "How to assign highest priority to local repository without using sources.list file"
I have setup a local repository with packages I downloaded. I use it to avoid downloading the same packages over the Internet, when I need to reinstall my Ubuntu. It is a basic repository, created with apt-ftparchive packages . > Packages
. I made this a trusted repository to avoid "unauthenticated repository" warning. (When you have a untrusted repository, apt
or synaptic
try to download the same packages over the Internet, 'cause it is trusted).
I have been using this local repository for at least 1 years. But I have to always put my local repository line at the top of the sources.list
file to use this. But this is annoying, since I must open a terminal and do some typing on it every time I reinstall Ubuntu, though there is a better tool software-properties-gtk
. I cannot use this tool since it place the source line at the end of `sources.list.
And the real problem is that, the apt
or synaptic
always download a package from the source which is mentioned earlier, without inspecting whether the packages are already available in the local repository. So, I have no choice but to place the local source at the top of sources.list
doing terminal (I actually don't hate terminal, but I need a solution) .
I have tried this method. But this does not help me.
My preference file is this in /etc/apt/preferences.d/local-pin-900
Package: *
Pin: release o=Local,n=ubuntu-local
Pin-Priority: 900
My release file is this
Origin: Local
Label: Local-Ubuntu
Description: Local Ubuntu Repository
Codename: ubuntu-local
MD5Sum:
ed43222856d18f389c637ac3d7dd6f85 1043412 Packages
d41d8cd98f00b204e9800998ecf8427e 0 Sources
When I enable the apt-preference, the apt-cache policy
correctly shows the preference, e.g. It shows the local repository has the highest priority.
But when I do this sudo apt-get install <package-name>
, apt
tries to download it from Internet. But when I place my local-repo at the top, it installs from local repository.
So, My question is -> 'Is it possible to force apt to use local repository when the package is available in local repository, without explicitly placing "the local source" at the top of my repository list (e.g sources.list file) ?'
Edit: output of apt-cache policy $package_name
is as follows
nautilus-wipe: Installed: (none) Candidate: 0.1.1-2 Version table: 0.1.1-2 0 500 http://archive.ubuntu.com/ubuntu/ precise/universe i386 Packages 900 file:/media/Main/Linux-Software/Ubuntu/Precise/ Packages
It is showing that my local repository has higher preference, though it is not the one which comes first in sources.list
file.
Here is the output of apt-get install nautilus-wipe
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: nautilus-wipe 0 upgraded, 1 newly installed, 0 to remove and 131 not upgraded. Need to get 30.7 kB of archives. After this operation, 150 kB of additional disk space will be used. 'http://archive.ubuntu.com/ubuntu/pool/universe/n/nautilus-wipe/nautilus-wipe_0.1.1-2_i386.deb' nautilus-wipe_0.1.1-2_i386.deb 30730 MD5Sum:7d497b8dfcefe1c0b51a45f3b0466994
It is still trying to get the file from Internet, though I think it should be happy with the local one.
Result of using "" or localhost as mediageek suggested
Using localhost has no effect. but "" has but was not different than my method
Package: *
Pin: origin ""
Pin-Priority: 1001
I have used them before posting the question. But again i tried this (for surity). The same result. apt-cache policy
showing that my local repository has indeed the highest priority. but when i tried to install it is saying "Need to get XXX/XXX KB of archive".