如何Packages.gz創建dpkg-scanpackages?

如何Packages.gz創建dpkg-scanpackages?

我目前正在尝试离线安装软件(学习问题)并希望根据使用离线存储库回答。

我遵循以下步骤:

  1. 把所有 deb 放进去/var/my-local-repo
  2. sudo bash -c 'dpkg-scanpackages /var/my-local-repo /dev/null > /var/my-local-repo/Packages'(注意:dpkg-dev已经安装才能执行此操作)
  3. echo "deb file:/var/my-local-repo ./" > /etc/apt/sources.list.d/my-local.list通过并设置存储库为 rootsudo apt-get update

但是当我尝试安装包时,显示以下错误:

下面是安装时终端的示例输出synaptic

$ sudo apt-get install synaptic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  docbook-xml libcairo-perl libept1.4.12 libglib-perl libgtk2-perl
  libpango-perl librarian0 rarian-compat sgml-data
Suggested packages:
  docbook docbook-dsssl docbook-xsl docbook-defguide libfont-freetype-perl
  libgtk2-perl-doc perlsgml w3-recs opensp libxml2-utils dwww menu deborphan
  tasksel
The following NEW packages will be installed:
  docbook-xml libcairo-perl libept1.4.12 libglib-perl libgtk2-perl
  libpango-perl librarian0 rarian-compat sgml-data synaptic
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3,437 kB of archives.
After this operation, 17.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
WARNING: The following packages cannot be authenticated!
  libept1.4.12 sgml-data docbook-xml libcairo-perl libglib-perl libpango-perl
  libgtk2-perl synaptic librarian0 rarian-compat
Install these packages without verification? [y/N] Y
Err file:/var/my-local-repo/ ./ libept1.4.12 1.0.12
  File not found
Err file:/var/my-local-repo/ ./ sgml-data 2.0.9-1
  File not found
Err file:/var/my-local-repo/ ./ docbook-xml 4.5-7.2
  File not found
Err file:/var/my-local-repo/ ./ libcairo-perl 1.104-1
  File not found
Err file:/var/my-local-repo/ ./ libglib-perl 3:1.304-1
  File not found
Err file:/var/my-local-repo/ ./ libpango-perl 1.224-2
  File not found
Err file:/var/my-local-repo/ ./ libgtk2-perl 2:1.249-2
  File not found
Err file:/var/my-local-repo/ ./ synaptic 0.81.1
  File not found
Err file:/var/my-local-repo/ ./ librarian0 0.8.1-5ubuntu1
  File not found
Err file:/var/my-local-repo/ ./ rarian-compat 0.8.1-5ubuntu1
  File not found
E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/libept1.4.12_1.0.12_i386.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/sgml-data_2.0.9-1_all.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/docbook-xml_4.5-7.2_all.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/libcairo-perl_1.104-1_i386.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/libglib-perl_3%3a1.304-1_i386.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/libpango-perl_1.224-2_i386.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/libgtk2-perl_2%3a1.249-2_i386.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/synaptic_0.81.1_i386.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/librarian0_0.8.1-5ubuntu1_i386.deb  File not found

E: Failed to fetch file:/var/my-local-repo//var/my-local-repo/rarian-compat_0.8.1-5ubuntu1_i386.deb  File not found

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

在这里我们可以看到apt 尝试从中获取 debs,/var/my-local-repo//var/my-local-repo/而不是var/my-local-repo/

如果我将所有 deb 移入/var/my-local-repo/var/my-local-repo/(通过创建子目录),那么 apt 就可以正常工作并且包也安装了! 并且突触工作正常。

所以,我的问题是为什么 Apt 从错误的位置获取 deb 或/以及需要进行哪些更正echo "deb file:/var/my-local-repo ./"

答案1

一到两天后我自己找到了解决方案/更正,需要的更正如下:

如何Packages.gz創建dpkg-scanpackages

方法 1:-

如果Packages.gz文件是通过以下命令创建的:

dpkg-scanpackages /var/my-local-repo | gzip > Packages.gz

然后它有所有的 deb 位置信息,如下所示:

文件名:/var/my-loca-repo/synaptic_0.81.1_i386.deb

方法 2(推荐):-

如果Packages.gz文件是通过以下命令创建的:(
换句话说,在切换到包含所有 deb 的目录之后)

dpkg-scanpackages . | gzip > ./Packages.gz

然后它有所有的 deb 位置信息,如下所示:

文件名:./synaptic_0.81.1_i386.deb


现在,如果Packages.gz通过 Way-1 创建,则存储库 .list 中需要更正的内容为:

