slitaz-doc-wiki-data view pages/en/scratchbook/base-apps.txt @ rev 45

Update pages/en folder.
author Christopher Rogers <slaxemulator@gmail.com>
date Sun May 01 07:41:07 2011 +0000 (2011-05-01)
parents
children
line source
1 ====== Base Applications ======
3 Install and configure libraries and basic applications.
5 ===== About =====
7 This chapter describes the facilities libraries and basic text mode applications supplied with SliTaz.
9 ==== Assign an environment variable ($fs) ====
11 An environmental variable can't specify the path to the directory, just the name of the directory. We will affect a variable '$fs' to indicate the path to the root filesystem (rootfs). To do this, we venture into the working directory SliTaz/, and type:
13 # export fs=$PWD/rootfs
15 To check:
17 # echo $fs
19 ===== bc-1.06 - Text mode calculator =====
21 The application bc ([[http://www.gnu.org/software/bc/|www.gnu.org/software/bc/]]) provides a small calculator. When compiling the utility, dc is also built, but not installed by SliTaz. Note that dc is also available with BusyBox. If you decide to copy dc, you need to delete the link to BusyBox (if it exists). We use a directory _pkg (package) for installation, use strip to clean the executables and copy the utilities:
23 # cd src
24 # wget http://ftp.gnu.org/pub/gnu/bc/bc-1.06.tar.gz
25 # tar xzfv bc-1.06.tar.gz
26 # cd bc-1.06
27 # ./configure --prefix=/usr --infodir=/usr/share/info \
28 --mandir=/usr/share/man
29 # make
30 # make DESTDIR=$PWD/_pkg install
31 # strip -vs _pkg/usr/bin/*
32 # cp -avi _pkg/usr/bin/bc $fs/usr/bin
34 ==== libs ====
36 A small "ldd" on bc should produce:
37 <file>
38 libc.so.6 => /lib/libc.so.6 (0x40029000)
39 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
40 </file>
41 ===== zlib-1.2.3 - Compression libraries =====
43 The zlib (http://www.zlib.net/) package provides compression and decompression functions used by among others, the SSH server Dropbear and the X server:
45 # cd ..
46 # wget http://www.gzip.org/zlib/zlib-1.2.3.tar.bz2
47 # tar xjfv zlib-1.2.3.tar.bz2
48 # cd zlib-1.2.3
49 # ./configure --shared --prefix=/usr
50 # make
51 # strip -vs libz.so*
52 # cp -av libz.so* $fs/usr/lib
54 ===== pcre-7.4 - Perl-compatible regular expressions =====
56 The package pcre (http://www.pcre.org/) provides libraries of functions for Perl compatible regular expressions used by among others, the web server Lighttpd:
58 # cd ..
59 # wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.4.tar.gz
60 # tar xzfv pcre-7.4.tar.gz
61 # cd pcre-7.4
62 # ./configure --prefix=/usr
63 # make
64 # make DESTDIR=$PWD/_pkg install
65 # strip -vs _pkg/usr/bin/*
66 # strip -vs _pkg/usr/lib/*
67 # cp -av _pkg/usr/bin/* $fs/usr/bin
68 # cp -av _pkg/usr/lib/*.so* $fs/usr/lib
70 ===== e2fsprogs-1.39 - Filesystem management utilities =====
72 The e3fsprogs (http://e2fsprogs.sourceforge.net/) provides utilities for handling ext2 and ext3 filesystems. We will not take all of them because we need the space. It should be noted that we use fsck of BusyBox:
74 # cd ..
75 # wget http://puzzle.dl.sourceforge.net/sourceforge/e2fsprogs/e2fsprogs-1.39.tar.gz
76 # tar xzf e2fsprogs-1.39.tar.gz
77 # cd e2fsprogs-1.39
78 # ./configure --prefix=/usr --with-root-prefix="" \
79 --enable-elf-shlibs --disable-evms --sysconfdir=/etc \
80 --infodir=/usr/share/info --mandir=/usr/share/man
81 # make
82 # make DESTDIR=$PWD/_pkg install
83 # strip -vs _pkg/sbin/*
84 # strip -vs _pkg/lib/*
85 # strip -vs _pkg/usr/bin/*
86 # strip -vs _pkg/usr/sbin/*
87 # strip -vs _pkg/usr/lib/*
89 Install the utilities, configuration files and libraries in the rootfs of SliTaz. Be careful if you used fsck, that you didn't destroy the link to BusyBox:
91 # cp -i _pkg/sbin/{badblocks,blkid,dumpe2fs,e2fsck,e2image} $fs/sbin
92 # cp -i _pkg/sbin/{e2label,findfs,logsave,mke2fs,mkfs.*} $fs/sbin
93 # cp -i _pkg/sbin/{resize2fs,tune2fs} $fs/sbin
94 # cp -a _pkg/lib/* $fs/lib
95 # rm -rf $fs/lib/libss*
96 # cp -a _pkg/etc/* $fs/etc
97 # cp -a _pkg/usr/bin/* $fs/usr/bin
98 # cp -a _pkg/usr/sbin/* $fs/usr/sbin
99 # cp -ad _pkg/usr/lib/*.so $fs/usr/lib
100 # rm -rf $fs/usr/lib/libss*
102 You can also copy files from the French locale:
104 # mkdir $fs/usr/share/locale
105 # cp -a _pkg/usr/share/locale/fr $fs/usr/share/locale
107 ===== Dropbear-0.50 - Lightweight SSH client and server =====
109 Dropbear (http://matt.ucc.asn.au/dropbear/dropbear.html) is a small secure client/server supporting SSH 2. Dropbear is compatible with OpenSSH and uses ~/.ssh/authorized_keys for the management of public keys. Dropbear also provides a version of scp, which must be compiled with 'make scp':
111 # cd ..
112 # wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.50.tar.gz
113 # tar xzf dropbear-0.50.tar.gz
114 # cd dropbear-0.50
115 # ./configure --prefix=/usr
116 # make
117 # make scp
118 # make DESTDIR=$PWD/_pkg install
119 # strip -v scp
120 # strip -v _pkg/usr/bin/*
121 # strip -v _pkg/usr/sbin/*
123 Install the client and tools in /usr/bin, and the server in /usr/sbin:
125 # cp scp $fs/usr/bin
126 # cp -a _pkg/usr/bin/* $fs/usr/bin
127 # cp -a _pkg/usr/sbin/* $fs/usr/sbin
129 ==== libs ====
130 <file>
131 libutil.so.1 => /lib/libutil.so.1 (0x40025000)
132 libz.so.1 => /usr/lib/libz.so.1 (0x40028000)
133 libcrypt.so.1 => /lib/libcrypt.so.1 (0x4003b000)
134 libc.so.6 => /lib/libc.so.6 (0x40068000)
135 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
136 </file>
137 Copy the library libutil.so.1 to $fs/lib, if this is not already the case. Other libraries should be present following the construction of the base system:
139 # cp -a /lib/libutil* $fs/lib
141 ==== Configure Dropbear ====
143 The user configuration files authorized_keys and known_hosts are in ~/.ssh. This directory and the file known_hosts are created automatically the first time the user launches dbclient. The system configuration files for the Dropbear server are in /etc/dropbear:
145 # mkdir $fs/etc/dropbear
147 You must generate the secure keys before starting the Dropbear server on SliTaz. You can use dropbearkey with the following commands:
149 # dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
150 # dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
152 On SliTaz, you can start the SSH server with the command:
154 # /etc/init.d/dropbear start
156 ===== lighttpd-1.4.18 - HTTP Web server =====
158 Lighttpd ([[http://www.lighttpd.net/|www.lighttpd.net]]) is a light, secure and powerful web server. The project is very active and the server's configuration simple. It supports virtual hosts, CGI scripts, and allows intelligent management of the CPU:
160 # cd ..
161 # wget http://www.lighttpd.net/download/lighttpd-1.4.18.tar.gz
162 # tar xzf lighttpd-1.4.18.tar.gz
163 # cd lighttpd-1.4.18
164 # ./configure -enable-shared --disable-ipv6 --prefix=/usr \
165 --libdir=/usr/lib/lighttpd --mandir=/usr/share/man
166 # make
167 # make DESTDIR=$PWD/_pkg install
168 # strip -vs _pkg/usr/bin/*
169 # strip -vs _pkg/usr/sbin/*
170 # strip -vs _pkg/usr/lib/lighttpd/*
172 Install the server and generated libraries. We will then copy some of the modules (9):
174 # cp _pkg/usr/bin/* $fs/usr/bin
175 # cp _pkg/usr/sbin/* $fs/usr/sbin
176 # mkdir $fs/usr/lib/lighttpd
177 Modules :
178 # cp _pkg/usr/lib/lighttpd/mod_access.so $fs/usr/lib/lighttpd
179 # cp _pkg/usr/lib/lighttpd/mod_accesslog.so $fs/usr/lib/lighttpd
180 # cp _pkg/usr/lib/lighttpd/mod_alias.so $fs/usr/lib/lighttpd
181 # cp _pkg/usr/lib/lighttpd/mod_auth.so $fs/usr/lib/lighttpd
182 # cp _pkg/usr/lib/lighttpd/mod_cgi.so $fs/usr/lib/lighttpd
183 # cp _pkg/usr/lib/lighttpd/mod_compress.so $fs/usr/lib/lighttpd
184 # cp _pkg/usr/lib/lighttpd/mod_rewrite.so $fs/usr/lib/lighttpd
185 # cp _pkg/usr/lib/lighttpd/mod_status.so $fs/usr/lib/lighttpd
186 # cp _pkg/usr/lib/lighttpd/mod_userdir.so $fs/usr/lib/lighttpd
188 ==== libs ====
190 There should be a libdl.so.2 library; if missing, we can copy:
192 # cp -a /lib/libdl* $fs/lib
194 ==== /var/www - root of documents served ====
196 /var/www is the root directory of documents served by default. You can access this via the url http://localhost/. This directory contains an "index.html" automatically displayed by a query. We will create the directory /var/www, to see what's placed inside:
198 # mkdir -p $fs/var/www
200 ==== lighttpd.conf - Lighttpd configuration file ====
202 The Lighttpd main configuration file is located at /etc/lighttpd and is called lighttpd.conf. The configuration file SliTaz provides is self-explanatary, just browse. You can find other examples on the Lighttpd website and as well as an example configuration in /doc in the Lighttpd archive:
204 # cp -a ../slitaz-tools-1.1/etc/lighttpd $fs/etc
206 Creating the directory containing the log files:
208 # mkdir $fs/var/log/lighttpd
210 ==== User and group www ====
212 We will add a user and a group for the web server, it adds security and there is no reason for it to be run a root. The default user on SliTaz is 'www', but you can change this in the configuration file lighttpd.conf. The BusyBox application adduser has some limitations, so we add user 'www' manually. We also change permissions on the directory of web server logs:
214 # echo "www:x:80:80:www:/var/www:/bin/sh" >> $fs/etc/passwd
215 # echo "www:*:13509:0:99999:7:::" >> $fs/etc/shadow
216 # echo "www:*:13509:0:99999:7:::" >> $fs/etc/shadow-
217 # chroot $fs /bin/ash
218 /# addgroup -g 80 www
219 /# chown www.www /var/log/lighttpd
220 # exit
222 To start the web server, you can use script /etc/init.d/lighttpd provided by SliTaz tools, by typing: "/etc/init.d/lighttpd start". You can also automate its launch at boot with a link /etc/init.d/lighttpd pointing to /etc/rc.d/60lighttpd.
224 ===== iptables-1.3.7 - Netfilter, Linux firewall =====
226 Netfilter ([[http://www.netfilter.org/|www.netfilter.org]]) is the module which provides the Linux kernel firewall functions, shared internet connections (NAT) and the archiving of network traffic. The iptables command allows you to configure Netfilter using iptables-restore and iptable-save, to save and restore the Netfilter configuration:
228 # cd ..
229 # wget http://www.netfilter.org/projects/iptables/files/iptables-1.3.7.tar.bz2
230 # tar xjf iptables-1.3.7.tar.bz2
231 # cd iptables-1.3.7
232 # make KERNEL_DIR=../linux-2.6.20 BINDIR=/sbin \
233 LIBDIR=/lib MANDIR=/usr/share/man
234 # make KERNEL_DIR=../linux-2.6.20 BINDIR=/sbin \
235 LIBDIR=/lib MANDIR=/usr/share/man \
236 DESTDIR=$PWD/_pkg install
237 # strip _pkg/sbin/*
238 # strip _pkg/lib/iptables/*
240 Installing the iptables* applications and libraries sufficient for a basic firewall:
242 # cp -a _pkg/sbin/iptables* $fs/sbin
243 # mkdir $fs/lib/iptables
244 # cp -a _pkg/lib/iptables/{libipt_standard.so,libipt_conntrack.so} \
245 $fs/lib/iptables
246 # cp -a _pkg/lib/iptables/{libipt_tcp.so,libipt_udp.so} $fs/lib/iptables
248 To satisfy the iptables dependencies, you must copy the libnsl* library:
250 # cp -va /lib/libnsl* $fs/lib/tls
251 # strip $fs/lib/libnsl*
253 ===== sqlite-3.5.1 - Small SQL database engine =====
255 This package provides sqlite3 ([[http://www.sqlite.org/|www.sqlite.org]]) and sqlite3.so* libraries. SQLite is fast and efficient and integrates directly to programs using database files:
257 # cd ..
258 # wget http://www.sqlite.org/sqlite-3.5.1.tar.gz
259 # tar xzf sqlite-3.5.1.tar.gz
260 # cd sqlite-3.5.1
261 # ./configure --prefix=/usr --disable-tcl
262 # make
263 # make DESTDIR=$PWD/_pkg install
264 # strip _pkg/usr/lib/*.so*
265 # strip _pkg/usr/bin/*
267 Installing the sqlite3 utility and libraries in the rootfs of SliTaz:
269 # cp -a _pkg/usr/lib/*.so* $fs/usr/lib
270 # cp -a _pkg/usr/bin/* $fs/usr/bin
272 ===== cdrkit-1.1.5 - Tools for manipulating cdrom and ISO images =====
274 cdrkit ([[http://www.cdrkit.org/|www.cdrkit.org]]) provides tools for manipulating cdroms. SliTaz installs by default wodim for burning and genisoimage to create an ISO image. The compilation is a bit different (cmake), but shouldn't pose any problems:
276 # cd ..
277 # wget http://cdrkit.org/releases/cdrkit-1.1.5.tar.gz
278 # tar xzf cdrkit-1.1.5.tar.gz
279 # cd cdrkit-1.1.5
280 # make
281 # make install PREFIX=$PWD/_pkg/usr
282 # strip -v _pkg/usr/bin/*
283 # strip -v _pkg/usr/sbin/*
284 # cp _pkg/usr/bin/genisoimage $fs/usr/bin
285 # cp _pkg/usr/bin/wodim $fs/usr/bin
287 Copy the library libcap.so.1 required by wodim:
289 # cp -a /lib/libcap.so* $fs/lib
291 ===== cpio-2.8 - Archiver =====
293 "cpio" (http://www.gnu.org/software/cpio/) provides tools for manipulating cpio archives. The archive format is used for packages and the SliTaz initramfs image of the cdrom. Note that BusyBox provides a version of cpio that only unpacks archives:
295 # cd ..
296 # wget ftp://sunsite.cnlab-switch.ch/mirror/gnu/cpio/cpio-2.8.tar.gz
297 # tar xzf cpio-2.8.tar.gz
298 # cd cpio-2.8
299 # ./configure --prefix=/usr --bindir=/bin \
300 --libexecdir=/usr/bin --mandir=/usr/share/man \
301 --infodir=/usr/share/info
302 # make
303 # make DESTDIR=$PWD/_pkg install
304 # strip -v _pkg/bin/*
305 # strip -v _pkg/usr/bin/*
307 nstalling "cpio" in /bin and "rmt" in /usr/bin. You can also install the French locale files:
309 # cp -a _pkg/bin/* $fs/bin
310 # cp -a _pkg/usr/bin/* $fs/usr/bin
311 # cp -a _pkg/usr/share/locale/fr $fs/usr/share/locale
313 ===== microperl-5.8.8 - A tiny Perl =====
315 Microperl is a tiny implementation of Perl using the most basic functions of the language. You can find more info in the source archive and the file "README.micro". We use a small "sed" on the configuration file that searches for microperl modules in /usr/lib/perl5. We also create a link to the #! /usr/bin/perl script:
317 # wget http://ftp.funet.fi/pub/CPAN/src/perl-5.8.8.tar.gz
318 # tar xzf perl-5.8.8.tar.gz
319 # cd perl-5.8.8
320 # sed -i s/'usr\/local'/'usr'/ uconfig.sh
321 # sed -i s/'perl5\/5.9'/'perl5'/ uconfig.sh
322 # sed -i s/'unknown'/'i486-pc-linux-gnu'/ uconfig.sh
323 # make -f Makefile.micro regen_uconfig
324 # make -f Makefile.micro
325 # strip microperl
326 # cp microperl $fs/usr/bin
327 # chroot $fs /bin/ash
328 /# cd /usr/bin
329 /# ln -s microperl perl
330 /# exit
332 ===== module-init-tools-3.2 - Utilities for manipulating kernel modules =====
334 The [[http://ftp.kernel.org/pub/linux/utils/kernel/module-init-tools/|module-init-tools]] from kernel.org: modprobe, insmod, rmmod and lsmod. We have chosen to use these because we can compile modutils/modprobe to support compressed (.gz) modules to save space. To do this we use the option --enable-zlib, we then clean and copy the binaries. We do not take everything that has been created, only what we need: depmod, insmod, modinfo, modprobe and rmmod in /sbin and lsmod in /bin:
336 # cd ..
337 # wget http://ftp.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.2.tar.bz2
338 # tar xjf module-init-tools-3.2.tar.bz2
339 # cd module-init-tools-3.2
340 # ./configure --enable-zlib --prefix=/usr --sbindir=/sbin --bindir=/bin \
341 --sysconfdir=/etc --infodir=/usr/share/info --mandir=/usr/share/man
342 # make
343 # make DESTDIR=$PWD/_pkg install
344 # strip -v _pkg/sbin/{depmod,insmod,modinfo,modprobe,rmmod}
345 # strip -v _pkg/bin/lsmod
346 # cp -i _pkg/sbin/{depmod,insmod,modinfo,modprobe,rmmod} $fs/sbin
347 # cp -i _pkg/bin/lsmod $fs/bin
348 # cd ..
350 ===== Copy kernel modules =====
352 Copy files from linux-2.6.20/_pkg:
354 # cp -a linux-2.6.20/_pkg/lib/* $fs/lib
356 ==== Compress kernel modules ====
358 Compress modules, this step will gain us back around 50% of available space. We begin by moving into the rootfs, then we search for all files with the ".ko" extension, and compress them. You can also do this with the 'gzmodtaz.sh' script found in SliTaz tools:
360 # cd $fs
362 With 'gztazmod.sh':
364 # cp -v ../src/slitaz-tools-1.1/utils/gztazmod.sh sbin
365 # ./sbin/gztazmod.sh lib/modules/2.6.20-slitaz
367 Or by hand:
369 # cd lib/modules/2.6.20-slitaz
370 # find . -name "*.ko" -exec gzip '{}' \;
371 # sed 's/\.ko/.ko.gz/g' modules.dep > tmp.dep
372 # rm modules.dep
373 # mv tmp.dep modules.dep
375 ===== Generate the initramfs and an ISO image =====
377 To create a new ISO image, you can use 'mktaziso' in [[http://doc.slitaz.org/en:cookbook:slitaztools|SliTaz tools]]. Or you can create a new initramfs image, copy it to /boot in the root of the cdrom (rootcd) and finally generate an ISO image with genisoimage:
379 # cd $fs
380 # find . -print | cpio -o -H newc | gzip -9 > ../rootfs.gz
381 # cd ..
382 # cp rootfs.gz rootcd/boot
383 # genisoimage -R -o slitaz-test.iso -b boot/isolinux/isolinux.bin \
384 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
385 -V "SliTaz" -input-charset iso8859-1 -boot-info-table rootcd
387 Test iso image:
389 # qemu -cdrom slitaz-test.iso
391 ==== Following chapter ====
393 The next chapter is called [[base-ncurses|Base Ncurses]]. It covers the installation and configuration of the ncurses libraries and applications.