As part of an OS deployment, I need to maintain sets of debian packages independently of the host operating system. It's pretty straightforward to override the Apt settings for the cache and lists, but not the dpkg setting for the admindir. For example:
apt-get -o Dir::Etc::Sourcelist='/path/to/sources.list' \ -o Dir::Cache::Archives='/path/to/cache/apt/archives' \ -o Dir::State::Lists='/path/to/lib/apt/lists' \ -o DPkg::Options::='--admindir=/path/to/lib/dpkg' update
This correctly reads my sources out of /path/to/sources.list, and builds the package available lists in /path/to/lib/apt/lists/*. However, at the end of the update command, I still get the following error:
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
This is despite the last option attempting to override the default dpkg admindir of '/var/lib/dpkg'. What am I doing wrong? According to guides like this, what I'm doing with DPkg::Options ought to work.