aboutsummaryrefslogtreecommitdiff
path: root/Documentation/pbuilder-doc.xml
blob: 6b04918f05af72ec840473b77db315dbc8f2cc25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "/usr/share/sgml/docbook/dtd/xml/4.2/docbookx.dtd"> 
<!-- the original of this documentation is in pbuilder source tar-ball,
  and the latest version is found in CVS repository. -->
<book>
  <bookinfo>
    <date>2005-02-13</date>
    <title>pbuilder User's Manual</title>
    <abbrev>pbuilder-doc</abbrev>
    <subtitle>Usage and operations</subtitle>
    <releaseinfo>documentation in progress ($Id$)</releaseinfo>
    <authorgroup>
      <author>
	<firstname>Junichi</firstname>
	<surname>Uekawa</surname>
      </author>
    </authorgroup>
  </bookinfo>
  <!-- FIXME: consistent markup of commands, files, and variables -->
  <!-- FIXME: wrap text so it always fits in 80 columns -->
  <!-- FIXME: trim trailing spaces from lines globally -->
  <chapter>
    <title>Introducing pbuilder</title>
    <sect1 id="aim">
      <title>Aims of pbuilder</title>
      <para>
	<command>pbuilder</command> stands for 
	Personal Builder, and it is an automatic Debian Package Building system
	for personal environments.
	<command>pbuilder</command> aims to be an 
	easy-to-setup system
	for auto-building Debian packages inside a clean-room
	environment, so that it is possible to verify that
	a package can be built on most Debian installations.
	The clean-room environment is achieved through the use of
	a chroot image,
	so that only minimal packages will be installed inside the
	chroot.
      </para>
      <para>
	The Debian distribution consists of free software
	accompanied with source.
	The source code within Debian's "main" section
	must build within Debian "main",
	with only the explicitly specified build-dependencies
	installed.
      </para>
      <para>
	The primary aim of pbuilder is different from other 
	auto-building systems in Debian in that its aim is not
	to try to build as many packages as possible. 
        It does not try to guess
	what a package needs, and in most cases it tries the
	worst choice of all if there is a choice to be made.
      </para>
      <para>
	In this way, <command>pbuilder</command> tries to ensure 
	that packages 
	tested against pbuilder will build properly in 
	most Debian installations, hopefully resulting
	in a good overall Debian source-buildability.
      </para>
      <para>
	The goal of making Debian buildable from source is 
	somewhat accomplished, and has seen good progress.
	It is known that Debian 3.0 is not quite 
	buildable from source, but the next version should 
	be better, and the version after.
      </para>
    </sect1>
  </chapter>
  <chapter id="usingpbuilder">
    <title>Using pbuilder</title>
    <sect1 id="creatingbase">
      <title>Creating a base chroot image</title>
      <para>
	<command>pbuilder create</command>
	will create a base chroot image.
	The distribution code-name needs to be specified with 
	the <command><option>--distribution</option></command>
	command-line option.
	Usually, "sid" is used, and the default is now sid.
      </para>
      <para>
	<command>debootstrap</command> is used to create 
	the bare minimum Debian installation, 
	and then build-essential packages are installed on top 
	of the minimum installation using <command>apt-get</command> 
	inside the chroot.
      </para>
      <para>
	For fuller documentation of command-line options, see
	the pbuilder.8 manual page.
	Some configuration will be required for <filename>/etc/pbuilderrc</filename>
	for the mirror site
	<footnote>
	  <para>
	    The mirror site should preferably be
	    a local mirror or a cache server,
	    so as not to overload the public mirrors with
	    a lot of access.
	    Use of tools such as apt-proxy would be advisable.
	  </para>
	</footnote>
	to use, and proxy configuration may be required to allow access
	through HTTP.
	See the pbuilderrc.5 manual page for details.
      </para>
    </sect1>
    <sect1>
      <title>Updating the base chroot image</title>
      <para><command>pbuilder update</command>
	will update the chroot image.
	It will extract the chroot, invoke <command>apt-get update</command>
	and <command>apt-get dist-upgrade</command> inside the 
	chroot, and then recreate the base tarball.
      </para>
      <para>
	It is possible to switch the distribution which the chroot 
	tarball is targeted at at this point.
	Specify <command><option>--distribution <parameter>sid</parameter></option> <option>--override-config</option></command> to change the distribution
	to sid.
	<footnote>
	  <para>Only upgrading is supported.
	  Debian does not generally support downgrading (yet?).</para>
	</footnote>
      </para>
      <para>
	For fuller documentation of command-line options, see
	the pbuilder.8 manual page
      </para>
    </sect1>
    <sect1 id="buildpackagechroot">
      <title>Building a package using the chroot image</title>
      <para>
	To build a package inside the chroot, invoke
	<command>pbuilder build <option>whatever.dsc</option></command>.
	<command>pbuilder</command> will extract 
	the chroot image to a temporary working directory,
	and satisfy the build-dependencies inside the chroot,
	and build the package.
	The built packages will be moved to a 
	directory specified with 
	the <command><option>--buildresult</option></command>
	command-line option.
      </para>
      <para>
	The <command><option>--basetgz</option></command> option can be 
	used to specify which chroot image to use.
      </para>
      <para>
	<command>pbuilder</command> will extract a fresh chroot image
	created with <command>pbuilder build</command>
	and updated with <command>pbuilder update</command>,
	and populate the chroot with build-dependencies by parsing 
	debian/control and invoking <command>apt-get</command>.
      </para>
      <para>
	For fuller documentation of command-line options, see
	the pbuilder.8 manual page
      </para>
    </sect1>
    <sect1 id="pdebuild">
      <title>Facilitating Debian Developers' typing, pdebuild</title>
      <para>
	<command>pdebuild</command> is a little wrapper 
	script that does the most frequent of all tasks.
	A Debian Developer may try to do <command>debuild</command>, and 
	build a package, inside a Debian source directory.
	<command>pdebuild</command> will allow similar 
	control, and allow package to be built inside the chroot,
	to check that the current source tree will build happily
	inside the chroot.
      </para>
      <para>
	<command>pdebuild</command> calls <command>dpkg-source</command>
	to build the source packages, and then invokes
	<command>pbuilder</command> on the resulting source package.
	However, unlike debuild, the resulting deb files will be
	found in the <command><option>--buildresult</option></command>
	directory.
      </para>
      <para>
	See the pdebuild.1 manual page for more details.
      </para>
      <para>
	There is a slightly different mode of operation available 
	in pdebuild since version 0.97. pdebuild usually runs
	<command>debian/rules clean</command> outside of the chroot;
	however, it is possible to change the behavior to run it
	inside the chroot with
	the <command><option>--use-pdebuild-internal</option></command>.
	<!-- FIXME: name of option is misleading, change it?
	 maybe when it's more useful.
	-->
	It will try to bind mount the working directory inside chroot, 
	and run <command>dpkg-buildpackage</command> inside.
	It has the following characteristics, and thus cannot be made default.
      </para>
      <itemizedlist>
	<listitem>
	  <para>The working directory is modified
	  from inside the chroot.</para>
	</listitem>
	<listitem>
	  <para>Building with pdebuild does not guarantee
	  that it works with pbuilder.</para>
	</listitem>
	<listitem>
	  <para>If making the source package fails,
	  the session using the chroot is wasted
	  (chroot creation takes a bit of time).</para>
	</listitem>
	<listitem>
	  <para>Does not work in the same manner as it used to;
	  for example, <command><option>--buildresult</option></command>
	  does not have any effect.</para>
	</listitem>
      </itemizedlist>

    </sect1>
    <sect1 id="configfile">
      <title>Configuration Files</title>
      <para>
	It is possible to specify all settings by command-line
	options. However, for typing convenience, it is possible to 
	use a configuration file.
      </para>
      <para>
	<filename>/etc/pbuilderrc</filename> and 
	<filename>${HOME}/.pbuilderrc</filename>
	are read in when pbuilder is invoked.
	The possible options are documented in 
	the pbuilderrc.5 manual page.
      </para>
      <para>
	It is useful to use --configfile option to load up a pre-set
	configuration file  when switching between configuration files for 
	different distributions.
      </para>
    </sect1>
    <sect1 id="nonrootchroot">
      <title>Building packages as non-root inside the chroot</title>
      <para>
	<command>pbuilder</command> requires full root privilege 
	when it is satisfying the build-dependencies, but most packages do not 
	need root privilege, or fail to build when they are root.
	<command>pbuilder </command> can create a user which is only used 
	inside <command>pbuilder </command> and use that user id when
	building, and use the <command>fakeroot</command> command
	when root privilege is required.
      </para>
      <para>
	BUILDUSERID configuration option should be set to a value for a user id that
	does not already exist on the system, so that it is more difficult for 
	packages that are being built with 
	<command>pbuilder</command> to affect the environment outside the chroot.
	When BUILDUSERNAME configuration option is also set,  
	pbuilder will use the specified user name and fakeroot for building packages,
	instead of running as root inside chroot.
      </para>
      <para>
	Even when using the fakerooting method, pbuilder will run with 
	root privilege when it is required.
	For example, when installing
	packages to the chroot, pbuilder will run under root privilege.
      </para>
      <para>
	To be able to invoke pbuilder without being 
	root, you need to use user-mode-linux, as explained
	in <xref linkend="pbuilder-uml"/>.
      </para>
    </sect1>
    <sect1 id="backporting">
      <title>Using pbuilder for back-porting</title>
      <para>
	pbuilder can be used for back-porting software from 
	the latest Debian distribution to 
	the older stable distribution, by using a chroot that contains
	an image of the older distribution, and building packages inside the
	chroot.
	There are several points to consider, and due to the following reasons,
	automatic back-porting is usually not possible, and 
	manual interaction is required:
      </para>
      <itemizedlist>
	<listitem>
	  <para>The package from the unstable distribution
	  may depend on packages or versions of packages which
	  are only available in unstable.
	  Thus, it may not be possible to satisfy Build-Depends:
	  on stable (without additional backporting work).</para>
	</listitem>
	<listitem>
	  <para>The stable distribution may have bugs that have been
	  fixed in unstable which need to be worked around.</para></listitem>
	<listitem>
	  <para>The package in the unstable distribution may have
	  problems building even on unstable.</para>
	</listitem>
      </itemizedlist>
    </sect1>
    <sect1 id="massbuild">
      <title>Mass-building packages</title>
      <para>
	pbuilder can be automated, because its operations are
	non-interactive.
	It is possible to run pbuilder through multiple packages 
	non-interactively.
	Several such scripts are known to exist.
	Junichi Uekawa has been running such a script since 2001,
	and has been filing bugs on packages that fail the 
	test of pbuilder. There were several problems with auto-building:
      </para>
      <itemizedlist>
	<listitem>
	  <para>Build-Dependencies need to install non-interactively, but 
	    some packages are so broken that they cannot install 
	    without interaction (like postgresql).</para>
	</listitem>
	<listitem>
	  <para>When a library package breaks, or gcc/gcj/g++ breaks, 
	    or even bison, a large number of build failures are reported.
	    (gcj-3.0 which had no "javac", bison which got more strict, etc.)
	  </para>
	</listitem>
	<listitem>
	  <para>Some people were quite hostile against build failure reports.</para>
	</listitem>
      </itemizedlist>
      <para>
	But most of these problems are now getting solved.
	Only about 10% of Debian now fails to build from source (29 Dec 2002).
	<!-- TODO: update for 2004/2005 time frame? -->
      </para>
      <para>
	A script that was used by Junichi Uekawa is now included in 
	the pbuilder distribution, as <command>pbuildd.sh</command>.
	It is available in <filename>/usr/share/doc/pbuilder/examples/pbuildd/</filename>
	and its configuration is in <filename>/etc/pbuilder/pbuildd-config.sh</filename>.
	It should be easy enough to set up for people who are used to 
	pbuilder. It has been running for quite a while, and it should be 
	possible to set the application up on your system also.
	However, it is a new introduction, and please file bugs
	to the Debian BTS if you know of possible problems,
	or improved on the script considerably.
      </para>
      <para>
	To set up pbuildd, there are some points to be aware of.
      </para>
      <itemizedlist>
	<listitem>
	  <para>A file <filename>./avoidlist</filename> needs to be available with the list of packages to avoid building. </para>
	</listitem>
	<listitem>
	  <para>It will try building anything, even packages
	  which are not aimed for your architecture.</para>
	</listitem>
	<listitem>
	  <para>Because you are running random build scripts, it is better to use 
	  the fakeroot option of pbuilder, to avoid running the build
	  under root privilege.</para>
	</listitem>
	<listitem>
	  <para>Because not all builds are guaranteed to finish in a finite time,
	    setting a timeout is probably necessary, or pbuildd may stall with
	    a bad build.</para>
	</listitem>
	<listitem>
	  <para>
	    Some packages require a lot of disk space, 
	    around 2GB seems to be sufficient for the largest packages for the time being.
            If you find otherwise, please inform the maintainer of this documentation.
	  </para>
	</listitem>
      </itemizedlist>
    </sect1>
    <sect1>
      <title>Auto-backporting scripts</title>
      <para>
	There are some people who use pbuilder to automatically back-port
	a subset of packages to the stable distribution.
      </para>
      <para>
	I would like some information on how people are doing it,
	I would appreciate any feedback or information on 
	how you are doing, or any examples.
      </para>
    </sect1>
    <sect1 id="autotesting">
      <title>Using pbuilder for automated testing of packages</title>
      <para>
	pbuilder can be used for automated testing of packages.
	It has the feature of allowing hooks to be placed,
	and these hooks can try to install packages inside
	the chroot, or run them, or whatever else that 
	can be done. Some known tests and ideas:
      </para>
      <itemizedlist>
	<listitem>
	  <para>Automatic install-remove-upgrade-remove-install-purge-upgrade-purge testsuite (distributed as an example, <filename>B91dpkg-i</filename>), 
	    or just check that everything installs somewhat (<filename>execute_installtest.sh</filename>).</para>
	</listitem>

	<listitem>
	  <para>Automatically running lintian/linda (distributed as an example in
	    <filename>/usr/share/doc/pbuilder/examples/B90linda</filename>).</para>
	</listitem>
	<listitem>
	  <para>Automatic debian-test of the package?
	  The debian-test package has been removed from Debian.
	  Someone please reintroduce it.</para>
	</listitem>
     </itemizedlist>
    </sect1>
    <sect1 id="altcompiler">
      <title>Using pbuilder for testing builds with alternate compilers</title>
      <para>
	Most packages are compiled with <command>gcc</command> 
	or <command>g++</command>
	and using the default compiler version, which was gcc 2.95 for Debian GNU/Linux 3.0 (i386).
	However, Debian 3.0 was distributed with other compilers, under package names
        such as <command>gcc-3.2</command> for gcc compiler 
	version 3.2.
	It was therefore possible to try compiling packages against different
	compiler versions.
	<command>pentium-builder</command> provides an infrastructure for 
	using a different compiler for building packages than the default gcc, by
	providing a wrapper script called gcc which calls the real gcc.
	To use <command>pentium-builder</command> in <command>pbuilder</command>, it is possible to set up the
	following in the configuration:
	<screen>
