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

Bug#456457: Add a mechanism for reparenting *all* file/directory names.



Package: apt
Version: 0.7.10
Severity: wishlist
Tags: patch

  There are times when it would be nice to be able to force apt to use
a different directory tree for everything.  Setting "Dir" to a new
location won't work, because absolute paths in the Dir hierarchy will
override this.  I propose creating a new option, "RootDir", that changes
the root under which filenames in the Dir hierarchy are placed.  This
effectively means that the new directory is prepended to all filenames
returned by FindFile.

  The attached patch adds support for RootDir to apt and documents it.

  Daniel

-- Package-specific info:

-- (/etc/apt/preferences present, but not submitted) --


-- (/etc/apt/sources.list present, but not submitted) --


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-3-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages apt depends on:
ii  debian-archive-keyring  2007.07.31       GnuPG archive keys of the Debian a
ii  libc6                   2.7-4            GNU C Library: Shared libraries
ii  libgcc1                 1:4.3-20071130-1 GCC support library
ii  libstdc++6              4.3-20071130-1   The GNU Standard C++ Library v3

apt recommends no packages.

-- no debconf information
=== modified file 'apt-pkg/contrib/configuration.cc'
--- apt-pkg/contrib/configuration.cc	2007-08-28 08:11:13 +0000
+++ apt-pkg/contrib/configuration.cc	2007-12-15 23:20:34 +0000
@@ -173,6 +173,11 @@
  */
 string Configuration::FindFile(const char *Name,const char *Default) const
 {
+   const Item *RootItem = Lookup("RootDir");
+   std::string rootDir =  (RootItem == 0) ? "" : RootItem->Value;
+   if(rootDir.size() > 0 && rootDir[rootDir.size() - 1] != '/')
+     rootDir.push_back('/');
+
    const Item *Itm = Lookup(Name);
    if (Itm == 0 || Itm->Value.empty() == true)
    {
@@ -204,7 +209,7 @@
       Itm = Itm->Parent;
    }
 
-   return val;
+   return rootDir + val;
 }
 									/*}}}*/
 // Configuration::FindDir - Find a directory name			/*{{{*/

=== modified file 'debian/changelog'
--- debian/changelog	2007-12-15 12:54:34 +0000
+++ debian/changelog	2007-12-15 22:43:33 +0000
@@ -38,6 +38,11 @@
     - support lzma data members
   * ftparchive/multicompress.cc:
     - support lzma output
+  
+  [ Daniel Burrows ]
+  * apt-pkg/contrib/configuration.cc:
+    - if RootDir is set, then FindFile and FindDir will return paths
+      relative to the directory stored in RootDir.
 
  -- Otavio Salvador <otavio@ossystems.com.br>  Sat, 08 Dec 2007 12:13:58 -0200
 

=== modified file 'doc/apt.conf.5.xml'
--- doc/apt.conf.5.xml	2007-12-15 21:20:01 +0000
+++ doc/apt.conf.5.xml	2007-12-15 22:35:53 +0000
@@ -295,6 +295,19 @@
    <literal>dpkg</literal>, <literal>apt-get</literal> <literal>dpkg-source</literal> 
    <literal>dpkg-buildpackage</literal> and <literal>apt-cache</literal> specify the location
    of the respective programs.</para>
+
+   <para>
+     The configuration item <literal>RootDir</literal> has a special
+     meaning.  If set, all paths in <literal>Dir::</literal> will be
+     relative to <literal>RootDir</literal>, <emphasis>even paths that
+     are specified absolutely</emphasis>.  So, for instance, if
+     <literal>RootDir</literal> is set to
+     <filename>/tmp/staging</filename> and
+     <literal>Dir::State::status</literal> is set to
+     <filename>/var/lib/dpkg/status</filename>, then the status file
+     will be looked up in
+     <filename>/tmp/staging/var/lib/dpkg/status</filename>.
+   </para>
  </refsect1>
  
  <refsect1><title>APT in DSelect</title>


Reply to: