Bonjour,
[edit]Si vous avez la flemme de lire ce post,
allez directement au deuxième.[/edit]
[edit2]Des changements vont être effectués dans ce message, prière de se référer pour le moment aux messages #10 à #13.[/edit2]
[edit3]
Bon, flemme de faire des changements sur ce message car je me suis rendu compte que la ligne n’est valable que pour une LTS.
Du coup
j’ai fait un script qui, semble-t-il, tiens la route.
[/edit3]
Il arrive fréquemment que le sources.list soit dans un état incohérent qu’il vaut mieux le recréer de toute pièce plutôt que de réparer ligne après ligne.
Je ne ferai pas de commentaire sur le fait de comment le sources.list est devenu incohérent si ce n’est sans doute que son propriétaire a probablement suivi un ou des tutos sur le net devenus obsolètes.
J’ai donc cherché une source officielle qui, j’espère, ne changera pas de place au fil du temps :
https://github.com/canonical/cloud-init/blob/master/templates/sources.list.ubuntu.tmpl.
En préambule, je conseille de faire une sauvegarde du sources.list existant. En effet, celui-ci peut contenir des dépôts tiers (dus à des pratiques ancestrales qui ajoutent le dépôt dans ce fichier plutôt que de créer un fichier spécifique dans le répertoire prévu à cet effet depuis maintenant quelques années, mais là n’est pas le propos et je ne vais pas partir en guerre contre les tutos mal fichus sur le net tel Don Quichotte se battant contre les moulins à vent).
Bref, sauvegarder votre sources.list car il peut contenir des éléments qui seront effacer par la ligne de commande que je présente ci-dessous.
Alors voilà, je vais essayer de détailler du mieux que je peux :
- on télécharge le fichier modèle ;
wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl
on obtient donc ceci ;
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$ wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl
## template:jinja
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb {{mirror}} {{codename}} main restricted
# deb-src {{mirror}} {{codename}} main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb {{mirror}} {{codename}}-updates main restricted
# deb-src {{mirror}} {{codename}}-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb {{mirror}} {{codename}} universe
# deb-src {{mirror}} {{codename}} universe
deb {{mirror}} {{codename}}-updates universe
# deb-src {{mirror}} {{codename}}-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb {{mirror}} {{codename}} multiverse
# deb-src {{mirror}} {{codename}} multiverse
deb {{mirror}} {{codename}}-updates multiverse
# deb-src {{mirror}} {{codename}}-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb {{mirror}} {{codename}}-backports main restricted universe multiverse
# deb-src {{mirror}} {{codename}}-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu {{codename}} partner
# deb-src http://archive.canonical.com/ubuntu {{codename}} partner
deb {{security}} {{codename}}-security main restricted
# deb-src {{security}} {{codename}}-security main restricted
deb {{security}} {{codename}}-security universe
# deb-src {{security}} {{codename}}-security universe
deb {{security}} {{codename}}-security multiverse
# deb-src {{security}} {{codename}}-security multiverse
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$
- on supprime les huit premières lignes de ce modèle qui sont des commentaires sur l’utilisation de celui-ci à l’aide de la commande
tail +9
que l’on ajoute avec un pipe (|) à la commande précédente ;
wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9
on obtient alors ;
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$ wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb {{mirror}} {{codename}} main restricted
# deb-src {{mirror}} {{codename}} main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb {{mirror}} {{codename}}-updates main restricted
# deb-src {{mirror}} {{codename}}-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb {{mirror}} {{codename}} universe
# deb-src {{mirror}} {{codename}} universe
deb {{mirror}} {{codename}}-updates universe
# deb-src {{mirror}} {{codename}}-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb {{mirror}} {{codename}} multiverse
# deb-src {{mirror}} {{codename}} multiverse
deb {{mirror}} {{codename}}-updates multiverse
# deb-src {{mirror}} {{codename}}-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb {{mirror}} {{codename}}-backports main restricted universe multiverse
# deb-src {{mirror}} {{codename}}-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu {{codename}} partner
# deb-src http://archive.canonical.com/ubuntu {{codename}} partner
deb {{security}} {{codename}}-security main restricted
# deb-src {{security}} {{codename}}-security main restricted
deb {{security}} {{codename}}-security universe
# deb-src {{security}} {{codename}}-security universe
deb {{security}} {{codename}}-security multiverse
# deb-src {{security}} {{codename}}-security multiverse
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$
- on va ensuite remplacer les occurences entre doubles-accolades à l’aide de la commande sed ;
sed "commandes_de_remplacements_détaillées_ci-dessous"
notons la présence des guillemets doubles car on va utiliser des commandes externes qui ne serait pas interprétées avec des guillemets simples ;
- commençons par remplacer {{mirror}} par l’adresse du serveur (j’utilise ici le serveur pour France qu’il faudra donc adapter selon votre situation géographique) ;
s#{{mirror}}#http://fr.archive.ubuntu.com/ubuntu/#
- remplaçons ensuite {{codename}} par le code de la version en cours ;
s#{{codename}}#$(lsb_release -sc)#
- enfin remplaçons {{security}} par l’adresse du dépôt security ;
s#{{security}}#http://security.ubuntu.com/ubuntu/#
on sépare les commandes de sed par des points-virgules et on ajoute le tout aux commandes précédentes avec un pipe ;
wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9 | sed "s#{{mirror}}#http://fr.archive.ubuntu.com/ubuntu/#;s#{{codename}}#$(lsb_release -sc)#;s#{{security}}#http://security.ubuntu.com/ubuntu/#"
on obtient ;
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$ wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9 | sed "s#{{mirror}}#http://fr.archive.ubuntu.com/ubuntu/#;s#{{codename}}#$(lsb_release -sc)#;s#{{security}}#http://security.ubuntu.com/ubuntu/#"
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal universe
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$
on peut se rendre compte ici que je suis sous focal pour mon exemple ;
- optionnel mais je l’ajoute car ça peut aporter des infos sur l’historique d’installation, les infos du CD ;
j’ajoute donc une commande d’insertion en première ligne à sed, commande un peu complexe que je ne vais pas détailler ici mais je dirai simplement qu’elle va lire les infos dans /var/log/installer/media-info et les mettre en forme pour le sources.list ;
1i\# deb cdrom:$(sed 's/^/\[/;s/\"/_/g;s/$/\]/' /var/log/installer/media-info)/ $(awk -F'[ "]' '{print tolower($5)}' /var/log/installer/media-info) main restricted
on ajoute cette commande dans le sed en mettant un point-virgule avant pour obtenir ;
wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9 | sed "s#{{mirror}}#http://fr.archive.ubuntu.com/ubuntu/#;s#{{codename}}#$(lsb_release -sc)#;s#{{security}}#http://security.ubuntu.com/ubuntu/#;1i\# deb cdrom:$(sed 's/^/\[/;s/\"/_/g;s/$/\]/' /var/log/installer/media-info)/ $(awk -F'[ "]' '{print tolower($5)}' /var/log/installer/media-info) main restricted"
qui donne ;
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$ wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9 | sed "s#{{mirror}}#http://fr.archive.ubuntu.com/ubuntu/#;s#{{codename}}#$(lsb_release -sc)#;s#{{security}}#http://security.ubuntu.com/ubuntu/#;1i\# deb cdrom:$(sed 's/^/\[/;s/\"/_/g;s/$/\]/' /var/log/installer/media-info)/ $(awk -F'[ "]' '{print tolower($5)}' /var/log/installer/media-info) main restricted"
# deb cdrom:[Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423)]/ focal main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal universe
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$
on se rend compte dans mon exemple que j’ai fait une installation de focal sans être passé par une mise à niveau ;
- terminons par écrire ce que ces commandes retournent dans le fichier sources.list en tant qu’administrateur à l’aide de la commande tee ;
sudo tee /etc/apt/sources.list
que l’on ajoute avec un pipe pour avoir ;
wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9 | sed "s#{{mirror}}#http://fr.archive.ubuntu.com/ubuntu/#;s#{{codename}}#$(lsb_release -sc)#;s#{{security}}#http://security.ubuntu.com/ubuntu/#;1i\# deb cdrom:$(sed 's/^/\[/;s/\"/_/g;s/$/\]/' /var/log/installer/media-info)/ $(awk -F'[ "]' '{print tolower($5)}' /var/log/installer/media-info) main restricted" | sudo tee /etc/apt/sources.list
et obtenir ;
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$ wget -qO- https://raw.githubusercontent.com/canonical/cloud-init/master/templates/sources.list.ubuntu.tmpl | tail +9 | sed "s#{{mirror}}#http://fr.archive.ubuntu.com/ubuntu/#;s#{{codename}}#$(lsb_release -sc)#;s#{{security}}#http://security.ubuntu.com/ubuntu/#;1i\# deb cdrom:$(sed 's/^/\[/;s/\"/_/g;s/$/\]/' /var/log/installer/media-info)/ $(awk -F'[ "]' '{print tolower($5)}' /var/log/installer/media-info) main restricted" | sudo tee /etc/apt/sources.list
# deb cdrom:[Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423)]/ focal main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal universe
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://fr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://fr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse
┏[ lundi 23 novembre 2020 ]
┣ nany@stupidcomputer :
┗▶ ~$
En espérant que ces explications sont suffisamment claires…
[edit3bis]
Non, ces explications ne sont pas suffisament claires car la ligne ne fonctionne que pour une LTS (cf. edit3 en début de message).
[/edit3bis]