Sharing

2013年10月9日 星期三

Rebuild Ubuntu Package

Reference

http://manpages.ubuntu.com/manpages/precise/man1/dpkg-buildpackage.1.html
http://www.debian.org/doc/manuals/maint-guide/index.en.html
http://debian-handbook.info/browse/stable/debian-packaging.html
http://askubuntu.com/questions/28372/how-do-i-get-the-source-code-of-packages-installed-through-apt-get
http://www.debian.org/doc/debian-policy/
http://debian-handbook.info/browse/stable/sect.becoming-package-maintainer.html


Rebuild Flow Example


Download Source Code


最簡單的方式是利用 apt-get source

$ sudo apt-get source python-twill
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'twill' as source package instead of 'python-twill'
NOTICE: 'twill' packaging is maintained in the 'Svn' version control system at:
svn://svn.debian.org/python-modules/packages/twill/trunk/
Need to get 255 kB of source archives.
Get:1 http://free.nchc.org.tw/ubuntu/ precise/universe twill 0.9-3 (dsc) [1,367 B]
Get:2 http://free.nchc.org.tw/ubuntu/ precise/universe twill 0.9-3 (tar) [242 kB]
Get:3 http://free.nchc.org.tw/ubuntu/ precise/universe twill 0.9-3 (diff) [11.5 kB]
Fetched 255 kB in 3s (64.5 kB/s) 
gpgv: Signature made Sun 04 Dec 2011 11:29:49 PM CST using DSA key ID 5E3619D3
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./twill_0.9-3.dsc
dpkg-source: info: extracting twill in twill-0.9
dpkg-source: info: unpacking twill_0.9.orig.tar.gz
dpkg-source: info: unpacking twill_0.9-3.debian.tar.gz
dpkg-source: info: applying 01_fix_history_path.patch
dpkg-source: info: applying 02_remove_ext.patch
dpkg-source: info: applying 03_no_setuptools.patch
dpkg-source: info: applying 04_fix_deprecated_ClientForm.patch
dpkg-source: info: applying 05_fix_missing_imports.patch

$ ll
total 268
drwxr-xr-x  3 eric_chen pjack   4096 Oct  9 15:39 ./
drwxr-xr-x 63 eric_chen pjack   4096 Oct  9 14:33 ../
drwxr-xr-x  9 root      root    4096 Oct  9 15:39 twill-0.9/
-rw-r--r--  1 root      root   11494 Dec 17  2011 twill_0.9-3.debian.tar.gz
-rw-r--r--  1 root      root    1367 Dec 17  2011 twill_0.9-3.dsc
-rw-r--r--  1 root      root  242291 Feb  9  2009 twill_0.9.orig.tar.gz

如果有 dsc 檔, 裡面含有 Link 時, 也可以用 dpkg-source 指令下載

$ dpkg-source -x twill_0.9-3.dsc 
gpgv: Signature made Sun 04 Dec 2011 11:29:49 PM CST using DSA key ID 5E3619D3
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./twill_0.9-3.dsc
dpkg-source: info: extracting twill in twill-0.9
dpkg-source: info: unpacking twill_0.9.orig.tar.gz
dpkg-source: info: unpacking twill_0.9-3.debian.tar.gz
dpkg-source: info: applying 01_fix_history_path.patch
dpkg-source: info: applying 02_remove_ext.patch
dpkg-source: info: applying 03_no_setuptools.patch
dpkg-source: info: applying 04_fix_deprecated_ClientForm.patch
dpkg-source: info: applying 05_fix_missing_imports.patch

Modify ChangeLog


$ sudo apt-get install devscripts
$ cd twill-0.9
~/twill-0.9/$ dch -v twill-0.9-3ubuntu1
# 或是用這個指令也可
~/twill-0.9/$ dch -i  # Increment the final component of the Debian release number

twill (0.9-3ubuntu1) precise; urgency=low

  * test rebuild

 -- eric_chen   Wed, 09 Oct 2013 15:40:31 +0800

twill (0.9-3) unstable; urgency=low

  * Add debian/patches/04_fix_deprecated_ClientForm.patch as ClientForm
    is now shipped with mechanize.
    + debian/rules:
      - Drop Depends on python-clientform.
    + debian/control:
      - Bump python-mechanize Depends to >= 0.2.0~.
  * debian/patches/02_remove_ext.patch:
    + Fix tests as well.
  * Add debian/patches/05_fix_missing_imports.patch.
  * debian/control:
    + Bump Standards-Version to 3.9.2. No changes needed.
  * Switch from now deprecated pysupport to dh_python2.
    + Drop debian/pyversions and debian/pycompat.
    + debian/rules:
      - Remove DEB_PYTHON_SYSTEM.
    + debian/control:
      - Add X-Python-Version field.
      - Bump python and cdbs versions.

Rebuild Package


先把需要的 package 裝一裝

$ sudo apt-get build-dep python-twill 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'twill' as source package instead of 'python-twill'
The following NEW packages will be installed:
  cdbs debhelper dh-apparmor dh-translations docbook-xml docbook-xsl html2text intltool python-scour xsltproc
