Adapt – Run any app version on any Ubuntu version
Meet ‘adapt’ that adapts any applications from any Ubuntu release.
Adapt is a simple, yet very useful application that can be used to install any package from any release of Ubuntu into any version of Ubuntu without using any PPA. You don’t have to wait for the developers to update their PPA for any particular application. Just install adapt, and start installing the app you want on any Ubuntu version. Not only from Ubuntu, you can run any application from any other Linux distribution, for example CentOS. In layman terms, Adapt is like apt command that allows us to run old software on a newer OS or newer software on an older OS. Sounds awesome? Yeah, it should be.
Adapt utility is something similar to Linux Containers, but little different. Adapt uses lightweight LXD and Ubuntu system containers to achieve this goal. Here, we refer the containers as adapt container. Whenever you install package, the package will be installed in an adapt container. Similarly, whenever you remove a application, it will be removed from the adapt container. Adapt is developed by Dustin Kirkland from Canonical’s Ubuntu Product and Strategy team. It is mainly developed for Ubuntu systems, However It might work on other Ubuntu derivatives.
Sometimes, you need to use or test an updated package from the newer release of Ubuntu or other distro. Of course, the updated packages will be available in Ubuntu Backports repository. Alternatively, you can use the software PPAs to get the updated packages. In case, some of the updated packages are not available in the backports repository and PPA for some reason, ‘adapt’ utility comes in help.
In this brief tutorial, let us see how to install and use adapt in Ubuntu 16.04 LTS beta desktop.
Install Adapt on Ubuntu
I tested ‘adapt’ in Ubuntu 14.04 LTS desktop and Ubuntu 16.04 LTS beta desktop. It worked perfectly.
To add ‘adapt’ PPA, run:
sudo add-apt-repository ppa:adapt/ppa
On Ubuntu 14.04, we must add the following PPA. On Ubuntu 14.10 and later versions, it’s not necessary.
sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
Update the software repositories using command:
sudo apt-get update
Finally install adapt as shown below.
sudo apt-get install adapt lxd
Adapt usage is simple and straight forward like ‘apt’ command. Let us see some examples.
I am in Ubuntu 16.04 LTS desktop. To view the Ubuntu version, run:
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu Xenial Xerus (development branch)"
Well, now I need to install Nginx software from Ubuntu 14.04 release in the current Ubuntu version (16.04 in our case). How can I do this? Manually download Nginx deb file for trusty version on Xenial. Nope. It is not necessary though.
Here is how adapt method simplifies this task:
sudo adapt install -r trusty -p nginx
- -r : Distribution release name (Trusty, Xenial etc)
- -p : Package name
The above command will download the Ubuntu 14.04 LTS container image (We call it as adapt container), and install Nginx in it. Clear?
Similarly, you can remove a software, run.
sudo adapt purge -r trusty -p gcc
Now, you might ask why should we complicate ourselves? You might think that we can simply install lxd in Xenial and pull the distribution of our choice, log in to the container, and finally install the required packages? Of course, we can. But, Adapt simplifies this task much easier, and it does the above whole task in a single command.
Also, you can install higher version software in lower version.
For example, to install a software from higher version (e.g Ubuntu 15.10) in lower version (e.g Ubuntu 14.04 LTS), use the following command:
sudo adapt install -r wily -p nginx
To list the available adapt containers, run:
sudo adapt list
| adapt-ubuntu-trusty | RUNNING | 10.0.3.114 (eth0) | | PERSISTENT | 0 | | adapt-ubuntu-xenial | RUNNING | 10.0.3.242 (eth0) | | PERSISTENT | 0 |
As you see in the above output, I have downloaded two containers, one is trusty, and another is Xenial. Also, the above command displays the IP address of each container.
We installed Nginx in the Container, right? So, let us check whether Nginx is working or not.
To do so, open your Web browser and point it to the Container’s IP address, for example http://10.0.3.114/.
You’ll see the Nginx test page.
How can you be so sure that we have installed Nginx from Ubuntu 14.04 LTS? Let us verify that.
Log in to the container using command:
sudo lxc exec adapt-ubuntu-trusty /bin/bash
Here, adapt-ubuntu-trusty is my Container name. You can use “sudo adapt list” command to find out a container details.
Find the Ubuntu version using command:
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
Find the version of the Nginx version.
As you probably know, to find a package version in Ubuntu and derivatives, we use the following command
apt-cache policy <packageName>
apt-cache policy nginx
nginx: Installed: 1.4.6-1ubuntu3.4 Candidate: 1.4.6-1ubuntu3.4 Version table: *** 1.4.6-1ubuntu3.4 0 500 http://archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages 100 /var/lib/dpkg/status 1.4.6-1ubuntu3 0 500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
As you see in the above outputs, we have installed Nginx from Ubuntu 14.04 LTS running on Ubuntu 16.04 LTS.
What about the other distributions? Is it possible to use other distros except Ubuntu? Yes, absolutely. Let us install Nginx from CentOS 7 in Ubuntu 16.04 LTS.
To do so, just run:
sudo adapt install -d centos -r 7 -p epel-release
sudo adapt install -d centos -r 7 -p nginx
- -d : Distribution name
- -r : Release version
- -p : Package name
Start and enable nginx service using command:
sudo adapt run -d centos -r 7 -c "systemctl start nginx"
sudo adapt run -d centos -r 7 -c "systemctl enable nginx"
Now, open the web browser and point it to http://container-ip/.
As you see above, I have installed Nginx from CentOS 7 running in Ubuntu 16.04 LTS desktop. Cool, yeah?
As I mentioned earlier, You can find the Container details such as name, IP address, status using the following command:
sudo adapt list
To know more about adapt usage, refer the man pages.
Adapt is pretty much suitable for developers who wants to adapt a package from a newer version of Ubuntu onto their stable LTS desktop or server. And also, adapt allows the developers to provide the latest releases for testing purposes to the users running an older LTS version of Ubuntu. Since it uses LXD Containers, it is light-weight, and you need not to install any extra Virtualization softwares to test various applications from various distributions.
That’s all for now. Hope this guide will help you. If you find this tutorial useful, share it on your social networks, and support OSTechNix.