deb file:/// var/my-local-repo/或者deb file:// /var/my-local-repo/

但建议Packages.gz通过方式 2 创建,这样就不需要进行任何更正,并且 .list 中的正确存储库是:

deb file:///var/my-local-repo/ ./或者deb file:/var/my-local-repo/ ./


之前我Packages.gz通过方法 1 创建了存储库,并为第二种方法设置了存储库,这就是为什么apt尝试从不需要的目录中获取 debs。

但是现在我明白了原因,并且使用了第二种创建方式Packages.gzdpkg-scanpackages最终命令是:

用于生成Packages.gz

dpkg-scanpackages . | gzip > ./Packages.gz

对于设置存储库:

sudo su
echo "deb file:/var/my-local-repo ./" > /etc/apt/sources.list.d/my-local.list
sudo apt-get update

然后包安装成功如下:

$ sudo apt-get install synaptic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  docbook-xml libcairo-perl libept1.4.12 libglib-perl libgtk2-perl
  libpango-perl librarian0 rarian-compat sgml-data
Suggested packages:
  docbook docbook-dsssl docbook-xsl docbook-defguide libfont-freetype-perl
  libgtk2-perl-doc perlsgml w3-recs opensp libxml2-utils dwww menu deborphan
  tasksel
The following NEW packages will be installed:
  docbook-xml libcairo-perl libept1.4.12 libglib-perl libgtk2-perl
  libpango-perl librarian0 rarian-compat sgml-data synaptic
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3,437 kB of archives.
After this operation, 17.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
WARNING: The following packages cannot be authenticated!
  libept1.4.12 sgml-data docbook-xml libcairo-perl libglib-perl libpango-perl
  libgtk2-perl synaptic librarian0 rarian-compat
Install these packages without verification? [y/N] Y
Selecting previously unselected package libept1.4.12:i386.
(Reading database ... 174777 files and directories currently installed.)
Preparing to unpack .../libept1.4.12_1.0.12_i386.deb ...
Unpacking libept1.4.12:i386 (1.0.12) ...
Selecting previously unselected package sgml-data.
Preparing to unpack .../sgml-data_2.0.9-1_all.deb ...
Unpacking sgml-data (2.0.9-1) ...
Selecting previously unselected package docbook-xml.
Preparing to unpack .../docbook-xml_4.5-7.2_all.deb ...
Unpacking docbook-xml (4.5-7.2) ...
Selecting previously unselected package libcairo-perl.
Preparing to unpack .../libcairo-perl_1.104-1_i386.deb ...
Unpacking libcairo-perl (1.104-1) ...
Selecting previously unselected package libglib-perl.
Preparing to unpack .../libglib-perl_3%3a1.304-1_i386.deb ...
Unpacking libglib-perl (3:1.304-1) ...
Selecting previously unselected package libpango-perl.
Preparing to unpack .../libpango-perl_1.224-2_i386.deb ...
Unpacking libpango-perl (1.224-2) ...
Selecting previously unselected package libgtk2-perl.
Preparing to unpack .../libgtk2-perl_2%3a1.249-2_i386.deb ...
Unpacking libgtk2-perl (2:1.249-2) ...
Selecting previously unselected package synaptic.
Preparing to unpack .../synaptic_0.81.1_i386.deb ...
Unpacking synaptic (0.81.1) ...
Selecting previously unselected package librarian0.
Preparing to unpack .../librarian0_0.8.1-5ubuntu1_i386.deb ...
Unpacking librarian0 (0.8.1-5ubuntu1) ...
Selecting previously unselected package rarian-compat.
Preparing to unpack .../rarian-compat_0.8.1-5ubuntu1_i386.deb ...
Unpacking rarian-compat (0.8.1-5ubuntu1) ...
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...
Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.54ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.13-1) ...
Processing triggers for doc-base (0.10.5) ...
Scrollkeeper was installed, forcing re-registration of all documents.
Unregistering 33 doc-base files, re-registering 33 doc-base files...
Registering documents with scrollkeeper...
Setting up libept1.4.12:i386 (1.0.12) ...
Setting up sgml-data (2.0.9-1) ...
Setting up libcairo-perl (1.104-1) ...
Setting up libglib-perl (3:1.304-1) ...
Setting up libpango-perl (1.224-2) ...
Setting up libgtk2-perl (2:1.249-2) ...
Setting up synaptic (0.81.1) ...
Setting up librarian0 (0.8.1-5ubuntu1) ...
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...
Setting up docbook-xml (4.5-7.2) ...
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...
Setting up rarian-compat (0.8.1-5ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...

相关内容