[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: `apt install ./<deb>` chooses http over local file



On Fri, Jun 30, 2023 at 09:02:36AM -0700, Ross Vandegrift wrote:
> Hi folks,
> 
> Imagine I want to install a local package.  I do : `apt install ./$deb`.
> This works fine.  But if $deb also exists in apt's sources, and is the
> same version, apt always chooses to download it.  I can reproduce in a
> clean env after `apt update`, so I don't think it's a local config
> issue.  Sample at the bottom.

I think the problem stems from us appending the .deb as ephemeral
sources to the cache, and the .deb is deduplicated with matching
packages as usual, and then the first sources.list entry wins.

There's two ways around that issue: Not dedup the .deb passed
in so that local deb != remote deb, or change the insertion
code to prepend the ephemeral sources instead (it's a singly
linked list IIRC, so it shouldn't be too hard).

I may have the order wrong fwiw, I don't remember, it may be
that the order in the cache is reversed so last source comes
first.

> 
> The internet says "just use dpkg -i" - fair enough.  But I was hoping to
> find an explanation of what's going on.  I have some uneducated guesses,
> but the internet has enough of those :).
> 
> Thanks in advance,
> Ross
> 
> (please cc me, I'm not subscribed to this list)
> 
> 
> $ docker run -it --rm -v $PWD:/root/deb debian:bookworm
> root@b451e94c3f56:/# apt update -qq
> All packages are up to date.
> root@b451e94c3f56:/# apt install -oDebug::pkgPolicy=1 /root/deb/zstd_1.5.4+dfsg2-5_amd64.deb
> Reading package lists... Done
> Prio of /root/deb/zstd_1.5.4+dfsg2-5_amd64.deb 500
> Prio of /var/lib/dpkg/status 100
> Prio of /var/lib/apt/lists/deb.debian.org_debian-security_dists_bookworm-security_main_binary-amd64_Packages.lz4 500
> Prio of /var/lib/apt/lists/deb.debian.org_debian_dists_bookworm_main_binary-amd64_Packages.lz4 500
> Building dependency tree... Done
> Reading state information... Done
> Note, selecting 'zstd' instead of '/root/deb/zstd_1.5.4+dfsg2-5_amd64.deb'
> The following NEW packages will be installed:
>   zstd
> 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
> Need to get 701 kB of archives.
> After this operation, 2152 kB of additional disk space will be used.
> Get:1 http://deb.debian.org/debian bookworm/main amd64 zstd amd64 1.5.4+dfsg2-5 [701 kB]
> Fetched 701 kB in 0s (5209 kB/s)
> debconf: delaying package configuration, since apt-utils is not installed
> Selecting previously unselected package zstd.
> (Reading database ... 6098 files and directories currently installed.)
> Preparing to unpack .../zstd_1.5.4+dfsg2-5_amd64.deb ...
> Unpacking zstd (1.5.4+dfsg2-5) ...
> Setting up zstd (1.5.4+dfsg2-5) ...
> 

-- 
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer                              i speak de, en

Attachment: signature.asc
Description: PGP signature


Reply to: