--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: [apt] improve Dpkg::Chroot-Directory for installation of packages in chroot
- From: Kel Modderman <kel@otaku42.de>
- Date: Sun, 11 Apr 2010 01:09:23 +1000
- Message-id: <201004110109.24017.kel@otaku42.de>
Package: apt
Version: 0.7.25.3
Severity: wishlist
Tags: patch
Hi,
Here is a python program which bootstraps a sid system, then attempts to
install a package in the chroot:
---
#!/usr/bin/python
import apt.cache
import apt_pkg
import os
import subprocess
import sys
subprocess.call('debootstrap --variant=minbase sid /tmp/crap http://localhost:9999/debian/'.split())
apt_pkg.init()
apt_pkg.config.set('Dpkg::Chroot-Directory', '/tmp/crap')
cache = apt.cache.Cache(rootdir='/tmp/crap')
apt_pkg.Config.clear("DPkg::Pre-Install-Pkgs")
cache.update()
cache.open()
cache['hello'].mark_install()
cache.commit()
---
It fails, because after chroot('/tmp/crap') the later dpkg process gets given
a filename argument which begins with the pathname to chroot itself and is
not accessible:
---
Reading package lists... Done
Building dependency tree... Done
Building data structures... Done
Reading package lists... Done
Building dependency tree... Done
Building data structures... Done
Chrooting into /tmp/crap/
dpkg: error processing /tmp/crap/var/cache/apt/archives/hello_2.5-1_amd64.deb (--unpack):
cannot access archive: No such file or directory
Errors were encountered while processing:
/tmp/crap/var/cache/apt/archives/hello_2.5-1_amd64.deb
Traceback (most recent call last):
File "./test_apt.py", line 17, in <module>
cache.commit()
File "/usr/lib/python2.5/site-packages/apt/deprecation.py", line 98, in deprecated_function
return func(*args, **kwds)
File "/usr/lib/python2.5/site-packages/apt/cache.py", line 381, in commit
raise SystemError("installArchives() failed")
SystemError: installArchives() failed
---
The following patch adds some logic to check each File, when
DPkg::Chroot-Directory != '/', to see if it begins with the pathname
of the chroot. If it does, it returns a substring of File without the
chroot pathname. It is careful not to strip the leading / from any File.
---
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -124,6 +124,18 @@ bool pkgDPkgPM::Install(PkgIterator Pkg,
if (File.empty() == true || Pkg.end() == true)
return _error->Error("Internal Error, No file name for %s",Pkg.Name());
+ // If the filename string begins with DPkg::Chroot-Directory, return the
+ // substr that is within the chroot so dpkg can access it.
+ string chrootdir = _config->FindDir("DPkg::Chroot-Directory","/");
+ if (chrootdir.compare("/") != 0 && File.find(chrootdir) == 0)
+ {
+ size_t len = chrootdir.length();
+ if (chrootdir.at(len - 1) == '/')
+ len--;
+ List.push_back(Item(Item::Install,Pkg,File.substr(len)));
+ return true;
+ }
+
List.push_back(Item(Item::Install,Pkg,File));
return true;
}
---
Can you please consider applying it?
Thanks, Kel.
--- System information. ---
Architecture: amd64
Kernel: Linux 2.6.33-2.slh.3-sidux-amd64
Debian Release: squeeze/sid
500 unstable localhost
1 experimental localhost
--- Package information. ---
Depends (Version) | Installed
=======================================-+-=============
libc6 (>= 2.3.4) | 2.10.2-6
libgcc1 (>= 1:4.1.1) | 1:4.4.3-7
libstdc++6 (>= 4.4.0) | 4.4.3-7
debian-archive-keyring | 2009.01.31
Package's Recommends field is empty.
Suggests (Version) | Installed
=========================-+-===========
aptitude |
OR synaptic |
OR wajig |
dpkg-dev | 1.15.5.6
apt-doc |
bzip2 | 1.0.5-4
lzma | 4.43-14
python-apt | 0.7.94.2
--- End Message ---
--- Begin Message ---
Source: apt
Source-Version: 0.7.26~exp4
We believe that the bug you reported is fixed in the latest version of
apt, which is due to be installed in the Debian FTP archive:
apt-doc_0.7.26~exp4_all.deb
to main/a/apt/apt-doc_0.7.26~exp4_all.deb
apt-transport-https_0.7.26~exp4_i386.deb
to main/a/apt/apt-transport-https_0.7.26~exp4_i386.deb
apt-utils_0.7.26~exp4_i386.deb
to main/a/apt/apt-utils_0.7.26~exp4_i386.deb
apt_0.7.26~exp4.dsc
to main/a/apt/apt_0.7.26~exp4.dsc
apt_0.7.26~exp4.tar.gz
to main/a/apt/apt_0.7.26~exp4.tar.gz
apt_0.7.26~exp4_i386.deb
to main/a/apt/apt_0.7.26~exp4_i386.deb
libapt-pkg-dev_0.7.26~exp4_i386.deb
to main/a/apt/libapt-pkg-dev_0.7.26~exp4_i386.deb
libapt-pkg-doc_0.7.26~exp4_all.deb
to main/a/apt/libapt-pkg-doc_0.7.26~exp4_all.deb
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 577226@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Michael Vogt <mvo@debian.org> (supplier of updated apt package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Format: 1.8
Date: Thu, 06 May 2010 09:32:54 +0200
Source: apt
Binary: apt apt-doc libapt-pkg-dev libapt-pkg-doc apt-utils apt-transport-https
Architecture: source all i386
Version: 0.7.26~exp4
Distribution: experimental
Urgency: low
Maintainer: APT Development Team <deity@lists.debian.org>
Changed-By: Michael Vogt <mvo@debian.org>
Description:
apt - Advanced front-end for dpkg
apt-doc - Documentation for APT
apt-transport-https - APT https transport
apt-utils - APT utility programs
libapt-pkg-dev - Development files for APT's libapt-pkg and libapt-inst
libapt-pkg-doc - Documentation for APT development
Closes: 523920 525783 576420 577116 577117 577168 577226 577759 578267 578385 578657 578959
Changes:
apt (0.7.26~exp4) experimental; urgency=low
.
[ David Kalnischkies ]
* apt-pkg/depcache.cc:
- rewrite the pseudo package reinstaller to be more intelligent
in his package choices
* apt-pkg/packagemanager.cc:
- don't try to "unpack" pseudo packages twice
* apt-pkg/contrib/fileutl.cc:
- add a parent-guarded "mkdir -p" as CreateDirectory()
* apt-pkg/acquire.{cc,h}:
- add a delayed constructor with Setup() for success reporting
- check for and create directories in Setup if needed instead of
error out unfriendly in the Constructor (Closes: #523920, #525783)
- optional handle a lock file in Setup()
* apt-pkg/acquire-item.cc:
- Acquire::ForceHash to force method for expected hash
* cmdline/apt-get.cc:
- remove the lock file handling and let Acquire take care of it instead
- display MD5Sum in --print-uris if not forced to use another method
instead of displaying the strongest available (Closes: #576420)
- regex for package names executed on Grp- not PkgIterator
- show non-candidates as fallback for virtual packages (Closes: #578385)
- set also "all" to this version for pseudo packages in TryToChangeVer
* apt-pkg/deb/dpkgpm.cc:
- remove Chroot-Directory from files passed to install commands.
Thanks to Kel Modderman for report & patch! (Closes: #577226)
* ftparchive/writer.cc:
- remove 999 chars Files and Checksums rewrite limit (Closes: #577759)
* cmdline/apt-cache.cc:
- align Installed and Candidate Version in policy so they can be compared
easier, thanks Ralf Gesellensetter for the pointer! (Closes: #578657)
* doc/apt.ent:
- Add a note about APT_CONFIG in the -c description (Closes: #578267)
* doc/po/de.po:
- correct typos in german apt_preferences manpage, thanks Chris Leick!
* apt-pkg/sourcelist.cc:
- be less strict and accept [option=value] as well
* apt-pkg/contrib/configuration.cc:
- error out if #clear directive has no argument
* doc/files.sgml:
- sync documentation with status quo, regarding files/directories in
use, extended_states and uri schemes.
* doc/cache.sgml:
- drop the file in favor of inplace documentation with doxygen
* apt-pkg/pkgcache.h:
- enhance the Groups ABI by providing a ID as the other structs does
- check also the size of the Group struct then checking for the others
.
[ Jari Aalto ]
* cmdline/apt-get.cc:
- replace backticks with single quotes around fix-broken command
in the broken packages message. (Closes: #577168)
* dselect/install:
- modernize if-statements not to use 'x' (Closes: #577117)
- replace backticks with POSIX $() (Closes: #577116)
.
[ Michael Vogt ]
* [ Abi break ] apt-pkg/acquire-item.{cc,h}:
- add "IsIndexFile" to constructor of pkgAcqFile so that it sends
the right cache control headers
* cmdline/apt-get.cc:
- fix crash when pkg.VersionList() is empty
* apt-pkg/depcache.cc:
- fix incorrect std::cout usage for debug output
* test/libapt/getlanguages_test.cc:
- Add test for Esperanto that has nocounty associated with them
(LP: #560956)
* apt-pkg/deb/debrecords.cc:
- fix max tag buffer size (LP: #545336, closes: #578959)
* debian/rules:
- install html doxygen in libapt-pkg-doc
* debian/control:
- build-depend on doxygen
.
[ Julian Andres Klode ]
* apt-pkg/contrib/weakptr.h:
- add a class WeakPointable which allows one to register weak pointers to
an object which will be set to NULL when the object is deallocated.
* [ABI break] apt-pkg/acquire{-worker,-item,}.h:
- subclass pkgAcquire::{Worker,Item,ItemDesc} from WeakPointable.
* apt-pkg/pkgcache.cc:
- Merge fix from David to correct handling in single-arch environments.
* cmdline/apt-cache.cc:
- Add a showauto command to apt-cache.
* cmdline/apt-get.cc:
- Add apt-get markauto and unmarkauto commands.
Checksums-Sha1:
2011156d4943a4e13d6cef23fd718f4a8e29bee5 1258 apt_0.7.26~exp4.dsc
30369db4ddc7562fd4b24e3e75eebffc4aacb3b6 2808024 apt_0.7.26~exp4.tar.gz
55996c9a244fcecbc8bbf64d2430e6bcb869b770 225814 apt-doc_0.7.26~exp4_all.deb
b0df561c3211c2e61ca7a692f0eb1f5c3bf850bc 611474 libapt-pkg-doc_0.7.26~exp4_all.deb
5bb73c6804049945f67253c58c4cc5e5bc3a58ef 1928280 apt_0.7.26~exp4_i386.deb
408d780e90f2ca3b0f707bbb3161efa2c9e3251e 134388 libapt-pkg-dev_0.7.26~exp4_i386.deb
e6c46faaaefecdea9ac5dd6ce0f68d351b1355e4 259928 apt-utils_0.7.26~exp4_i386.deb
735030008b06a895474e42821be93ca6de2dc072 73672 apt-transport-https_0.7.26~exp4_i386.deb
Checksums-Sha256:
b13d709c8e72967609dbc17f6ab2a93edc2b1c59de012f8b61323a55cc0b35f5 1258 apt_0.7.26~exp4.dsc
f14a062e97ef0683d87de2aa47c2c2f385e6b2731ec6247214e54354061c13f6 2808024 apt_0.7.26~exp4.tar.gz
723419155c8683527da1c4ed9ea272b3cbbc71dd121bd61004c87e65c4f49a91 225814 apt-doc_0.7.26~exp4_all.deb
26ed776605a8e6ad650d93b12a2ef409d3a185c9637e9ba58b0c6e09dadd87b6 611474 libapt-pkg-doc_0.7.26~exp4_all.deb
270ae322784891008221a8ad2a57db57808ec5df6c701d962de23e3f47a3bd7a 1928280 apt_0.7.26~exp4_i386.deb
8a08db5540e116b2aaf7ce534beeb16c49362c276acbdcae8d5e6c26bc415273 134388 libapt-pkg-dev_0.7.26~exp4_i386.deb
c9e3f42f2967eb27f143a941e04e37c850e9a1f78b563babfbe20fd0b5cc6f9b 259928 apt-utils_0.7.26~exp4_i386.deb
d4c33249e799487a6b8203aa36c24a58ee4c8ce22c73429ef59910bc6c28e110 73672 apt-transport-https_0.7.26~exp4_i386.deb
Files:
1963728281ac39c8eafd857359be2389 1258 admin important apt_0.7.26~exp4.dsc
3a1907c13d0d6f012d3cfdeb8f125e32 2808024 admin important apt_0.7.26~exp4.tar.gz
fb151cae6c3f2b786e24c14cedfc256f 225814 doc optional apt-doc_0.7.26~exp4_all.deb
4bdc0cce2d62d6a69707c201e255ed88 611474 doc optional libapt-pkg-doc_0.7.26~exp4_all.deb
d0df3ce54e3e9005aaca7ac8ffd1fef9 1928280 admin important apt_0.7.26~exp4_i386.deb
f0910ce2144dfa154574673e49c548e9 134388 libdevel optional libapt-pkg-dev_0.7.26~exp4_i386.deb
ff792ada0118a6d85ecf4d7725a7d4b6 259928 admin important apt-utils_0.7.26~exp4_i386.deb
8e14d62f9474f8651498385f477fed86 73672 admin optional apt-transport-https_0.7.26~exp4_i386.deb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAkvilYQACgkQliSD4VZixzSVAgCfWuG8Kgx3Lbu2VxGGlPWg4+7y
GggAnRxhxeyiNOfQJ4mPCsI201MIg/1r
=YwgV
-----END PGP SIGNATURE-----
--- End Message ---