EXTRAPACKAGES="pentium-builder gcc-3.2 g++-3.2"
export DEBIAN_BUILDARCH=athlon
export DEBIAN_BUILDGCCVER=3.2
	</screen>
      </para>
      <para>
	It will instruct <command>pbuilder</command> to install the <command>pentium-builder</command> package 
	and also the GCC 3.2 compiler packages inside the chroot,
	and set the environment variables required for 
	<command>pentium-builder</command> to function.
      </para>
    </sect1>
  </chapter>

  <chapter id="pbuilder-uml">
    <title>Using User-mode-linux with pbuilder</title>
    <para>
      It is possible to use user-mode-linux
      by invoking <command>pbuilder-uml</command>
      instead of <command>pbuilder</command>.
      <command>pbuilder-uml</command> doesn't require
      root privileges, and it uses
      the copy-on-write (COW) disk access method of User-mode-linux
      which typically makes it much faster
      than the traditional <command>pbuilder</command>.
    </para>
    <para>
      User-mode-linux is a somewhat less proven platform
      than the standard Unix tools which
      <command>pbuilder</command> relies on
      (<command>chroot</command>,
      <command>tar</command>,
      and <command>gzip</command>)
      but mature enough to support <command>pbuilder-uml</command>
      since its version 0.59.
      And since then, pbuilder-uml has seen a rapid evolution.
    </para>
    <para>
      The configuration of pbuilder-uml goes in three steps:
      <itemizedlist>
	<listitem>
	  <para>Configuration of user-mode-linux</para>
	</listitem>
	<listitem>
	  <para>Configuration of rootstrap</para>
	</listitem>
	<listitem>
	  <para>Configuration of pbuilder-uml</para>
	</listitem>
      </itemizedlist>
    </para>
    <sect1 id="user-mode-linux-config">
      <title>Configuring user-mode-linux</title>
      <para>
	UML isn't completely trivial to set up.
	It would probably be useful to acquaint yourself with it a bit
	before attempting to use rootstrap or pbuilder-uml.
	For details,
	read <filename>/usr/share/doc/uml-utilities/README.Debian</filename>
	and the user-mode-linux documentation.
	(It's in a separate package, user-mode-linux-doc.)
      </para>
      <para>
	<command>user-mode-linux</command> requires 
	the user to be in the uml-net group in order to configure the network 
	unless you are using slirp.
      </para>
      <para>
	If you compile your own kernel, you may want to
	verify that you enable TUN/TAP support,
	and you might want to consider the SKAS patch.
      </para>
    </sect1>
    <sect1 id="rootstrap">
      <title>Configuring rootstrap</title>
      <para>
	<command>rootstrap</command>
	is a wrapper around debootstrap.
	It creates a Debian disk image for use with UML.
	To configure rootstrap, there are several requirements.
      </para>
      <itemizedlist>
	<listitem>
	  <para>Install the rootstrap package.</para>
	</listitem>
	<listitem>
	  <para>
	    TUN/TAP only: 
	    add the user to the uml-net group to allow access to the network
	    <screen>
adduser dancer uml-net
	    </screen></para>
	</listitem>
	<listitem>
	  <para>TUN/TAP only: 
	    Check that the kernel supports the TUN/TAP interface,
	    or recompile the kernel if necessary.
	  </para>
	</listitem>
	<listitem>
	  <para>Set up <filename>/etc/rootstrap/rootstrap.conf</filename>.
	    For example,
	    if the current host is 192.168.1.2, changing following 
	    entries to something like this seems to work.
	    <screen>
transport=tuntap
interface=eth0
gateway=192.168.1.1
mirror=http://192.168.1.2:8081/debian
host=192.168.1.198
uml=192.168.1.199
netmask=255.255.255.0
	    </screen>
	    Some experimentation with configuration and running
	    <command>rootstrap ~/test.uml</command> to actually 
	    test it would be handy.
	  </para>
	  <para>
	    Using slirp requires less configuration. 
	    The default configuration comes with a working example.
	  </para>
	</listitem>
      </itemizedlist>
    </sect1>
    <sect1 id="pbuilderumlconfig">
      <title>Configuring pbuilder-uml</title>
      <para>
	The following needs to happen:
	<itemizedlist>
	  <listitem>
	    <para>Install the pbuilder-uml package.</para>
	  </listitem>
	  <listitem>
	    <para>
	      Set up the configuration file
	      <filename>/etc/pbuilder/pbuilder-uml.conf</filename>
	      in the following manner. It will be different for slirp.
	      <screen>
MY_ETH0=tuntap,,,192.168.1.198
UML_IP=192.168.1.199
UML_NETMASK=255.255.255.0
UML_NETWORK=192.168.1.0
UML_BROADCAST=255.255.255.255
UML_GATEWAY=192.168.1.1
PBUILDER_UML_IMAGE="/home/dancer/uml-image"
	      </screen>
	      Also, it needs to match the rootstrap configuration.
	    </para>
	  </listitem>
	  <listitem>
	    <para>
	      Make sure BUILDPLACE is writable by the user.
	      Change BUILDPLACE in the configuration file to a place
	      where the user has access.
	    </para>
	  </listitem>
	  <listitem>
	    <para>Run <command>pbuilder-user-mode-linux create --distribution sid</command> to create the image.</para>
	  </listitem>
	  <listitem>
	    <para>Try running <command>pbuilder-user-mode-linux build</command>.</para>
	  </listitem>
	</itemizedlist>
      </para>
    </sect1>
    <sect1 id="consideruml">
      <title>Considerations for running pbuilder-uml</title>
      <para>
	pbuilder-user-mode-linux emulates most of pbuilder, but there
	are some differences.
      </para>
      <itemizedlist>
	<listitem>
	  <para>	  
	    pbuilder-user-mode-linux does not support all options of pbuilder
	    properly yet. This is a problem, and will be addressed as 
	    specific areas are discovered.
	  </para>
	</listitem>
	<listitem>
	  <para>
	    /tmp is handled differently inside pbuilder-uml.
	    In pbuilder-uml, /tmp is mounted as tmpfs inside UML,
	    so accessing files under /tmp from outside user-mode-linux
	    does not work.
	    It affects options like
	    <command><option>--configfile</option></command>,
	    and when trying to build packages placed under <filename>/tmp</filename>.
	  </para>
	</listitem>
      </itemizedlist>
    </sect1>
    <sect1 id="paralleluml">
      <title>Parallel running of pbuilder-user-mode-linux</title>
      <para>
	To run pbuilder-uml in parallel on a system, there are a few things 
	to bear in mind.
      </para>
      <itemizedlist>
	<listitem>
	  <para>The create and update methods must not be run when
	  a build is in progress, or the COW file will be invalidated.</para>
	</listitem>
	<listitem>
	  <para>
	    If you are not using slirp, UML processes which are
	    running in parallel need to have different IP addresses.
	    Just trying to run the <command>pbuilder-uml</command> 
	    several times will result in failure to access the network.
	    But something like the following will work:
	    <screen>
for IP in 102 103 104 105; do
  xterm -e pbuilder-user-mode-linux build --uml-ip 192.168.0.$IP \
    20030107/whizzytex_1.1.1-1.dsc &amp;
done 
	    </screen>
	    When using slirp, this problem does not exist.
	  </para>
	</listitem>
      </itemizedlist>
    </sect1>
    <sect1 id="pbuilderumlwrap">
      <title>Using pbuilder-uml as a wrapper script to start up a virtual machine</title>
      <para>
	It is possible to use pbuilder-uml for other uses than just building Debian 
	packages.
	<command>pbuilder-user-mode-linux login</command>
	will let a user use a shell inside the user-mode-linux
	pbuilder base image,
	and <command>pbuilder-user-mode-linux execute</command> will
	allow the user to execute a script inside the image.
      </para>
      <para>
	You can use the script to install ssh and add a new user,
	so that it is possible to access inside the UML through ssh.
      </para>
      <para>
	Note that it is not possible to use a script from 
	<filename>/tmp</filename> due to the way pbuilder-uml mounts 
	a tmpfs at <filename>/tmp</filename>.
      </para>
      <para>
	The following example script may be useful in starting a sshd 
	inside uml.
      </para>
      <screen>
#!/bin/bash

apt-get install -y ssh xbase-clients xterm
echo "enter root password"
passwd
cp /etc/ssh/sshd_config{,-}
sed 's/X11Forwarding.*/X11Forwarding yes/' /etc/ssh/sshd_config- &gt; /etc/ssh/sshd_config

/etc/init.d/ssh restart
ifconfig
echo "Hit enter to finish"
read
      </screen>
    </sect1>
  </chapter>
  <chapter id="faq">
    <title>Frequently asked questions </title>
    <!-- Start of FAQ -->
    <para>
      Here, known problems and frequently asked questions are
      documented. This portion was initially available in README.Debian
      file, but moved here.
    </para>
    <sect1>
      <title>pbuilder create fails</title>
      <para>
	It often happens that pbuilder cannot create the latest chroot.
	Try upgrading pbuilder and debootstrap.
	It is currently only possible to create software that handles the 
	past. Future prediction is a feature which may be added later after 
	we have become comfortable with the past. 
      </para>
      <para>
	There are people who occasionally backport debootstrap to stable
	versions; hunt for them.
      </para>
      <para>
	When there are errors with the debootstrap phase,
	the debootstrap script needs to be fixed.
	pbuilder does not provide a way to work around debootstrap.
      </para>
    </sect1>
    <sect1 id="bindmountlimits">
      <title>Directories that cannot be bind-mounted</title>
      <para>
	Because of the way pbuilder works, there are several directories 
	which cannot be bind-mounted when running pbuilder.
	The directories include <filename>/tmp</filename>,
	<filename>/var/cache/pbuilder</filename>, 
	and system directories such as <filename>/etc</filename> and
	<filename>/usr</filename>.
	The recommendation is to use directories under the user's home directory
	for bind-mounts.
      </para>
    </sect1>
    <sect1 id="modifyupdate">
      <title>Logging in to pbuilder to modify the environment</title>
      <para>
	It is sometimes necessary to modify the chroot environment.
	<command>login</command> will remove the contents of the chroot after logout.
	It is possible to invoke a shell using hook scripts.
	<command>pbuilder update</command> executes 'E' scripts,
	and a sample for invoking a shell
	is provided as <filename>C10shell</filename>.
      </para>
      <screen>
$ mkdir ~/loginhooks
$ cp C10shell ~/loginhooks/E10shell
$ sudo pbuilder update --hookdir ~/loginhooks/E10shell
      </screen>
      <para>
	It is also possible to add --save-after-exec
	and/or --save-after-login options
	to the <command>pbuilder login</command> session
	to accomplish the goal.
	It is possible to add the --uml-login-nocow option
	to <command>pbuilder-user-mode-linux login</command> session
	as well.
      </para>
    </sect1>
    <sect1 id="BUILDRESULTUID">
      <title>Setting BUILDRESULTUID for sudo sessions</title>
      <para>
	It is possible to set BUILDRESULTUID=$SUDO_UID in pbuilderrc 
	to set the proper BUILDRESULTUID when using sudo.
      </para>
    </sect1>
    <sect1 id="tmpdir">
      <title>Notes on usage of $TMPDIR</title>
      <para>
	If you are setting $TMPDIR to an unusual value, of other than
	<filename>/tmp</filename>, you will find that some errors may occur inside the chroot,
	such as <command>dpkg-source</command> failing.
      </para>
      <para>There are two options, you may install a hook to create that
	directory, or set 
	<screen>export TMPDIR=/tmp</screen>
	in pbuilderrc. Take your pick.
      </para>
      <para>
	An example script is provided as 
	<filename>examples/D10tmp</filename> with pbuilder.
      </para>
    </sect1>
    <sect1 id="DISTRIBUTIONSWITCH">
      <title>Creating a shortcut for running pbuilder with a specific distribution</title>
      <para>
	When working with multiple chroots, it would be nice to work with 
	scripts that reduce the amount of typing.
	An example script 
	<filename>pbuilder-distribution.sh</filename> is provided as an example.
	Invoking the script as <filename>pbuilder-woody</filename> will invoke
	pbuilder with a woody chroot.
      </para>
    </sect1>
    <sect1>
      <title>Using special apt sources lists</title>
      <para>
	If you have some very specialized requirements on your 
	apt setup inside pbuilder, 
	it is possible to specify that through 
	the <command><option>--othermirror</option></command>
	option.
	Try something like:
	<command><option>--othermirror "deb http://local/mirror stable main|deb-src http://local/source/repository ./"</option></command>
      </para>
      <para>
	To use the local filesystem instead of http, it is necessary to do 
	bind-mounting.
	<command><option>--bindmounts</option></command>
	is a command-line option useful for such cases.
      </para>
    </sect1>
    <sect1>
      <title>How to get pbuilder to run apt-get update before trying to satisfy build-dependency</title>
      <para>
	You can use hook scripts for this.
	D scripts are run before satisfying build-dependency.
      </para>
    </sect1>
    <sect1>
      <title>Different bash prompts inside pbuilder login</title>
      <para>
	To make distinguishing bash prompts inside pbuilder
	easier, it is possible to set environment variables such as PS1
	inside <filename>pbuilderrc</filename>
      </para>
      <para>
	With versions of bash more recent than 2.05b-2-15,
	the value of the debian_chroot variable, if set,
	is included in the value of PS1 (the Bash prompt)
	inside the chroot.
	In prior versions of bash,<footnote>
	  <para>Versions of bash from and before Debian 3.0</para>
	</footnote>
	setting PS1 in pbuilderrc worked.
      </para>
      <para>example of debian_chroot</para>
      <screen>
	export debian_chroot="pbuild$$"
      </screen>
      <para>example of PS1</para>
      <screen>
	export PS1="pbuild chroot 32165 # "
      </screen>
    </sect1>
    <sect1>
      <title>Using /var/cache/apt/archives for the package cache</title>
      <para>
	For the help of low-bandwidth systems,
	it is possible to use <filename>/var/cache/apt/archives</filename> as the 
	package cache.
	Just specify it instead of the default <filename>/var/cache/pbuilder/aptcache</filename>.
      </para>
      <para>
	It is however not possible to do so currently with the user-mode-linux 
	version of pbuilder, because <filename>/var/cache/apt/archives</filename>
	is usually only writable by root.
      </para>
      <para>
	Use of dedicated tools such as apt-proxy is recommended, since caching of packages 
	would benefit the system outside the scope of pbuilder.
      </para>
    </sect1>
    <sect1 id="woodybackport">
      <title>pbuilder backported to stable Debian releases</title>
      <para>
	It is known that Brian May does a backport of 
	pbuilder, available at:
	<screen>deb http://www.microcomaustralia.com.au/debian/ woody main</screen>
      </para>
    </sect1>
    <sect1 id="LOGNAME">
      <title>Warning about LOGNAME not being defined</title>
      <para>
	You might see a lot of warning messages when running pbuilder.
      </para>
      <para>
	<screen>
	dpkg-genchanges: warning: no utmp entry available and LOGNAME not defined; using uid of process (1234)
	</screen>
      </para>
      <para>
	It is currently safe to ignore this warning message.
	Please report back if you find any problem with having LOGNAME unset.
	Setting LOGNAME caused a few problems when invoking chroot.
      </para>
    </sect1>
    <sect1 id="nobuildconflictessential">
      <title>Cannot Build-conflict against an essential package</title>
      <para>
	pbuilder does not currently allow Build-Conflicts against 
	essential packages.
	It should be obvious that essential packages should not be 
	removed from a working Debian system, and a source 
	package should not try to force removal of such packages 
	on people building the package.
      </para>
    </sect1>
    <sect1>
      <title>Avoiding the "ln: Invalid cross-device link" message</title>
      <para>
	By default, pbuilder uses hard links to manage the pbuilder package cache.
	It is not possible to make hard links across different devices; 
	and thus this error will occur, depending on your set up.
	If this happens, set <screen>APTCACHEHARDLINK=no</screen>
	in your pbuilderrc file.
      </para>
    </sect1>
    <sect1>
      <title>Using fakechroot</title>
      <para>
	It is possible to use <command>fakechroot</command> instead of being root
	to run pbuilder; however, several things make this impractical.
	<command>fakechroot</command> overrides library loads and tries to 
	override default libc functions when providing the functionality of
	virtual chroot.
	However, some binaries do no use libc to function, or override the overriding 
	provided by fakechroot. 
	One example is <command>ldd</command>.
	Inside <command>fakechroot</command>,
	<command>ldd</command>
	will check the library dependency outside of the chroot,
	which is not the expected behavior.
      </para>
      <para>
	To work around the problem, fakechroot provides a patch for debootstrap.
	Use that, so that ldd and ldconfig are overridden.
      </para>
      <para>
	Make sure you have set your path correctly, as described in <filename>/usr/share/doc/fakechroot/README.Debian</filename>
      </para>
    </sect1>
    <sect1 id="debconfinsidepbuilder">
      <title>Using debconf inside pbuilder sessions</title>
      <para>
	To use debconf inside pbuilder, setting DEBIAN_FRONTEND to 
	<quote>readline</quote> in <filename>pbuilderrc</filename> should work.
	Setting it to <quote>dialog</quote> should also work, but make sure
	whiptail or dialog is installed inside the chroot.
      </para>
    </sect1>
    <sect1 id="nodev">
      <title>nodev mount options hinder pbuilder activity</title>
      <para>
	If you see messages such as this when building a chroot, you are mounting the filesystem with 
	the nodev option.
      </para>
      <screen>
	/var/lib/dpkg/info/base-files.postinst: /dev/null: Permission denied
      </screen>
      <para>
	You will also have problems if you mount the filesystem with
	the noexec option, or nosuid.
	Make sure you do not have these flags set when mounting the filesystem for 
	<filename>/var/cache/pbuilder</filename> or $BUILDPLACE.
      </para>
      <para>
	This is not a problem when using User-mode-linux.
      </para>
    </sect1>
    <sect1 id="faqslowpbuilder">
      <title>pbuilder is slow</title>
      <para>
	pbuilder is often slow. The slowest part of pbuilder is extracting the tar.gz every time 
	pbuilder is invoked. That can be avoided by using <command>pbuilder-user-mode-linux</command>.
	<command>pbuilder-user-mode-linux</command> uses 
	COW filesystem, and thus does not need to clean up and recreate the root filesystem.
      </para>
      <para>
	pbuilder-user-mode-linux is slower in executing the actual build system, due to the 
	usual user-mode-linux overhead for system calls. It is more friendly to the hard drive.
      </para>
    </sect1>
    <sect1 id="chrootmemo">
      <title>Creating a chroot reminder</title>
      <para>
	You may want a sign that you are inside a chroot, when 
	working with chroot.
	Check out the <filename>examples/F90chrootmemo</filename>
	hook script.
	It will create a file called <filename>/CHROOT</filename>
	inside your chroot.
      </para>
    </sect1>
    <!-- end of FAQ -->
  </chapter>
  <chapter id="otheruse">
    <title>Other uses of pbuilder</title>
    <sect1 id="chroot">
      <title>Using pbuilder for small experiments</title>
      <para>
	There are cases when some small experimenting is required, and 
	you do not want to damage the main system,
	like when installing experimental library packages,
	or compiling with experimental compilers.
	For such cases, the <command>pbuilder login</command> command is available.
      </para>
      <para>
	<command>pbuilder login </command> is a debugging feature for 
	pbuilder itself, but it also allows users to have a temporary chroot.
      </para>
      <para>
	Note that the chroot is cleaned after logging out of the shell,
	and mounting file systems inside it is considered harmful.
      </para>
    </sect1>
    <sect1>
      <title>Running little programs inside the chroot</title>
      <para>
	To facilitate using pbuilder for other uses, 
	<command>pbuilder execute</command> is available.
	<command>pbuilder execute </command> will take a script 
	specified in the command-line argument, and 
	invoke the script inside the chroot.
      </para>
      <para>
	The script can be useful for sequences of operations such as
	installing ssh and adding a new user inside the chroot.
      </para>
    </sect1>
  </chapter>
  <chapter id="experimental">
    <title>Experimental or wish list features of pbuilder</title>
    <para>
      There are some advanced features, above that of the 
      basic feature of pbuilder, for some specific purposes.
    </para>
    <sect1 id="lvm">
      <title>Using LVM</title>
      <para>
	LVM has a snapshot function that features Copy-on-write images.
	That could be used for pbuilder just as it can be used for 
	the user-mode-linux pbuilder port.
	It may prove to be faster, but it is not implemented yet,
	and so no measurement has been made, yet.
      </para>
      <para>
	Since user-mode-linux port seems to be more interesting,
	this is abandoned.
      </para>
    </sect1>
    <sect1 id="withouttargz">
      <title>Using pbuilder without tar.gz</title>
      <para>
	The <command><option>--no-targz</option></command>
	option of <command>pbuilder</command>
	will allow usage of pbuilder in a different way
	from conventional usage.
	It will try to use an existing chroot, 
	and will not try to clean up after 
	working on it.
	It is an operation mode more like 
	<command>sbuild</command>.
      </para>
      <para>
	It should be possible to create chroot images
	for <command>dchroot</command> with the following commands:
	<screen>
# pbuilder create --distribution potato --no-targz --basetgz /chroot/potato
# pbuilder create --distribution woody --no-targz --basetgz /chroot/woody
# pbuilder create --distribution sid --no-targz --basetgz /chroot/sid
	</screen>
      </para>
    </sect1>
  </chapter>
  <chapter>
    <title>Minor details</title>
    <sect1>
      <title>Documentation history </title>
      <para>
	This document was started on 28 Dec 2002 by
	Junichi Uekawa, trying to document what is known
	about pbuilder.
      </para>
      <para>
	This documentation is available from the pbuilder source tarball,
	and from the CVS repository of pbuilder (web-based access is possible).
	A copy of this documentation can be found on the
	<ulink url="http://www.netfort.gr.jp/~dancer/software/pbuilder-doc/pbuilder-doc.html">Netfort page for pbuilder</ulink>.
	The homepage for pbuilder is 
	<ulink url="http://www.netfort.gr.jp/~dancer/software/pbuilder.html">
	  http://www.netfort.gr.jp/~dancer/software/pbuilder.html
	</ulink>
      </para>
    </sect1>
    <sect1 id="pbuilderbackgroundhistory">
      <title>Possibly inaccurate Background History of pbuilder</title>
      <para>
	The following is a most possibly inaccurate account of how 
	pbuilder came to happen, and other attempts to 
	make something like pbuilder happen.
	This part of the document was originally in the AUTHORS file,
	to give credit to those who existed before pbuilder.
      </para>
      <sect2>
	<title>The Time Before pbuilder</title>
	<para>
	  There was once dbuild, which was a shell script to build
	  Debian packages from source. Lars Wirzenius wrote that 
	  script, and it was good, short, and simple (probably).
	  There was nothing like build-depends then (I think), and it was simple.
	  It could have been improved, I could only find references and no actual source.
	</para>
	<para>
	  debbuild was probably written by James Troup. I don't know it 
	  because I have never seen the actual code, I could only find some
	  references to it on the net, and mailing list logs.
	</para>
	<para>
	  sbuild is a perl script to build Debian packages from source.
	  It parses Build-Depends, and performs other miscellaneous checks,
	  and has a lot of hacks to actually get things building,
	  including a table of what package to use when virtual packages are
	  specified (does it do that still?).
	  It supports the use of a local database for packages which do not 
	  have build-dependencies. It was written by Ronan Hodek, 
	  and I think it was patched and fixed and extended by
	  several people. It is part of wanna-build, and used extensively
	  in the Debian buildd system. I think it was maintained
	  mostly by Ryan Murray.
	</para>
      </sect2>
      <sect2>
	<title>Birth of pbuilder</title>
	<para>
	  wanna-build (sbuild) was (at the time of year 2001) quite difficult to 
	  set up, and it was never a Debian package. dbuild was something that predated
	  Build-Depends.
	</para>
	<para>
	  Building packages from source using Build-Depends 
	  information within a chroot sounded trivial; and 
	  pbuilder was born. It was initially a shell script
	  with only a few lines, which called debootstrap
	  and chroot and dpkg-buildpackage in the same run,
	  but soon, it was decided that that's too slow.
	</para>
	<para>
	  Yes, and it took almost an year to get things somewhat 
	  right, and in the middle of the process, Debian 3.0
	  was released. Yay.
	  Debian 3.0 wasn't completely buildable with pbuilder,
	  but the amount of packages which are not buildable
	  is steadily decreasing. (I hope)
	</para>
      </sect2>
      <sect2>
	<title>And the second year of its life</title>
	<para>
	  Someone wanted pbuilder to not run as root,
	  and as User-mode-linux has become more useful as time passed,
	  I've started experimenting with pbuilder-uml.
	  pbuilder-uml has not been able to run as often as it should,
	  and bootstrapping user-mode-linux environment has been
	  pretty hard.
	</para>
	<para>
	  The third and fourth year is already here. pbuilder is widely adopted,
	  and activity is focused on fixing minor problems.
	  Some features have been added, but most of the work has been
	  filling in the missing portions of the user-mode-linux port.
	</para>
      </sect2>
    </sect1>
  </chapter>
</book>