| 1 |
The bootstrap-installer udeb is responsible for calling debootstrap to |
| 2 |
install the base system, as well as selecting and installing a kernel. |
| 3 |
|
| 4 |
The base-installer udeb provides a framework that can be used by |
| 5 |
alternative udebs that install the base system in other ways. A simplified |
| 6 |
example of using this framework: |
| 7 |
|
| 8 |
#!/bin/sh |
| 9 |
. /usr/share/debconf/confmodule |
| 10 |
. /usr/lib/base-installer/library.sh |
| 11 |
|
| 12 |
install_base_system () { |
| 13 |
# stuff to install base here |
| 14 |
# cd /target && tar zxvf /tmp/base.tgz |
| 15 |
log "base system installed!" |
| 16 |
} |
| 17 |
|
| 18 |
waypoint 1 check_target |
| 19 |
waypoint 1 pre_install_hooks |
| 20 |
waypoint 100 install_base_system |
| 21 |
waypoint 1 configure_apt |
| 22 |
waypoint 5 post_install_hooks |
| 23 |
waypoint 10 install_extra |
| 24 |
|
| 25 |
run_waypoints |
| 26 |
exit 0 |
| 27 |
|
| 28 |
|
| 29 |
The waypoints are positions on the progress bar, which will be |
| 30 |
automatically advanced to the next waypoint as each section of the base |
| 31 |
installation completes (you can also advance it manually within a step). In |
| 32 |
the example above all the sections except for install_base_system are |
| 33 |
provided by library.sh. As a section is running, the progress bar displays |
| 34 |
the text in the debconf template base-installer/debootstrap/section/<name>. |
| 35 |
|
| 36 |
|
| 37 |
On progress bars |
| 38 |
---------------- |
| 39 |
run-debootstrap translates the debootstrap progress stream into debconf |
| 40 |
progress bars. There are essentially two ways the progress information from |
| 41 |
debootstrap can be dislayed. The naive way is to start a new progress bar |
| 42 |
for each new progress id debootstrap dislays; the problem with this |
| 43 |
approach is it gives the user no clue as to the overall progress as they |
| 44 |
just see a bewildering series of progress bars. |
| 45 |
|
| 46 |
A more sophisticated approach is to use only one logical progress bar, and |
| 47 |
know about various debootstrap waypoints, using each as it appears to |
| 48 |
update the bar to a given point, and using the more detailed progress |
| 49 |
information to keep the bar updating in between. The waypoints we currently |
| 50 |
care about, and where the progress bar will be when they complete are |
| 51 |
listed in waypoints.h. |
| 52 |
|
| 53 |
Say between 30 and 50%, while downloading debs, debootstrap sends us |
| 54 |
progress commands telling us what the current amount done is, and what the |
| 55 |
total amount is. For example: |
| 56 |
|
| 57 |
P: 22422934 31625258 DOWNDEBS |
| 58 |
|
| 59 |
This is 22422934 / 31625258 = 70% of the way done with downloading debs. |
| 60 |
Since the DOWNDEBS waypoint uses 20% of the progress bar, that scales to |
| 61 |
70% of 20, or 14%. So the progress bar should be positioned to 30+14, or |
| 62 |
44%. |
| 63 |
|
| 64 |
Since we want to use the same progress bar for both run-debootstrap and |
| 65 |
for the end of the base-installer postinst, the actual setup of the |
| 66 |
progress bar should happen in base-installer's postinst. Then |
| 67 |
run-debootstrap just updates it to 90%, and finally the end of the |
| 68 |
postinst takes care of updating it to the final waypoint as it does the |
| 69 |
apt-install stuff. |
| 70 |
|
| 71 |
|
| 72 |
Appendix A: The debootstrap --debian-installer progress stream |
| 73 |
============================================================== |
| 74 |
|
| 75 |
As far as I know, there is no other documentation of the data debootstrap |
| 76 |
outputs on fd 3 if run with --debian-installer (except its source). |
| 77 |
But then I have not looked too hard. Here is what I have been able to piece |
| 78 |
together. |
| 79 |
|
| 80 |
The stream consists of a number of lines. Each line is of the form: |
| 81 |
CODE: arg1 [arg2 .. argn] |
| 82 |
|
| 83 |
The codes are: |
| 84 |
|
| 85 |
P (progress) |
| 86 |
arg1 is an integer, the current amount done |
| 87 |
arg2 is the total amount of work that must be done for this progress item |
| 88 |
arg3 is a unique identifier for the progress item. It may be omitted |
| 89 |
sometimes. |
| 90 |
|
| 91 |
P is generally followed by PA and PF to build up a message to dislay. If |
| 92 |
they are left off, an earlier info message can be displayed to indicate what |
| 93 |
is being done. |
| 94 |
|
| 95 |
PA (progress arguments) |
| 96 |
args combine to form the value of one argument |
| 97 |
|
| 98 |
PF (progress format) |
| 99 |
args combine to be a progress format string. |
| 100 |
|
| 101 |
PF (progress format) |
| 102 |
args combine to form a format string. The info arguments are then |
| 103 |
substituted in turn into the %s tokens in the string to form the message to |
| 104 |
display to the user to indicate progress. |
| 105 |
|
| 106 |
I (info) |
| 107 |
arg1 is an identifier for the information message in question |
| 108 |
Generally followed by an IA and IF. |
| 109 |
|
| 110 |
IA (info arguments) |
| 111 |
args combine to form the value of one argument |
| 112 |
|
| 113 |
IF (info format) |
| 114 |
args combine to form a format string. The info arguments are then |
| 115 |
substituted in turn into the %s tokens in the string to form the message to |
| 116 |
display to the user to indicate info. |
| 117 |
|
| 118 |
E (error) |
| 119 |
arg1 is the id of the error |
| 120 |
May be followed by EA, and EF |
| 121 |
|
| 122 |
EA (error arguments) |
| 123 |
args combine to form the value of one argument |
| 124 |
|
| 125 |
EF (error format) |
| 126 |
args combine to form a format string. The info arguments are then |
| 127 |
substituted in turn into the %s tokens in the string to form the error |
| 128 |
message. |
| 129 |
|
| 130 |
W (warning) |
| 131 |
arg1 is the id of the warning |
| 132 |
May be followed by WA, and WF |
| 133 |
|
| 134 |
WA (warning arguments) |
| 135 |
args combine to form the value of one argument |
| 136 |
|
| 137 |
WF (warning format) |
| 138 |
args combine to form a format string. The info arguments are then |
| 139 |
substituted in turn into the %s tokens in the string to form the warning |
| 140 |
message. |