Projet

Général

Profil

GitPackagingSbuildPostInstall » Historique » Version 9

Daniel Dehennin, 29/10/2013 14:38

1 9 Daniel Dehennin
h4. Démontage du système de fichier
2 9 Daniel Dehennin
3 9 Daniel Dehennin
<pre>
4 9 Daniel Dehennin
system@build:~$ sudo umount /srv/chroot/${dist}-${arch}-sbuild
5 9 Daniel Dehennin
</pre>
6 9 Daniel Dehennin
7 6 Daniel Dehennin
h4. Configuration des outils Debian
8 6 Daniel Dehennin
9 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.
10 6 Daniel Dehennin
11 6 Daniel Dehennin
h5. Mode non interactif lors de l’installation des paquets
12 6 Daniel Dehennin
13 6 Daniel Dehennin
<pre>
14 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
15 6 Daniel Dehennin
    /bin/bash -c 'echo "debconf debconf/priority select critical" | debconf-set-selections
16 6 Daniel Dehennin
echo "debconf debconf/frontend string noninteractive" | debconf-set-selections'
17 6 Daniel Dehennin
</pre>
18 6 Daniel Dehennin
19 6 Daniel Dehennin
h5. Ne pas installer les paquets recommandés et suggérés
20 6 Daniel Dehennin
21 6 Daniel Dehennin
<pre>
22 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
23 6 Daniel Dehennin
    /bin/bash -c 'cat > /etc/apt/apt.conf.d/no-install-recommends <<EOF
24 6 Daniel Dehennin
APT::Install-Recommends "False";
25 6 Daniel Dehennin
APT::Install-Suggests "False";
26 6 Daniel Dehennin
EOF'
27 6 Daniel Dehennin
</pre>
28 6 Daniel Dehennin
29 7 Daniel Dehennin
h5. Ne pas utiliser les diff des indexes de paquets
30 7 Daniel Dehennin
31 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 :
32 7 Daniel Dehennin
33 7 Daniel Dehennin
<pre>
34 7 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
35 7 Daniel Dehennin
    /bin/bash -c 'cat > /etc/apt/apt.conf.d/no-pdiff <<EOF
36 7 Daniel Dehennin
Acquire::PDiffs "False";
37 7 Daniel Dehennin
EOF'
38 7 Daniel Dehennin
</pre>
39 7 Daniel Dehennin
40 6 Daniel Dehennin
h5. Forcer la mise à jour des fichiers de configuration
41 6 Daniel Dehennin
42 6 Daniel Dehennin
<pre>
43 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
44 6 Daniel Dehennin
    /bin/bash -c 'echo "force-confnew" > /etc/dpkg/dpkg.cfg.d/force-confnew'
45 6 Daniel Dehennin
</pre>
46 6 Daniel Dehennin
47 6 Daniel Dehennin
h5. Configurer debfoster
48 6 Daniel Dehennin
49 6 Daniel Dehennin
L’outil "debfoster":http://packages.qa.debian.org/d/debfoster.html permet de garder un système propre.
50 6 Daniel Dehennin
51 6 Daniel Dehennin
<pre>
52 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
53 6 Daniel Dehennin
    /bin/bash -c 'cat > /var/lib/debfoster/keepers <<EOF
54 6 Daniel Dehennin
build-essential
55 6 Daniel Dehennin
debfoster
56 6 Daniel Dehennin
eatmydata
57 6 Daniel Dehennin
sudo
58 6 Daniel Dehennin
EOF'
59 6 Daniel Dehennin
</pre>
60 6 Daniel Dehennin
61 2 Daniel Dehennin
h4. Gestion des alias
62 2 Daniel Dehennin
63 1 Daniel Dehennin
Nous venons de créer des schroots Ubuntu Lucid Lynx dans lesquels les builds seront effectués.
64 1 Daniel Dehennin
65 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@.
66 1 Daniel Dehennin
67 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.
68 1 Daniel Dehennin
69 1 Daniel Dehennin
La commande suivante créé un fichier @.changes@ contenant la distribution @eole-2.3-dev@, ce fichier étant utilisé pour le triage :
70 1 Daniel Dehennin
<pre>
71 1 Daniel Dehennin
buildd@build:~$ sbuild -d eole-2.3-dev $package_$version.dsc
72 1 Daniel Dehennin
</pre>
73 1 Daniel Dehennin
74 1 Daniel Dehennin
Nous configurons les alias en ajoutant une ligne:
75 1 Daniel Dehennin
76 1 Daniel Dehennin
<pre>
77 1 Daniel Dehennin
system@build:~$ sudo sed -i \
78 1 Daniel Dehennin
    -e "/type=/ialiases=eole-2.3,eole-2.3-dev,eole-2.3-proposed,eole-2.3-security" \
79 1 Daniel Dehennin
    /etc/schroot/chroot.d/$dist-$arch-sbuild*
80 1 Daniel Dehennin
</pre>
81 1 Daniel Dehennin
82 1 Daniel Dehennin
Les alias ci-dessus font que l’appel à @sbuild -d eole-2.3-dev@ utilisera l’architecture @AMD64@ par défaut.
83 1 Daniel Dehennin
84 1 Daniel Dehennin
La création d’un schroot @i386@ devrait ajouter des alias contenant l’architecture afin de ne pas entrer en conflit :
85 1 Daniel Dehennin
<pre>
86 1 Daniel Dehennin
system@build:~$ sudo sed -i \
87 1 Daniel Dehennin
    -e "/type=/ialiases=eole-2.3-i386,eole-2.3-dev-i386,eole-2.3-proposed-i386,eole-2.3-security-i386" \
88 2 Daniel Dehennin
    /etc/schroot/chroot.d/$dist-$arch-sbuild*
89 2 Daniel Dehennin
</pre>
90 2 Daniel Dehennin
91 2 Daniel Dehennin
Ainsi, la commande @sbuild -d eole-2.3-dev --arch=i386@ utilisera le schroot @i386@ et non le @AMD64@.
92 2 Daniel Dehennin
93 2 Daniel Dehennin
h4. Autoriser l’utilisateur system à installer des paquets dans les schroots
94 2 Daniel Dehennin
95 2 Daniel Dehennin
Il faut en premier lieu configurer @sudo@ :
96 2 Daniel Dehennin
97 2 Daniel Dehennin
<pre>
98 2 Daniel Dehennin
system@build:~$ sudo /bin/sh -c "cat >> `expr /etc/sudoers.d/apt` <<EOT
99 2 Daniel Dehennin
Cmnd_Alias APT_INSTALL = /usr/bin/apt-get install *, /usr/bin/dpkg -i *.deb
100 2 Daniel Dehennin
Cmnd_Alias APT_REMOVE = /usr/bin/apt-get remove *, /usr/bin/apt-get purge *
101 2 Daniel Dehennin
Cmnd_Alias APT_CLEAN = /usr/bin/apt-get clean, /usr/bin/apt-get --purge autoremove, /usr/bin/orphaner --purge
102 2 Daniel Dehennin
Cmnd_Alias APT_UPGRADE = /usr/bin/apt-get update, /usr/bin/apt-get upgrade, /usr/bin/apt-get dist-upgrade
103 2 Daniel Dehennin
104 2 Daniel Dehennin
system ALL=NOPASSWD : APT_INSTALL, APT_REMOVE, APT_CLEAN, APT_UPGRADE
105 8 Daniel Dehennin
EOT
106 8 Daniel Dehennin
"
107 2 Daniel Dehennin
</pre>
108 2 Daniel Dehennin
109 2 Daniel Dehennin
Il faut ensuite ajouter ce fichier à la liste des fichiers à copier dans les @schroot@ :
110 2 Daniel Dehennin
<pre>
111 2 Daniel Dehennin
system@build:~$ sudo /bin/sh -c "cat >> `expr /etc/schroot/sbuild/copyfile` <<EOT
112 2 Daniel Dehennin
/etc/sudoers.d/apt
113 2 Daniel Dehennin
EOT
114 2 Daniel Dehennin
"
115 2 Daniel Dehennin
</pre>
116 2 Daniel Dehennin
117 2 Daniel Dehennin
h4. Accélération de la création de paquet
118 2 Daniel Dehennin
119 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.
120 3 Daniel Dehennin
121 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.
122 3 Daniel Dehennin
123 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@:
124 2 Daniel Dehennin
125 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.
126 1 Daniel Dehennin
127 1 Daniel Dehennin
<pre>
128 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')
129 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
130 2 Daniel Dehennin
    /bin/bash -c \
131 6 Daniel Dehennin
        "apt-get install wget \
132 1 Daniel Dehennin
            && wget ${EAT_URL} \
133 6 Daniel Dehennin
            && dpkg -i eatmydata_26-2~lucid1_$arch.deb"
134 1 Daniel Dehennin
</pre>
135 1 Daniel Dehennin
136 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@.
137 3 Daniel Dehennin
138 3 Daniel Dehennin
<pre>
139 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- \
140 3 Daniel Dehennin
    /bin/bash -c \
141 6 Daniel Dehennin
        "apt-get install eatmydata"
142 3 Daniel Dehennin
</pre>
143 3 Daniel Dehennin
144 2 Daniel Dehennin
145 2 Daniel Dehennin
Il faut ensuite ajouter une configuration au @schroot@ :
146 1 Daniel Dehennin
147 1 Daniel Dehennin
<pre>
148 1 Daniel Dehennin
system@build:~$ sudo /bin/sh -c "cat >> `expr /etc/schroot/chroot.d/$dist-$arch-sbuild*` <<EOT
149 1 Daniel Dehennin
command-prefix=eatmydata
150 1 Daniel Dehennin
EOT
151 1 Daniel Dehennin
"
152 6 Daniel Dehennin
</pre>
153 6 Daniel Dehennin
154 6 Daniel Dehennin
h4. Mettre à jour et nettoyer le schroot
155 6 Daniel Dehennin
156 6 Daniel Dehennin
Nous pouvons maintenant mettre à jour le schroot et supprimer les paquets inutiles :
157 6 Daniel Dehennin
158 6 Daniel Dehennin
<pre>
159 6 Daniel Dehennin
system@build:~$ sbuild-update -udcar source:$dist-$arch-sbuild
160 6 Daniel Dehennin
system@build:~$ schroot -u root -c source:$dist-$arch-sbuild -d /tmp -- debfoster -f
161 2 Daniel Dehennin
</pre>