website annotate pt/doc/handbook/development.html @ rev 142

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