website view en/doc/handbook/development.html @ rev 166

en: Edits (aargh)
author Paul Issott <paul@slitaz.org>
date Sat Sep 13 14:13:30 2008 +0000 (2008-09-13)
parents 658f2885e2f2
children e8ceba26f899
line source
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <title>SliTaz Handbook (en) - Development</title>
6 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
7 <meta name="description" content="slitaz English handbook" />
8 <meta name="expires" content="never" />
9 <meta name="modified" content="2008-07-16 23:00:00" />
10 <meta name="publisher" content="www.slitaz.org" />
11 <meta name="author" content="Christophe Lincoln"/>
12 <link rel="shortcut icon" href="favicon.ico" />
13 <link rel="stylesheet" type="text/css" href="book.css" />
14 </head>
15 <body bgcolor="#ffffff">
17 <!-- Header and quick navigation -->
18 <div id="header">
19 <div align="right" id="quicknav">
20 <a name="top"></a>
21 <a href="multimedia.html">Multimedia</a> |
22 <a href="index.html">Table of contents</a>
23 </div>
24 <h1><font color="#3E1220">SliTaz Handbook (en)</font></h1>
25 </div>
27 <!-- Content. -->
28 <div id="content">
29 <div class="content-right"></div>
31 <h2><font color="#DF8F06">Development</font></h2>
33 <ul>
34 <li><a href="#about">About Development</a></li>
35 <li><a href="#shell-scripts">SHell scripts</a> - #!/bin/sh</li>
36 <li><a href="#dialog">Dialog</a> - GUI based console.</li>
37 <li><a href="#geany">Geany</a> - IDE or Integrated Development Environment.
38 </li>
39 <li><a href="#perl">Perl or Microperl</a> - Code Perl scripts.</li>
40 <li><a href="#python">Python</a> - The Python Language.</li>
41 <li><a href="#ruby">Ruby</a> - The Ruby Language.</li>
42 <li><a href="#toolchain">Toolchain</a> - Libraries, C compiler and tools.</li>
43 </ul>
45 <a name="about"></a>
46 <h3>About Development</h3>
47 <p>
48 SliTaz provides development tools for web design, editing scripts and source code.
49 On the website, the <a href="http://www.slitaz.org/en/devel/">Development</a> page will
50 give you general information about the developers and opportunities for involvement.
51 </p>
53 <a name="shell-scripts"></a>
54 <h3>SHell scripts</h3>
55 <p>
56 Writing SHell scripts is the easiest way to start coding, they can provide quick results and
57 the only prerequisites are being able to open a terminal and using a text editor such as Nano,
58 Leafpad or Geany. SHell scripts can do many things on a GNU/Linux system - initialize the system,
59 make backups, perform repetitive tasks, display system information, create or modify files and so on.
60 In a SHell script you can use variables, functions or calls to include a file. Note that you can
61 name your script as you see fit and the .sh extension is widely used.
62 </p>
63 <h4>Create a SHell script</h4>
64 <p>
65 Before starting a new SHell script, you must pay attention to the interpreter used. Most SHell
66 scripts use <code>/bin/sh</code>, because it's more portable, but there are scripts that rely on
67 <code>/bin/bash</code> and this must be installed on the system. For a SHell script to function, it
68 must be made executable by changing permissions on the command line
69 using the <code>chmod</code> tool. To create a <code>script.sh</code> and make it executable:
70 </p>
71 <pre>
72 $ touch script.sh
73 $ chmod +x script.sh
74 </pre>
75 <p>
76 Now that you have a new executable file, you can edit it. You can continue to stay in the terminal
77 and use the Nano editor (ctrl + x to save &amp; exit) or IDE Geany to edit:
78 </p>
79 <pre>
80 $ nano script.sh
81 Or :
82 $ geany script.sh &amp;
83 </pre>
84 <p>
85 Here's a script that contains a variable <code>NAME</code> and displays the value with the <code>echo</code>
86 command:
87 </p>
88 <pre class="script">
89 #!/bin/sh
91 NAME="kayam"
93 echo "$NAME is nice."
95 </pre>
96 <p>
97 Once you have created/modified your <code>script.sh</code>, you can execute it to see the result:
98 </p>
99 <pre>
100 $ ./script.sh
101 </pre>
102 <p>
103 So much for this brief introduction to SHell scripts. The Web is full of information if you wish to
104 explore further.
105 </p>
107 <a name="dialog"></a>
108 <h3>Dialog</h3>
109 <p>
110 Dialog can create GUI-based consoles such as 'tazkmap'. The configuration files are /etc/dialogrc
111 and/or ~/dialogrc for each user. Here's a simple example of using dialog via a console or terminal:
112 </p>
113 <pre>
114 $ dialog --title "Hello $USER" \
115 --msgbox "Message made by dialog." 5 54
116 </pre>
117 <p>
118 You can find plenty of example scripts in the /sample directory inside the source code of dialog,
119 which can be downloaded from: <a href="http://invisible-island.net/dialog/dialog.html"
120 >invisible-island.net/dialog/dialog.html</a>. Download sources and decompress:
121 </p>
122 <pre>
123 $ wget ftp://invisible-island.net/dialog/dialog.tar.gz
124 $ tar xzf dialog.tar.gz
125 </pre>
127 <a name="geany"></a>
128 <h3>Geany IDE</h3>
129 <p>
130 Geany is an IDE or Integrated Development Environment. Geany is simple, quick and light, offering colored
131 syntax, tabs and auto completion. Geany was used to create this page and most of the website documentation
132 (with a little bit of Nano as well).
133 </p>
134 <h4>Launch Geany</h4>
135 <p>
136 You will find Geany in the menu --&gt; Development --&gt; Geany.
137 Once launched for the first time, you can adjust your preferences via Edit --&gt; Preferences.
138 You can also launch Geany via a terminal:
139 </p>
140 <pre>
141 $ geany &amp;
142 </pre>
143 <p>
144 Note when compiling the source code, the <code>./configure</code> script offers the option:
145 <code>-enable-the-force</code>... Which you can use if you ever feel the need to become a
146 Jedi Knight!
147 </p>
149 <a name="perl"></a>
150 <h3><font color="#6c0023">Perl or Microperl - Code/use Perl scripts</font></h3>
151 <p>
152 On SliTaz you can use the powerful scripting language Perl
153 via the <code>perl</code> or <code>microperl</code> binary. Microperl is a streamlined version of perl -
154 compiled from official sources, Perl scripts running Microperl are compatible with the complete version of Perl.
155 One of Perl's strengths is its portability, it can be used on any system and it's an interpreted language,
156 which means that the code doesn't need to be compiled and can be used directly. On SliTaz Perl and Microperl
157 are not installed by default on the LiveCD; you can either rebuild your ISO or install through the package
158 manager. Note: Microperl is only 1 MB and provides no modules:
159 </p>
160 <pre>
161 # tazpkg install perl
162 Or :
163 # tazpkg install microperl
164 </pre>
166 <h4>Hello world!</h4>
167 <p>
168 The purpose of this script is to display <em>Hello World</em>. You can start
169 by creating the file and making it executable on the command line and then editing with IDE Geany.
170 Note the script is called <code>hello.pl</code>, but you can name it as you see
171 fit, with or without the <code>.pl</code> extension:
172 </p>
173 <pre>
174 $ touch hello.pl
175 $ chmod +x hello.pl
176 $ geany hello.pl &amp;
177 </pre>
178 <p>
179 The first line of a Perl script begins by defining the path
180 to the Perl interpreter, usually <code>/usr/bin/perl</code> and to display text, just use the
181 <code>print</code> command. It should be noted that Perl is case sensitive and a line of code should
182 always end with a semicolon. Example code (you can copy and paste):
183 </p>
184 <pre class="script">
185 #!/usr/bin/perl
186 #
188 print "Hello World!\n";
190 </pre>
191 <p>
192 To execute and test the script:
193 </p>
194 <pre>
195 $ ./hello.pl
196 </pre>
198 <h4>CGI Scripts and Perl</h4>
199 <p>
200 CGI scripts are designed to display dynamically generated
201 web pages. The Perl language associated with the LightTPD
202 web server allows you to use CGI scripts through your public space or via virtual hosts.
203 Perl is quite adapted to Web 2.0 and can generate xHTML pages. On SliTaz you must
204 have Perl or Microperl installed and the <a href="web-server.html#cgi-perl">LightTPD server</a>
205 configured before you can use CGI scripts coded in Perl. Note that
206 by default SHell scripts (.sh) can be placed in /cgi-bin/.
207 </p>
208 <p>
209 Once the server is properly configured, you can put your CGI in your <code>$HOME/Public/cgi-bin</code> using
210 the <code>.pl</code> or <code>.cgi</code> extension and view them locally or remotely. Example of using a
211 Perl CGI script:
212 </p>
213 <pre class="script">
214 #!/usr/bin/perl
215 #
216 print "content-type : text/html\n\n";
218 print "Hello World!\n";
220 </pre>
222 <a name="python"></a>
223 <h3>Python</h3>
224 <p>
225 The Python programming language is available as an installable package. Once installed, you can create your
226 own scripts/programs and use CGI applications with the LightTPD web server, taking care to
227 <a href="web-server.html#cgi-python">configure the server</a> properly. The official SliTaz Mercurial
228 repositories are provided by a CGI/Python web interface - a solution suited to a product that's
229 reliable and robust. To install the <code>python</code> package with tazpkg:
230 </p>
231 <pre>
232 # tazpkg get-install python
233 </pre>
235 <a name="ruby"></a>
236 <h3>Ruby</h3>
237 <p>
238 The Ruby programming language is available as an installable package. Ruby is
239 (to quote the official website):- "A dynamic, open source programming language with a focus on simplicity
240 and productivity. It has an elegant syntax that is natural to read and easy to write".
241 Ruby handles exceptions, supports Object-Orientated Programming (OOP), automatic memory management and is
242 highly portable. To install the <code>ruby</code> package with tazpkg:
243 </p>
244 <pre>
245 # tazpkg get-install ruby
246 </pre>
248 <a name="toolchain"></a>
249 <h3>Toolchain - Libraries, C compiler and tools</h3>
250 <p>
251 To compile software from sources or your own code, you need
252 at least the basic <em>toolchain</em>, comprising of Binutils,
253 Glibc, C compiler, Kernel <em>headers</em> and the Make utility.
254 Note that the <em>toolchain</em> is used by the SliTaz developers to compile the entire system from source.
255 To install the meta package and all dependancies:
256 </p>
257 <pre>
258 # tazpkg get-install slitaz-toolchain
259 </pre>
260 <p>
261 The installation of the toolchain can now compile basic applications in console mode without a problem using
262 the Busybox Ash SHell, but some other packages will not compile without Bash. GNU Bash is available as
263 a <a href="system-admin.html#bash">package</a> along with various other development tools such as
264 Flex, M4, Bison or Pkg-config. If you are looking for pkg-config for example:
265 </p>
266 <pre>
267 $ tazpkg search pkg-config
268 </pre>
269 <p>
270 If you would like to compile applications utilizing the Ncurses library, you must install the
271 <code>ncurses-dev</code> package.
272 Note the ncurses package also provides a variety of small programs such as <code>tic</code> or
273 <code>tack</code>:
274 </p>
275 <pre>
276 $ tazpkg search ncurses
277 </pre>
279 <!-- End of content -->
280 </div>
282 <!-- Footer. -->
283 <div id="footer">
284 <div class="footer-right"></div>
285 <a href="#top">Top of the page</a> |
286 <a href="index.html">Table of contents</a>
287 </div>
289 <div id="copy">
290 Copyright &copy; 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> -
291 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
292 Documentation is under
293 <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
294 and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
295 </div>
297 </body>
298 </html>