tag:blogger.com,1999:blog-144898082024-03-08T10:08:51.261+08:00$4 blogGNU/Linux, Debian/Ubuntu, Mac OS X, Free Software/Open Source Software, Freeware, and Programming.$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.comBlogger126125tag:blogger.com,1999:blog-14489808.post-52947222718531373072017-06-19T18:16:00.000+08:002017-06-19T18:16:46.699+08:00手動快速編譯 Ubuntu 16.04 當中 Linux kernel 4.4 裡面的 kernel module<p>以前寫過一篇「<a href="/2015/11/ubuntu-1404-linux-kernel-i915-module.html">手動快速編譯 Ubuntu 14.04 當中 Linux kernel 裡面的 i915 module</a>」這次是要針對 Ubuntu 16.04 LTS 上面的 Linux kernel 4.4 編譯,步驟都差不多只是有些不一樣的地方。</p>
<p>首先是 Linux kernel git tree 的來源改從 Launchpad 而來,是的! Ubuntu 使用的 Linux kernel 現在也放到 Launchpad 上面了。</p>
<pre class="brush:shell">$ git clone https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/xenial</pre>
<p>然後是編譯的設定檔的位置不一樣了,不過大致上只要找出 config.common.ubuntu config.common.amd64 config.flavour.generic 這三個檔案的位置出來就可以了。</p>
<pre class="brush:shell">cat ./debian.master/config/config.common.ubuntu ./debian.master/config/amd64/config.common.amd64 ./debian.master/config/amd64/config.flavour.generic > .config</pre>
<p>然後這次我的目標是 ubuntu/i915 底下的 kernel module 其它的部份就直接參考前一份文章就可以了。</p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-90421750364243020622017-01-06T16:20:00.000+08:002017-01-07T10:59:05.746+08:00使用 zenity 進度條的小眉角<p>zenity 是一個小程式用來顯示簡單的 GTK+ 對話框,其中也有進度條的選項。</p>
<pre class="brush:shell">
$ zenity --help-progress
用法:
zenity [選項…]
進度列選項
--progress 顯示進度指示窗
--text=文字 指定對話方塊中的文字
--percentage=百分比 指定開始時的百份比數值
--pulsate 令進度列內的方塊來回移動
--auto-close 當進度達到 100% 時關閉對話方塊
--auto-kill 若按下取消按鈕則中止父程序
--no-cancel 隱藏取消按鈕
--time-remaining 估計當進度到達 100% 的時間
</pre>
<p>使用上可將其它程式的標準輸入當成輸入,例如:</p>
<pre class="brush:shell">$ for i in {0..100..20}; do echo $i; sleep 1; done | \
zenity --progress</pre>
<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUpzVWyuQg-M5VV-qYfdVoP5Co5Gv6VkRjlJmpVPq_MjTYVHTz0UOOpBG56OgHK04gsVFBwGSEbtyui8wHrb1uH2_hA720aB8-9aN2s5td8qpG2CIM3aER5y5GFX8W1LTN92c/s1600/zenity.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUpzVWyuQg-M5VV-qYfdVoP5Co5Gv6VkRjlJmpVPq_MjTYVHTz0UOOpBG56OgHK04gsVFBwGSEbtyui8wHrb1uH2_hA720aB8-9aN2s5td8qpG2CIM3aER5y5GFX8W1LTN92c/s1600/zenity.png" /></a></p>
<p>如果想讓進度達到百分之百時自動結束可以加上 --auto-close</p>
<pre class="brush:shell">$ for i in {0..100..20}; do echo $i; sleep 1; done | \
zenity --progress --auto-close</pre>
或是加上 --no-cancel 讓確定跟取消的按鈕都不見。
<pre class="brush:shell">$ for i in {0..100..20}; do echo $i; sleep 1; done | \
zenity --progress --auto-close --no-cancel</pre>
<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxue8HCLKkjZbvjGMsuburvoAI_AXCcBsrcAxAvWnYw6dBEbCJfIxNGtEmlgiKTU9N7qlZ4TNm3iF312PjleaevXgw3kDWryE-cpENDmRFQeNHPfiP7vpLvI-qYl4K8OTxLS0/s1600/zenity.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxue8HCLKkjZbvjGMsuburvoAI_AXCcBsrcAxAvWnYw6dBEbCJfIxNGtEmlgiKTU9N7qlZ4TNm3iF312PjleaevXgw3kDWryE-cpENDmRFQeNHPfiP7vpLvI-qYl4K8OTxLS0/s1600/zenity.png" /></a></p>
<p>再加上 --time-remaining 剩餘時間的估計。</p>
<pre class="brush:shell">$ for i in {0..100..20}; do echo $i; sleep 1; done | \
zenity --progress --auto-close --no-cancel --time-remaining</pre>
<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFTnBaaKAg0VIsVXd4zp-sIkCgYiJ3fuLpsUpFWFwzd9_4fywuw5_EXPURQTVLuoZSHBXQ8dp1Pg30yc0Sq8mTYdk3c36TSLOqskES3u2FRm1ahyphenhyphenDT6vUyUZYwQRqWq8vIUVc/s1600/zenity.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFTnBaaKAg0VIsVXd4zp-sIkCgYiJ3fuLpsUpFWFwzd9_4fywuw5_EXPURQTVLuoZSHBXQ8dp1Pg30yc0Sq8mTYdk3c36TSLOqskES3u2FRm1ahyphenhyphenDT6vUyUZYwQRqWq8vIUVc/s1600/zenity.png" /></a></p>
<p>當然還可以使用其它元件都有的 --title 跟 --text 來客製對話框的訊息。</p>
<pre class="brush:shell">$ for i in {0..100..20}; do echo $i; sleep 1; done | \
zenity --progress --auto-close --no-cancel --time-remaining --title "新建築正在倒塌中" --text "貓在鋼琴上昏倒了"</pre>
<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg83hi8w3Ih6zlBZqfqx0Wy5S-mxiaWgbjZWeQDFXQSCBgPw_xi7UTaM0zs6r7h3DAobu-C0Oyp9a5s-VU7IeJeAkhcSF7xZzFhnZqDKWrZ5dNCH0FoINePGYSksRKsNYGs74o/s1600/zenity.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg83hi8w3Ih6zlBZqfqx0Wy5S-mxiaWgbjZWeQDFXQSCBgPw_xi7UTaM0zs6r7h3DAobu-C0Oyp9a5s-VU7IeJeAkhcSF7xZzFhnZqDKWrZ5dNCH0FoINePGYSksRKsNYGs74o/s1600/zenity.png" /></a></p>
<p>另外就是 --text 有支援一些簡單的 HTML 標籤,所以可以有一些變化。</p>
<pre class="brush:shell">$ for i in {0..100..20}; do echo $i; sleep 1; done | \
zenity --progress --auto-close --no-cancel --time-remaining --title "新建築正在倒塌中" --text "<b>貓</b>在<u>鋼琴</u>上<i>昏倒</i>了\n<span foreground='red'>謠言真可怕</span>"</pre>
<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tiIi6NdIwKC4G2pVVtf7dLKWbTWF28r6BbY6Tda7X1tI9KTGroYBJmnFtNRAtQsd8ozT830irAZf7Vw7Vh7m9VUChDc4DxdGlyTBFequ40i0BEEkEs7tjBTSf-L-0refG4w/s1600/zenity.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tiIi6NdIwKC4G2pVVtf7dLKWbTWF28r6BbY6Tda7X1tI9KTGroYBJmnFtNRAtQsd8ozT830irAZf7Vw7Vh7m9VUChDc4DxdGlyTBFequ40i0BEEkEs7tjBTSf-L-0refG4w/s1600/zenity.png" /></a></p>
<p>最後就是要小心其它程式所產生的標準輸出,像是 apt-get upgrade --yes 的輸出有時候會有數字開頭的訊息,這樣的訊息在使用 zenity --progress --auto-close 時都會導致對話框突然結束,任何超過 100 的數字都會結束程式。</p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-33751645021213765632016-09-05T16:08:00.000+08:002016-09-05T16:08:57.827+08:00Linux 系統上面的 NVIDIA 圖形顯示的私有驅動程式<p>NVIDIA 官方網站上面有提供驅動程式的<a href="http://www.nvidia.com/Download/index.aspx">下載</a>,只是不曉得是否有支援我們正在使用的顯示晶片。</p>
<p>最直接的方式是將驅動程式下載後解開來看裡面的 README.txt 的內容,例如目前最新的 Beta 版本 NVIDIA-Linux-x86_64-370.23.run,下載後可執行以下指令來解開它。</p>
<pre class="brush:shell">$ bash NVIDIA-Linux-x86_64-370.23.run -x</pre>
<p>然後就可以去查看 NVIDIA-Linux-x86_64-370.23 目錄底下的 README.txt 檔案。</p>
<p>然後直接跳轉到 Appendix A. Supported NVIDIA GPU Products 的地方,就可以看到許多的 Device PCI ID,這時候再去對一下自己系統上面的 lspci -vnn 的輸出上面的 NVIDIA 顯示都是 10de 開頭的。</p>
<pre class="brush:text">Appendix A. Supported NVIDIA GPU Products
______________________________________________________________________________
...
A1. NVIDIA GEFORCE GPUS
NVIDIA GPU product Device PCI ID* VDPAU features
---------------------------------- --------------- ---------------
GeForce GTX 480 06C0 C
...
GeForce GT 620M 0DE9 1025 0692 C
...
...
</pre>
<p>像是 06C0 對應到 [10de:06c0] 只要對一組 PCI ID 就好了,而 0DE9 1025 0692 則是對應到 [10de:0de9] 然後還要檢查 Subsystem ID 是不是 [1025:0692],類似下面的輸出(假造的)。</p>
<pre class="brush:text">00:02.0 VGA compatible controller [0300]: NVIDIA GeForce GT 620M [10de:0de9] (rev 00) (prog-if 00 [VGA controller])
Subsystem: Foo bar system [1025:0692]</pre>
<p>如果系統上面的 Device PCI ID 跟 Subsystem PCI ID 有跟 README.txt 裡面的符合就表示這個驅動程式應該有支援,如果沒有出現在 README.txt 裡面的話,就是沒有支援。</p>
<p>而 Ubuntu 上面的 NVIDIA 私有驅動也是透過同樣的 README.txt 轉換成 dh-modaliases 使用的格式,讓使用者可以透過 ubuntu-drivers 來自動找到合適的驅動程式。</p>
<pre class="brush:shell">$ apt-cache show nvidia-361
Package: nvidia-361
Priority: optional
Section: restricted/misc
Installed-Size: 292039
Maintainer: Ubuntu Core Developers <...>
Architecture: amd64
Source: nvidia-graphics-drivers-361
...
Description: NVIDIA binary driver - version 361.42
Description-md5: 2f2445ec5e04329593078984a32bc2ae
Modaliases: nvidia_361(pci:v000010DEd000006C0sv*sd*bc03sc*i*,...</pre>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-80452683591545508362016-07-25T12:32:00.000+08:002016-07-25T12:32:21.271+08:00Disable Secure Boot in shim-signed<p>The latest Ubuntu kernel updates bring some Secure Boot enhancement for the kernel modules when the Secure Boot is enabled in BIOS settings. However there is no easy way to sign those kernel modules in DKMS packages automatically so far. If we want to use those DKMS packages, we need to disable Secure Boot in BIOS settings temporarily or we can also disable Secure Boot in shim-signed temporarily. The following steps introduced how to disable Secure Boot in shim-signed.</p>
<p><ol>
<li>Open a terminal by <b>Ctrl + Alt + T</b>, execute <b>`sudo update-secureboot-policy`</b> and then select ‘Yes’.<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihtHw0yAjrYj5doNNt4IhUycyb2uR4MqBJS_umtLrd6TaDKXOhFOP7Xbpwj6nD2cVrRatySAJvOdg869nDRA1b_TpILCrUm-qf6cGnsjKiZ4iK3b_GrpEOQfuHJplrQpFucjw/s1600/DisableSecureBoot.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihtHw0yAjrYj5doNNt4IhUycyb2uR4MqBJS_umtLrd6TaDKXOhFOP7Xbpwj6nD2cVrRatySAJvOdg869nDRA1b_TpILCrUm-qf6cGnsjKiZ4iK3b_GrpEOQfuHJplrQpFucjw/s400/DisableSecureBoot.png" width="400" height="256" /></a></li>
<li>Enter a temporary password between 8 to 16 digits. (For example, 12345678, we will use this password later.)<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxV4w6LvgcMf6pjn60fIeiDGVxMQJ5oS9nz4laprIJudWIRZMSU21utGn2TjHpqyAhVc1LjRaflAq5o6T2xh2nCzH0_yIA09rZ1i0oU2NsLKsF-Auclnkf9_VGAq2FXQRMo1I/s1600/DisableSecureBootPassword.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxV4w6LvgcMf6pjn60fIeiDGVxMQJ5oS9nz4laprIJudWIRZMSU21utGn2TjHpqyAhVc1LjRaflAq5o6T2xh2nCzH0_yIA09rZ1i0oU2NsLKsF-Auclnkf9_VGAq2FXQRMo1I/s400/DisableSecureBootPassword.png" width="400" height="256" /></a></li>
<li>Enter the same password again to confirm.<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfpnG_7RmwPkJBsujAMdcnGO6xNJjp4ELiRqFfHtYkBqtm2-5KZ8Wbwwh-0sfW9435-GYc49JXenxENhOhmJdIUhvAJp-BV0iy57mr9rnaAAMsc7Guyvf59kiOgLR6FxzTf2c/s1600/DisableSecureBootPasswordAgain.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfpnG_7RmwPkJBsujAMdcnGO6xNJjp4ELiRqFfHtYkBqtm2-5KZ8Wbwwh-0sfW9435-GYc49JXenxENhOhmJdIUhvAJp-BV0iy57mr9rnaAAMsc7Guyvf59kiOgLR6FxzTf2c/s400/DisableSecureBootPasswordAgain.png" width="400" height="256" /></a></li>
<li>Reboot the system and press any key when you see the blue screen (MOK management).<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3R4cLzvvJrMS0NqOzUnVgj_3NKFcTGWyDWUdETrqEk0ME4gRHQZK6Dv_CMtu56ApA3LecQ7u1Y4a-UN1f0uhalbPTJZD7a_yqswCkdqt4NfB7-ULAWxDDuEx7T1qob59LnpQ/s1600/IMG_20160722_175659.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3R4cLzvvJrMS0NqOzUnVgj_3NKFcTGWyDWUdETrqEk0ME4gRHQZK6Dv_CMtu56ApA3LecQ7u1Y4a-UN1f0uhalbPTJZD7a_yqswCkdqt4NfB7-ULAWxDDuEx7T1qob59LnpQ/s400/IMG_20160722_175659.jpg" width="400" height="300" /></a></li>
<li>Select “Change Secure Boot state”.<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn2bcEkGkkhszscT7FIvGlSRDJ884-JYBuyHXKkysCPPlq9uU7Vcs6lpwKWT-jjm78H9hMsJLFtU8tZhlwWA_kmntI6nSK_S92I30CUH0UfcUgy-7MDpQ27EeyH-abfFR92wA/s1600/IMG_20160722_175709.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn2bcEkGkkhszscT7FIvGlSRDJ884-JYBuyHXKkysCPPlq9uU7Vcs6lpwKWT-jjm78H9hMsJLFtU8tZhlwWA_kmntI6nSK_S92I30CUH0UfcUgy-7MDpQ27EeyH-abfFR92wA/s400/IMG_20160722_175709.jpg" width="400" height="300" /></a></li>
<li>Press the corresponding password character and press Enter. Repeat this step several times to confirm previous temporary password like ‘12345678’ in step 2&3. For exmaple, '2' for this screen.<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7ux1YCaiEi4vwyL1lhQ5GWbe2NSf6QqeBgTKwbQ7vlvOOcVl-CwawlaDFr_Zi54JXo-Y_HDeZnW9YAhwccgWNUKwZb9EWPq71buzoQgboo2ORcbGQ2ArgtZlDsAuwXJBTIJs/s1600/IMG_20160722_174945.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7ux1YCaiEi4vwyL1lhQ5GWbe2NSf6QqeBgTKwbQ7vlvOOcVl-CwawlaDFr_Zi54JXo-Y_HDeZnW9YAhwccgWNUKwZb9EWPq71buzoQgboo2ORcbGQ2ArgtZlDsAuwXJBTIJs/s400/IMG_20160722_174945.jpg" width="400" height="300" /></a></li>
<li>Select ‘Yes’ to disable Secure Boot in shim-signed.<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixOu6aCHNZJCxhdFjSbym_kvffauRTpWwu9xTBBS4rSIzt9uTHJ8rLQHt8hJyifQC-YPPPeiikV8lyqunJ33pJ_fFDWAiGBMzzqZjHEA8XfdUeYMp8BcuwH6omKpBJu3_RqWQ/s1600/IMG_20160722_175731.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixOu6aCHNZJCxhdFjSbym_kvffauRTpWwu9xTBBS4rSIzt9uTHJ8rLQHt8hJyifQC-YPPPeiikV8lyqunJ33pJ_fFDWAiGBMzzqZjHEA8XfdUeYMp8BcuwH6omKpBJu3_RqWQ/s400/IMG_20160722_175731.jpg" width="400" height="300" /></a></li>
<li>Press Enter key to finish the whole procedure.<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh217QDASzjaEwIGTJZ_KalxDmGlaTGrsS_a_Ot_4-0iHIjoMeDmYrR3Xf2PrG2LBDisJc4CsBtl-b23Z8ZuOFVYZ8-sdDc8yD7ehsgI2gRL3RAujGsPIgM2bNrpBOEz-wMYsM/s1600/IMG_20160722_175741.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh217QDASzjaEwIGTJZ_KalxDmGlaTGrsS_a_Ot_4-0iHIjoMeDmYrR3Xf2PrG2LBDisJc4CsBtl-b23Z8ZuOFVYZ8-sdDc8yD7ehsgI2gRL3RAujGsPIgM2bNrpBOEz-wMYsM/s400/IMG_20160722_175741.jpg" width="400" height="300" /></a></li>
</ol>
</p>
<p>We can still enable Secure Boot in shim-signed again. Just execute <b>`sudo update-secureboot-policy --enable`</b> and then follow the similar steps above.<br><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIK4ja51XkuNPd7FNYce-fFKBBszQDdi0yV3F0B4PMblcXy349t_3b5bxe4TeYk1lZHJ7q0WH0C6sSeQpWWyJZF1MGepixxAeew5D5eZEfL9PM6GJZbzfmMGM2PWspX3A_vDE/s1600/EnableSecureBoot.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIK4ja51XkuNPd7FNYce-fFKBBszQDdi0yV3F0B4PMblcXy349t_3b5bxe4TeYk1lZHJ7q0WH0C6sSeQpWWyJZF1MGepixxAeew5D5eZEfL9PM6GJZbzfmMGM2PWspX3A_vDE/s400/EnableSecureBoot.png" width="400" height="256" /></a></p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-46158374924568081932016-05-30T23:02:00.000+08:002016-06-03T12:25:29.618+08:00編譯 Ubuntu 的 Linux kernel 來使用 USB to RS-232 輸出訊息<p>如果曾經有參加過台北的 <a href="http://blog.canonical.com/2011/12/12/ubuntu-hardware-summit-presentations-now-live/">Ubuntu Hardware Summit</a>,應該都會拿到一本橘色小手冊 <a href="http://odm.ubuntu.com/uhs/2011/Ubuntu-Debugging_A5-booklet.pdf">Ubuntu Debugging</a>,當中有提到可以設定幾個 Linux kernel 編譯選項中<pre class="brush:text">CONFIG_USB_SERIAL_CONSOLE=y
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_PL2303=y</pre></p>
<p>然後就可以在 Linux kernel 開機參數加上<pre class="brush:text">console=tty console=ttyUSB0,115200n8</pre></p>
<p>這樣就可以透過 USB to RS-232 傳輸線將 Linux kernel 訊息輸出到另外一台電腦上面,為什麼要這樣做有時候是因為 Linux kernel 開機時是什麼畫面也沒有,也不曉得中間到底發生了什麼事情,又或者是 Linux kernel 訊息出現的太快了,來不及看清楚完整的訊息一下子就過去了,也沒有來得及儲存到檔案系統上面就當機了,有著許許多多不同的情況可能會需要。</p>
<p>但是實際上要怎麼做才能夠編譯出 Ubuntu 上面所使用的 Linux kernel 呢?</p>
<p>首先是將 Ubuntu 所使用的 Linux kernel 的原始碼下載回來。</p>
<pre class="brush:shell">$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-xenial.git</pre>
<p>然後我自己 commit 了一些修改 (主要是針對 amd64)。</p>
<pre class="brush:shell">$ git diff HEAD^..HEAD
diff --git a/debian.master/abi/4.4.0-22.39/amd64/generic.modules b/debian.master/abi/4.4.0-22.39/amd64/generic.modules
index e1b9392..53d7914 100644
--- a/debian.master/abi/4.4.0-22.39/amd64/generic.modules
+++ b/debian.master/abi/4.4.0-22.39/amd64/generic.modules
@@ -2873,7 +2873,6 @@ pixcir_i2c_ts
pkcs7_test_key
pktcdvd
pktgen
-pl2303
platform_lcd
plat_nand
plat-ram
@@ -4236,7 +4235,6 @@ usblp
usbmon
usbmouse
usbnet
-usbserial
usb-serial-simple
usbsevseg
usb-storage
diff --git a/debian.master/config/annotations b/debian.master/config/annotations
index 825012f..167ab6e 100644
--- a/debian.master/config/annotations
+++ b/debian.master/config/annotations
@@ -6609,7 +6609,7 @@ CONFIG_USB_STORAGE_ENE_UB6250 policy<{'amd64': 'm', 'arm64': '
CONFIG_USB_UAS policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
# Menu: Device Drivers >> USB support >> Support for Host-side USB >> USB Serial Converter support
-CONFIG_USB_SERIAL policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
+CONFIG_USB_SERIAL policy<{'amd64': 'y', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
CONFIG_USB_SERIAL_GENERIC policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'i386': 'y', 'powerpc': 'y', 'ppc64el': 'y'}>
CONFIG_USB_SERIAL_SIMPLE policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
CONFIG_USB_SERIAL_AIRCABLE policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
@@ -6641,7 +6641,7 @@ CONFIG_USB_SERIAL_MOS7715_PARPORT policy<{'amd64': 'y', 'arm64': '
CONFIG_USB_SERIAL_MOS7840 policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
CONFIG_USB_SERIAL_MXUPORT policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
CONFIG_USB_SERIAL_NAVMAN policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
-CONFIG_USB_SERIAL_PL2303 policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
+CONFIG_USB_SERIAL_PL2303 policy<{'amd64': 'y', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
CONFIG_USB_SERIAL_OTI6858 policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
CONFIG_USB_SERIAL_QCAUX policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
CONFIG_USB_SERIAL_QUALCOMM policy<{'amd64': 'm', 'arm64': 'm', 'armhf': 'm', 'i386': 'm', 'powerpc': 'm', 'ppc64el': 'm'}>
diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu
index 505a3c7..7cb1284 100644
--- a/debian.master/config/config.common.ubuntu
+++ b/debian.master/config/config.common.ubuntu
@@ -8391,7 +8391,8 @@ CONFIG_USB_RIO500=m
CONFIG_USB_RTL8150=m
CONFIG_USB_RTL8152=m
CONFIG_USB_S2255=m
-CONFIG_USB_SERIAL=m
+CONFIG_USB_SERIAL=y
+CONFIG_USB_SERIAL_CONSOLE=y
CONFIG_USB_SERIAL_AIRCABLE=m
CONFIG_USB_SERIAL_ARK3116=m
CONFIG_USB_SERIAL_BELKIN=m
@@ -8439,7 +8440,7 @@ CONFIG_USB_SERIAL_OMNINET=m
CONFIG_USB_SERIAL_OPTICON=m
CONFIG_USB_SERIAL_OPTION=m
CONFIG_USB_SERIAL_OTI6858=m
-CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_PL2303=y
CONFIG_USB_SERIAL_QCAUX=m
CONFIG_USB_SERIAL_QT2=m
CONFIG_USB_SERIAL_QUALCOMM=m
</pre>
<p>接著開始編譯 Linux kernel (在有八個 CPU cores 的電腦上)</p>
<pre class="brush:shell">$ CONCURRENCY_LEVEL=8 fakeroot debian/rules clean binary-generic</pre>
<p>最後就會在上層目錄產生 Ubuntu 所使用的 Linux kernel 的 Debian packages 了。</p>
<pre class="brush:text">$ ls -1 ../*.deb
../linux-cloud-tools-4.4.0-22-generic_4.4.0-22.40_amd64.deb
../linux-headers-4.4.0-22-generic_4.4.0-22.40_amd64.deb
../linux-image-4.4.0-22-generic_4.4.0-22.40_amd64.deb
../linux-image-extra-4.4.0-22-generic_4.4.0-22.40_amd64.deb
../linux-tools-4.4.0-22-generic_4.4.0-22.40_amd64.deb
</pre>
<p>這樣就可以將這些 Debian packages 拿去安裝使用了。</p>
<p>最後我放了一份在 <a href="http://people.ubuntu.com/~fourdollars/usb2rs232/">http://people.ubuntu.com/~fourdollars/usb2rs232/</a> 上面,也許有人剛好也需要想要測試一下效果如何。</p>
<p>參考資料:<a href="https://wiki.ubuntu.com/Kernel/KernelDebuggingTricks">https://wiki.ubuntu.com/Kernel/KernelDebuggingTricks</a></p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-55152098887538939642015-11-09T17:59:00.000+08:002015-11-10T15:10:32.289+08:00手動快速編譯 Ubuntu 14.04 當中 Linux kernel 裡面的 i915 module<p>首先要下載 Linux kernel source tree</p>
<pre class="brush:shell">$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-trusty.git</pre>
<p>然後進去該目錄,並且切換到 vivid branch (這邊使用的是 Ubuntu 14.04 當中 <a href="https://wiki.ubuntu.com/Kernel/LTSEnablementStack">LTS Enablement Stacks</a> 當中的 vivid)</p>
<pre class="brush:shell">$ git checkout -b vivid origin/lts-backport-vivid</pre>
<p>快速產生目標的 .config</p>
<pre class="brush:shell">$ cat debian.vivid/config/config.common.ubuntu debian.vivid/config/amd64/config.common.amd64 debian.vivid/config/amd64/config.flavour.generic > .config</pre>
<p>執行一些設定腳本</p>
<pre class="brush:shell">$ make oldconfig && make prepare && make scripts</pre>
<p>設定環境變數 (接下來會使用到)</p>
<pre class="brush:shell">$ export KDIR=$PWD</pre>
<p>複製 Module.symvers (如果要編譯的 Linux kernel 跟系統所使用的剛好相同)</p>
<pre class="brush:shell">$ cp -v /lib/modules/$(uname -r)/build/Module.symvers Module.symvers</pre>
<p>不然就需要至少編譯整個 Linux kernel 一遍才行 (-j? 可以參考 /proc/cpuinfo 的數量來決定)</p>
<pre class="brush:shell">$ make -j8</pre>
<p>切換到該 module 的目錄底下,不過 Ubuntu 的 Linux kernel 目前有兩份不同的 i915 module,一份放在 drivers/gpu/drm/i915 底下,另一份放在 ubuntu/i915 底下。</p>
<pre class="brush:shell">$ cd drivers/gpu/drm/i915</pre>
<p>或是</p>
<pre class="brush:shell">$ cd ubuntu/i915</pre>
<p>然後開始編譯 (J=? 可以參考 /proc/cpuinfo 的數量來決定)</p>
<pre class="brush:shell">$ make -C $KDIR M=$PWD J=8</pre>
<p>參考資料:<a href="https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel">Kernel/BuildYourOwnKernel - Ubuntu Wiki</a> 跟 <a href="https://www.kernel.org/doc/Documentation/kbuild/modules.txt">Documentation/kbuild/modules.txt</a></p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-84481590116351631002015-07-21T23:22:00.000+08:002015-07-21T23:22:58.811+08:00在 GNU/Linux 系統上使用指令來燒錄光碟的一些心得<p>首先是 dvd+rw-mediainfo 這個指令可以用來檢查光碟機裡面到底是放著哪一種光碟片。</p>
<pre class="brush:shell; highlight: [4, 15];">$ sudo dvd+rw-mediainfo /dev/sr0
INQUIRY: [HL-DT-ST][DVD+-RW GP60N ][A300]
GET [CURRENT] CONFIGURATION:
Mounted Media: 1Ah, DVD+RW
Media ID: RITEK/004
Current Write Speed: 4.0x1385=5540KB/s
Write Speed #0: 4.0x1385=5540KB/s
Write Speed #1: 2.4x1385=3324KB/s
Speed Descriptor#0: 00/2295103 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s
Speed Descriptor#1: 00/2295103 R@8.0x1385=11080KB/s W@2.4x1385=3324KB/s
READ DVD STRUCTURE[#0h]:
Media Book Type: 00h, DVD-ROM book [revision 0]
Legacy lead-out at: 2295104*2KB=4700372992
READ DISC INFORMATION:
Disc status: blank
Number of Sessions: 1
State of Last Session: empty
"Next" Track: 1
Number of Tracks: 1
READ FORMAT CAPACITIES:
unformatted: 2295104*2048=4700372992
26h(0): 2295104*2048=4700372992
READ TRACK INFORMATION[#1]:
Track State: invisible incremental
Track Start Address: 0*2KB
Free Blocks: 2295104*2KB
Track Size: 2295104*2KB
READ CAPACITY: 0*2048=0</pre>
<p>看到 Mounted Media 這行寫著 DVD+RW 就是<b>光碟片的規格</b>了,另外是 Disc status 這行可以看到目前光碟片的內容是空白的。</p>
<p>另外使用 wodim 也可以看到光碟片的規格,不過更重要的是 wodim 可以看到<b>光碟機的規格</b>。</p>
<pre class="brush:shell; highlight: [18, 34];">$ sudo wodim dev=/dev/sr0 driveropts=help -checkdrive -v
TOC Type: 1 = CD-ROM
scsidev: '/dev/sr0'
devname: '/dev/sr0'
scsibus: -2 target: -2 lun: -2
Linux sg driver version: 3.5.27
Wodim version: 1.1.11
Driveropts: 'help'
SCSI buffer size: 64512
Device type : Removable CD-ROM
Version : 0
Response Format: 2
Capabilities :
Vendor_info : 'HL-DT-ST'
Identification : 'DVD+-RW GP60N '
Revision : 'A300'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Current: 0x001A (DVD+RW)
Profile: 0x0012 (DVD-RAM)
Profile: 0x002B (DVD+R/DL)
Profile: 0x001B (DVD+R)
Profile: 0x001A (DVD+RW) (current)
Profile: 0x0016 (DVD-R/DL layer jump recording)
Profile: 0x0015 (DVD-R/DL sequential recording)
Profile: 0x0014 (DVD-RW sequential recording)
Profile: 0x0013 (DVD-RW restricted overwrite)
Profile: 0x0011 (DVD-R sequential recording)
Profile: 0x0010 (DVD-ROM)
Profile: 0x000A (CD-RW)
Profile: 0x0009 (CD-R)
Profile: 0x0008 (CD-ROM)
Profile: 0x0002 (Removable disk)
Driver options:
burnfree Prepare writer to use BURN-Free technology
noburnfree Disable using BURN-Free technology
</pre>
<p>像是我目前使用的燒錄機有支援 burnfree 的功能,wodim 如果加上 -prcap 來使用,可以看到更詳細的細節。</p>
<pre class="brush:shell">$ sudo wodim -prcap dev=/dev/sr0 driveropts=help -checkdrive -v
TOC Type: 1 = CD-ROM
scsidev: '/dev/sr0'
devname: '/dev/sr0'
scsibus: -2 target: -2 lun: -2
Linux sg driver version: 3.5.27
Wodim version: 1.1.11
Driveropts: 'help'
SCSI buffer size: 64512
Device type : Removable CD-ROM
Version : 0
Response Format: 2
Capabilities :
Vendor_info : 'HL-DT-ST'
Identification : 'DVD+-RW GP60N '
Revision : 'A300'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Drive capabilities, per MMC-3 page 2A:
Does read CD-R media
Does write CD-R media
Does read CD-RW media
Does write CD-RW media
Does read DVD-ROM media
Does read DVD-R media
Does write DVD-R media
Does read DVD-RAM media
Does write DVD-RAM media
Does support test writing
Does read Mode 2 Form 1 blocks
Does read Mode 2 Form 2 blocks
Does read digital audio blocks
Does restart non-streamed digital audio reads accurately
Does support Buffer-Underrun-Free recording
Does read multi-session CDs
Does read fixed-packet CD media using Method 2
Does not read CD bar code
Does not read R-W subcode information
Does read raw P-W subcode data from lead in
Does return CD media catalog number
Does return CD ISRC information
Does support C2 error pointers
Does not deliver composite A/V data
Does play audio CDs
Number of volume control levels: 255
Does support individual volume control setting for each channel
Does support independent mute setting for each channel
Does not support digital output on port 1
Does not support digital output on port 2
Loading mechanism type: tray
Does support ejection of CD via START/STOP command
Does not lock media on power up via prevent jumper
Does allow media to be locked in the drive via PREVENT/ALLOW command
Is currently in a media-locked state
Does not support changing side of disk
Does not have load-empty-slot-in-changer feature
Does not support Individual Disk Present feature
Maximum read speed: 11080 kB/s (CD 62x, DVD 8x)
Current read speed: 11080 kB/s (CD 62x, DVD 8x)
Maximum write speed: 5540 kB/s (CD 31x, DVD 4x)
Current write speed: 5540 kB/s (CD 31x, DVD 4x)
Rotational control selected: CLV/PCAV
Buffer size in KB: 768
Copy management revision supported: 1
Number of supported write speeds: 2
Write speed # 0: 5540 kB/s CLV/PCAV (CD 31x, DVD 4x)
Write speed # 1: 3324 kB/s CLV/PCAV (CD 18x, DVD 2x)
Supported CD-RW media types according to MMC-4 feature 0x37:
Does write multi speed CD-RW media
Does write high speed CD-RW media
Does write ultra high speed CD-RW media
Does not write ultra high speed+ CD-RW media</pre>
<p>如果是從來都沒有使用過的 DVD+RW 片,可能會需要先格式化一次。<p>
<pre class="brush:shell; highlight:[17];">$ sudo wodim dev=/dev/sr0 -format
...
$ sudo dvd+rw-mediainfo /dev/sr0
INQUIRY: [HL-DT-ST][DVD+-RW GP60N ][A300]
GET [CURRENT] CONFIGURATION:
Mounted Media: 1Ah, DVD+RW
Media ID: RITEK/004
Current Write Speed: 4.0x1385=5540KB/s
Write Speed #0: 4.0x1385=5540KB/s
Write Speed #1: 2.4x1385=3324KB/s
Speed Descriptor#0: 00/2295103 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s
Speed Descriptor#1: 00/2295103 R@8.0x1385=11080KB/s W@2.4x1385=3324KB/s
READ DVD STRUCTURE[#0h]:
Media Book Type: 00h, DVD-ROM book [revision 0]
Legacy lead-out at: 2295104*2KB=4700372992
READ DISC INFORMATION:
Disc status: complete
Number of Sessions: 1
State of Last Session: complete
Number of Tracks: 1
BG Format Status: in progress, 78.1% complete
READ FORMAT CAPACITIES:
formatted: 2295104*2048=4700372992
26h(0): 2295104*2048=4700372992
READ TRACK INFORMATION[#1]:
Track State: complete incremental
Track Start Address: 0*2KB
Free Blocks: 0*2KB
Track Size: 2295104*2KB
FABRICATED TOC:
Track#1 : 14@0
Track#AA : 14@2295104
Multi-session Info: #1@0
READ CAPACITY: 2295104*2048=4700372992
</pre>
<p>DVD+RW 格式化完後 Disc status 會變成 complete。</p>
<p>如果使用的是已經有寫入資料的 DVD-RW 片,可能會需要先快速抹除光碟內容。</p>
<pre class="brush:shell">$ sudo wodim -v dev=/dev/sr0 blank=fast</pre>
<p>如果快速抹除光碟片執行失敗,也許可以試試看強迫完整抹除光碟內容。</p>
<pre class="brush:shell">$ sudo wodim -v dev=/dev/sr0 blank=all -force</pre>
<p>DVD-RW 抹除後會長像下面這樣。</p>
<pre class="brush:shell">$ sudo dvd+rw-mediainfo /dev/sr0
INQUIRY: [HL-DT-ST][DVD+-RW GP60N ][A300]
GET [CURRENT] CONFIGURATION:
Mounted Media: 14h, DVD-RW Sequential
Media ID: RITEKW04
Current Write Speed: 4.0x1385=5540KB/s
Write Speed #0: 4.0x1385=5540KB/s
Write Speed #1: 2.0x1385=2770KB/s
Speed Descriptor#0: 00/2298495 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s
Speed Descriptor#1: 00/2298495 R@8.0x1385=11080KB/s W@2.0x1385=2770KB/s
READ DVD STRUCTURE[#10h]:
Media Book Type: 00h, DVD-ROM book [revision 0]
Legacy lead-out at: 2298496*2KB=4707319808
READ DVD STRUCTURE[#0h]:
Media Book Type: 33h, DVD-RW book [revision 3]
Last border-out at: 8390653*2KB=17184057344
READ DISC INFORMATION:
Disc status: blank
Number of Sessions: 1
State of Last Session: empty
"Next" Track: 1
Number of Tracks: 1
READ FORMAT CAPACITIES:
unformatted: 2297888*2048=4706074624
00h(800): 2297888*2048=4706074624
10h(10): 2297888*2048=4706074624
15h(10): 2297888*2048=4706074624
READ TRACK INFORMATION[#1]:
Track State: blank
Track Start Address: 0*2KB
Next Writable Address: 0*2KB
Free Blocks: 2297888*2KB
Track Size: 2297888*2KB
READ CAPACITY: 0*2048=0</pre>
<p>有時候可能會想要指定最低倍速來燒錄光碟片,因為光碟機或光碟片的品質問題,會導致全速燒錄時的失敗,最低倍速的燒錄會相對保險一些。</p>
<pre class="brush:shell">$ sudo wodim -v -eject dev=/dev/sr0 speed=2 driveropts=burnfree Windows10_InsiderPreview_x64_ZH-TW_10162.iso</pre>
<p>加上 -eject 是希望燒錄完成後將光碟片拖盤退出(如果光碟機真的有拖盤的話),加上 driveropts=burnfree 是因為光碟機有這個功能。</p>
<p>使用 DVD+RW 跟 DVD-RW 的不同點在於 DVD+RW 只要格式化一次,之後就可以重覆地直接將 ISO 寫進去,不需要像 DVD-RW 那樣,每次都要先抹除內容,然後才可以將 ISO 寫進去。</p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-55883921220785314262015-03-23T18:19:00.000+08:002015-09-07T20:59:18.096+08:00為 Bay Trail 低功耗小電腦安裝 Ubuntu 14.04.2 所做的一些最佳化<h3>首先是實體記憶體只有 1~2 GB</h3>
<p>
所以安裝 zram-config 跟修改 /etc/default/grub 當中的 GRUB_CMDLINE_LINUX 加上 zswap.enabled=1
<pre class="brush:shell">
sudo apt-get install zram-config
sudo service zram-config start
sudo sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="zswap.enabled=1"/' /etc/default/grub
</pre>
<a href="http://zh.wikipedia.org/wiki/Zram">Zram</a> 是壓縮實體記憶體當中的資料的技術,而 <a href="http://zh.wikipedia.org/wiki/Zswap">Zswap</a> 則是壓縮 Swap 分割區當中的資料的技術,兩者都會稍微增加 CPU 使用量。</p>
<p>另外也可以使用更有效率的 <a href="https://github.com/Cyan4973/lz4">lz4</a> 壓縮格式,請參考 <a href="http://www.plurk.com/p/kumpgn">http://www.plurk.com/p/kumpgn</a> 及 <a href="http://paste.ubuntu.com/10722290/">/etc/init/zram-config.conf</a> 的設定。</p>
<h3>然後是透過 VAAPI 來使用硬體解碼器</h3>
<p>首先可以安裝 <a href="https://01.org/linuxgraphics/community/vaapi">VAAPI</a> 相關的軟體套件。</p>
<pre class="brush:shell">
sudo apt-get install i965-va-driver gstreamer1.0-vaapi vainfo
</pre>
<p>然後就可以透過 vainfo 指令看到有支援哪些硬體加速編碼跟解碼</p>
<pre class="brush:shell">
$ vainfo
libva info: VA-API version 0.35.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.35 (libva 1.3.0)
vainfo: Driver version: Intel i965 driver - 1.3.0
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
VAProfileJPEGBaseline : VAEntrypointVLD
</pre>
<p>然後安裝 VLC 媒體播放器後,再從偏好設定中開啟功能。</p>
<pre class="brush:shell">
sudo apt-get install --yes vlc
</pre>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6ZaZFBhVzrleKLWr7DGDAZc1ll5l-q1fshdAlKBtGSjEVdjmPLXgfIvPAcjVvKdgf0gpv0SdQKTR8U84Zz51GMhXJvx1OlbwFMFB2CgyMwYQj4hQdTypzRbTtTK_bnvptslc/s1600/vlc.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6ZaZFBhVzrleKLWr7DGDAZc1ll5l-q1fshdAlKBtGSjEVdjmPLXgfIvPAcjVvKdgf0gpv0SdQKTR8U84Zz51GMhXJvx1OlbwFMFB2CgyMwYQj4hQdTypzRbTtTK_bnvptslc/s1600/vlc.png" /></a>
<h3>讓 Chromium 支援 VAAPI</h3>
<p>然後因為到目前為止 (2015/03/23) Google Chrome/Chromium 並沒有支援一般 Linux 系統上的 VAAPI,所以如果想要使用必須安裝 <a href="https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta">ppa:saiarcot895/chromium-beta</a> 所提供的 Chromium 才會有。</p>
<p>另外可能還需要更改 Chromium 的啟動參數,為了減少 Chromium 的記憶體使用量,我還參考了 <a href="http://www.chromium.org/developers/design-documents/process-models">Process Models - The Chromium Projects</a> 上面的模式,使用了 --process-per-site。</p>
<pre class="brush:shell">
sudo add-apt-repository --yes ppa:saiarcot895/chromium-beta
sudo apt-get update
sudo apt-get install --yes chromium-browser
sudo sed -i 's/CHROMIUM_FLAGS=""/CHROMIUM_FLAGS="--ignore-gpu-blacklist --process-per-site"/' /etc/chromium-browser/default
</pre>
<p>另外還要在 Chromium 上安裝 <a href="https://chrome.google.com/webstore/detail/adblock-for-youtube/cmedhionkhpnakcndndgjdbohmhepckk">Adblock for Youtube™</a> 跟 <a href="https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal">h264ify</a>,安裝 Adblock for Youtube™ 是因為 Youtube™ 影片內嵌的廣告會影響到播放品質,在這個低功耗的電腦上面特別明顯,而安裝 h264ify 則是因為 Youtube™ 預設的串流編碼是 VP9,而我用的這個電腦上面並沒有支援 VP9 的硬體加速解碼,所以安裝 h264ify 強制讓 Youtube™ 串流編碼變成 H264。</p>
<p>另外就是 Ubuntu Unity 桌面預設的 Totem 媒體播放器目前還沒有支援 VAAPI,不然安裝 gstreamer1.0-vaapi 可以派上用場了,不過也許可以參考 <a href="http://gitorious.org/vaapi/gstreamer-vaapi">http://gitorious.org/vaapi/gstreamer-vaapi</a> 當中的 README 使用 gst-launch-1.0 來感受一下。</p>
<pre class="brush:text">
Usage
-----
VA elements are automatically plugged into GStreamer pipelines. So,
using playbin (or playbin2 with GStreamer 0.10) should work as is.
However, here are a few alternate pipelines that could be manually
constructed.
* Play an H.264 video with an MP4 container in fullscreen mode
$ gst-launch-1.0 -v filesrc location=/path/to/video.mp4 ! \
qtdemux ! vaapidecode ! vaapisink fullscreen=true
* Play a raw MPEG-2 interlaced stream
$ gst-launch-1.0 -v filesrc location=/path/to/mpeg2.bits ! \
mpegvideoparse ! vaapidecode ! vaapipostproc ! vaapisink
* Convert from one pixel format to another, while also downscaling
$ gst-launch-1.0 -v filesrc location=/path/to/raw_video.yuv ! \
videoparse format=yuy2 width=1280 height=720 ! \
vaapipostproc format=nv12 height=480 ! vaapisink
* Encode a 1080p stream in raw I420 format into H.264
$ gst-launch-1.0 -v filesrc location=/path/to/raw_video.yuv ! \
videoparse format=i420 width=1920 height=1080 framerate=30/1 ! \
vaapiencode_h264 rate-control=cbr tune=high-compression ! \
qtmux ! filesink location=/path/to/encoded_video.mp4
</pre>
<p>Mozilla Firefox 目前好像也沒有支援 VAAPI,也許有人可以幫忙補充一下進度。</p>
<h3>未來的 PowerVR 對於 VP8 的硬體加速解碼支援</h3>
<p>目前只看到了兩則報導,分別是去年十月的 <a href="http://www.phoronix.com/scan.php?page=news_item&px=MTgxMjY">Intel Publishes DRM Driver For PowerVR Video Decoder! VP8 Decoding!</a> 跟今年一月的 <a href="http://www.phoronix.com/scan.php?page=news_item&px=MTg4Mjg">Intel Is Still Working On The VED DRM Driver For PowerVR</a>,但是還沒有看到那些 commits 進到 <a href="http://kernel.ubuntu.com/~kernel-ppa/mainline/">mainline kernel</a> 裡面,另外 Youtube™ 上面的預設串流編碼是 VP9,不曉得 VP8 的硬解支援能不能夠幫助到 VP9,目前看起來未來會多一兩個檔案名稱內有 ipvr 的 kernel module 。</p>
<p>最後另外順便收集了一下 <a href="http://www.dell.com/tw/p/xps-13-9343-laptop/pd">Dell New XPS 13</a> 在 vivid 上面的 vainfo 感覺還不錯。</p>
<pre class="brush: text">
libva info: VA-API version 0.37.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_37
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.37 (libva 1.5.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Broadwell - 1.5.0
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264MultiviewHigh : VAEntrypointVLD
VAProfileH264MultiviewHigh : VAEntrypointEncSlice
VAProfileH264StereoHigh : VAEntrypointVLD
VAProfileH264StereoHigh : VAEntrypointEncSlice
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileH264MultiviewHigh : VAEntrypointVLD
VAProfileH264MultiviewHigh : VAEntrypointEncSlice
VAProfileH264StereoHigh : VAEntrypointVLD
VAProfileH264StereoHigh : VAEntrypointEncSlice
</pre>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-45713634138457021652014-07-15T14:14:00.000+08:002017-07-03T11:19:00.764+08:00在 Ubuntu 上面安裝 mainline kernels<p>所謂的 mainline kernels 就是在 <a href="https://www.kernel.org/">The Linux Kernel Archives</a> 上面由 Linus Torvalds 本人釋出的版本,
而 Ubuntu 本來有一個 <a href="https://launchpad.net/~kernel-ppa">Ubuntu Kernel PPA</a> 專門用來編譯這些 mainline kernels,
只是後來不曉得為何就不再使用 PPA 改用手動編譯的方式,可能是因為 Linux kernel 的釋出方式有了許多變化,除了原本的 stable 跟 mainline 還另加入了 longterm 的支援,
而 Ubuntu 的 Kernel team 本來就有準備一個 <a href="http://kernel.ubuntu.com/~kernel-ppa/mainline/">http://kernel.ubuntu.com/~kernel-ppa/mainline/</a> 上面備份了所有的 mainline kernels,
所以就繼續沿用這樣的名稱,但其實這上面還包括了 stable 跟 longterm 後來所有的版本。</p>
<p>總之 <a href="http://kernel.ubuntu.com/~kernel-ppa/mainline/">http://kernel.ubuntu.com/~kernel-ppa/mainline/</a> 上面放的是沒有 Ubuntu 額外加料的原始 kernel 版本,只是都編譯成了 Debian package,
所以想要使用的人可以直接下載來安裝就可以使用了,而這些 kernel 如果在安裝使用上會有什麼問題,當然也不會在 Ubuntu 的支援之中,這些 kernel 的存在只是用來測試的,藉由安裝不同的版本來找出問題是在哪兩個版本之間發生的,或是在哪兩個版本之間解決的,進而幫助開發者縮小問題發生的地方,來找出相關合適的修補檔。</p>
<p>但是這樣不斷地手動下載安裝,也是很麻煩的,所以我寫了一個小工具來幫忙,它就叫做 <a href="https://raw.githubusercontent.com/fourdollars/scripts/master/mainline-kernels.sh">mainline-kernels.sh</a>,下載後像下面這樣執行就可以看到使用說明:</p>
<pre class="brush:shell">
$ ./mainline-kernels.sh --help
Usage ./mainline-kernels.sh:
-h|--help The manual of this script
-f|--from NUM Lower bound of kernel version
-t|--to NUM Upper bound of kernel version
-l|--list List available kernel versions
-r|--remove Remove mainline kernels
</pre>
<p>可以先使用 ./mainline-kernels.sh --list 來找出現在有哪些 kernel 可以使用。</p>
<pre class="brush:shell">
$ ./mainline-kernels.sh --list
2.6.15 2.6.24.7 2.6.24 2.6.25 2.6.26 2.6.27.47-intrepid
2.6.27.58-intrepid 2.6.27.59-intrepid 2.6.27.60-intrepid 2.6.27.61-intrepid 2.6.27.62-intrepid 2.6.27
2.6.28.10 2.6.28 2.6.29.6 2.6.29 2.6.30.10 2.6.30
...
3.15~rc3-utopic 3.15~rc4-utopic 3.15~rc5-utopic 3.15~rc6-utopic 3.15~rc7-utopic 3.15~rc8-utopic
3.15-utopic 3.15.1-utopic 3.15.2-utopic 3.15.3-utopic 3.15.4-utopic 3.15.5-utopic
3.16~rc1-utopic 3.16~rc2-utopic 3.16~rc3-utopic 3.16~rc4-utopic 3.16~rc5-utopic
</pre>
<p>然後直接安裝想要的 Linux kernel</p>
<pre class="brush:shell">
$ ./mainline-kernels.sh 3.16~rc4-utopic 3.16~rc5-utopic
</pre>
<p>或是指定一個範圍來安裝</p>
<pre class="brush:shell">
./mainline-kernels.sh --from 3.15~ --to 3.16
</pre>
<p>或是什麼都不指定直接執行,之後再慢慢從選單上面挑選。</p>
<pre class="brush:shell">
./mainline-kernels.sh
</pre>
<p>最後再將安裝的 Linux kernel 移除掉。</p>
<pre class="brush:shell">
./mainline-kernels.sh --remove
</pre>
<p>要提醒的一點是,這邊的版本號碼是遵循 Debian version 的規則,所以波浪符號有特別的意義,可以參考我以前的<a href="http://fourdollars.blogspot.com/2010/06/debian-package-5.html">文章</a>。</p>
<p>最後分享一下 <a href="http://people.canonical.com/~kernel/info/kernel-version-map.html">Ubuntu to Mainline kernel version mapping</a>,結束這一回合。</p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com1tag:blogger.com,1999:blog-14489808.post-55303327776504711062013-12-02T15:50:00.000+08:002013-12-02T15:59:11.971+08:00VirtualBox Guest 裡面共用資料夾的自動掛載<p>VirtualBox 有提供一個方便的功能,能將 Host 的某個資料夾自動掛載到 Guest 裡面使用,只是自動掛載的權限不是預設的使用者。</p>
<pre class="brush: shell">
sylee@vbox:~$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
vbox on /media/sf_vbox type vboxsf (gid=999,rw)
sylee@vbox:~$ id
uid=1000(sylee) gid=1000(sylee) groups=1000(sylee),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),111(lpadmin),112(sambashare)
</pre>
<p>這時候只要參考以前寫過的『<a href="http://fourdollars.blogspot.com/2012/08/ubuntu-virtualbox-vboxusers.html">如何解決在 Ubuntu 上面安裝 VirtualBox 後缺少 vboxusers 群組權限的問題</a>』,將預設的使用者加入到 vboxsf 這個群組裡面,再重新登入後,就可以自由地使用 /media/sf_vbox 底下的檔案了。</p>
<pre class="brush: shell">
sylee@vbox:~$ sudo usermod -a -G vboxsf sylee
</pre>
<p>隨意拿了 linux-generic-lts-quantal_3.5.0.44.50_amd64.deb linux-signed-generic-lts-quantal_3.5.0.44.50_amd64.deb linux-signed-image-generic-lts-quantal_3.5.0.44.50_amd64.deb linux-image-3.5.0-44-generic_3.5.0-44.67~precise1_amd64.deb linux-signed-image-3.5.0-44-generic_3.5.0-44.67~precise1_amd64.deb 來測試。</p>
<p>使用 vboxsf 來複製檔案。</p>
<pre class="brush:shell">
real 0m0.661s
user 0m0.004s
sys 0m0.284s
</pre>
<p>使用 sshfs 來複製檔案。</p>
<pre class="brush:shell">
real 0m2.276s
user 0m0.000s
sys 0m0.103s
</pre>
<p>sshfs 掰~</p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-27812633381722197942013-08-07T19:48:00.000+08:002013-08-07T19:48:22.720+08:00使用 GDB 追縱執行中程式裡面的變數值<p>首先是要安裝 debug symbols 的套件來使用。</p>
<p>Debian 可以參考 <a href="https://wiki.debian.org/HowToGetABacktrace">HowToGetABacktrace - Debian Wiki</a><br/>
Ubuntu 可以參考 <a href="https://wiki.ubuntu.com/DebuggingProgramCrash">DebuggingProgramCrash - Ubuntu Wiki</a></p>
<p>例如目標是 Ubuntu 12.04 中的 Xorg 裡面的 positionSprite() 函式在執行時傳入的變數值,所以先用 <pre class="brush: shell">$ ps aux | grep X
root 1044 0.4 1.0 127440 21524 tty7 Ss+ 18:44 0:06 /usr/bin/X :0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch -background none
u 2633 0.0 0.0 13616 928 pts/2 S+ 19:11 0:00 grep --color=auto X</pre>
來找出 Xorg 的 PID</p>
<p>然後執行以下指令:</p>
<pre class="brush: shell">
$ sudo gdb /usr/bin/Xorg 1044
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /usr/bin/Xorg...Reading symbols from /usr/lib/debug/usr/bin/Xorg...done.
done.
Attaching to program: /usr/bin/Xorg, process 1044
Reading symbols from /lib/x86_64-linux-gnu/libudev.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/x86_64-linux-gnu/libudev.so.0
... [省略]
(gdb) set height 0
(gdb) break positionSprite
Breakpoint 1 at 0x7fedc71d1140: file ../../dix/getevents.c, line 940.
(gdb) c
Continuing.
Breakpoint 1, positionSprite (dev=0x7fedc94105d0, mode=0, mask=0x7fff3c6e6780, devx=0x7fff3c6e6770, devy=0x7fff3c6e6778, screenx=0x7fff3c6e6760, screeny=0x7fff3c6e6768) at ../../dix/getevents.c:940
940 ../../dix/getevents.c: 沒有此一檔案或目錄.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>print *devx
>print *devy
>print *screenx
>print *screeny
>continue
>end
(gdb) c
Continuing.
</pre>
<p>接下來移動滑鼠就可以看到以下的訊息。</p>
<pre class="brush: shell">
Breakpoint 1, positionSprite (dev=0x7fedc94105d0, mode=0, mask=0x7fff3c6e6780, devx=0x7fff3c6e6770, devy=0x7fff3c6e6778, screenx=0x7fff3c6e6760, screeny=0x7fff3c6e6768) at ../../dix/getevents.c:940
940 in ../../dix/getevents.c
$45 = 1023.4510981145139
$46 = 757.60130195816362
$47 = 1366.6023460649326
$48 = 758.58904811456273
Breakpoint 1, positionSprite (dev=0x7fedc94105d0, mode=0, mask=0x7fff3c6e6780, devx=0x7fff3c6e6770, devy=0x7fff3c6e6778, screenx=0x7fff3c6e6760, screeny=0x7fff3c6e6768) at ../../dix/getevents.c:940
940 in ../../dix/getevents.c
$49 = 1022.651098102593
$50 = 757.60130195816362
$51 = 1365.5341153549775
$52 = 758.58904811456273
</pre>
<p>可以將設定好的 breakpoints 的動作儲存成一個腳本檔</p>
<pre class="brush: shell">
(gdb) save breakpoints break.cmd
Saved to file 'break.cmd'.
</pre>
<p>腳本的內容是:</p>
<pre class="brush:text">
set height 0
break positionSprite
commands
print *devx
print *devy
print *screenx
print *screeny
cont
end
</pre>
<p>只是第一行的 set height 0 是手動加上去的,目的是不要訊息過長就停下來。</p>
<p>下次再使用 GDB 時就可以執行 source 載入使用。</p>
<pre class="brush: shell">
(gdb) source break.cmd
Breakpoint 1 at 0x7fedc71d1140: file ../../dix/getevents.c, line 940.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00007fedc71d1140 in positionSprite at ../../dix/getevents.c:940
print *devx
print *devy
print *screenx
print *screeny
cont
</pre>
<p>只是前面有一個找不到原始碼的小問題,可以執行以下指令來下載原始碼:</p>
<pre class="brush: shell">
$ apt-get source xserver-xorg-core-lts-quantal
</pre>
或是:
<pre class="brush: shell">
$ pull-lp-source xorg-server-lts-quantal precise
</pre>
<p>然後再執行:</p>
<pre class="brush: shell">
$ sudo gdb /usr/bin/Xorg 1044 -d xorg-server-lts-quantal-1.13.0
</pre>
<p>最後 GDB 有其它的 Frontend 可以使用,像是 cgdb 以及 ddd 在這裡就不多提了。</p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-50214778286994376252013-07-31T18:38:00.000+08:002013-07-31T18:38:10.271+08:00Linux 電源供應的系統資訊<p>在筆記型電腦或是使用藍牙裝置時,系統上面都會有電源供應的資訊。</p>
<p>只要在 /sys/devices 底下找尋 power_supply 的目錄就可以找到。</p>
<p>如下所示:</p>
<pre class="brush: shell">
u@u:/sys/devices$ find -name power_supply | while read path; do ls -l $(dirname $path); done
total 0
lrwxrwxrwx 1 root root 0 Jul 31 17:42 driver -> ../../../../../../../../../../bus/hid/drivers/apple
drwxr-xr-x 3 root root 0 Jul 31 17:38 hidraw
-r--r--r-- 1 root root 4096 Jul 31 17:42 modalias
drwxr-xr-x 2 root root 0 Jul 31 17:39 power
drwxr-xr-x 3 root root 0 Jul 31 17:39 power_supply
-r--r--r-- 1 root root 4096 Jul 31 17:42 report_descriptor
lrwxrwxrwx 1 root root 0 Jul 31 17:38 subsystem -> ../../../../../../../../../../bus/hid
-rw-r--r-- 1 root root 4096 Jul 31 17:38 uevent
total 0
lrwxrwxrwx 1 root root 0 Jul 31 17:42 driver -> ../../../../../../../../../../bus/hid/drivers/magicmouse
drwxr-xr-x 3 root root 0 Jul 31 17:39 hidraw
-r--r--r-- 1 root root 4096 Jul 31 17:42 modalias
drwxr-xr-x 2 root root 0 Jul 31 17:39 power
drwxr-xr-x 3 root root 0 Jul 31 17:39 power_supply
-r--r--r-- 1 root root 4096 Jul 31 17:42 report_descriptor
lrwxrwxrwx 1 root root 0 Jul 31 17:39 subsystem -> ../../../../../../../../../../bus/hid
-rw-r--r-- 1 root root 4096 Jul 31 17:39 uevent
total 0
lrwxrwxrwx 1 root root 0 Jul 31 17:42 driver -> ../../../../../../bus/acpi/drivers/battery
-r--r--r-- 1 root root 4096 Jul 31 17:42 hid
-r--r--r-- 1 root root 4096 Jul 31 17:42 modalias
-r--r--r-- 1 root root 4096 Jul 31 17:42 path
drwxr-xr-x 2 root root 0 Jul 31 17:39 power
drwxr-xr-x 3 root root 0 Jul 31 17:36 power_supply
lrwxrwxrwx 1 root root 0 Jul 31 17:36 subsystem -> ../../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Jul 31 17:36 uevent
total 0
lrwxrwxrwx 1 root root 0 Jul 31 17:42 driver -> ../../../../../../bus/acpi/drivers/ac
-r--r--r-- 1 root root 4096 Jul 31 17:42 hid
-r--r--r-- 1 root root 4096 Jul 31 17:42 modalias
-r--r--r-- 1 root root 4096 Jul 31 17:42 path
drwxr-xr-x 2 root root 0 Jul 31 17:39 power
drwxr-xr-x 3 root root 0 Jul 31 17:36 power_supply
lrwxrwxrwx 1 root root 0 Jul 31 17:36 subsystem -> ../../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Jul 31 17:36 uevent
</pre>
<p>所以可以從 driver 這個 symbolic link 看出每個電源供應是屬於哪些裝置。</p>
<p>另外也可以使用指令來監測 udev 裡面關於 power_supply 的訊息。</p>
<p>如下所示:</p>
<pre class="brush: shell">
u@u:~$ udevadm monitor --subsystem-match=power_supply
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[65.358427] change /devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1:1.0/bluetooth/hci0/hci0:13/0005:05AC:030D.0002/power_supply/hid-AB:CD:EF:12:34:56-battery (power_supply)
UDEV [65.398449] change /devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1:1.0/bluetooth/hci0/hci0:13/0005:05AC:030D.0002/power_supply/hid-AB:CD:EF:12:34:56-battery (power_supply)
KERNEL[81.032204] change /devices/LNXSYSTM:00/device:00/PNP0A08:00/device:0c/PNP0C0A:00/power_supply/BAT1 (power_supply)
UDEV [81.033615] change /devices/LNXSYSTM:00/device:00/PNP0A08:00/device:0c/PNP0C0A:00/power_supply/BAT1 (power_supply)
</pre>
<p>最後就是 Freedesktop 有一個 <a href="http://upower.freedesktop.org/">UPower</a> 專案,專門用來提供底層電源資訊的介面給桌面應用程式來使用。</p>
<p>如果是在 GNOME 桌面環境底下就是 gnome-settings-daemon 與 gnome-power-manager 透過 DBus 來使用 UPower 以提供圖形介面給桌面使用者使用。</p>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-36219330503742835512013-05-13T16:16:00.000+08:002013-05-13T16:16:37.340+08:00自製 Ubuntu 13.04/12.10/12.04.2 與 Debian 7.0 測試硬體安裝使用的 USB 隨身碟<p>為了同時可以在 Legacy BIOS 與 UEFI BIOS 上使用的,首先使用 Ubuntu 12.04.2 以上內建的 usb-creator-gtk 工具來產生一個 Ubuntu 13.04 desktop amd64 的 USB 隨身碟來用。</p>
<pre class="brush:shell">$ usb-creator-gtk -n -i ubuntu-13.04-desktop-amd64.iso</pre>
<p>接下來的動作,只要使用 Ubuntu 13.04 的 Live System (amd64) 就可以了,不用安裝到硬碟上面。</p>
<p>進入 Ubuntu 13.04 Live System (amd64) 之後,執行以下指令。</p>
<pre class="brush:shell">ubuntu@ubuntu:~$ sudo apt-get install grub-pc-bin grub-efi-amd64-bin
正在讀取套件清單... 完成
正在重建相依關係
正在讀取狀態資料... 完成
grub-pc-bin 已經是最新版本了。
下列【新】套件將會被安裝:
efibootmgr grub-efi-amd64-bin
升級 0 個,新安裝 2 個,移除 0 個,有 0 個未被升級。
需要下載 0 B/581 kB 的套件檔。
此操作完成之後,會多佔用 2,316 kB 的磁碟空間。
選取了原先未選的套件 efibootmgr。
(讀取資料庫 ... 目前共安裝了 161462 個檔案和目錄。)
解開 efibootmgr(從 .../efibootmgr_0.5.4-4ubuntu1_amd64.deb)...
選取了原先未選的套件 grub-efi-amd64-bin。
解開 grub-efi-amd64-bin(從 .../grub-efi-amd64-bin_2.00-13ubuntu3_amd64.deb)...
執行 man-db 的觸發程式 ...
設定 efibootmgr (0.5.4-4ubuntu1) ...
設定 grub-efi-amd64-bin (2.00-13ubuntu3) ...
</pre>
<p>將另外一隻 USB 隨身碟插入 USB 埠,執行以下指令。</p>
<pre class="brush:shell">
ubuntu@ubuntu:~$ sudo grub-install --removable --target=i386-pc --root-directory=/media/ubuntu/UsbStick/ /dev/sdc
Installation finished. No error reported.
ubuntu@ubuntu:~$ sudo grub-install --removable --target=x86_64-efi --root-directory=/media/ubuntu/UsbStick/ /dev/sdc
/usr/sbin/grub-probe: error: failed to get canonical path of /cow.
Installation finished. No error reported.</pre>
<p>請將以上的 /dev/sdc 與 /media/ubuntu/UsbStick/ 代換成符合實際使用環境上的字串。</p>
<p>接下來將 <a href="https://gist.github.com/fourdollars/5479632">grub.cfg</a> 放到 /media/ubuntu/UsbStick/boot/grub/ 底下。</p>
<p>最後再將相對應的 ISO 檔案都放到 /media/ubuntu/UsbStick/iso/ 底下就可以了。</p>
<p>之後只要針對 grub.cfg 的內容做調整加入需要的選項即可。</p>
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRHEyxlF5c7LlGRipslrrB3ElgoI9S5FRWUcOYvOzu_Fas8Gel_xDyvfs7FGwkfnlQn13q_4wfLObNHgiAq15guTDrnPieSEQJcdFdt9zi50unvQgZm09zURehBb-xarvHO_k/s1600/usb-installer.png" />
<p>這樣一來就可以在安裝前先測試看看硬體的相容性,再來決定要不要安裝到硬碟裡面。</p>
<cite>P.S. Ubuntu 上面有些無線網路的驅動程式是要安裝到硬碟裡面重新啟動才會正常運作的。</cite>
$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-5128905310548808052012-12-24T14:07:00.000+08:002012-12-24T15:32:41.936+08:00Quick - an installation helper for GNU/Linux.<p>我自己平時都是使用 Debian/Ubuntu 裡面的 APT 來安裝軟體套件,就連自己寫了一些小軟體也是會放到 PPA 上面,然後再透過 APT 下載回來安裝,但是並不是所有的軟體都有 Open Source 或是有人有準備好 PPA 可以直接透過 APT 來安裝。</p>
<p>於是乎,我花了兩三天的時間製作了這個簡單的工具用來管理這些額外的軟體。</p>
<p><a href="http://fourdollars.github.com/quick/">Quick - an installation helper for GNU/Linux.</a></p>
<p>使用方式就是執行下面這段指令來安裝:</p>
<pre class="brush:shell">$ wget http://bit.ly/quick-installer -O - | bash -</pre>
<p>安裝完成之後要先登出,再重新登入系統。</p>
<p>接下來執行以下指令來安裝更新套件列表:</p>
<pre class="brush:shell">$ quick update</pre>
<p>然後再執行以下指令來安裝軟體套件:</p>
<pre class="brush:shell">$ quick install sublime-text</pre>
<p>安裝後,想要移除掉就執行:</p>
<pre class="brush:shell">$ quick remove sublime-text</pre>
<p>其它使用方式執行以下指令來看說明。</p>
<pre class="brush:shell">$ quick</pre>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-39943644148465785812011-07-24T22:50:00.004+08:002011-07-25T15:28:59.140+08:00關於 uptime 的一些小事在 GNU/Linux 系統底下如果想要知道電腦開機後使用了多久的時間,可以直接打指令:<br />
<pre class="brush: shell">$ uptime
22:35:06 up 6:26, 4 users, load average: 0.00, 0.03, 0.05
</pre>或是利用 /proc/uptime 來取得資料:<br />
<pre class="brush: shell">$ cat /proc/uptime
23282.04 41316.79
</pre>但是如果想要寫 C 程式來取得資料呢?<br />
我找到一個在 <time.h> 裡面的函式 clock_gettime()<br />
程式碼如下:<br />
<pre class="brush:c">#include <stdio.h>
#include <time.h>
int main(int argc, char* argv[])
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
printf("%ld.%ld\n", ts.tv_sec, ts.tv_nsec);
}
return 0;
}
</pre>在編譯的時候要加上 -lrt 才能通過編譯<br />
<pre class="brush: shell">$ gcc -Wall -g -lrt uptime.c -o uptime
</pre>執行的結果<br />
<pre class="brush: shell">$ ./uptime
23637.821285555
</pre>因為我想要在 XWindow 底下根據當下的開機時間,製造出新的 XKeyEvent 出來,而所有的 XEvent 都是使用毫秒的時間格式 (ex. 23637821),所以才去找出這個的函式來用。<br />
詳細的使用說明可以看 manpage<br />
<pre class="brush: shell">$ man clock_gettime
</pre>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-24016758901904207132011-01-31T10:52:00.000+08:002011-01-31T10:52:03.239+08:00一個好用的 irssi plugin - irssi-libnotifyirssi 是一個在終端機文字模式下面連 IRC 的工具<br />
通常 irssi 的使用方式是搭配 screen 或是 tmux<br />
然後找一台一直開著 BSD/Linux 主機在上面掛著<br />
不過也有的人用久了即使是在本機上面使用也是開 irssi<br />
然後就會開始想著有沒有辦法在別人丟你訊息的時候能夠在桌面上跳出通知<br />
<a href="http://code.google.com/p/irssi-libnotify/">irssi-libnotify</a> 就是這樣的工具<br />
在 GNU/Linux 上面使用要另外搭配 notify-send 這個指令<br />
如果使在 Ubuntu 上面就是直接安裝 libnotify-bin 這個套件<br />
<br />
首先把 notify.pl 裝進 .irssi/scripts/ 底下<br />
<pre class="brush: shell">$ mkdir -p ~/.irssi/scripts/
$ wget http://irssi-libnotify.googlecode.com/svn/trunk/notify.pl -O ~/.irssi/scripts/notify.pl
</pre><br />
使用方法是在 irssi 啟動後輸入<br />
<pre class="brush: shell">/load perl
/script load notify
</pre><br />
這樣之後當別人丟訊息的時候就會收到桌面通知了~ :)<br />
<br />
P.S. 目前有中文亂碼的問題$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-7493517743773750672010-06-26T18:57:00.001+08:002010-06-26T19:02:57.380+08:00BetaRadio v1.0 網路廣播點播器 正式釋出<a href="http://code.google.com/p/betaradio/">BetaRadio</a> 因為 <a href="http://hichannel.hinet.net/radio.html">hichannel</a> 網頁不斷地改版,最後碰到了 <a href="https://launchpad.net/libmms">libmms</a> 這個函式庫的一個 bug 所以專案就一直呈現死掉的狀態;不過最近終於有時間能夠找出 libmms 的 bug 並且修正,所以才能夠再次地讓這個純 C 語言寫出來的網路廣播點播器復活。<br />
<br />
Source code tarball 可以在 <a href="http://code.google.com/p/betaradio/downloads/list">http://code.google.com/p/betaradio/downloads/list</a> 下載<br />
相依一個特別的函式庫 <a href="http://github.com/fourdollars/json-cat">json-cat</a> 可以在 <a href="http://github.com/fourdollars/json-cat/downloads">http://github.com/fourdollars/json-cat/downloads</a> 下載 Source code tarball<br />
<br />
另外就是特別為 Ubuntu 10.04 使用者準備好一個 PPA 可以馬上裝起來就可以使用了。<br />
<br />
GUI 安裝方式 [系統]->[管理]->[軟體來源] 裡面的 [其它軟體] 點擊 [加入] 後輸入<br />
<blockquote>ppa:fourdollars/lucid</blockquote><span class="Apple-style-span" style="font-family: serif;">然後關閉 [軟體來源] 選擇 [重新載入] </span><br />
<span class="Apple-style-span" style="font-family: serif;">再打開 [系統]->[管理]->[Synaptic套件管理程式] 搜尋 betaradio 就可以找到來安裝了</span><br />
<br />
或是可以使用命令列輸入來安裝<br />
<blockquote>$ sudo apt-add-repository ppa:fourdollars/lucid</blockquote><blockquote>$ sudo apt-get update</blockquote><blockquote>$ sudo apt-get install betaradio</blockquote>安裝完就可以在 [應用程式]->[影音] 裡面看到 "BetaRadio 點播器" 點一下就可以使用了~ :)$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com6tag:blogger.com,1999:blog-14489808.post-42031034034704566722010-05-05T22:58:00.004+08:002010-06-14T18:08:50.257+08:00自製 Ubuntu 10.04 Desktop/Server/Alternate/DVD ISO i386/amd64 安裝用 USB 隨身碟<div xmlns="http://www.w3.org/1999/xhtml">首先要準備安裝用的 ISO 檔案<br />
<blockquote>ubuntu-10.04-alternate-amd64.iso<br />
ubuntu-10.04-alternate-i386.iso<br />
ubuntu-10.04-desktop-amd64.iso<br />
ubuntu-10.04-desktop-i386.iso<br />
ubuntu-10.04-dvd-amd64.iso<br />
ubuntu-10.04-dvd-i386.iso<br />
ubuntu-10.04-server-amd64.iso<br />
ubuntu-10.04-server-i386.iso</blockquote>然後準備一隻容量至少 1GB 的 USB 隨身碟;如果要使用 DVD ISO 來製作的話,USB 隨身碟要準備容量至少 8GB 以上;如果想要製作多重開機的話,就準備容量越大越好的 USB 隨身碟,大到足夠塞進所有想要放進去的 ISO 檔案。<br />
<br />
<big><big>Ubuntu 10.04 Alternate/Server 安裝用 USB 隨身碟製作方法</big></big><br />
<blockquote>$ wget http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-<b>i386</b>/current/images/hd-media/boot.img.gz<br />
$ sudo dd if=/dev/zero of=/dev/<b>sdc</b> count=512<br />
$ sudo su -c "zcat boot.img.gz > /dev/<b>sdc</b>"</blockquote><span style="font-family: monospace;">等待約五分鐘完成後,再執行以下步驟就完成了。<br />
</span><br />
<blockquote><span style="font-family: monospace;">$ sudo mount /dev/<b>sdc</b> /mnt</span><br />
<span style="font-family: monospace;">$ sudo cp -av ubuntu-10.04-<b>alternate</b>-<b>i386</b>.iso /mnt</span><br />
<span style="font-family: monospace;">$ sudo umount /mnt</span></blockquote><span style="font-family: monospace;">以上粗體字的部份需要根據需求調整,例如 sdc -> sdb 或 alternate -> server 或 i386 -> amd64<br />
<br />
<big><big>Ubuntu 10.04 Desktop/DVD 安裝用 USB 隨身碟製作方法</big></big><br />
<br />
<code>先使用 fdisk 或是 gparted 將隨身碟分割好再進行以下步驟<br />
</code></span><br />
<blockquote><span style="font-family: monospace;">$ <code>sudo mkfs.vfat /dev/<b>sdc</b>1</code></span><br />
<code><span style="font-family: monospace;">$ <code>sudo mount </code><code>/dev/<b>sdc</b>1 /mnt</code><br />
<code>$ <code>sudo </code><code>grub-install --no-floppy --root-directory=/mnt /dev/<b>sdc</b></code><br />
<code></code></code></span></code></blockquote><code><span style="font-family: monospace;">然後再新增一個檔案 /mnt/boot/grub/grub.cfg 內容如下<br />
</span></code><br />
<blockquote><code><span style="font-family: monospace;">menuentry "Ubuntu 10.04 <b>Desktop</b> <b>i386</b>" {</span></code><br />
<code><span style="font-family: monospace;"> loopback loop /iso/</span></code><span style="font-family: monospace;">ubuntu-10.04-<b>desktop</b>-<b>i386</b>.iso</span><br />
<code><span style="font-family: monospace;"> linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/</span></code><span style="font-family: monospace;">ubuntu-10.04-<b>desktop</b>-<b>i386</b>.iso<code> noeject noprompt --</code></span><br />
<code><span style="font-family: monospace;"> initrd (loop)/casper/initrd.lz<br />
}</span></code></blockquote><span style="font-family: monospace;">記得要把 ISO 檔案複製進 USB 隨身碟<br />
</span><br />
<blockquote><span style="font-family: monospace;">$ sudo mkdir /mnt/iso</span><br />
<span style="font-family: monospace;">$ sudo cp -av <code>ubuntu-10.04-<b>desktop</b>-<b>i386</b>.iso /mnt/iso<br />
$ sudo umount /mnt<br />
</code></span></blockquote><span style="font-family: monospace;">以上粗體字的部份需要根據需求調整,例如 sdc -> sdb 或 desktop -> dvd 或 i386 -> amd64<br />
<br />
Desktop/DVD 的製作比較有彈性,只要在 grub.cfg 裡面增加 menuentry 就可以了,所以可以輕易地製作出多重 ISO 開機的 USB 隨身碟。<br />
<br />
P.S. DVD 的部份因為筆者本身沒有 8GB 以上的 USB 隨身碟,所以沒有驗證過,不過應該是可以可行的。<br />
</span></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com2tag:blogger.com,1999:blog-14489808.post-74221292787449737932010-04-23T10:31:00.001+08:002010-04-23T10:31:59.765+08:00使用 GnuPG 驗證 Ubuntu 10.04 LTS RC 安裝光碟 ISO 檔<div xmlns='http://www.w3.org/1999/xhtml'>首先到台灣的 <a href='http://tw.releases.ubuntu.com/'>Mirror Site</a> 上面下載相關的檔案回來<br/><blockquote>$ wget http://tw.releases.ubuntu.com/10.04/<b>SHA1SUMS</b><br/>$ wget http://tw.releases.ubuntu.com/10.04/<b>SHA1SUMS.gpg</b><br/>$ wget http://tw.releases.ubuntu.com/10.04/<b>ubuntu-10.04-rc-desktop-i386.iso</b><br/></blockquote>利用 SHA1SUMS.gpg 來檢查 SHA1SUMS 是否為 Ubuntu 官方釋出的檔案 (有可能是經過偽造的)<br/><blockquote>$ gpg --verify SHA1SUMS.gpg SHA1SUMS<br/>gpg: 由 2010年04月22日 (週四) 21時22分58秒 CST 建立的簽章, 使用 DSA 金鑰 ID <b>FBB75451</b><br/>gpg: 無法檢查簽章: 找不到公鑰<br/></blockquote>在 Ubuntu 系統上一開始檢查一定會找不到,不過可以透過 apt-key list 找到公鑰<br/><blockquote>$ sudo apt-key list<br/>/etc/apt/trusted.gpg<br/>--------------------<br/>pub 1024D/437D05B5 2004-09-12<br/>uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com><br/>sub 2048g/79164387 2004-09-12<br/><br/>pub 1024D/<b>FBB75451</b> 2004-12-30<br/>uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com><br/></blockquote>那麼就可以使用 apt-key export 取出公鑰<br/><blockquote>$ sudo apt-key export FBB75451 > cdimage.gpg<br/></blockquote>接下來在匯入 GnuPG 的金鑰鑰匙圈裡<br/><blockquote>$ gpg --import cdimage.gpg <br/>gpg: 金鑰 FBB75451: 公鑰 "Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>" 已匯入<br/>gpg: 處理總量: 1<br/>gpg: 已匯入: 1<br/>gpg: 3 個勉強信任以及 1 個完全信任是 classic 信任模型的最小需求<br/>gpg: 深度: 0 有效: 3 已簽署: 18 信任: 0-, 0q, 0n, 0m, 0f, 3u<br/>gpg: 深度: 1 有效: 18 已簽署: 12 信任: 5-, 0q, 0n, 13m, 0f, 0u<br/>gpg: 深度: 2 有效: 2 已簽署: 2 信任: 2-, 0q, 0n, 0m, 0f, 0u<br/>gpg: 下次信任資料庫檢查將於 2012-07-13 進行<br/></blockquote>這時候再重新執行前面第一行指令<br/><blockquote>$ gpg --verify SHA1SUMS.gpg SHA1SUMS<br/>gpg: 由 2010年04月22日 (週四) 21時22分58秒 CST 建立的簽章, 使用 DSA 金鑰 ID FBB75451<br/>gpg: 完好的簽章來自於 "Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>"<br/>gpg: <b>警告: 這把金鑰並非以受信任的簽章所認證!</b><br/>gpg: <b>沒有證據指出這個簽章屬於這個持有者.</b><br/>主鑰指紋: C598 6B4F 1257 FFA8 6632 CBA7 4618 1433 FBB7 5451<br/></blockquote>出現這個警告的原因是因為還沒有將 FBB75451 這把公鑰加進自己的信任小圈圈裡面<br/>不過不要緊,假設我們能夠信任 Ubuntu 系統裡面本來就有的公鑰 (如果不能信任的話,那就不應該繼續使用你的 Ubuntu 系統了 :P)<br/>所以現在可以相信 SHA1SUMS 這個檔案真的是 Ubuntu 官方釋放出來的<br/>於是就可以使用指令 sha1sum 來檢查 ubuntu-10.04-rc-desktop-i386.iso 這個檔案的完整性了<br/><blockquote>$ grep ubuntu-10.04-rc-desktop-i386.iso SHA1SUMS<br/>66227f4fb31a25a22614666cd4ab538cc8f60956 *ubuntu-10.04-rc-desktop-i386.iso<br/>$ sha1sum ubuntu-10.04-rc-desktop-i386.iso<br/>66227f4fb31a25a22614666cd4ab538cc8f60956 ubuntu-10.04-rc-desktop-i386.iso<br/></blockquote>嗯~ 沒錯我下載的 ISO 真的是 Ubuntu 官方釋出的版本~ :D<br/><br/>參考資料:<a href='http://wiki.debian.org.tw/index.php/GnuPG'>http://wiki.debian.org.tw/index.php/GnuPG</a><br/></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-82089691221202581992010-04-20T14:53:00.001+08:002010-04-20T14:53:17.959+08:00Linux 系統上面的免費防毒軟體 avast! Linux Home Edition<div xmlns='http://www.w3.org/1999/xhtml'>官方網頁在 <a href='http://www.avast.com/linux-home-edition'>http://www.avast.com/linux-home-edition</a><br/>在 Download 底下就可以下載到安裝的套件包了<br/>每次使用前要先到 <a href='http://www.avast.com/registration-free-antivirus.php'>http://www.avast.com/registration-free-antivirus.php</a> 上面申請 license key<br/>如果遇到 crash 的問題可以試試看<br/><ul><li style='list-style-type: none;'><p class='line891'><tt>$ sudo sysctl -w kernel.shmmax=128000000</tt> <span id='line-10' class='anchor'/><span id='line-11' class='anchor'/></p></li></ul>也許可以解決問題<br/><br/>參考資料:<br/><blockquote><a href='http://forum.avast.com/index.php?topic=57775.0'>http://forum.avast.com/index.php?topic=57775.0</a></blockquote></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-77910955526077463252010-01-31T13:57:00.000+08:002010-01-31T14:01:02.565+08:00在 Debian GNU/Linux 5.0.3 (Lenny) 上面安裝 Drupal 6.15<div xmlns='http://www.w3.org/1999/xhtml'>首先要準備一個 Debian GNU/Linux 5.0.3 (Lenny) 的系統環境,這邊是選擇使用 debian-503-i386-netinst.iso 並透過網路安裝,<br/>在安裝過程當中語系選擇英文並且在 Software selection 時只選擇安裝 Web server 以及 SQL database 來安裝,盡量維持系統精簡,<br/><img style='max-width: 800px;' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig4EXGphLw-BeYGVSU4GmebBW96tSNu50xZKEyViEvRehIvjiclEsuNMRQ6YX5Z3ifdPK5PWZtdeDIrvVFFgGhbFqB2qaRfDW7Hpvw0w-Z8rAZ5Uhng_StyZ3Xeofp8gG9Xxk/?imgmax=800'/><br/>接下來應該只要再抓 59 個套件安裝,在 2M/256K ADSL 正常情況的網路環境下五分鐘以內就可以裝好了,<br/><img style='max-width: 800px;' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYTIOcy49MemZk2NL3X55d7dhfVv80R1M9hCETvxRlLbzXjF3B2q9p-CcAiir8fQbkbRjSTumDq4mzSwIdMdYjpdGvTFmLnLQ03eB9cCVlaZwmyZd1Wjnwp5cqKJC_dVu4ZLM/?imgmax=800'/><br/>到這邊為止應該已經裝好所需要的 Apache 跟 PostgreSQL 了,重新啟動系統後再安裝 drupal6 跟 php5-pgsql 套件,<br/><blockquote># apt-get install drupal6 php5-pgsql<br/></blockquote>在設定 drupal6 的畫面中記得要輸入密碼,不然系統會改使用 ident 機制,安裝完後需要重新啟動 Apache<br/><blockquote># /etc/init.d/apache2 restart<br/></blockquote>就可以在 http://XXX.XXX.XXX.XXX/drupal6/install.php 看到 Drupal6 接下來的安裝程序<br/><img style='max-width: 800px;' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8wSDnWOOP5salShu8AWCg2MetelTWb-GhFlq1pORj7cpVU6GC-GqnTI2w77W3GXudZflRhZkgoZ5JgS8G-7G71ao3Pf2FXDHoI30g1fHepUg_4iUhwdRLukFPuu83bEP4pws/?imgmax=800'/><br/>不過此時只有英文介面,如果需要安裝繁體中文介面就要執行接下來的動作,<br/><blockquote># wget http://ftp.drupal.org/files/projects/zh-hant-6.x-1.5.tar.gz -O - | tar xz -C /usr/share/drupal6<br/></blockquote>然後重新載入網頁就可以看到繁體中文介面,<br/><img style='max-width: 800px;' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtngQxylV-7rXJoUcCqBa83Br9g9CgZ6VoqEY2Af1CF0eJh3Xb2ax11tNdWxfkpOmcORJ1SfOJUf61uKEh31nxCAZn7oic8gUbVMG1WwqLac71PziXmAKziuK_1n9CMtg5whQ/?imgmax=800'/><br/>Drupal6 初始設定完成之後馬上就會發現到目前的 Drupal6 版本並不安全,<br/><img style='max-width: 800px;' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJnqZQwRtxcCqDYU33ojzRlTTZwRhgF0-Zdm7rLzvJN_dq8dqTWPf0RTSAfO-Lgr9iUf5TpBeBcCxFMTcOD8ejKb8X_2RyMO87alnKI5SQjWZ_eW7sRk15-bgMr2P9tYLQ7ak/?imgmax=800'/><br/>因為 Debian GNU/Linux 5.0.3 (Lenny) 上面的 Drupal 版本只有到 6.6 版,<br/>所以現在要去升級到目前最新穩定版本 6.15<br/><blockquote># wget http://ftp.drupal.org/files/projects/drupal-6.15.tar.gz -O - | tar xz -C /usr/share<br/># wget http://ftp.drupal.org/files/projects/zh-hant-6.x-1.5.tar.gz -O - | tar xz -C /usr/share/drupal-6.15<br/># cd /usr/share<br/># chown -R root.root drupal-6.15<br/># mv -v drupal6 drupal-6.6<br/># ln -s drupal-6.15 drupal6<br/># cd drupal-6.15<br/># rm -fr profiles sites<br/># ln -s /etc/drupal/6/profiles<br/># ln -s /etc/drupal/6/sites<br/></blockquote>然後在網頁瀏灠器裡面訪問 http://XXX.XXX.XXX.XXX/drupal6/update.php 來更新資料庫<br/><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkFCuziLYpnKIiYinRWsnMBTENiu0DoIk4IIMowOZ4-V_THMtZHq4xhBQMUI8zMpaUdPHBvqRUeP7VNKWT3e18jNZZ8v41vKTbddBMqnOrYlRzbwg6piG5LJB4AUYA-doEL0M/?imgmax=800'/><br/>更新完後回到 [狀態報告] 就可以看到<br/><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4yEBI7p1Jp7rryIrsFDgPWyMPUCxNplAQkruqcPxB6buMfkqjLIOPF8zAiOLRp6ThXoo9R_4bdk-n6qqYywlbPLQjXuyga9PdzCkln7HNXor6E9_9ICfgkPaKEEP07Cj-rK4/?imgmax=800'/><br/>此時算是才把 Drupal 6.15 在 Debian GNU/Linux 5.0.3 (Lenny) 上面安裝好,<br/>不過目前都只有框架沒有內容也沒有安裝任何模組也沒有客製化的 Theme<br/></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com0tag:blogger.com,1999:blog-14489808.post-2066834937983796632010-01-22T12:56:00.001+08:002010-01-22T12:56:08.452+08:00在 Linux 系統上面手動安裝 Firefox 3.6<div xmlns='http://www.w3.org/1999/xhtml'>首先到 <a href='http://www.mozilla.com/'>http://www.mozilla.com/</a> 下載 firefox-3.6.tar.bz2 回來<br/>然後解壓縮到 /usr/local/lib/firefox-3.6 底下<br/><blockquote>$ mkdir -p /usr/local/lib<br/>$ tar xf firefox-3.6.tar.bz2 -C /usr/local/lib<br/>$ mv /usr/local/lib/firefox /usr/local/lib/firefox-3.6<br/></blockquote>然後建立一個啟動圖示<br/><blockquote>$ mkdir -p .local/share/applications/<br/>$ cat > .local/share/applications/firefox-3.6.desktop <<ENDLINE<br/>[Desktop Entry]<br/>Version=3.6<br/>Name=Firefox 3.6 網頁瀏灠器<br/>Comment=瀏灠網頁<br/>GenericName=網頁瀏灠器<br/>Exec=/usr/local/lib/firefox-3.6/firefox %u<br/>Terminal=false<br/>X-MultipleArgs=false<br/>Type=Application<br/>Icon=/usr/local/lib/firefox-3.6/chrome/icons/default/default48.png<br/>Categories=Application;Network;<br/>MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;<br/>StartupWMClass=Firefox<br/>StartupNotify=true <br/>ENDLINE<br/></blockquote>這樣就可以了~ :D<br/></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com3tag:blogger.com,1999:blog-14489808.post-27740178239562054352010-01-09T20:32:00.000+08:002010-01-09T20:33:21.943+08:00在 Ubuntu 8.04.3 可以使用 Google Chrome 瀏灠器來聽網路廣播~ ;)<div xmlns='http://www.w3.org/1999/xhtml'>延續上一篇文章 <a href='http://fourdollars.blogspot.com/2010/01/ubuntu-8043-firefox-d.html'>在 Ubuntu 8.04.3 用 Firefox 瀏灠器就可以聽網路廣播了~ :D</a><br/>如果是想要在 Ubuntu 8.04.3 上面使用 Google Chrome 來收聽網路廣播的話<br/>就要另外安裝 mozilla-mplayer 這個套件才行<br/>然後連到 <a href='http://fd.idv.tw/radio/player.html'>http://fd.idv.tw/radio/player.html</a><br/>或者是直接安裝使用 Google Chrome Extension<br/><a href='http://fd.idv.tw/radio/hichannel.crx'>http://fd.idv.tw/radio/hichannel.crx</a><br/>又或者是增加一個檔案 ~/.local/share/applications/hichannel.desktop<br/>內容填上<br/><blockquote>[Desktop Entry]<br/>Name=hiChannel 網路廣播<br/>Exec=google-chrome --app=http://fd.idv.tw/radio/player.html<br/>Icon=google-chrome<br/>Type=Application<br/>Categories=GTK;Application;AudioVideo;Audio;Player;<br/></blockquote>這樣就是一個(偽)不用開網頁瀏灠器也可以聽網路廣播的應用程式了~ :P<br/><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiwis2qS9M9xNCEqzeUoSrt2Pusp-VrwnZYrtEb4Hqq61rSbWiGxiNA4e4uVVgvcV0fQnqmp-w9MUnDtxp_vYsRZcXj8oEqvlMzle8DhHYSPdg0wO3jg2qyy0LKNKX6ZqX76g/?imgmax=800' style='max-width: 800px;'/><br/><h3 class='post-title'/></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com1tag:blogger.com,1999:blog-14489808.post-75422127610838707342010-01-08T12:31:00.001+08:002010-01-08T13:04:58.728+08:00在 Ubuntu 8.04.3 用 Firefox 瀏灠器就可以聽網路廣播了~ :D<div xmlns='http://www.w3.org/1999/xhtml'>要在 Ubuntu 8.04.3 底下的 Firefox 3.0.17 聽網路廣播<br/>只安裝好 gstreamer0.10-plugins-bad, gstreamer0.10-plugins-ugly, gstreamer0.10-ffmpeg 這幾個套件<br/>然後連到 <a href='http://fd.idv.tw/radio/player.html'>http://fd.idv.tw/radio/player.html</a> 就可以聽了~<br/><br/><span class='plurk_content'>Mac OS X 10.4+ 上面要裝 <a href='http://www.microsoft.com/windows/windowsmedia/player/wmcomponents.mspx'>Flip4Mac WMV Components for QuickTime</a></span><br/>然後用 Safari 就可以聽了~<br/><br/>在 Windows 上面開 IE7/IE8/Safari/Opera/Firefox/Google Chrome 都可以聽~<br/><br/>另外寫了一個給 Google Chrome 用的 Extension<br/><a href='http://fd.idv.tw/radio/hichannel.crx'>http://fd.idv.tw/radio/hichannel.crx</a><br/><br/>Have Fun~ ^o^<br/><br/>P.S. 誠徵 Icon 設計師幫小弟做出 Google Chrome Extension 要使用的 Icon 尺寸分別是 19x19/32x32/48x48/128x128 的 PNG<br/></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com2tag:blogger.com,1999:blog-14489808.post-54880483135158701452009-12-06T20:06:00.000+08:002009-12-06T20:07:39.087+08:00在 Linux 系統上面合併多個 PDF 檔案成為一個 PDF 檔案<div xmlns='http://www.w3.org/1999/xhtml'>今天臨時興起想要去複習一下 <a href='http://www.advancedlinuxprogramming.com/'>Advanced Linux Programming</a> 這本相當不錯的電子書<br/>於是就把網頁上面的 PDF 檔案都下載回電腦裡面<br/>這時候突然覺得要這樣分別開啟多個 PDF 檔案實在是麻煩<br/>於是在網路上面找了一些方法<br/>第一個方法是利用 ImageMagick 這個套件裡面的 convert 指令<br/><blockquote>$ <b>convert</b> alp-toc.pdf alp-ch*.pdf alp-ap*.pdf alp-index.pdf <b>alp.pdf</b><br/></blockquote>不過製作出來的 alp.pdf 品質感覺不是很好<br/>第二個方法是用 ghostscript 的 gs 指令<br/><blockquote>$ <b>gs</b> -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=<b>alp.pdf</b> -dBATCH alp-toc.pdf alp-ch*.pdf alp-ap*.pdf alp-index.pdf<br/></blockquote>製作出來的 alp.pdf 品質不錯,不過花了不少時間<br/>第三個方法是用 pdftk 這個套件當中的指令 pdftk<br/><blockquote>$ <b>pdftk</b> alp-toc.pdf alp-ch*.pdf alp-ap*.pdf alp-index.pdf cat output <b>alp.pdf</b><br/></blockquote>這個方法比之前的方法都要來的快速~<br/>另外有網友提到可以使用看看 <a href='http://www.pdfsam.org/'>pdfsam</a> 因為有太多相依上的套件要額外安裝就沒有想要繼續試下去啦~ :P<br/></div>$4http://www.blogger.com/profile/05027047996196141367noreply@blogger.com2