Problemas na instalação de pacotes de um sistema para outro via scripts

0

Sistema - > Ubuntu 14.04

Sistema na VM - > Ubuntu DEV 14.04

Estou usando os seguintes scripts:

Fazer backup de pacotes

#!/bin/bash

dir=source_files

# if directory doesn't exist then make it
if [ ! -d "$dir" ]; then
    mkdir $dir
    echo "Created directory $dir"
fi

# Back up files to created directory
dpkg --get-selections > ./$dir/Package.list
sudo cp -R /etc/apt/sources.list* ./$dir
sudo apt-key exportall > ./$dir/Repo.keys

exit

Restaurar pacotes

#!/bin/sh

path=./source_files

apt-cache dumpavail > ~/temp_avail
sudo dpkg --merge-avail ~/temp_avail
rm ~/temp_avail


sudo apt-key add $path/Repo.keys
sudo cp -R $path/sources.list* /etc/apt/
sudo apt-get update
sudo apt-get install dselect
sudo dpkg --set-selections < $path/Package.list
sudo apt-get dselect-upgrade -y

exit

Aqui está um link para a lista de pacotes (É bastante longo)

Editei o arquivo de pacote acima para baixo, para que ele fosse executado somente até ack-grep , isso foi apenas para fins de teste.

Antes de executar o script ack-grep não funcionou, eu esperava poder usá-lo depois de executar os pacotes de restauração, eu ainda não consegui embora.

Esta é a lista editada:

account-plugin-aim                  install
account-plugin-facebook             install
account-plugin-flickr               install
account-plugin-google               install
account-plugin-jabber               install
account-plugin-salut                install
account-plugin-twitter              install
account-plugin-windows-live         install
account-plugin-yahoo                install
accountsservice                     install
ack-grep                            install

Editar

Alguns erros que vejo quando tento executar o script packageRestore.sh ;

W: GPG error: http://download.virtualbox.org trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54422A4B98AB5139
W: Failed to fetch cdrom://Ubuntu 14.04 LTS _Trusty Tahr_ - Release amd64 (20140417)/dists/trusty/main/binary-amd64/Packages  Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs

W: Failed to fetch cdrom://Ubuntu 14.04 LTS _Trusty Tahr_ - Release amd64 (20140417)/dists/trusty/restricted/binary-amd64/Packages  Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs

W: Failed to fetch cdrom://Ubuntu 14.04 LTS _Trusty Tahr_ - Release amd64 (20140417)/dists/trusty/main/binary-i386/Packages  Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs

W: Failed to fetch cdrom://Ubuntu 14.04 LTS _Trusty Tahr_ - Release amd64 (20140417)/dists/trusty/restricted/binary-i386/Packages  Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs

W: Failed to fetch http://ppa.launchpad.net/jon-severinsson/ffmpeg/ubuntu/dists/trusty/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/jon-severinsson/ffmpeg/ubuntu/dists/trusty/main/binary-i386/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.

saída de apt-key list

vco@osc:~/package-test$ apt-key list
/etc/apt/trusted.gpg
--------------------
pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key <[email protected]>
sub   2048g/79164387 2004-09-12

pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key <[email protected]>

pub   4096R/C0B21F32 2012-05-11
uid                  Ubuntu Archive Automatic Signing Key (2012) <[email protected]>

pub   4096R/EFE21092 2012-05-11
uid                  Ubuntu CD Image Automatic Signing Key (2012) <[email protected]>

pub   1024D/3E5C1192 2010-09-20
uid                  Ubuntu Extras Archive Automatic Signing Key <[email protected]>

pub   1024D/7FAC5991 2007-03-08
uid                  Google, Inc. Linux Package Signing Key <[email protected]>
sub   2048g/C07CB649 2007-03-08

pub   1024R/1BD3A65C 2009-01-19
uid                  Launchpad PPA for Terminator

pub   1024R/CFCA9579 2009-06-02
uid                  Launchpad Jon Severinsson's PPA

pub   1024R/BF7B8DAF 2013-06-30
uid                  Launchpad PPA for Michael Blennerhassett

pub   1024R/EEA14886 2010-05-04
uid                  Launchpad VLC

A instalação dos pacotes manualmente funciona, assim como a edição do pacote.list para o seguinte formato, em seguida, executado como um shell script, o problema é que alguns dos pacotes devem ser desinstalados em vez de instalados (como thunderbird e banshee )

#! /bin/bash                                                                                                                                                                    

apt-get install account-plugin-aim -y
apt-get install account-plugin-facebook -y
apt-get install account-plugin-flickr -y
apt-get install account-plugin-google -y
apt-get install account-plugin-jabber -y
apt-get install account-plugin-salut -y
apt-get install account-plugin-twitter -y
apt-get install account-plugin-windows-live -y
apt-get install account-plugin-yahoo -y
apt-get install accountsservice -y
apt-get install ack-grep -y
apt-get install acl -y
apt-get install acpi-support -y
apt-get install acpid -y
apt-get install activity-log-manager -y
apt-get install activity-log-manager-control-center -y
apt-get install adduser -y
apt-get install adium-theme-ubuntu -y

editar 2

Eu escrevi um script para isso, mas ainda não tenho certeza do motivo pelo qual o acima não funciona

#!/usr/bin/env python3
# encoding: utf-8

import os
import sys
import subprocess

'''Takes in a list of installed packages and converts them into a shell script

Script creates two files 

    (1) installed_packages.sh 
    (2) deinstall_packages.sh

These are formatted into shell scripts (though still need "chmod +x ./") that
can be used to install the same packages on another system

'''

# Write information of all packages to this file
package_list_file = 'Package.List'

# Create file containing installed packages
subprocess.call('dpkg --get-selections > ./{}'.format(package_list_file), shell=True)

# so all lines are apt-get lines
aptget = 'apt-get install'
apt_remove = 'apt-get purge'

# shebang!
shebang = "#! /bin/bash\n\n"

# alter the lines to be apt-get lines
with open(package_list_file,'r') as f:
    with open('./install_packages.sh','w+') as install_file:
        with open('./deinstall_packages.sh','w+') as deinstall_file:
            install_file.write(shebang)
            deinstall_file.write(shebang)
            for line in f.readlines():
                package, action = line.split()
                if action == 'deinstall':
                    deinstall_file.write("{} {} -y\n".format(apt_remove,package))
                elif action == 'install':
                    install_file.write("{} {} -y\n".format(aptget,package))
                else:
                    print("line didn't match the pattern....")

exit()
    
por baxx 19.04.2015 / 15:47

1 resposta

0

Edição 1

Você copia o arquivo sources.list, que contém referências a um CD. Ao tentar instalar os pacotes em sua VM, não há CD na unidade (virtual), portanto, Failed to fetch cdrom:// .

Edição 2

W: Failed to fetch http://ppa.launchpad.net/jon-severinsson/ffmpeg/ubuntu/dists/trusty/main/binary-amd64/Packages 404 Not Found Novamente, há algo no original sources.lst que está causando o erro: O PPA não existe (mais), daí o 404.

Se você usou set -e para o script de restauração, todo o script será encerrado prematuramente com o erro apt-get update ...

    
por Jan 23.04.2015 / 13:22