| 134 | | The configuration of packages is found [http://trac.hackable1.org/trac/browser/trunk/build/packages here]. There is one file per package, and they are sourced after the extraction process if they are installed. They can have a different logic depending on the target platform and actual purpose of the image. |
| 135 | | |
| 136 | | == Known problems == |
| 137 | | |
| 138 | | === Dependency resolving is not perfect === |
| 139 | | |
| 140 | | Dependencies are not resolved recursively at the moment. They rely on proper information from the `Packages.gz` files. |
| 141 | | |
| 142 | | === Installation hook scripts are not executed === |
| 143 | | |
| 144 | | There's no simple way around this one. It needs to be duplicated in the configuration files as described above. |
| | 134 | As packages are simply extracted into the staging directory before |
| | 135 | building the actual image, they are configured with their default |
| | 136 | settings, or sometimes not at all. Each package can be configured inside |
| | 137 | the packages directory, within a shell script of the same name. |
| | 138 | |
| | 139 | These shell scripts rely on a number of variables. The options defined |
| | 140 | above can be used to alter the behaviour of the scripts, and hence the |
| | 141 | final configuration of the images to be generated (eg the |
| | 142 | VENDOR-MODEL-PURPOSE profile). |
| | 143 | |
| | 144 | Other essential commands are available, and can be overriden as well: |
| | 145 | |
| | 146 | ||'''Variable'''||'''Description'''|| |
| | 147 | ||AR||Create, analyze and extract archives|| |
| | 148 | ||CHMOD||Change the permissions of files and directories|| |
| | 149 | ||CHOWN||Change the ownership of files and directories|| |
| | 150 | ||CP||Copy files and directories|| |
| | 151 | ||CUT||Process text data on the command-line|| |
| | 152 | ||DU||Query the disk space used by files and directories|| |
| | 153 | ||GREP||Look for given text patterns in files or on the command-line|| |
| | 154 | ||GUNZIP||Decompress files|| |
| | 155 | ||LN||Create and modify hard and symbolic links|| |
| | 156 | ||MKDIR||Create directories|| |
| | 157 | ||MKNOD||Create device nodes|| |
| | 158 | ||MV||Rename and move files and directories|| |
| | 159 | ||RMDIR||Delete directories|| |
| | 160 | ||RM||Delete files and directories|| |
| | 161 | ||SED||Replace content in files or on the command-line|| |
| | 162 | ||STRIP||Remove debugging|| |
| | 163 | ||TAR||Create, analyze and extract archives|| |
| | 164 | ||TOUCH||Create files and alter timestamps|| |
| | 165 | ||WGET||Download files over HTTP or FTP|| |
| | 166 | |
| | 167 | Some examples follow. |
| | 168 | |
| | 169 | Within packages/base-passwd: |
| | 170 | |
| | 171 | {{{ |
| | 172 | #/etc/passwd |
| | 173 | $SUDO$MKDIR "$DESTDIR/home/$USERNAME" || exit 2 |
| | 174 | $SUDO$CHMOD 0750 "$DESTDIR/home/$USERNAME" || exit 2 |
| | 175 | $SUDO$CHOWN 1000:1000 "$DESTDIR/home/$USERNAME" || exit 2 |
| | 176 | ${SUDO}sh -c "cat > \"$DESTDIR/etc/passwd\"" << EOF |
| | 177 | root:x:0:0:root:/root:/bin/sh |
| | 178 | $USERNAME:x:1000:1000:Hackable1 user:/home/hackable1:/bin/sh |
| | 179 | EOF |
| | 180 | }}} |
| | 181 | |
| | 182 | Within packages/bluez-utils: |
| | 183 | |
| | 184 | {{{ |
| | 185 | #/etc/rc?.d/S25bluetooth |
| | 186 | for i in 2 3 4 5; do |
| | 187 | $SUDO$MKDIR "$DESTDIR/etc/rc$i.d" || exit 2 |
| | 188 | $SUDO$LN -s "../init.d/bluetooth" |
| | 189 | "$DESTDIR/etc/rc$i.d/S25bluetooth" \ |
| | 190 | || exit 2 |
| | 191 | done |
| | 192 | }}} |
| | 193 | |
| | 194 | Within packages/fakeroot: |
| | 195 | |
| | 196 | {{{ |
| | 197 | #/usr/bin/fakeroot |
| | 198 | $SUDO$MKDIR "$DESTDIR/etc/alternatives" "$DESTDIR/usr/bin" || exit 2 |
| | 199 | $SUDO$LN -s "/usr/bin/fakeroot-tcp" "$DESTDIR/etc/alternatives/fakeroot" \ |
| | 200 | || exit 2 |
| | 201 | $SUDO$LN -s "/etc/alternatives/fakeroot" "$DESTDIR/usr/bin/fakeroot" \ |
| | 202 | || exit 2 |
| | 203 | }}} |
| | 204 | |
| | 205 | |
| | 206 | == Generating images == |
| | 207 | |
| | 208 | The operational mode of strap1 is fairly simple, and can be decomposed |
| | 209 | this way: |
| | 210 | |
| | 211 | 1. Resolve and cache dependencies |
| | 212 | 1. Extract the required packages |
| | 213 | 1. Create the device nodes |
| | 214 | 1. Configure the packages installed |
| | 215 | 1. Clean up the filesystem as required |
| | 216 | 1. Generate the final image |
| | 217 | |
| | 218 | |
| | 219 | === Packages dependencies === |
| | 220 | |
| | 221 | Debian packages repositories contain a Packages file, gathering the |
| | 222 | meta-data from the different packages in one convenient place. This is |
| | 223 | particularly welcome when resolving dependencies, and therefore listing |
| | 224 | the packages to be installed. There are a few relevant parameters there: |
| | 225 | |
| | 226 | * priorities: the essential packages have a particular "Priority" header, like "required", "important" or "standard"; if it matches PACKAGES_PRIORITY, the packages gets selected; |
| | 227 | * dependencies: the "Depends", "Pre-Depends" and "Recommends" headers are also used to select packages. |
| | 228 | |
| | 229 | Two files are created during this process: |
| | 230 | |
| | 231 | * depends/VENDOR-MODEL-PURPOSE.Depends |
| | 232 | * depends/VENDOR-MODEL-PURPOSE.Packages |
| | 233 | |
| | 234 | The "Depends" file contains the list of the packages selected for |
| | 235 | inclusion, while the "Packages" file gathers all of the meta-data in one |
| | 236 | file. The latter resembles dpkg's "available" file. |
| | 237 | |
| | 238 | |
| | 239 | === Packages extraction === |
| | 240 | |
| | 241 | Debian packages consist of an ar archive, with a meta-data archive |
| | 242 | member, and an optional archive to decompress. The extraction is |
| | 243 | performed without the dpkg tool, using the ar, gzip, bzip2 and tar |
| | 244 | utilities as required. |
| | 245 | |
| | 246 | The packages database is completed at the same time, always appending |
| | 247 | information to the "available" database, and appending information to |
| | 248 | the "status" database for the packages extracted. The list of files |
| | 249 | extracted, and the package meta-data is also placed in |
| | 250 | "/var/lib/dpkg/info". Minor modifications to ar's output are also |
| | 251 | necessary to format the "package.list" file properly. |
| | 252 | |
| | 253 | |
| | 254 | === Device nodes creation === |
| | 255 | |
| | 256 | At this stage, device nodes are created. The regular device node |
| | 257 | creation script from Debian is used in this process, with the |
| | 258 | appropriate architecture specified on the command line. |
| | 259 | |
| | 260 | This phase is only performed if the sbin/MAKEDEV script was installed on |
| | 261 | the target platform. Otherwise, it has to be performed from within the |
| | 262 | packages configuration scripts. |
| | 263 | |
| | 264 | This phase is the only one currently known not to be portable. It is |
| | 265 | automatically skipped by Debian's device node creation script when it |
| | 266 | detects a non-Linux system. |
| | 267 | |
| | 268 | |
| | 269 | === Configure the packages installed === |
| | 270 | |
| | 271 | As packages get extracted, they also need to be configured in the |
| | 272 | context of the image generated. Many packages also actually require some |
| | 273 | scripts and executables to be ran right before or after extraction. |
| | 274 | |
| | 275 | Unfortunately, in the case of hackable:1, the staging filesystem is |
| | 276 | often compiled for a different architecture than the native host. It is |
| | 277 | therefore impossible to run the configuration scripts. Instead, the |
| | 278 | necessary steps are reproduced within the "packages" directory. |
| | 279 | |
| | 280 | For each configuration script found in the "packages" directory, it is |
| | 281 | checked if the package of the same name was actually installed on the |
| | 282 | filesystem (by testing the presence of the |
| | 283 | "/var/lib/dpkg/info/package.list" file). If it is the case, the |
| | 284 | configuration script is sourced from within the build.sh script. |
| | 285 | |
| | 286 | It is possible to reproduce this phase at will, using the "config" |
| | 287 | target of the build.sh script. Beware that this can only work if the |
| | 288 | packages database information was kept (eg without the CLEAN_APT option |
| | 289 | set to "yes"). |
| | 290 | |
| | 291 | === Clean up the filesystem as required === |
| | 292 | |
| | 293 | Some operations can then be conducted in order to gain space. They were |
| | 294 | mentioned in the 2.2 section: |
| | 295 | |
| | 296 | ||'''Variable'''||'''Description'''|| |
| | 297 | ||CLEAN_APT||Deletes everything in /var/lib/dpkg|| |
| | 298 | ||CLEAN_DEVEL||Deletes /usr/include, /usr/lib/pkgconfig, /usr/lib/*.a...|| |
| | 299 | ||CLEAN_DOC||Deletes /usr/share/doc, /usr/share/man...|| |
| | 300 | ||CLEAN_KERNEL||Deletes /boot|| |
| | 301 | ||CLEAN_LOCALES||Deletes /usr/share/locales|| |
| | 302 | ||CLEAN_STRIP||Strips all the binaries found in /usr/bin, /usr/lib...|| |
| | 303 | |
| | 304 | |
| | 305 | === Generate the final image === |
| | 306 | |
| | 307 | Lastly, the filesystem is either saved as a compressed tar archive (the |
| | 308 | "archive" target), or packed as a ready-to-flash software image (the |
| | 309 | "image" target). Unfortunately, this phase is currently hard-coded |
| | 310 | within the build.sh script. |
| | 311 | |
| | 312 | |
| | 313 | == Comparison with debootstrap == |
| | 314 | |
| | 315 | In fact, strap1 implements parts of deboostrap, and extends it in some |
| | 316 | regards. |
| | 317 | |
| | 318 | === Why debootstrap is not enough === |
| | 319 | |
| | 320 | deboostrap is also useful to create Debian systems from scratch, without |
| | 321 | requiring dpkg or apt either. It is actually used by the Debian |
| | 322 | installer to initialize the system being installed. debootstrap consists |
| | 323 | of several thousands of lines of perl, of which cdebootstrap is an |
| | 324 | alternative implementation in C. |
| | 325 | |
| | 326 | However, both assume that the installer will resume the installation by |
| | 327 | chrooting to the target system, and then install and configure packages |
| | 328 | using the native tools. In many cases, this is not likely during |
| | 329 | embedded development. |
| | 330 | |
| | 331 | |
| | 332 | === Limitations of debootstrap === |
| | 333 | |
| | 334 | First, in Debian packages the configuration process is relying on the |
| | 335 | possibility to run native binary programs from within the target system. |
| | 336 | This is used to either automatically detect, or ask the user |
| | 337 | specifically the settings to apply. |
| | 338 | |
| | 339 | Moreover, debootstrap can not conveniently be used to generate systems |
| | 340 | from multiple source repositories. It is also not able to initialize the |
| | 341 | packages database as well as apt does itself. |
| | 342 | |
| | 343 | Finally, debootstrap stops at the packages extraction phase. It does not |
| | 344 | provide filesystem images ready to flash, nor a way to conveniently |
| | 345 | automatically reproduce images from updated packages. |
| | 346 | |
| | 347 | |
| | 348 | === Advantages of strap1 === |
| | 349 | |
| | 350 | strap1 addresses some of these issues already: |
| | 351 | |
| | 352 | * it can use multiple package repositories at once |
| | 353 | * it can generate valid packages databases, almost as complete as what apt does itself |
| | 354 | * it can configure packages cross-platform |
| | 355 | * it can generate final images. |
| | 356 | |
| | 357 | It is also very portable, and easy to extend: it consists only of a |
| | 358 | simple core script, along with individual profiles and configuration files. |
| | 359 | |
| | 360 | |
| | 361 | == Remaining issues == |
| | 362 | |
| | 363 | === Incomplete dependencies === |
| | 364 | |
| | 365 | Dependencies are not resolved recursively at the moment (this problem is |
| | 366 | also found in debootstrap). The images generated may therefore be |
| | 367 | incomplete in some cases. |
| | 368 | |
| | 369 | === Device nodes creation === |
| | 370 | |
| | 371 | Device nodes creation is not portable across Unix systems. This can |
| | 372 | sometimes be work-arounded with a tar archive of the necessary nodes, |
| | 373 | however it cannot be conveniently forced during the process at the moment. |
| | 374 | |
| | 375 | === Not always embedded === |
| | 376 | |
| | 377 | The stock Debian packages may not always fit in an embedded environment. |
| | 378 | More cooperation with the Emdebian project is certainly desirable. |
| | 379 | |
| | 380 | === Performance === |
| | 381 | |
| | 382 | The overall performance could be improved. |