apt-get 尝试获取奇怪的 URL

apt-get 尝试获取奇怪的 URL

注意:我隐藏了超链接,因为我的声誉不足以在问题中包含如此多的链接。当您看到“ht tp:”时,请理解它实际上是“http:”

我认为这个问题与其他可能重复的问题不同。就我而言,我有自己的 Debian 存储库,托管我自己的 Debian 软件包,并使用 apt-get 将它们拉到客户端。

背景:这都是新问题。这不是以前能用然后坏掉的东西。这是我正在努力解决的问题。我相信这个问题是由我以某种方式错误地构建存储库引起的。

当我调用 apt-get update 时,一切似乎都很好。这些是相关行,显示 apt 已使用我的存储库 (10.1.20.65) 进行更新

$ sudo apt-get update
Get:4 ht tp://10.1.20.65/debian/ota xenial-testing InRelease [3,114 B]
Get:5 ht tp://10.1.20.65/debian/ota xenial-testing/main amd64 Packages [559 B] 

当我尝试安装示例应用程序时,问题出现了:

sudo apt-get install sample
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  sample
0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded.
Need to get 4,304 B of archives.
After this operation, 17.4 kB of additional disk space will be used.
Err:1 ht tp://10.1.20.65/debian/ota xenial-testing/main i386 sample amd64 1.0-1
  400  Bad Request
Err:1 ht tp://10.1.20.65/debian/ota xenial-testing/main i386 sample amd64 1.0-1
  400  Bad Request
E: Failed to fetch ht tp://10.1.20.65/debian/ota//var/www/html/debian/ota/pool/main/sample/sample_1.0-1_amd64.deb  400  Bad Request

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

一个明显的问题是 URL。我知道它是错的。

ht tp://10.1.20.65/debian/ota//var/www/html/debian/ota/pool/main/sample/sample_1.0-1_amd64.deb

它看起来应该是这样的:

ht tp://10.1.20.65/debian/ota/pool/main/sample/sample_1.0-1_amd64.deb

但我不知道它是如何生成的。这是我的存储库中的文件层次结构

user@machine:/var/www/html/debian/ota$ ll -R

.:
drwxrwsr-x 3 user www-data 4096 Jan 26 09:51 dists/
-rw-r--r-- 1 root www-data 1609 Jan 26 10:47 keyFile
drwxrwsr-x 3 user www-data 4096 Jan 26 09:27 pool/

./dists:
drwxrwsr-x 3 user www-data 4096 Jan 26 11:31 xenial-testing/

./dists/xenial-testing:
-rw-rw-r-- 1 user www-data 3114 Jan 26 11:31 InRelease
drwxrwsr-x 4 user www-data 4096 Jan 26 11:14 main/
-rw-rw-r-- 1 user www-data 2246 Jan 26 11:31 Release
-rw-rw-r-- 1 user www-data  819 Jan 26 11:31 Release.gpg

./dists/xenial-testing/main:
drwxrwsr-x 2 user www-data 4096 Jan 26 11:30 binary-amd64/
drwxrwsr-x 2 user www-data 4096 Jan 26 11:14 binary-i386/

./dists/xenial-testing/main/binary-amd64:
-rw-rw-r-- 1 user www-data  776 Jan 26 11:30 Packages
-rw-rw-r-- 1 user www-data  559 Jan 26 11:30 Packages.gz

./dists/xenial-testing/main/binary-i386:
-rw-rw-r-- 1 user www-data  789 Jan 26 11:14 Packages
-rw-rw-r-- 1 user www-data  572 Jan 26 11:14 Packages.gz

./pool:
drwxrwsr-x 3 user www-data 4096 Jan 26 11:06 main/

./pool/main:
drwxrwsr-x 2 user www-data 4096 Jan 26 09:22 sample/

./pool/main/sample:
-rw-r--r-- 1 user www-data 4650 Jan 26 09:18 sample_1.0-1_amd64.build
-rw-rw-r-- 1 user www-data 1430 Jan 26 09:18 sample_1.0-1_amd64.changes
-rw-r--r-- 1 user www-data 4304 Jan 26 09:18 sample_1.0-1_amd64.deb
-rw-r--r-- 1 user www-data 1296 Jan 26 09:18 sample_1.0-1.debian.tar.xz
-rw-rw-r-- 1 user www-data  809 Jan 26 09:18 sample_1.0-1.dsc
-rw-rw-r-- 1 user www-data  672 Jan 26 09:22 sample_1.0.orig.tar.xz

我的客户是16.04

user@machine:/var/www/html/debian/ota$ dpkg --print-architecture
amd64
user@machine:/var/www/html/debian/ota$ dpkg --print-foreign-architectures
i386

ota/pool/main/binary-amd64/Packages 文件包含以下内容:

Package: sample
Priority: optional
Section: misc
Installed-Size: 17
Maintainer: User Name (Comment) <[email protected]>
Architecture: amd64
Version: 1.0-1
Depends: libc6 (>= 2.2.5)
Filename: /var/www/html/debian/ota/pool/main/sample/sample_1.0-1_amd64.deb
Size: 4304
MD5sum: f9438161fbbbbcdcc121bde6117eec62
SHA1: 0fcf04736a638bea6c2737c06a2cad1452db4fbc
SHA256: 1afa50b3147d30065af90ba8cff49a3d18028baadf2a5502c691592fecad37bd
SHA512: 34a1c4b2f404aeb8ab00c7a032d59ac83ca188c69a92778cb394dd7fb1bfb85990cb43b44533d90ceb77bf79b76ac8ca8fe247e5cdb72ebd96318264c9cdb69d
Description: A sample program
 This Debian binary package was auto-generated by the
 debmake(1) command provided by the debmake package.
