Because of internet connection speed limitation i prefer installing packages offline. I usually obtain required packages from a system with the same os installed. But when I install programs this way I usually ended up with broken packages on my system which is not fixable with the following:
sudo apt-get update
sudo apt-get install -f
Sometimes the last command wants to delete grub or some obviously essential packages from my system! or after performing the last command i can't install some programs for example:
The following packages have unmet dependencies:
mysql-client : Depends: mysql-client-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
how should i fix such problems? is there any way to save system status before installing programs this way and restore system to its previous state if installing process doesn't go well? is there any way to fix such problems manually without depending on package manager?
I wish in Ubuntu it were possible to install programs isolated from each other like it is in windows.
Firstly, you mention this is not the case in Windows. You're actually wrong - in Windows the dependencies for software need to be downloaded too.
Now to your issue. The problem with trying to install all the packages you need from an offline state is that you have no way to fix dependency problems. What
apt
and such do is they pull a list of all the dependencies, determine which ones need to be installed, and then try and install them. If it cannot install the dependencies, it fails.You bring up
mysql-client
as an example. That's a metapackage, as in it refers to other packages, and doesn't contain any real executables. It relies on specific versions ofmysql-client
as well and needs to download them.There's no real way to avoid this with an offline box. The only real way to avoid this issue is to actually connect your box to a network with either a Debian mirror on it or internet access, and set up firewall rules to restrict outbound traffic to only reach to update servers.
You didn't say how you install the packages you downloaded. If you simply get the
.deb
files from the other system, then I bet you're usingdpkg --install
to install the.deb
directly.As you have found out by now,
dpkg
can't resolve and handle dependency issues likeapt
can.One way to "roll back" the changes is to use
apt-get
to remove the packages you tried to install.One thing you could try is dpkg-offline (disclaimer: I wrote it). On your on-line system, get an ISO for the Ubuntu version you have on your off-line system. Run
dpkg-offline
indicating which packages you want to install. It will useapt-get
to download the packages and all their dependencies, and give you a tarball with a few helper scripts to run on the offline system. It will add an "offline" repository for those packages, so then you can useapt-get
and have it work out the dependencies.