Sincronizzare i pacchetti installati su due macchine Debian

From RVM Wiki
Revision as of 17:39, 6 April 2009 by Gabriele.vivinetto (talk | contribs) (Esecuzione batch)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Passaggi manuali

  • Sulla macchina sorgente, esportare la lista pacchetti:
dpkg --get-selections "*" > select.src
  • Sulla macchina destinazione, importare la lista pacchetti:
sudo dpkg --set-selections < select.src
  • Applicare le selezioni dei pacchetti. Verranno installati e disinstallati i pacchetti:
sudo apt-get -u --purge dselect-upgrade

I PACCHETTI IN PIÙ GIÀ INSTALLATI CHE NON INTERFERISCONO CON LE DIPENDENZE, NON VERRANNO DISINSTALLATI.

  • Cancellare le configurazioni dei pacchetti installati:
sudo dpkg --purge $(dpkg -l | grep ^rc | tr -s ' ' | cut -f2 --delim=' ')

Controllare che la lista pacchetti sia uguale:

cd /tmp
dpkg --get-selections > select.dst
vimdiff select.src select.dst

Se così non fosse, per eliminare anche i pacchetti in più:

for PKG in $(diff --suppress-common-lines -y select.dst select.src  | less | cut -f 1); do; sudo apt-get remove --purge $PKG; done

Esecuzione batch

Questi comandi

  • prelevano la lista sorgente
  • confrontano visualmente le liste sorgente e destinazione
  • sincronizzano i pacchetti
  • riconfronta le liste
  • rimuove i pacchetti in più
  • riconfronta le liste
export SRCSRV="mp.galimberti.net"
cat > /tmp/syncpkg <<'EOFile'
#!/bin/bash
cd /tmp
ssh $SRCSRV 'dpkg --get-selections' > select.REM
ssh $SRCSRV 'dpkg --get-selections "*"' > select.SRC
dpkg --get-selections > select.LOC
vimdiff select.REM select.LOC
sudo dpkg --set-selections < select.SRC
sudo apt-get -u --purge dselect-upgrade
for PKG in $(dpkg -l | grep ^rc | tr -s ' ' | cut -f2 --delim=' '); do sudo dpkg --purge $PKG; done
dpkg --get-selections > select.NEW
vimdiff select.REM select.NEW
for PKG in $(diff --suppress-common-lines -y select.NEW select.REM  | less | cut -f 1); do sudo apt-get remove --purge $PKG; done
dpkg --get-selections > select.NEW
vimdiff select.REM select.NEW
EOFile

chmod +x  /tmp/syncpkg
/tmp/syncpkg

Riferimenti