Is there anyway or any popular tool that can allow me to create an isolated package environment for apt-get similar to what virtualenv does for pip and python packages?
Virtualenv type tool for apt-get
aptpackage-management
Related Solutions
This sounds like it may work, but personally, I'd just use apt-offline.
From the manpage:
apt-offline brings offline package management functionality to Debian based system. It can be used to download packages and its dependencies to be installed later on (or required to update) a disconnected machine. Packages can be downloaded from a different connected machine.
Excerpt from Debian Administration:
Using apt-offline
:
- You generate a signature on your Debian box at home and carry the signature file on a removable medium
- Now you take the USB Stick (with the
apt-offline.txt
signature file) to the office machine which could be running any linux version or even Windows. - There, you could run
apt-offline
giving it the signature file. apt-offline
would generate you an archive file or a folder with all the data. That data can be copied on a removable media. The removable media can be attached back to the disconnected Debian box at home and installed. (e.g. "apt-offline install /tmp/apt-offline.zip
")
APT doesn’t manage package changes as transactions, so there’s no built-in operation to undo a package installation (or any other package manipulation). However, it does log all the operations it performs, grouped by end-user request: if you look in /var/log/apt/history.log
, you’ll find the mypackage
installation, along with a list of all the other packages which were installed automatically alongside it. You can use this to undo the installation manually.
You could also use aptitude
instead, for your general package management: it effectively autoremove
s by default. This won’t help you right now though since it will want to remove the same 166MiB of packages as apt autoremove
.
As pointed out by Weijun Zhou, yum
and dnf
do manage package changes as units which can be undone (in some circumstances). dnf history
will list the transactions stored in the history, and dnf history rollback
or dnf history undo
can be used to roll the history back or undo a specific transaction (if possible). I’m not sure yum
or dnf
can be used properly instead of APT on Debian-based systems; you might need to switch to Fedora, RHEL or CentOS if you want to use those tools for all your package management.
Best Answer
I think what you're looking after is the combination of schroot and debootstrap. Schroot is a utility that essentially lets you run a Linux distribution inside another. Debootstrap is a utility to install a (Debian-based) distribution inside another. See How do I run 32-bit programs on a 64-bit Debian/Ubuntu? (which is easily generalized to running a Debian or Ubuntu-based distribution inside another).