Multi-Arch: foreign
Homepage: <insert the upstream URL, if relevant>

ota/dists/xenial-testing/Release 文件包含以下内容:

Date: Thu, 26 Jan 2017 16:31:30 UTC
MD5Sum:
 d41d8cd98f00b204e9800998ecf8427e                0 Release
 a89ecbbf9f4aea63fa014bf572577e16              776 main/binary-amd64/Packages
 53e475fd10fe0944b2eb25e53feef886              559 main/binary-amd64/Packages.gz
 7bcf648b5326f5939e384d7fc1c67bf4              789 main/binary-i386/Packages
 ef22faf6ed3912ac493422bc9c31f1dd              572 main/binary-i386/Packages.gz
SHA1:
 da39a3ee5e6b4b0d3255bfef95601890afd80709                0 Release
 5f63449fd9ff95190d518d4841352f8971a9b9e7              776 main/binary-amd64/Packages
 35ce11e83154c2c2259b5894f913384192d5baee              559 main/binary-amd64/Packages.gz
 4ed047da6b795d2a6cd1231cec50820bf74dfdd9              789 main/binary-i386/Packages
 ac8c6c27279477131e008c230332f816c67f0068              572 main/binary-i386/Packages.gz
SHA256:
 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855                0 Release
 ad638125ee8ca88f9239da6248e2c3143cc62171d18ff9e51b47d8f1fba091c4              776 main/binary-amd64/Packages
 b82270e96b9bd9c0c2426dee989274e606ee3fbbeda6cdc9a59227c438c1a373              559 main/binary-amd64/Packages.gz
 aeb658d8aa0222005f1aad5c83ced0efe8343114710c62f07affe7a6c9775be7              789 main/binary-i386/Packages
 8c715600c2401e97f391a9c8f40f6e17d257ee76a1b4b2bd9653d89fc2dd765e              572 main/binary-i386/Packages.gz
SHA512:
 cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e                0 Release
 c19e015cefb344dc7cf1344700e43577bd7854bb60e1f3a778feff4b7c076dde43ae2e2a7cb4a3fbefaf59268df9c8a7d25d08d9162413418ffdf541d8b21404              776 main/binary-amd64/Packages
 1a6630388293428330416bf15d643aaf540792c449f2a60217cff32641b6d11a752645ee8ef20d3563c52575fb3653a6693621320c672178d538f3280bd1d420              559 main/binary-amd64/Packages.gz
 6b0766e30a366f3ca065f56979c31f129dc0d406a8d27e8147e5029e04fce0ad891256cd4da70dbba92b411e25e6fc7ab1c5192e6ad7848dff4530b29eb5236d              789 main/binary-i386/Packages
 926dfa28405aef42c9f9deae454376fa8b42a4db411aee03da8844bf361e96950022aeabe7f70a6264f8a2cf1a8bf9d166fedebf5bef3a2f8b9f4fc54834dba7              572 main/binary-i386/Packages.gz

问题:

apt 在哪里/如何获取那个“奇怪的” URL?

E: Failed to fetch ht tp://10.1.20.65/debian/ota//var/www/html/debian/ota/pool/main/sample/sample_1.0-1_amd64.deb  400  Bad Request

答案1

我找到解决办法了!

事实证明,套餐文件实际上被附加到档案根目录..我想这是由 apt-get 程序完成的。

我的档案根目录是这样的:

/var/www/html/debian/ota/

我的 Packages 文件中有这样一行:

Filename: /var/www/html/debian/ota/pool/main/sample/sample_1.0-1_amd64.deb

这些连接起来产生下载 DEB 的最终 URL:

/var/www/html/debian/ota//var/www/html/debian/ota/pool/main/sample/sample_1.0-1_amd64.deb

这种混淆是由错误的软件包文件。它不应包含绝对路径。

我的包文件中的正确路径应该是这样的:

Filename: pool/main/sample/sample_1.0-1_amd64.deb

以下是我修复的方法

之前我一直在调用apt-ftparchive 软件包 从我的二进制文件夹内:

/var/www/html/debian/ota/dists/xenial-testing/main/binary-amd64/$ apt-ftparchive packages /var/www/html/debian/ota/pool > Packages

(请注意,我必须使用绝对路径来引用水池我的 debs 的位置)

这不是构建 Packages 文件的正确文件夹。我在 Debian 的这段可爱的文字中找到了线索:

The 'packages' and 'sources' command should be run in the root of the
tree. BinaryPath should point to the base of the recursive search and 
override file should contain the override flags. Pathprefix is
appended to the filename fields if present. Example usage from the 
Debian archive:
   apt-ftparchive packages dists/potato/main/binary-i386/ > \
               dists/potato/main/binary-i386/Packages

一旦我开始以这种方式做事,我的 Packages 文件内部就开始有相对路径。

我的新命令行:

/var/www/html/debian/ota/$ apt-ftparchive packages pool/binary-amd64/ > dists/xenial-testing/main/binary-amd64/Packages

我的 Packages 文件现在包含以下行:

Filename: pool/main/sample/sample_1.0-1_amd64.deb

相关内容