Projet

Général

Profil

GitPackagingSbuildCommon » Historique » Version 20

Daniel Dehennin, 23/11/2012 09:35
On a aussi besoin d’un utilisateur système

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 4 Daniel Dehennin
system@build:~$ sudo sbuild-adduser buildd
51 2 Daniel Dehennin
</pre>
52 2 Daniel Dehennin
53 2 Daniel Dehennin
h2. Création d’une paire de clef GPG
54 2 Daniel Dehennin
55 2 Daniel Dehennin
L’outil sbuild créé des pseudos paquets pour la gestion des
56 2 Daniel Dehennin
Build-Depends lors de la construction des paquets.
57 2 Daniel Dehennin
58 2 Daniel Dehennin
Cette paire de clef est locale à la machine
59 2 Daniel Dehennin
(@/var/lib/sbuild/apt-keys@) et spécifique à la procédure de build, il
60 2 Daniel Dehennin
n’y a nullement lieu de la publier.
61 2 Daniel Dehennin
62 2 Daniel Dehennin
<pre>
63 4 Daniel Dehennin
buildd@build:~$ sbuild-update --keygen
64 2 Daniel Dehennin
</pre>
65 2 Daniel Dehennin
66 2 Daniel Dehennin
Afin de générer de l’entropie, j’exécute dans un autre terminal la
67 2 Daniel Dehennin
commande suivante :
68 2 Daniel Dehennin
69 2 Daniel Dehennin
<pre>
70 4 Daniel Dehennin
buildd@build:~$ find / -type f -exec sha512sum {} \; > /dev/null 2>&1
71 2 Daniel Dehennin
</pre>
72 2 Daniel Dehennin
73 2 Daniel Dehennin
Si vous êtes en SSH sur une machine (virtuelle ou physique), la frappe
74 2 Daniel Dehennin
de touche au clavier doit consommer autant d’entropie qu’elle n’en
75 2 Daniel Dehennin
fournie.
76 2 Daniel Dehennin
77 2 Daniel Dehennin
h2. Mutualisation du cache apt
78 2 Daniel Dehennin
79 1 Daniel Dehennin
<pre>
80 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"
81 2 Daniel Dehennin
</pre>
82 2 Daniel Dehennin
83 2 Daniel Dehennin
h2. Récupération des clefs publiques des dépôts
84 2 Daniel Dehennin
85 11 Daniel Dehennin
La machine de build étant une debian, il faut ajouter les clefs GPG publique du projet ubuntu et de EOLE.
86 1 Daniel Dehennin
87 2 Daniel Dehennin
<pre>
88 13 Daniel Dehennin
system@build:~$ wget http://eoleng.ac-dijon.fr/eoleng/eole-repository.key
89 13 Daniel Dehennin
system@build:~$ wget http://fr.archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg
90 19 Daniel Dehennin
system@build:~$ sudo apt-key --keyring /etc/apt/trusted.gpg.d/sbuild.gpg add eole-repository.key
91 19 Daniel Dehennin
system@build:~$ sudo apt-key --keyring /etc/apt/trusted.gpg.d/sbuild.gpg add ubuntu-archive-keyring.gpg
92 2 Daniel Dehennin
</pre>
93 2 Daniel Dehennin
94 12 Daniel Dehennin
h2. Préparation de l’environnement
95 12 Daniel Dehennin
96 12 Daniel Dehennin
Afin d’avoir des commandes réutilisables facilement, nous partirons du principe que :
97 12 Daniel Dehennin
98 12 Daniel Dehennin
* la variable d’environnement @${YOUR_VG}@ contient le nom de votre groupe de volume ;
99 1 Daniel Dehennin
100 12 Daniel Dehennin
* La variable d’environnement @${dist}@ contient le nom de la distribution ;
101 12 Daniel Dehennin
102 12 Daniel Dehennin
* La variable d’environnement @${arch}@ contient le nom de l’architecture ;
103 12 Daniel Dehennin
104 12 Daniel Dehennin
<pre>
105 13 Daniel Dehennin
system@buildd:~$ export YOUR_VG=build dist=lucid arch=amd64
106 12 Daniel Dehennin
</pre>
107 12 Daniel Dehennin
108 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é.
109 1 Daniel Dehennin
110 15 Daniel Dehennin
<pre>
111 15 Daniel Dehennin
system@build:~$ sudo lvchange -a n /dev/${YOUR_VG}/keep_1
112 15 Daniel Dehennin
system@build:~$ sudo lvremove /dev/${YOUR_VG}/keep_1
113 15 Daniel Dehennin
</pre>
114 15 Daniel Dehennin
115 15 Daniel Dehennin
116 13 Daniel Dehennin
h2. Création d’un volume logique dédié aux builds
117 2 Daniel Dehennin
118 1 Daniel Dehennin
Ce volume sera monté dans chaque snapshot lors d’un build afin de ne
119 14 Benjamin Bohard
pas surcharger les snapshots de construction.
120 14 Benjamin Bohard
121 14 Benjamin Bohard
<pre>
122 14 Benjamin Bohard
system@build:~$ sudo lvcreate -L20g -n var+lib+sbuild+build ${YOUR_VG}
123 14 Benjamin Bohard
system@build:~$ sudo mkfs.ext4 -L /var/lib/sbuild/build -m0 /dev/${YOUR_VG}/var+lib+sbuild+build
124 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"
125 14 Benjamin Bohard
system@build:~$ sudo mount /var/lib/sbuild/build
126 16 Daniel Dehennin
system@build:~$ sudo chown sbuild:sbuild /var/lib/sbuild/build
127 16 Daniel Dehennin
system@build:~$ sudo chmod 2770 /var/lib/sbuild/build
128 14 Benjamin Bohard
</pre>
129 14 Benjamin Bohard
130 2 Daniel Dehennin
h2. Création des environnements de build
131 2 Daniel Dehennin
132 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 :
133 2 Daniel Dehennin
134 8 Daniel Dehennin
* Les volumes logiques ;
135 2 Daniel Dehennin
* Le système de fichier @btrfs@.