Project Wild Penguin 19.4.2017: How to install manually installed packages on one system to another system remotely

So, finally after a long time, I've found an original solution to my set of problems stated below:

  1. To backup and restore repositories. 
  2. To install manually installed packages on a new system or another system remotely.
Most of the times, I've found straightforward answers to my queries from techgurus at askubuntu.com or any other sites. But this time, I've to be a bit more jugaadu by applying combinatorics to various solutions that I found to create a single solution for my problem 

While implementing the solution, the question that was on back of my mind is beautifully depicted in the following xkcd comic:
'Copy and paste from a random thread on a website' is the hardest to predict, and depends on the specific website, programming language, tone of the description, and current phase of the moon.

Will it work? If it doesn't, there is a likely chance of my system breaking down and lose of valuable time in fixing it. But thankfully, it did work. 

Now, I'll share the process that I followed in implementing this solution.

First part of the problem was achieved using the Y PPA Manager that I've mentioned in my blog post Fix duplicate sources.list entry. Follow the same steps mentioned in this blog except here you will double click on the option Backup repositories. Now, copy the backed up repositories zipped file to your new system and restore it using the Y PPA Manager. After that run sudo apt-get update and sudo reboot.

Now, the second part of the problem. In this part, I've remotely installed the manually installed packages of one system to another. 

For this, please follow the steps given below:
  • Prerequisites:
    1. Both systems are on same network running any Ubuntu based distro. I've successfully done this on Xubuntu 16.10.
    2. You have restored the backed up repository on your new system.
  • Main Process:
    1. Install SSH on both systems using following commands:
      1. sudo apt-get update
        sudo apt-get install openssh-client
        sudo apt-get install openssh-server
        sudo service ssh restart

    2.  Now on the older system, go to home directory and save the following script titled ManualInstalledPackages.sh:
      #!/bin/bash 
      comm -23 <(aptitude search '~i ! ~M' -F '%p' | sed "s/ *$//" | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
                3. Make the script executable by running the following command in terminal:                    
          chmod +x ManualInstalledPackages.sh

                4.  Now in the system run the following set of commands:
          mapfile -t packages < <(ssh max@10.0.0.5"./ManualInstalledPackages.sh 1")

                5. Check if you can see the list of packages by running the command:
          echo ${packages[@]}"
       
                6. There might some packages that you need now or it might be breaking the installation l                        like wine2.0. To remove those packages, follow the steps given below:
           delete=(wine2.0)
           packages=( "${packages[@]/$delete}" )
           
              7. Confirm again by running the command mentioned in step 5.
 
              8.  In last step, run the given below command to install the listed packages:
          sudo apt-get install -y --allow-unauthenticated --fix-missing                       "${packages[@]}"

Now just sit back and relax. Your system would be ready with all your favourite applications and other packages.

Sources:




Comments

Popular posts from this blog

Project Wild Penguin 22.4.2017: To delete directories inside current directory whose contents are less than a given size

ANPR Project Day 1: Standard Format of Indian Number Plate

ANPR Day 5: User requirement Analysis