GitPackagingSbuildCommon » Historique » Version 21
Daniel Dehennin, 23/11/2012 09:37
system aussi peut accéder au schroot
1 | 1 | Daniel Dehennin | {{toc}} |
---|---|---|---|
2 | 1 | Daniel Dehennin | |
3 | 1 | Daniel Dehennin | |
4 | 2 | Daniel Dehennin | h1. Mise en place d’un environnement de compilation personnel |
5 | 1 | Daniel Dehennin | |
6 | 2 | Daniel Dehennin | Sur une machine dédiée au build, nous avons besoin : |
7 | 1 | Daniel Dehennin | |
8 | 20 | Daniel Dehennin | * D’un utilisateur pour administrer le système (@system@) ; |
9 | 1 | Daniel Dehennin | |
10 | 20 | Daniel Dehennin | * D’un utilisateur dédié au build (@buildd@) ; |
11 | 20 | Daniel Dehennin | |
12 | 2 | Daniel Dehennin | * D’un groupe de volume logique d’une taille suffisante pour les |
13 | 20 | Daniel Dehennin | chroot (@build@) ; |
14 | 1 | Daniel Dehennin | |
15 | 2 | Daniel Dehennin | * De suffisamment d’espace libre sur le groupe de volume pour les |
16 | 2 | Daniel Dehennin | snapshots. |
17 | 2 | Daniel Dehennin | |
18 | 2 | Daniel Dehennin | h2. Installation des paquets nécessaires |
19 | 2 | Daniel Dehennin | |
20 | 2 | Daniel Dehennin | Les deux paquets nécessaire à la création et la gestion des |
21 | 2 | Daniel Dehennin | environnements sont les suivants : |
22 | 2 | Daniel Dehennin | |
23 | 18 | Daniel Dehennin | * sbuild: l’utilitaire de gestion des chroot en version @0.63.2-1@ ou supérieure disponible sur Wheezy |
24 | 2 | Daniel Dehennin | * debootstrap: l’utilitaire d’installation |
25 | 2 | Daniel Dehennin | |
26 | 2 | Daniel Dehennin | <pre> |
27 | 4 | Daniel Dehennin | system@build:~$ sudo apt-get install sbuild debootstrap |
28 | 2 | Daniel Dehennin | </pre> |
29 | 2 | Daniel Dehennin | |
30 | 2 | Daniel Dehennin | h2. Création d’un utilisateur pour le build |
31 | 2 | Daniel Dehennin | |
32 | 2 | Daniel Dehennin | Ce dernier recevra les logs dans son répertoire personnel. |
33 | 2 | Daniel Dehennin | |
34 | 2 | Daniel Dehennin | Il est cependant possible d’utiliser votre compte utilisateur, mais |
35 | 2 | Daniel Dehennin | sera indispensable lors de la mise en place d’un système de build |
36 | 2 | Daniel Dehennin | automatique. |
37 | 2 | Daniel Dehennin | |
38 | 2 | Daniel Dehennin | <pre> |
39 | 4 | Daniel Dehennin | system@build:~$ sudo adduser buildd |
40 | 2 | Daniel Dehennin | </pre> |
41 | 2 | Daniel Dehennin | |
42 | 2 | Daniel Dehennin | h2. Ajoute de l’utilisateur au groupe sbuild |
43 | 2 | Daniel Dehennin | |
44 | 5 | Fabrice Barconnière | L’accès aux outils de gestion de schroot est restreint aux membres du |
45 | 2 | Daniel Dehennin | groupe sbuild. |
46 | 2 | Daniel Dehennin | |
47 | 2 | Daniel Dehennin | Exécuter la commande suivante et copier le fichier comme indiqué : |
48 | 2 | Daniel Dehennin | |
49 | 2 | Daniel Dehennin | <pre> |
50 | 21 | Daniel Dehennin | system@build:~$ sudo sbuild-adduser system |
51 | 4 | Daniel Dehennin | system@build:~$ sudo sbuild-adduser buildd |
52 | 2 | Daniel Dehennin | </pre> |
53 | 2 | Daniel Dehennin | |
54 | 2 | Daniel Dehennin | h2. Création d’une paire de clef GPG |
55 | 2 | Daniel Dehennin | |
56 | 2 | Daniel Dehennin | L’outil sbuild créé des pseudos paquets pour la gestion des |
57 | 2 | Daniel Dehennin | Build-Depends lors de la construction des paquets. |
58 | 2 | Daniel Dehennin | |
59 | 2 | Daniel Dehennin | Cette paire de clef est locale à la machine |
60 | 2 | Daniel Dehennin | (@/var/lib/sbuild/apt-keys@) et spécifique à la procédure de build, il |
61 | 2 | Daniel Dehennin | n’y a nullement lieu de la publier. |
62 | 2 | Daniel Dehennin | |
63 | 2 | Daniel Dehennin | <pre> |
64 | 4 | Daniel Dehennin | buildd@build:~$ sbuild-update --keygen |
65 | 2 | Daniel Dehennin | </pre> |
66 | 2 | Daniel Dehennin | |
67 | 2 | Daniel Dehennin | Afin de générer de l’entropie, j’exécute dans un autre terminal la |
68 | 2 | Daniel Dehennin | commande suivante : |
69 | 2 | Daniel Dehennin | |
70 | 2 | Daniel Dehennin | <pre> |
71 | 4 | Daniel Dehennin | buildd@build:~$ find / -type f -exec sha512sum {} \; > /dev/null 2>&1 |
72 | 2 | Daniel Dehennin | </pre> |
73 | 2 | Daniel Dehennin | |
74 | 2 | Daniel Dehennin | Si vous êtes en SSH sur une machine (virtuelle ou physique), la frappe |
75 | 2 | Daniel Dehennin | de touche au clavier doit consommer autant d’entropie qu’elle n’en |
76 | 2 | Daniel Dehennin | fournie. |
77 | 2 | Daniel Dehennin | |
78 | 2 | Daniel Dehennin | h2. Mutualisation du cache apt |
79 | 2 | Daniel Dehennin | |
80 | 1 | Daniel Dehennin | <pre> |
81 | 13 | Daniel Dehennin | system@build:~$ sudo /bin/sh -c "echo /var/cache/apt/archives /var/cache/apt/archives none rw,bind 0 0 >>/etc/schroot/sbuild/fstab" |
82 | 2 | Daniel Dehennin | </pre> |
83 | 2 | Daniel Dehennin | |
84 | 2 | Daniel Dehennin | h2. Récupération des clefs publiques des dépôts |
85 | 2 | Daniel Dehennin | |
86 | 11 | Daniel Dehennin | La machine de build étant une debian, il faut ajouter les clefs GPG publique du projet ubuntu et de EOLE. |
87 | 1 | Daniel Dehennin | |
88 | 2 | Daniel Dehennin | <pre> |
89 | 13 | Daniel Dehennin | system@build:~$ wget http://eoleng.ac-dijon.fr/eoleng/eole-repository.key |
90 | 13 | Daniel Dehennin | system@build:~$ wget http://fr.archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg |
91 | 19 | Daniel Dehennin | system@build:~$ sudo apt-key --keyring /etc/apt/trusted.gpg.d/sbuild.gpg add eole-repository.key |
92 | 19 | Daniel Dehennin | system@build:~$ sudo apt-key --keyring /etc/apt/trusted.gpg.d/sbuild.gpg add ubuntu-archive-keyring.gpg |
93 | 2 | Daniel Dehennin | </pre> |
94 | 2 | Daniel Dehennin | |
95 | 12 | Daniel Dehennin | h2. Préparation de l’environnement |
96 | 12 | Daniel Dehennin | |
97 | 12 | Daniel Dehennin | Afin d’avoir des commandes réutilisables facilement, nous partirons du principe que : |
98 | 12 | Daniel Dehennin | |
99 | 12 | Daniel Dehennin | * la variable d’environnement @${YOUR_VG}@ contient le nom de votre groupe de volume ; |
100 | 1 | Daniel Dehennin | |
101 | 12 | Daniel Dehennin | * La variable d’environnement @${dist}@ contient le nom de la distribution ; |
102 | 12 | Daniel Dehennin | |
103 | 12 | Daniel Dehennin | * La variable d’environnement @${arch}@ contient le nom de l’architecture ; |
104 | 12 | Daniel Dehennin | |
105 | 12 | Daniel Dehennin | <pre> |
106 | 13 | Daniel Dehennin | system@buildd:~$ export YOUR_VG=build dist=lucid arch=amd64 |
107 | 12 | Daniel Dehennin | </pre> |
108 | 12 | Daniel Dehennin | |
109 | 17 | Benjamin Bohard | En partant d'une installation utilisant @partman-auto@, le groupe de volume est déjà complet. Si la recette est bien faite, un volume logique a été créé avec l'option @method{ keep }@. Ce volume (nommé par défaut keep_1) peut-être supprimé et l’espace libéré ainsi peut-être réutilisé. |
110 | 1 | Daniel Dehennin | |
111 | 15 | Daniel Dehennin | <pre> |
112 | 15 | Daniel Dehennin | system@build:~$ sudo lvchange -a n /dev/${YOUR_VG}/keep_1 |
113 | 15 | Daniel Dehennin | system@build:~$ sudo lvremove /dev/${YOUR_VG}/keep_1 |
114 | 15 | Daniel Dehennin | </pre> |
115 | 15 | Daniel Dehennin | |
116 | 15 | Daniel Dehennin | |
117 | 13 | Daniel Dehennin | h2. Création d’un volume logique dédié aux builds |
118 | 2 | Daniel Dehennin | |
119 | 1 | Daniel Dehennin | Ce volume sera monté dans chaque snapshot lors d’un build afin de ne |
120 | 14 | Benjamin Bohard | pas surcharger les snapshots de construction. |
121 | 14 | Benjamin Bohard | |
122 | 14 | Benjamin Bohard | <pre> |
123 | 14 | Benjamin Bohard | system@build:~$ sudo lvcreate -L20g -n var+lib+sbuild+build ${YOUR_VG} |
124 | 14 | Benjamin Bohard | system@build:~$ sudo mkfs.ext4 -L /var/lib/sbuild/build -m0 /dev/${YOUR_VG}/var+lib+sbuild+build |
125 | 14 | Benjamin Bohard | system@build:~$ sudo /bin/sh -c "echo /dev/${YOUR_VG}/var+lib+sbuild+build /var/lib/sbuild/build ext4 rw,noatime 0 2 >> /etc/fstab" |
126 | 14 | Benjamin Bohard | system@build:~$ sudo mount /var/lib/sbuild/build |
127 | 16 | Daniel Dehennin | system@build:~$ sudo chown sbuild:sbuild /var/lib/sbuild/build |
128 | 16 | Daniel Dehennin | system@build:~$ sudo chmod 2770 /var/lib/sbuild/build |
129 | 14 | Benjamin Bohard | </pre> |
130 | 14 | Benjamin Bohard | |
131 | 2 | Daniel Dehennin | h2. Création des environnements de build |
132 | 2 | Daniel Dehennin | |
133 | 12 | Daniel Dehennin | La gestion des environnements de build est faite par schroot et peut utiliser plusieurs systèmes afin de partager une image de base et ainsi gagner du temps lors des compilation : |
134 | 2 | Daniel Dehennin | |
135 | 8 | Daniel Dehennin | * Les volumes logiques ; |
136 | 2 | Daniel Dehennin | * Le système de fichier @btrfs@. |