Projet

Général

Profil

GitPackagingSbuildPostInstall » Historique » Version 15

Daniel Dehennin, 09/01/2015 15:09

1 6 Daniel Dehennin
h4. Configuration des outils Debian
2 6 Daniel Dehennin
3 6 Daniel Dehennin
Des optimisations de configuration permettent aux outils Debian "debconf":http://wiki.debian.org/debconf et "Apt":http://wiki.debian.org/Apt de fonctionner de façon optimale dans les schroots de compilation.
4 6 Daniel Dehennin
5 6 Daniel Dehennin
h5. Mode non interactif lors de l’installation des paquets
6 6 Daniel Dehennin
7 6 Daniel Dehennin
<pre>
8 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
9 6 Daniel Dehennin
    /bin/bash -c 'echo "debconf debconf/priority select critical" | debconf-set-selections
10 6 Daniel Dehennin
echo "debconf debconf/frontend string noninteractive" | debconf-set-selections'
11 6 Daniel Dehennin
</pre>
12 6 Daniel Dehennin
13 6 Daniel Dehennin
h5. Ne pas installer les paquets recommandés et suggérés
14 6 Daniel Dehennin
15 6 Daniel Dehennin
<pre>
16 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
17 13 Daniel Dehennin
    /bin/bash -c 'cat > /etc/apt/apt.conf.d/90no-install-recommends <<EOF
18 6 Daniel Dehennin
APT::Install-Recommends "False";
19 6 Daniel Dehennin
APT::Install-Suggests "False";
20 6 Daniel Dehennin
EOF'
21 6 Daniel Dehennin
</pre>
22 6 Daniel Dehennin
23 7 Daniel Dehennin
h5. Ne pas utiliser les diff des indexes de paquets
24 7 Daniel Dehennin
25 7 Daniel Dehennin
Ces fichiers permettent de diminuer la quantité de données téléchargées lors des @apt-get update@ mais peuvent faire planter l’outil @apt-get@ de temps en temps :
26 7 Daniel Dehennin
27 7 Daniel Dehennin
<pre>
28 7 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
29 14 Daniel Dehennin
    /bin/bash -c 'cat > /etc/apt/apt.conf.d/80no-pdiff <<EOF
30 7 Daniel Dehennin
Acquire::PDiffs "False";
31 7 Daniel Dehennin
EOF'
32 7 Daniel Dehennin
</pre>
33 7 Daniel Dehennin
34 6 Daniel Dehennin
h5. Forcer la mise à jour des fichiers de configuration
35 6 Daniel Dehennin
36 6 Daniel Dehennin
<pre>
37 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
38 6 Daniel Dehennin
    /bin/bash -c 'echo "force-confnew" > /etc/dpkg/dpkg.cfg.d/force-confnew'
39 6 Daniel Dehennin
</pre>
40 6 Daniel Dehennin
41 6 Daniel Dehennin
h5. Configurer debfoster
42 6 Daniel Dehennin
43 6 Daniel Dehennin
L’outil "debfoster":http://packages.qa.debian.org/d/debfoster.html permet de garder un système propre.
44 6 Daniel Dehennin
45 6 Daniel Dehennin
<pre>
46 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
47 6 Daniel Dehennin
    /bin/bash -c 'cat > /var/lib/debfoster/keepers <<EOF
48 6 Daniel Dehennin
build-essential
49 6 Daniel Dehennin
debfoster
50 6 Daniel Dehennin
eatmydata
51 6 Daniel Dehennin
sudo
52 6 Daniel Dehennin
EOF'
53 6 Daniel Dehennin
</pre>
54 6 Daniel Dehennin
55 2 Daniel Dehennin
h4. Gestion des alias
56 2 Daniel Dehennin
57 1 Daniel Dehennin
Nous venons de créer des schroots Ubuntu Lucid Lynx dans lesquels les builds seront effectués.
58 1 Daniel Dehennin
59 1 Daniel Dehennin
Il nous reste à déclarer que ces schroots seront utilisés pour compiler des paquets pour notre distribution, nos distributions en prenant en compte les variantes @-security@, @-updates@, @-proposed@ et @-dev@.
60 1 Daniel Dehennin
61 1 Daniel Dehennin
Cette étape est importante afin que les paquets compilés pour une distribution soient répartis dans la bonne distribution sur le dépôt de paquets "deb":https://fr.wikipedia.org/wiki/Deb.
62 1 Daniel Dehennin
63 1 Daniel Dehennin
La commande suivante créé un fichier @.changes@ contenant la distribution @eole-2.3-dev@, ce fichier étant utilisé pour le triage :
64 1 Daniel Dehennin
<pre>
65 1 Daniel Dehennin
buildd@build:~$ sbuild -d eole-2.3-dev $package_$version.dsc
66 1 Daniel Dehennin
</pre>
67 1 Daniel Dehennin
68 1 Daniel Dehennin
Nous configurons les alias en ajoutant une ligne:
69 1 Daniel Dehennin
70 1 Daniel Dehennin
<pre>
71 1 Daniel Dehennin
system@build:~$ sudo sed -i \
72 15 Daniel Dehennin
    -e "/type=/ialiases=eole-2.3-${arch}-sbuild,eole-2.3-dev-${arch}-sbuild,eole-2.3-proposed-${arch}-sbuild,eole-2.3-security-${arch}-sbuild" \
73 1 Daniel Dehennin
    /etc/schroot/chroot.d/$dist-$arch-sbuild*
