Ubuntu-14.04 [SOLVED]: List all package versions and install these exact versions on another system?

Ubuntu-14.04 [SOLVED]: List all package versions and install these exact versions on another system?

Home Forums Ubuntu 14.04 Ubuntu-14.04 [SOLVED]: List all package versions and install these exact versions on another system?

Tagged: , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36616

    Anonymous

    QuestionQuestion

    Is it possible to list all of the installed package versions in such a way that they could then be installed on another system?

    I know that it’s possible to list the versions with

    dpkg -l > versions.txt
    

    but is there a simple way to use the output on another system?

    dpkg --get-selections
    

    doesn’t list the versions.

    (If the OS version is important, I’m using 14.04)

    #36617

    Anonymous

    Accepted AnswerAnswer

    One way that you could do it would be to create a list file with the install commands. The following command will create a file containing the commands telling apt-get what version of the application to install:

    dpkg -l | tail -n +6 | awk '{print $2"="$3}' | while read pkg; do echo "sudo apt-get install $pkg" >> install_pkg; done
    

    I put a command above to skip the first 6 lines of dpkg -l as those are information lines that turn into garbage lines. I also didn’t add the -y to the apt-get command so that it didn’t automatically install an application that you didn’t want installed. I can leave that up to you. When I tested if this would work or not, I added in -s for simulate the install after the apt-get in the command and it seemed to have worked.

    The command will create a file with lines that look like this that contains the package name and version to install (I truncated for a long list):

    sudo apt-get install y-ppa-manager=2017.06.13-1~webupd8~0
    sudo apt-get install yad=0.39.0-1~webupd8~xenial0
    sudo apt-get install yelp=3.20.1-1ubuntu1~xenial1
    sudo apt-get install yelp-xsl=3.20.1-1~ubuntu16.04.1~xenial1
    sudo apt-get install youtube-screenlet=0.3.2+++~trusty1
    sudo apt-get install zeitgeist=0.9.16-0ubuntu4
    sudo apt-get install zeitgeist-core=0.9.16-0ubuntu4
    sudo apt-get install zeitgeist-datahub=0.9.16-0ubuntu4
    sudo apt-get install zenity=3.20.0-1~ubuntu16.04.1
    sudo apt-get install zenity-common=3.20.0-1~ubuntu16.04.1
    sudo apt-get install zip=3.0-11
    sudo apt-get install zlib1g:amd64=1:1.2.8.dfsg-2ubuntu4.1
    sudo apt-get install zlib1g:i386=1:1.2.8.dfsg-2ubuntu4.1
    sudo apt-get install zlib1g-dev:amd64=1:1.2.8.dfsg-2ubuntu4.1
    sudo apt-get install zsync=0.6.2-1ubuntu1
    

    Then all you should have to do is to copy the file install_pkg that was created to the other system, given that all the PPAs on the other system match the system you are on, and run the following command to start the installation:

    sh ./install_pkg
    

    Hope this helps!

    Source: https://askubuntu.com/questions/988536/list-all-package-versions-and-install-these-exact-versions-on-another-system
    Author: Terrance
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.