website diff en/doc/handbook/development.html @ rev 68
Tidy up Handbook (en) and add Apps
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Sat Jun 14 14:48:17 2008 +0000 (2008-06-14) |
parents | |
children | b9186eb65961 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/en/doc/handbook/development.html Sat Jun 14 14:48:17 2008 +0000 1.3 @@ -0,0 +1,300 @@ 1.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 1.5 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1.6 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 1.7 +<head> 1.8 + <title>SliTaz Handbook (en) - Development</title> 1.9 + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> 1.10 + <meta name="description" content="slitaz English handbook" /> 1.11 + <meta name="expires" content="never" /> 1.12 + <meta name="modified" content="2008-02-26 18:30:00" /> 1.13 + <meta name="publisher" content="www.slitaz.org" /> 1.14 + <meta name="author" content="Christophe Lincoln"/> 1.15 + <link rel="shortcut icon" href="favicon.ico" /> 1.16 + <link rel="stylesheet" type="text/css" href="book.css" /> 1.17 +</head> 1.18 +<body bgcolor="#ffffff"> 1.19 + 1.20 +<!-- Header and quick navigation --> 1.21 +<div id="header"> 1.22 +<div align="right" id="quicknav"> 1.23 + <a name="top"></a> 1.24 + <a href="multimedia.html">Multimedia</a> | 1.25 + <a href="index.html">Table of contents</a> 1.26 +</div> 1.27 +<h1><font color="#3E1220">SliTaz Handbook (en)</font></h1> 1.28 +</div> 1.29 + 1.30 +<!-- Content. --> 1.31 +<div id="content"> 1.32 +<div class="content-right"></div> 1.33 + 1.34 +<h2><font color="#DF8F06">Developement</font></h2> 1.35 + 1.36 +<ul> 1.37 + <li><a href="#about">About Development</a></li> 1.38 + <li><a href="#shell-scripts">SHell scripts</a> - #!/bin/sh</li> 1.39 + <li><a href="#dialog">Dialog</a> - GUI based console.</li> 1.40 + <li><a href="#geany">Geany</a> - IDE or Integrated Development Environment. 1.41 + </li> 1.42 + <li><a href="#perl">Perl or Microperl</a> - Code Perl scripts.</li> 1.43 + <li><a href="#python">Python</a> - The Python Language</li> 1.44 + <li><a href="#ruby">Ruby</a> - The Ruby Language.</li> 1.45 + <li><a href="#toolchain">Toolchain</a> - Libraries, C compiler and tools.</li> 1.46 +</ul> 1.47 + 1.48 +<a name="about"></a> 1.49 +<h3>About Development</h3> 1.50 +<p> 1.51 +SliTaz provides development tools for web design, editing scripts and source code. 1.52 +On the website, the <a href="http://www.slitaz.org/en/devel/">Development</a> page will 1.53 +give you general information about the developers and opportunities for involvement. 1.54 +</p> 1.55 + 1.56 +<a name="shell-scripts"></a> 1.57 +<h3>SHell scripts</h3> 1.58 +<p> 1.59 +Writing SHell scripts is the easiest way to start coding, they can provide quick results and 1.60 +the only prerequisites are being able to open a terminal and using a text editor such as Nano, 1.61 +Leafpad or Geany. SHell scripts can do many things on a GNU/Linux system - initialize the system, 1.62 +make backups, perform repetitive tasks, display system information, create or modify files and so on. 1.63 +In a SHell script you can use variables, functions or calls to include a file. Note that you can 1.64 +name your script as you see fit and the .sh extension is widely used. 1.65 +</p> 1.66 +<h4>Create a SHell script</h4> 1.67 +<p> 1.68 +Before starting a new SHell script, you must pay attention to the interpreter used. Most SHell 1.69 +scripts use <code>/bin/sh</code>, because it's more portable, but there are scripts that rely on 1.70 +<code>/bin/bash</code> and this must be installed on the system. For a SHell script to function it 1.71 +must be made executable by the current user, changing permissions on the command line can be 1.72 +made by using the <code>chmod</code> tool. To create a <code>script.sh</code> and make it executable: 1.73 +</p> 1.74 +<pre> 1.75 + $ touch script.sh 1.76 + $ chmod +x script.sh 1.77 +</pre> 1.78 +<p> 1.79 +Now that you have a new executable file, you can edit it. You can continue to stay in the terminal 1.80 +and use the Nano editor (ctrl + x to save & exit) or IDE Geany to edit: 1.81 +</p> 1.82 +<pre> 1.83 + $ nano script.sh 1.84 + Or : 1.85 + $ geany script.sh & 1.86 +</pre> 1.87 +<p> 1.88 +Here's a script that contains a variable <code>NAME</code> and displays the value with the <code>echo</code> 1.89 +command: 1.90 +</p> 1.91 +<pre class="script"> 1.92 +#!/bin/sh 1.93 + 1.94 +NAME="kayam" 1.95 + 1.96 +echo "$NAME is nice." 1.97 + 1.98 +</pre> 1.99 +<p> 1.100 +Once you have created/modified your <code>script.sh</code>, you can execute it to see the result: 1.101 +</p> 1.102 +<pre> 1.103 + $ ./script.sh 1.104 +</pre> 1.105 +<p> 1.106 +So much for this brief introduction to SHell scripts. The Web is full of information if you wish to 1.107 +explore further. 1.108 +</p> 1.109 + 1.110 +<a name="dialog"></a> 1.111 +<h3>Dialog</h3> 1.112 +<p> 1.113 +Dialog can create GUI-based consoles such as 'tazkmap'. The configuration files are /etc/dialogrc 1.114 +and/or ~/dialogrc for each user. Here's a simple example of using dialog via a console or terminal: 1.115 +</p> 1.116 +<pre> 1.117 + $ dialog --title "Hello $USER" \ 1.118 + --msgbox "Message made by dialog." 5 54 1.119 +</pre> 1.120 +<p> 1.121 +You can find plenty of example scripts in the /sample directory inside the source code of dialog, 1.122 +which can be downloaded from: <a href="http://invisible-island.net/dialog/dialog.html" 1.123 + >invisible-island.net/dialog/dialog.html</a>. Download sources and decompress: 1.124 +</p> 1.125 +<pre> 1.126 + $ wget ftp://invisible-island.net/dialog/dialog.tar.gz 1.127 + $ tar xzf dialog.tar.gz 1.128 +</pre> 1.129 + 1.130 +<a name="geany"></a> 1.131 +<h3>Geany IDE</h3> 1.132 +<p> 1.133 +Geany is an IDE or Integrated Development Environment. Geany is simple, quick and light, offering colored 1.134 +syntax, tabs and auto completion. Geany was used to create this page and most of the website documentation 1.135 +(with a little bit of Nano as well). 1.136 +</p> 1.137 +<h4>Launch Geany</h4> 1.138 +<p> 1.139 +You will find Geany in the menu --> Development --> Geany. 1.140 +Once launched for the first time, you can adjust your preferences via Edit --> Preferences. 1.141 +You can also launch Geany via a terminal: 1.142 +</p> 1.143 +<pre> 1.144 + $ geany & 1.145 +</pre> 1.146 +<p> 1.147 +Note: when compiling the source code, the <code>./configure</code> script offers the option: 1.148 +<code>-enable-the-force</code>... Which you can use if you ever feel the need to become Luke 1.149 +Skywalker! 1.150 +</p> 1.151 + 1.152 +<a name="perl"></a> 1.153 +<h3><font color="#6c0023">Perl or Microperl - Code/use Perl scripts</font></h3> 1.154 +<p> 1.155 +On SliTaz you can use the powerful scripting language Perl 1.156 +via the <code>perl</code> or <code>microperl</code> binary. Microperl is a streamlined version of perl - 1.157 +compiled from official sources, Perl scripts running Microperl are compatible with the full version of Perl. 1.158 +One of Perl's strengths is it's portability, it can used on any system and it's an interpreted language, 1.159 +this means that the code doesn't need to be compiled and can be used directly. On SliTaz Perl and Microperl 1.160 +are not installed by default on LiveCD; you can either rebuild your ISO or install through the package 1.161 +manager. Note: Microperl is only 1 MB and provides no modules: 1.162 +</p> 1.163 +<pre> 1.164 + # tazpkg install perl 1.165 + Or : 1.166 + # tazpkg install microperl 1.167 +</pre> 1.168 + 1.169 +<h4>Hello world!</h4> 1.170 +<p> 1.171 +The purpose of this script is to display <em>Hello World</em>. You start 1.172 +by creating the file and then making it executable on the command line and then editing with IDE Geany. 1.173 +Note the script is called <code>hello.pl</code>, but you can name it as you see 1.174 +fit with or without the <code>.pl</code> extension: 1.175 +</p> 1.176 +<pre> 1.177 + $ touch hello.pl 1.178 + $ chmod +x hello.pl 1.179 + $ geany hello.pl & 1.180 +</pre> 1.181 +<p> 1.182 +The first line of a Perl script begins by defining the path 1.183 +to the Perl interpreter, usually <code>/usr/bin/perl</code> and to display text, just use the 1.184 +<code>print</code> command. It should be noted that Perl is case sensitive and a line of code should 1.185 +always end with a semicolon. Example code (you can copy and paste): 1.186 +</p> 1.187 +<pre class="script"> 1.188 +#!/usr/bin/perl 1.189 +# 1.190 + 1.191 +print "Hello World!\n"; 1.192 + 1.193 +</pre> 1.194 +<p> 1.195 +To execute and test the script: 1.196 +</p> 1.197 +<pre> 1.198 + $ ./hello.pl 1.199 +</pre> 1.200 + 1.201 +<h4>CGI Scripts and Perl</h4> 1.202 +<p> 1.203 +CGI scripts are designed to display dynamically generated 1.204 +web pages. The Perl language associated with the LightTPD 1.205 +web server allows you to use CGI scripts through your public space or via virtual hosts. 1.206 +Perl is quite adapted to Web 2.0 and can generate xHTML pages. On SliTaz you must 1.207 +have Perl or Microperl installed and the <a href="web-server.html#cgi-perl">LightTPD server</a> 1.208 +configured before you can use CGI scripts coded in Perl. Note that 1.209 +by default SHell scripts (.sh) can be placed in /cgi-bin/. 1.210 +</p> 1.211 +<p> 1.212 +Once the server is properly configured, you can put your CGI in your <code>$HOME/Public/cgi-bin</code> using 1.213 +the <code>.pl</code> or <code>.cgi</code> extension and view them locally or remotely. Example of using a 1.214 +Perl CGI script: 1.215 +</p> 1.216 +<pre class="script"> 1.217 +#!/usr/bin/perl 1.218 +# 1.219 +print "content-type : text/html\n\n"; 1.220 + 1.221 +print "Hello World!\n"; 1.222 + 1.223 +</pre> 1.224 + 1.225 +<a name="python"></a> 1.226 +<h3>Python</h3> 1.227 +<p> 1.228 +The Python programming language is available as an installable package. Once installed, you can create your 1.229 +own scripts/programs and use CGI applications with the LightTPD web server, taking care to 1.230 +<a href="web-server.html#cgi-python">configure the server</a> properly. The official SliTaz Mercurial 1.231 +repositories are provided by a CGI/Python web interface - a solution best suited to a robust, reliable 1.232 +combination. To install the <code>python</code> package with tazpkg: 1.233 +</p> 1.234 +<pre> 1.235 + # tazpkg get-install python 1.236 +</pre> 1.237 + 1.238 +<a name="ruby"></a> 1.239 +<h3>Ruby</h3> 1.240 +<p> 1.241 +The Ruby programming language is available as an installable package. Ruby is 1.242 +(to quote the official website):- "A dynamic, open source programming language with a focus on simplicity 1.243 +and productivity. It has an elegant syntax that is natural to read and easy to write". 1.244 +</p> 1.245 +<p> 1.246 +Ruby supports Object-Orientated Programming (OOP), automatic memory management and is portable. 1.247 +To install Ruby: 1.248 +</p> 1.249 +<pre> 1.250 + # tazpkg get-install ruby 1.251 +</pre> 1.252 + 1.253 +<a name="toolchain"></a> 1.254 +<h3>Toolchain - Libraries, C compiler and tools</h3> 1.255 +<p> 1.256 +To compile software from sources or your own code, you need 1.257 +at least the basic <em>toolchain</em>, comprising of Binutils, 1.258 +Glibc, C compiler, Kernel <em>headers</em> and the Make utility. 1.259 +Note that the <em>toolchain</em> is used by the SliTaz developers to compile the entire system from source. 1.260 +To install the meta package and all dependancies: 1.261 +</p> 1.262 +<pre> 1.263 + # tazpkg get-install slitaz-toolchain 1.264 +</pre> 1.265 +<p> 1.266 +The installation of the toolchain can now compile basic applications in console mode without a problem using 1.267 +the Busybox Ash SHell, but some other packages will not compile without Bash. GNU Bash is available as 1.268 +a <a href="system-admin.html#bash">package</a> along with various other development tools such as 1.269 +Flex, M4, Bison or Pkg-config. If you are looking for pkg-config for example: 1.270 +</p> 1.271 +<pre> 1.272 + $ tazpkg search pkg-config 1.273 +</pre> 1.274 +<p> 1.275 +If you would like to compile applications utilizing the Ncurses library, you must install the 1.276 +<code>ncurses-dev</code> package. 1.277 +Note the ncurses package also provides a variety of small programs such as <code>tic</code> or 1.278 +<code>tack</code>: 1.279 +</p> 1.280 +<pre> 1.281 + $ tazpkg search ncurses 1.282 +</pre> 1.283 + 1.284 +<!-- End of content --> 1.285 +</div> 1.286 + 1.287 +<!-- Footer. --> 1.288 +<div id="footer"> 1.289 + <div class="footer-right"></div> 1.290 + <a href="#top">Top of the page</a> | 1.291 + <a href="index.html">Table of contents</a> 1.292 +</div> 1.293 + 1.294 +<div id="copy"> 1.295 + Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> - 1.296 + <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br /> 1.297 + Documentation is under 1.298 + <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a> 1.299 + and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>. 1.300 +</div> 1.301 + 1.302 +</body> 1.303 +</html>