Sunday, July 23, 2006
Debian Console下支援BIG5 碼
#env //顯示環境變量
:
:
LANG= zh_HK.UTF8
...
LANGUAGE=en_HK:en_US:en_GB:en
#dpkg-reconfigure locales
選要用到的區域,如zh_tw.
再次env查看
LANG=zh_TW
重新登入即可.
Tuesday, July 18, 2006
web browser language detection
This variable show what the web browser accept or prefer language, like en-us, zh-hk etc.
when the browser configure more than one accept language, there is a "quality values" which are floating point values between 0 and 1, higher values indicate higher preference.
zh-hk,en;q=0.5 example in IE, two language
zh-hk,en;q=0.7,zh-cn;q=0.3 example in Firefox three language
the most prefer language is zh-hk(chinese hongkong, no q value), en(english) q= 0.7 is second, zh-cn, q=0.3 is the last in these three language.
Thursday, July 06, 2006
Tips on build debian package
http://linuxdevices.com/articles/AT8047723203.html
What is a package, exactly?
To put it very simply, a package is a collection of files with instructions on what to do with them. A package usually contains a program or programs, but sometimes it has only documentation, window manager themes, or other files that are easier to distribute in an installable package.
The package contains instructions on where those files should reside in the filesystem, what libraries or other programs the contents of the package are dependent on (if any), setup instructions, and basic configuration scripts. Note that many packages cannot be used or should not be used with the default settings contained in their configuration files. With packages such as Apache, you'll still need to configure your installation after the package has been set up.
Packages usually contain precompiled software, but you can also package source code. Some admins may prefer to install from source, or your application may require customization prior to compilation, so if you're distributing software that is under a free or open source license, you may wish to create a source package as well as a "binary" package.
All binary Debian packages consist of three basic things: a text file called debian-binary, a compressed tarball called control.tar.gz, and another compressed tarball called data.tar.gz.
The debian-binary text file contains the version number for the binary package, which should be 2.0. The control.tar.gz file contains the control file; the postinst file, which contains instructions on what to do after installing the package; and the prerm file, which contains removal instructions. control.tar.gz may also contain a file with information about configuration files for the package called conffiles and a file with the MD5 checksums for the package called md5sums.
The data.tar.gz contains the actual "payload" of the package. That is, it contains a filesystem with all the relevant files for your program that, when installed, will be placed in the appropriate spots in your system's filesystem.
If you want to see what a package looks like for yourself, download a few packages from the Debian site and run ar -x packagename.deb. (-x will unpackage the .deb archive, use -t to view only). Debian packages are simply archives of the files mentioned above.
example: adduser_3.87_all.deb
# ar -t adduser_3.87_all.debdebian-binary
control.tar.gz
data.tar.gz
# tar -tvf control.tar.gz
drwxr-xr-x root/root 0 2006-04-26 22:01:15 ./
-rw-r--r-- root/root 18 2006-04-26 22:01:13 ./conffiles
-rwxr-xr-x root/root 958 2006-04-26 22:01:13 ./postinst
-rwxr-xr-x root/root 220 2006-04-26 22:01:13 ./postrm
-rwxr-xr-x root/root 908 2006-04-26 22:01:13 ./config
-rw-r--r-- root/root 12559 2006-04-26 22:01:14 ./templates
-rw-r--r-- root/root 4772 2006-04-26 22:01:15 ./md5sums
-rw-r--r-- root/root 1303 2006-04-26 22:01:15 ./control
# tar -tvf data.tar.gz
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./
drwxr-xr-x root/root 0 2006-04-26 22:01:13 ./etc/
-rw-r--r-- root/root 600 2006-04-26 22:01:13 ./etc/deluser.conf
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/sbin/
-rwxr-xr-x root/root 29690 2006-04-26 22:01:12 ./usr/sbin/adduser
-rwxr-xr-x root/root 13994 2006-04-26 22:01:12 ./usr/sbin/deluser
drwxr-xr-x root/root 0 2006-04-26 22:01:14 ./usr/share/
drwxr-xr-x root/root 0 2006-04-26 22:01:13 ./usr/share/adduser/
-rw-r--r-- root/root 2244 2006-04-26 22:01:13 ./usr/share/adduser/adduser.conf
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/share/doc/
:
.
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/share/man/fr/man5/
-rw-r--r-- root/root 2089 2006-04-26 22:01:12 ./usr/share/man/fr/man5/adduser.conf.5.gz
-rw-r--r-- root/root 1551 2006-04-26 22:01:12 ./usr/share/man/fr/man5/deluser.conf.5.gz
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/share/man/fr/man8/
-rw-r--r-- root/root 3901 2006-04-26 22:01:12 ./usr/share/man/fr/man8/adduser.8.gz
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/share/man/pl/
drwxr-xr-x root/root 0 2006-04-26 22:01:13 ./usr/share/man/pl/man5/
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/share/man/pl/man8/
-rw-r--r-- root/root 4013 2006-04-26 22:01:12 ./usr/share/man/pl/man8/adduser.8.gz
drwxr-xr-x root/root 0 2006-04-26 22:01:12 ./usr/share/man/sv/
http://www.debian.org/doc/FAQ/ch-pkg_basics.en.html
6.4 What is a Debian control file?
Specifics regarding the contents of a Debian control file are provided in the Debian Policy Manual, section 5, see What other documentation exists on and for a Debian system?, Section 11.1.
Briefly, a sample control file is shown below for the Debian package hello:
Package: hello
Priority: optional
Section: devel
Installed-Size: 45
Maintainer: Adam Heath
Architecture: i386
Version: 1.3-16
Depends: libc6 (>= 2.1)
Description: The classic greeting, and a good example
The GNU hello program produces a familiar, friendly greeting. It
allows nonprogrammers to use a classic computer science tool which
would otherwise be unavailable to them.
.
Seriously, though: this is an example of how to do a Debian package.
It is the Debian version of the GNU Project's `hello world' program
(which is itself an example for the GNU Project).
The Package field gives the package name. This is the name by which the package can be manipulated by the package tools, and usually similar to but not necessarily the same as the first component string in the Debian archive file name.
The Version field gives both the upstream developer's version number and (in the last component) the revision level of the Debian package of this program as explained in Why are Debian package file names so long?, Section 6.3.
The Architecture field specifies the chip for which this particular binary was compiled.
The Depends field gives a list of packages that have to be installed in order to install this package successfully.
The Installed-Size indicates how much disk space the installed package will consume. This is intended to be used by installation front-ends in order to show whether there is enough disk space available to install the program.
The Section line gives the "section" where this Debian package is stored at the Debian FTP sites. This is the name of a subdirectory (within one of the main directories, see What are all those directories at the Debian FTP archives?, Section 5.1) where the package is stored.
The Priority indicates how important is this package for installation, so that semi-intelligent software like dselect or console-apt can sort the package into a category of e.g. packages optionally installed. See What is an Essential Required, Important, Standard, Optional, or Extra package?, Section 6.7.
The Maintainer field gives the e-mail address of the person who is currently responsible for maintaining this package.
The Description field gives a brief summary of the package's features.
For more information about all possible fields a package can have, please see the Debian Policy Manual, section 5., "Control files and their fields".
6.5 What is a Debian conffile?
Conffiles is a list of configuration files (usually placed in /etc) that the package management system will not overwrite when the package is upgraded. This ensures that local values for the contents of these files will be preserved, and is a critical feature enabling the in-place upgrade of packages on a running system.
To determine exactly which files are preserved during an upgrade, run:
dpkg --status package
And look under "Conffiles:".
6.6 What is a Debian preinst, postinst, prerm, and postrm script?
These files are executable scripts which are automatically run before or after a package is installed. Along with a file named control, all of these files are part of the "control" section of a Debian archive file.
The individual files are:
- preinst
- This script executes before that package will be unpacked from its Debian archive (".deb") file. Many 'preinst' scripts stop services for packages which are being upgraded until their installation or upgrade is completed (following the successful execution of the 'postinst' script).
- postinst
- This script typically completes any required configuration of the package foo once foo has been unpacked from its Debian archive (".deb") file. Often, 'postinst' scripts ask the user for input, and/or warn the user that if he accepts default values, he should remember to go back and re-configure that package as the situation warrants. Many 'postinst' scripts then execute any commands necessary to start or restart a service once a new package has been installed or upgraded.
- prerm
- This script typically stops any daemons which are associated with a package. It is executed before the removal of files associated with the package.
- postrm
- This script typically modifies links or other files associated with foo, and/or removes files created by the package. (Also see What is a Virtual Package?, Section 6.8.)
Currently all of the control files can be found in directory /var/lib/dpkg/info. The files relevant to package foo begin with the name "foo" and have file extensions of "preinst", "postinst", etc., as appropriate. The file foo.list in that directory lists all of the files that were installed with the package foo. (Note that the location of these files is a dpkg internal; you should not rely on it.)
6.13 How do I install a source package?
Debian source packages can't actually be "installed", they are just unpacked in whatever directory you want to build the binary packages they produce.
Source packages are distributed on most of the same mirrors where you can obtain the binary packages. If you set up your APT's sources.list(5) to include the appropriate "deb-src" lines, you'll be able to easily download any source packages by running
apt-get source foo
To help you in actually building the source package, Debian source package provide the so-called build-dependencies mechanism. This means that the source package maintainer keeps a list of other packages that are required to build their package. To see how this is useful, run
apt-get build-dep foo
before building the source.
6.14 How do I build binary packages from a source package?
You will need all of foo_*.dsc, foo_*.tar.gz and foo_*.diff.gz to compile the source (note: there is no .diff.gz for some packages that are native to Debian).
Once you have them (How do I install a source package?, Section 6.13), if you have the dpkg-dev package installed, the following command:
dpkg-source -x foo_version-revision.dsc
will extract the package into a directory called foo-version.
If you want just to compile the package, you may cd into foo-version directory and issue the command
dpkg-buildpackage -rfakeroot -b
to build the package (note that this also requires the fakeroot package), and then
dpkg -i ../foo_version-revision_arch.deb
to install the newly-built package(s).
6.15 How do I create Debian packages myself?
For more detailed description on this, read the New Maintainers' Guide, available in the maint-guide package, or at http://www.debian.org/doc/devel-manuals#maint-guide.