0 upgraded, 10 newly installed, 0 to remove and 2 not upgraded.
Need to get 1,701 kB/2,781 kB of archives.
After this operation, 16.5 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

開始 rebuild

~/twill-0.9$ debuild -us -uc
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor): -D_FORTIFY_SOURCE=2
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor): -Wl,-Bsymbolic-functions -Wl,-z,relro
dpkg-buildpackage: source package twill
dpkg-buildpackage: source version 0.9-3
dpkg-buildpackage: source changed by Arnaud Fontaine 
 dpkg-source --before-build twill-0.9
dpkg-buildpackage: host architecture amd64
 fakeroot debian/rules clean
...


$ ll
-rw-r--r--  1 eric_chen pjack  68498 Oct  9 15:42 python-twill_0.9-3ubuntu1_all.deb
drwxr-xr-x 10 eric_chen pjack   4096 Oct  9 15:42 twill-0.9/
-rw-r--r--  1 eric_chen pjack  17480 Oct  9 15:43 twill_0.9-3ubuntu1_amd64.build
-rw-r--r--  1 eric_chen pjack   1252 Oct  9 15:42 twill_0.9-3ubuntu1_amd64.changes
-rw-r--r--  1 eric_chen pjack  11468 Oct  9 15:42 twill_0.9-3ubuntu1.debian.tar.gz
-rw-r--r--  1 eric_chen pjack   1149 Oct  9 15:42 twill_0.9-3ubuntu1.dsc

2013年10月8日 星期二

How to get Apache status

Apache Document:
http://httpd.apache.org/docs/

Enable mod_status

http://httpd.apache.org/docs/2.2/mod/mod_status.html

Sample: http://www.apache.org/server-status



Get Server Status From Command Line


By LYNX

http://www.cpanelkb.net/apache-status-in-command-line/


$ wget -q -O - --no-proxy http://10.42.93.36/server-status | lynx -stdin                                                                                                                       Apache Status (p1 of 2)
                                                     Apache Server Status for 10.42.93.36                                                     
                                                                                                                                              
   Server Version: Apache/2.2.22 (Ubuntu) mod_apreq2-20090110/2.8.0 mod_perl/2.0.5 Perl/v5.14.2                                               
   Server Built: Feb 13 2013 16:06:29                                                                                                         
     ________________________________________________________________________________________________________________________________         
                                                                                                                                              
   Current Time: Wednesday, 09-Oct-2013 06:22:36 BST                                                                                          
   Restart Time: Wednesday, 09-Oct-2013 04:01:27 BST                                                                                          
   Parent Server Generation: 0                                                                                                                
   Server uptime: 2 hours 21 minutes 8 seconds                                                                                                
   Total accesses: 322 - Total Traffic: 198 kB                                                                                                
   CPU Usage: u4.58 s.26 cu0 cs0 - .0572% CPU load                                                                                            
   .038 requests/sec - 23 B/second - 629 B/request                                                                                            
   1 requests currently being processed, 5 idle workers                                                                                       
                                                                                                                                              
_____W..........................................................                                                                              
................................................................                                                                              
................................................................                                                                              
................................................................                                                                              
                                                                                                                                              
   Scoreboard Key:                                                                                                                            
   "_" Waiting for Connection, "S" Starting up, "R" Reading Request,                                                                          
   "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,                                                                                   
   "C" Closing connection, "L" Logging, "G" Gracefully finishing,                                                                             
   "I" Idle cleanup of worker, "." Open slot with no current process                                                                          
                                                                                                                                              
   Srv PID    Acc   M CPU  SS  Req Conn Child Slot   Client       VHost                 Request                                               
   0-0 3575 0/55/55 _ 0.46 104 3   0.0  0.02  0.02 10.42.93.36 safesync.com GET / HTTP/1.1                                                    
   1-0 3576 0/55/55 _ 1.20 36  0   0.0  0.05  0.05 10.42.93.36 safesync.com GET /server-status HTTP/1.1                                       
   2-0 3577 0/55/55 _ 0.99 18  39  0.0  0.03  0.03 10.42.93.36 safesync.com GET /login HTTP/1.1                                               
   3-0 3578 0/55/55 _ 0.45 9   2   0.0  0.03  0.03 10.42.93.36 safesync.com GET / HTTP/1.1                                                    
   4-0 3579 0/54/54 _ 0.70 117 0   0.0  0.03  0.03 10.42.93.36 safesync.com GET /server-status?auto HTTP/1.1                                  
   5-0 5702 0/48/48 W 1.04 0   0   0.0  0.04  0.04 10.42.93.36 safesync.com GET /server-status HTTP/1.1                                       
     ________________________________________________________________________________________________________________________________         
                                                                                                                                              
    Srv  Child Server number - generation                                                                                                     
    PID  OS process ID                                                                                          

By Auto Parameter


$ wget -q -O - --no-proxy http://10.42.93.36/server-status?auto
Total Accesses: 324
Total kBytes: 202
CPULoad: .0567675
Uptime: 8526
ReqPerSec: .0380014
BytesPerSec: 24.2608
BytesPerReq: 638.42
BusyWorkers: 1
IdleWorkers: 5
Scoreboard: W_____..........................................................................................................................................................................................................................................................