website annotate en/doc/handbook/development.html @ rev 117

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