74 1 Daniel Dehennin
</pre>
75 2 Daniel Dehennin
76 2 Daniel Dehennin
77 2 Daniel Dehennin
h4. Autoriser l’utilisateur system à installer des paquets dans les schroots
78 2 Daniel Dehennin
79 2 Daniel Dehennin
Il faut en premier lieu configurer @sudo@ :
80 2 Daniel Dehennin
81 2 Daniel Dehennin
<pre>
82 2 Daniel Dehennin
system@build:~$ sudo /bin/sh -c "cat >> `expr /etc/sudoers.d/apt` <<EOT
83 2 Daniel Dehennin
Cmnd_Alias APT_INSTALL = /usr/bin/apt-get install *, /usr/bin/dpkg -i *.deb
84 2 Daniel Dehennin
Cmnd_Alias APT_REMOVE = /usr/bin/apt-get remove *, /usr/bin/apt-get purge *
85 2 Daniel Dehennin
Cmnd_Alias APT_CLEAN = /usr/bin/apt-get clean, /usr/bin/apt-get --purge autoremove, /usr/bin/orphaner --purge
86 2 Daniel Dehennin
Cmnd_Alias APT_UPGRADE = /usr/bin/apt-get update, /usr/bin/apt-get upgrade, /usr/bin/apt-get dist-upgrade
87 2 Daniel Dehennin
88 2 Daniel Dehennin
system ALL=NOPASSWD : APT_INSTALL, APT_REMOVE, APT_CLEAN, APT_UPGRADE
89 8 Daniel Dehennin
EOT
90 8 Daniel Dehennin
"
91 2 Daniel Dehennin
</pre>
92 2 Daniel Dehennin
93 2 Daniel Dehennin
Il faut ensuite ajouter ce fichier à la liste des fichiers à copier dans les @schroot@ :
94 2 Daniel Dehennin
<pre>
95 2 Daniel Dehennin
system@build:~$ sudo /bin/sh -c "cat >> `expr /etc/schroot/sbuild/copyfile` <<EOT
96 2 Daniel Dehennin
/etc/sudoers.d/apt
97 2 Daniel Dehennin
EOT
98 2 Daniel Dehennin
"
99 2 Daniel Dehennin
</pre>
100 2 Daniel Dehennin
101 2 Daniel Dehennin
h4. Accélération de la création de paquet
102 2 Daniel Dehennin
103 3 Daniel Dehennin
Le système de packaging @dpkg@ utilise intensément l’appel systeme "fsync":http://manpages.ubuntu.com/manpages/precise/man2/fsync.2.html afin d’assurer au maximum la cohérence des systèmes de fichiers.
104 3 Daniel Dehennin
105 1 Daniel Dehennin
Cette frénésie de @fsync@ ralenti considérablement les accès disques et n’est pas primordiale lors de la compilation d’un paquet.
106 3 Daniel Dehennin
107 4 Daniel Dehennin
On peut donc installer le paquet "eatmydata":https://launchpad.net/ubuntu/+source/libeatmydata à l’intérieur des @schroot@ et les configurer pour inhiber les appels à @fsync@:
108 2 Daniel Dehennin
109 2 Daniel Dehennin
Pour "Lucid Lynx":https://launchpad.net/ubuntu/lucid/+source/libeatmydata, le paquet est disponible et supporté dans les @backports@ qui ne sont pas activé par défaut, on peut télécharger et installer le paquet manuellement.
110 1 Daniel Dehennin
111 1 Daniel Dehennin
<pre>
112 6 Daniel Dehennin
system@build:~$ EAT_URL=$([ "$arch" = "amd64" ] && echo 'http://launchpadlibrarian.net/68861934/eatmydata_26-2~lucid1_amd64.deb' || echo 'http://launchpadlibrarian.net/68861936/eatmydata_26-2~lucid1_i386.deb')
113 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
114 2 Daniel Dehennin
    /bin/bash -c \
115 6 Daniel Dehennin
        "apt-get install wget \
116 1 Daniel Dehennin
            && wget ${EAT_URL} \
117 6 Daniel Dehennin
            && dpkg -i eatmydata_26-2~lucid1_$arch.deb"
118 1 Daniel Dehennin
</pre>
119 1 Daniel Dehennin
120 3 Daniel Dehennin
Pour "Precise Pangolin":https://launchpad.net/ubuntu/precise/+source/libeatmydata le paquet est disponible dans les composants @universe@ qui a été activé lors de la création du @schroot@.
121 3 Daniel Dehennin
122 3 Daniel Dehennin
<pre>
123 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
124 3 Daniel Dehennin
    /bin/bash -c \
125 6 Daniel Dehennin
        "apt-get install eatmydata"
126 3 Daniel Dehennin
</pre>
127 3 Daniel Dehennin
128 2 Daniel Dehennin
129 2 Daniel Dehennin
Il faut ensuite ajouter une configuration au @schroot@ :
130 1 Daniel Dehennin
131 1 Daniel Dehennin
<pre>
132 1 Daniel Dehennin
system@build:~$ sudo /bin/sh -c "cat >> `expr /etc/schroot/chroot.d/$dist-$arch-sbuild*` <<EOT
133 1 Daniel Dehennin
command-prefix=eatmydata
134 1 Daniel Dehennin
EOT
135 1 Daniel Dehennin
"
136 6 Daniel Dehennin
</pre>
137 6 Daniel Dehennin
138 6 Daniel Dehennin
h4. Mettre à jour et nettoyer le schroot
139 6 Daniel Dehennin
140 6 Daniel Dehennin
Nous pouvons maintenant mettre à jour le schroot et supprimer les paquets inutiles :
141 6 Daniel Dehennin
142 6 Daniel Dehennin
<pre>
143 6 Daniel Dehennin
system@build:~$ sbuild-update -udcar source:$dist-$arch-sbuild
144 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- debfoster -f
145 2 Daniel Dehennin
</pre>