Contents
Cross-grading un système Debian
Cette page a pour but de documenter la procédure pour "cross-grader" une installation Debian en utilisant Multiarch.
Prérequis
La première release Debian à fournir la fonctionnalité Multiarch est Wheezy, ainsi vous devez avoir upgrader avant d'effectuer la procédure décrites ici.
Une sauvegarde intégrale est fortement recommander sachant que cette procédure est en toujours en cours de mise au point. Réinstaller est encore l'option la plus sûr. Vous avez été averti !
Étapes
Ces étapes sont pour convertir une installation 'i386' en 'amd64', mais elles devraient être applicables pour n'importe quelles autres architectures paires tant que votre machine peut exécuter les deux (e.g. armel and armhf). Vous pouvez utiliser arch-test pour déterminer quel architectures Debian votre machine peut exécuter. Vous pouvez installer qemu-user-static pour ajouter plus d'architectures.
Ajouter la nouvelle architecture
# dpkg --print-architecture i386 # dpkg --add-architecture amd64 # dpkg --print-foreign-architectures amd64 # apt-get update
Installer un noyau qui supporte les deux architectures
# apt-get install linux-image-amd64:amd64 # reboot
Soyez sûr que vous exécuter le nouveau noyau avant de continuer les prochaines étapes (en faisant un uname -a).
Soyez sûr que tous les paquets sont synchroniser entre les architectures
Vous devez upgrader d'abord, et vérifier que toutes les versions des paquets qui sont a crossgrader dans cette étape sont synchroniser en version, sinon le cross-grade cassera l'installation.
# apt-get clean # apt-get upgrade
Crossgrade de `dpkg` `tar` et `apt`
Récupérer tous les paquets nécessaires pour remplacer dpkg, tar et apt et ensuite les installer pour la nouvelle architecture. C'est changer dpkg qui compte pour changer l'architecture par défaut. Tar doit être remplacer avec dpkg, pas apt sinon il sera supprimé et il n'y aura pas de tar pour mettre un nouveau.
# apt-get --download-only install dpkg:amd64 tar:amd64 apt:amd64 # dpkg --install /var/cache/apt/archives/*_amd64.deb # dpkg --print-architecture amd64 # dpkg --print-foreign-architectures i386 # apt-get update
Crossgrade tous les autres paquets architecture-dependant
Si vous êtes aussi loin c'est que vous êtes effectivement sous un système amd64, mais avec de nombreux paquets en i386. Vous pouvez essayer de les remlacer avec le paquets amd64 correspondant. Si cela ne fonctionne pas (toutes les librairies n'ont pas été converties en Multiarch) il est possible de supprimer le le paquet i386 et d'installer la version amd64.
Une autre façon brutale de faire de changement est
dpkg --get-selections | grep :i386 | sed -e s/:i386/:amd64/ | dpkg --set-selections apt-get -f install
Vous aurez à taper 'Oui, faites ce que je vous dis !' pour que apt fasse ceci.
Mise en garde et problème connue
APT veut résoudre la résolution de dépendance en se remettant lui-même
Si le système a des paquest qui dépendent de dérivé d'apt comme apt-utils, il est possible de se retrouver dans une situation où apt-get -f install veux se remettre lui-même en version i386. Aborting and doing another operation apt-get autoremove will illustrate the reason better:
The following packages have unmet dependencies: apt-utils:i386 : Depends: apt:i386 (= 1.4.8) but it is not installed
In such a case, the solution is to temporarily remove apt-utils:i386 from the system, and install apt-utils afterwards. Note: this new apt-utils will be amd64, but once you switch apt to amd64, using the :amd64 suffix will not work.
Apt dependency resolver generates broken solutions
It might happen that apt's resolver emits an unworkable solution:
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages. E: Unable to correct dependencies
In this case you can inspect what packages are marked as Broken and decide what to do:
apt -o Debug::pkgProblemResolver=1 -f install
KDE
The KDE desktop environment creates the file ~/.config/Trolltech.conf which contains locations of shared libararies and, more problematic, their architecture. This causes panel widgets to crash. The file can apparently be safely removed or renamed to fix these problems.
iamerican (and possibly others/similar)
Similar to KDE, some package(s) (e.g. iamerican on at least Debian 7.5) may have saved caches/hashes that need updating. E.g. encountered:
$ echo foo | spell /usr/bin/ispell: Illegal format hash table $
corrected with:
# (cd / && umask 022 && dpkg-reconfigure iamerican)
which then caused updating of: /var/lib/ispell/american.hash
Articles
Announce by Guillem Jover, dpkg Maintainer (see "Cross-grading" at the bottom of the message)
Howto amd64 an i386 Debian installation with multiarch by Marc Haber
Crossgrading Debian in 2017 by Simon Richter
Upgrading Debian from 32-bit to 64-bit - AKA crossgrading from i386 to amd64 by anarcat
i386 to amd64 - Debian 7.5 from i386 to amd64, discussion + links to edited script(1) capture, etc., by Michael Paoli
- Articles by Jose M. Calhariz:
Sample cross-grade script
Here is a script to essentially do the above for you. It could do with some work to put in a lot more error checking, but it works OK on a build-essential basic chroot - you may have problems on a more fully-configured real system. Use at your own risk!
# scary script to crossgrade your debian machine between arches.
# usage crossgrade <final-architecture>
set -e
if [ -z "$1" ]; then
echo "Usage: crossgrade <architecture> (debian architecture to convert to)"
exit 1
fi
#validate arch
if ! TO=$(dpkg-architecture -qDEB_HOST_ARCH -a$1); then
echo "$1 is not a recognised architecture name"
exit 1
fi
FROM=$(dpkg --print-architecture)
echo "Crossgrading from $FROM to $TO"
#check for a compatible kernel
# should check $FROM and $TO harder
# allow for switching kernel over too to minimal one if requested?
case $TO in
amd64)
TO_KERN=amd64
;;
i386)
TO_KERN=amd64
;;
armhf)
TO_KERN=armhf
;;
armel)
TO_KERN=armhf
;;
arm64)
TO_KERN=arm64
;;
mips)
TO_KERN=mips64le
;;
mipsel)
TO_KERN=mips64le
;;
mips64le)
TO_KERN=mips64le
;;
ppc)
TO_KERN=ppc64el
;;
powerpc)
TO_KERN=ppc64el
;;
ppc64el)
TO_KERN=ppc64el
esac
dpkg --add-architecture $TO
# check that dpkg --print-foreign-architectures is $TO
apt-get update
apt-get upgrade
# Install a kernel capable to run the new architecture with the old
# architecture in userspace
KERNEL=$(uname -m)
echo "Current kernel arch is $KERNEL"
if [ "$KERNEL" != "$TO_KERN" ]; then
if apt-get install linux-image-$TO:$TO; then
echo "There should be a reboot here"
#reboot
else
echo "kernel updating to linux-image-$TO:$TO failed"
fi
fi
#Crossgrade dpkg and apt
apt-get clean
apt-get --download-only install dpkg:$TO apt:$TO
#check ever package to be installed is available in same version for amd64 if installed (multiarch sync is needed)
#for pkg in /var/cache/apt/archives/*_$TO.deb
#do
# file=$(basename $pkg)
# pkgname= ${file%%_.*}
# version= ${file##*._}
# if dpkg -l $($pkgname)
#done
#in practice this needs to run twice (do it more? is there a better way?)
if ! dpkg --install /var/cache/apt/archives/*_$TO.deb; then
dpkg --install /var/cache/apt/archives/*_$TO.deb
fi
test $(dpkg --print-architecture) = $TO
test $(dpkg --print-foreign-architectures | grep $FROM) = $FROM
echo "Yay! dpkg and apt crossgrade completed successfully"
echo "Updating core packages"
apt-get -f install