Apt

apt-get : 大小不匹配

  • December 16, 2015

我創建了一個私人 deb 儲存庫來傳播一個軟體,它更新到 600 台 Ubuntu 上網本。每次連接網路時,我的腳本都會嘗試進行 apt-get 更新。

但有時(事實上經常),我有這個:

Failed to fetch https://myserver/ubuntu/dists/maverick/main/binary-i386/voosicomat.deb  **Size mismatch**

伺服器是 2.2 Apache,僅 HTTPS。它的日誌沒有錯誤。

這是腳本:

apt-get update
apt-get dist-upgrade --force-yes --yes

這是 apt-get 的完整輸出

Ign https://myserver maverick Release.gpg
Ign https://myserver/ubuntu/ maverick/main Translation-en
Ign https://myserver maverick Release
Ign https://myserver maverick/main i386 Packages/DiffIndex
Ign https://myserver maverick/main i386 Packages
Ign https://myserver maverick/main i386 Packages
Hit https://myserver maverick/main i386 Packages
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be upgraded:
 majdb utilitaires voosicomat
3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 6207kB/6273kB of archives.
After this operation, 0B of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
 utilitaires voosicomat majdb
Get:1 https://myserver/ubuntu/ maverick/main voosicomat all 2.0.1 [4755kB]
Get:2 https://myserver/ubuntu/ maverick/main majdb all 1.0.17 [1452kB]
Failed to fetch https://myserver/ubuntu/dists/maverick/main/binary-i386/voosicomat.deb  Size mismatch
Fetched 7091kB in 21s (324kB/s)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

您的問題可能是回購錯誤。如果索引沒有在 repo 上更新,那麼你會得到(不是很有幫助的)Size mismatch錯誤。

一個可能的解決方法是通過以下方式更新您的儲存庫

  1. 刪除問題包
  2. 將包複製回儲存庫
  3. 執行儲存庫更新腳本sudo /usr/local/deb/update

您還可以編輯您的 apt sources.list 以刪除除本地儲存庫之外的所有儲存庫。

以上答案都不適合我。原來問題與一些代理和 HTTP/1.1 管道有關

apt-get -o Debug::Acquire::http=true update

從 2012 年開始顯示一些瘋狂的 Last-Modified Headers… 我們也遇到了問題,下載的包的內容與我們預期的不同,這很奇怪

解決方案是禁用 apt 的 http 流水線

  1. 創建文件/etc/apt/apt.conf.d/00httppipeline

  2. 複製粘貼Acquire::http::Pipeline-Depth "0";

3)刪除apt記憶體rm -rf /var/cache/apt/*

之後,大小不匹配或雜湊大小不匹配錯誤消失了,我可以升級我的包

引用自:https://serverfault.com/questions/282612