2012年8月22日 星期三

如何解決在 Ubuntu 上面安裝 VirtualBox 後缺少 vboxusers 群組權限的問題

正確的解決方式是執行一個指令就好了

$ sudo gpasswd -a username vboxusers

或是執行另外一個指令

$ sudo usermod -a -G vboxusers username

但是有一點要特別提醒的,就是第二個指令的 '-a' 要記得加,不然就會杯具... 冏rz

杯具就是其它原本已經加入的群組都消失了,只剩下 vboxusers 一個群組。XD

修復杯具的方法是先從其它相同版本的 Ubuntu 上面查詢本來應該要加入的群組來,查詢的指令是:

$ id -Gn username

然後再把它們加上去。

2012年8月2日 星期四

在 Ubuntu 上面減少 apt-get update 的時間

想要讓 apt-get update 快一點完成
除了找一個速度快又近的 Mirror 點
另外就是減少下載的檔案數量
如果對中文翻譯不是很在意的話
可以增加一個檔案 /etc/apt/apt.conf.d/60language
裡面寫著 Acquire::Languages {"none";}; 就是什麼翻譯都不要下載
不過這樣會導致 Debian package 裡面的 Long Description 都看不到了
如果不在意這些 Long Description 也還好
又或者改用 Acquire::Languages {"en";}; 下載英文的 Long Description 就好了
又或者有些人就只想要下載正體中文的翻譯,那就使用 Acquire::Languages {"zh_TW";}; 吧
系統預設上是下載當下環境的語言跟英文
詳細的使用方式請看 `man apt.conf`
Update 2013/06/19

不曉得為什麼在 Ubuntu 13.04 上面要使用 Acquire::Languages "none"; 才可以運作。

P.S. 使用 apt-config dump 可以檢查目前的設定值。

2012年6月28日 星期四

在 iMac 8.1 (Early 2008) 上面安裝 Ubuntu 12.04

首先在我的 iMac 8.1 (Early 2008) 上面要先使用 Mac OS X 裡面的磁碟工具程式分割出多餘的空間,而我是將 250GB 的硬碟對半分,一半留給 Mac OS X 繼續使用,另一半給 Ubuntu 12.04 使用。

因為 Mac Intel 系列的電腦現在都是使用 EFI 來開機,所以要下載 Ubuntu 12.04 Desktop amd64 的版本才會有支援 EFI 啟動,所以要下載 ubuntu-12.04-desktop-amd64.iso 然後使用 Ubuntu 12.04 內建的 usb-creator-gtk 中文譯成「製作開機碟」來製作出一隻可以安裝 Ubuntu 12.04 Desktop amd64 的 USB 開機碟。

接下來是重新啟動 Mac 並且按下 Option (Alt) 不放,直到出現以下畫面:

然後就可以選擇最右邊的 EFI Boot 圖示來啟動 Ubuntu 的安裝程序。

另外也可以使用燒錄好的 Ubuntu 12.04 Dekstop amd64 的光碟片來安裝,只是畫面會有一點不一樣,如下:

一樣是選擇最右邊的 EFI Boot 圖示來啟動 Ubuntu 的安裝程序。

建議使用 USB 隨身碟來安裝,一方面比較安靜,另一方面比較環保,而且安裝速度也比較快。

接下來就是一般 Ubuntu 的安裝方法,只是有個小訣竅可以在安裝程序中啟動無線網路的支援,就是在安裝過程中選擇要安裝 Fluendo MP3 Decoder 然後按下一步,稍微等一下它會偷偷把無線網卡的驅動程式裝上去,然後就可以按上一步回到上一個步驟把網路連一連,這樣在安裝的過程才會再從網路上下載其它額外需要的軟體套件

在 Ubuntu 安裝完畢重開機後仍然是無法進入 Ubuntu,此時還要在 Mac OS X 上面安裝 rEFIt,以後每次開機預設進入 Ubuntu 但是會有十幾秒的等待時間可以選 Mac OS X 進入。

以上就是我的安裝過程,接下來就是驅動程式的問題。

顯示的部份,我是使用 open source 的 ati 驅動程式,因為安裝私有的 fglrx 驅動程式反而畫面會顯示不出來。

音效的問題,我是參考 https://help.ubuntu.com/community/Intel_iMac#Sound 將 options snd-hda-intel model=mbp3 加入 /etc/modprobe.d/options.conf 裡面來解決。

WebCam 的驅動則是參考 https://help.ubuntu.com/community/MactelSupportTeam/AppleiSight 的作法。

Apple 無線鍵盤可以使用 Ubuntu 內建的藍牙配對程式就可以了。

Apple 無線滑鼠一樣是使用 Ubuntu 內建的藍牙配對程式,然後配對的 pin 碼好像是 0000

以上就是我在 iMac 8.1 (Early 2008) 上面安裝 Ubuntu 12.04 的心得筆記。

Have fun! ;)

2012年5月21日 星期一

使用 Ubuntu 12.04 透過網路報稅 (台灣)

首先安裝 sudo apt-get install icedtea-6-plugin

然後打開終端機輸入 sed -i '$a export _JAVA_OPTIONS="-Dfile.encoding=BIG5"' ~/.profile 再重新登入

打開 Firefox 登入報稅網站

準備好「戶口名簿戶號」以及「國民身分證統一編號」就可以登入了。

就這樣,不需要「自然人憑證」。

2012年3月23日 星期五

Automake 的測試套件 make check-TESTS

在寫程式的時候會想要寫一些測試套件來驗證程式的功能是否正常,Automake 支援了這種需求。

一般來說寫一個給 Hello World 程式的 Makefile.am 會長得像以下這樣:
bin_PROGRAMS = hello
hello_SOURCES = hello.c
如果說希望能夠在編譯完程式後,順便執行一下來檢查,就可以加一行:
bin_PROGRAMS = hello
hello_SOURCES = hello.c
TESTS = $(bin_PROGRAMS)
這樣一來就可以執行 make check 來自動編譯並且執行測試; 只是通常不會想要把測試程式釋出給一般人使用,所以就會改寫成:
check_PROGRAMS = hello
hello_SOURCES = hello.c
TESTS = $(check_PROGRAMS)
這樣就只會在 make check 的時候,編譯 hello 這隻程式並且自動執行它來做測試。

如果想要看到彩色的測試結果,就要修改 configure.ac 加上 color-tests 像是以下這樣:
AC_PREREQ([2.68])
AC_INIT([hello], [0.1], [foo@bar.com])
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign color-tests])                                                                                                                        
AM_MAINTAINER_MODE([enable])
其實 GNU Build System 很好用的,只是要多看 info Automake 的文件來理解它的使用方法。:)
對以上內容不太瞭解的,可以先看看簡報 GNU Build System (aka Autotools) 入門一下。

2012年1月18日 星期三

要求 Ubuntu 開發中版本同步 Debian 上面的套件

Ubuntu 是個每半年釋出一個版本的 GNU/Linux 發行套件,因此每次正式版本釋出的同時代表的是下一個版本開發的開始,因此每個 Ubuntu 版本的開發總是依循著同樣的步調跟大同小異的規則。

Ubuntu 開發中版本上面的套件大多是來是 Debian testing/unstable 的自動同步,不過等到 DebianImportFreeze 之後跟 FeatureFreeze 之前,如果還有新版本的套件在 Debian testing/unstable 上面出現時,就要透過 SyncRequestProcess 來要求 Ubuntu 開發中版本同步 Debian 上面的套件,FeatureFreeze 之後就不能再要求同步套件了,只能夠修正程式的錯誤。

以下示範三種情況。

狀況一: Ubuntu 開發中版本的套件並沒有包含 Ubuntu 社群的錯誤修正

使用 ubuntu-dev-tools 套件底下的 requestsync 指令
$ requestsync -C -d unstable --lp betaradio precise

然後會看到以下內容:
Summary (one line):
Sync betaradio 1.4-1 (universe) from Debian unstable (main)

Description:
Please sync betaradio 1.4-1 (universe) from Debian unstable (main)

Changelog entries since current precise version 1.3-1:

XXX FIXME: add changelog here XXX                                 

要將最後一行改掉,加上 Debian testing/unstable 套件裡面的訊息,所以就變成了:
Summary (one line):
Sync betaradio 1.4-1 (universe) from Debian unstable (main)

Description:
Please sync betaradio 1.4-1 (universe) from Debian unstable (main)

Changelog entries since current precise version 1.3-1:

betaradio (1.4-1) unstable; urgency=low

  * New upstream release.
  * debian/patches/00_dont_install_header: Don't install header file into the
    system.

 -- Shih-Yuan Lee (FourDollars) <fourdollars[at]gmail.com> Sat, 14 Jan 2012 20:58:32 +0800

最後就會產生一個 Launchpad Bug 像是 Bug #918059 in betaradio (Ubuntu): “Sync betaradio 1.4-1 (universe) from Debian unstable (main)” 這樣就做好了,之後就是去注意這個 Bug 的變化,適時的去回應 Ubuntu Developer 提出的問題(如果有的話)。

狀況二: Ubuntu 開發中版本的套件已經有包含了一些 Ubuntu 社群的錯誤修正

在這種情況底下 Ubuntu 不會自動去同步 Debian testing/unstable 上面的套件,以防有些 Ubuntu 社群所做的錯誤修正遺失。

使用跟上面一樣的指令:
$ requestsync -C -d unstable --lp ibus-chewing precise

然後會看到以下內容:
Summary: Sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)
Description:
Please sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)

Explanation of the Ubuntu delta and why it can be dropped:
  * debian/patches/IBusChewingEngine-def-fix-SIGSEGV-on-preference-save.patch:
    Fix misuse of g_value_get_gtype in g_value_to_g_variant. (LP: #874028)
  * debian/patches/escape-to-close-candidate-window-on-plain-
     zhuyin.patch: Fix plain zhuyin with space as selection problem.
     (https://github.com/definite/ibus-chewing/pull/8/) (LP: #843619)
[這邊有一行我忘了原本寫些什麼了,總之要你改掉寫上你的解釋]

Changelog entries since current precise version 1.3.9.2-3ubuntu2:

XXX FIXME: add changelog here XXX                                 

跟前面一樣加上 Debian testing/unstable 套件裡面的訊息,還有解釋一下為什麼 Ubuntu 社群的錯誤修正都被拿掉了,然後就變成了:
Please sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)

Explanation of the Ubuntu delta and why it can be dropped:
  * debian/patches/IBusChewingEngine-def-fix-SIGSEGV-on-preference-save.patch:
    Fix misuse of g_value_get_gtype in g_value_to_g_variant. (LP: #874028)
  * debian/patches/escape-to-close-candidate-window-on-plain-
     zhuyin.patch: Fix plain zhuyin with space as selection problem.
     (https://github.com/definite/ibus-chewing/pull/8/) (LP: #843619)
These patches are already included in ibus-chewing 1.3.10+clean-1.

Changelog entries since current precise version 1.3.9.2-3ubuntu2:

ibus-chewing (1.3.10+clean-1) unstable; urgency=low

  * New upstream release.
  * All Debian patcheds dropped.
  * Add Osamu as uploaders.
  * Repackaged upstream tar with normal tar and removing .swo

 -- Osamu Aoki <osamu[at]debian.org> Mon, 26 Dec 2011 00:17:58 +0900

最後就會產生一個 Launchpad Bug 像是 Bug #918061 in ibus-chewing (Ubuntu): “Sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)” ,之後就是去注意這個 Bug 的變化,適時的去回應 Ubuntu Developer 提出的問題(如果有的話)。

狀況三: Ubuntu 開發中版本並沒有包含這個套件

在這種情況下應該是最單純的,應該不會有額外的動作要做,都是按下 Enter 就可以做到完。

使用跟上面一樣的指令:
$ requestsync -C -d unstable --lp hime precise

然後會看到以下內容:
'hime' doesn't exist in 'Ubuntu precise'.
Do you want to sync a new package?
Press [Enter] to continue or [Ctrl-C] to abort.

當然是按下 Enter 到下一步
Your sync request shall require an approval by a member of the appropriate
sponsorship team, who shall be subscribed to this bug report.
This must be done before it can be processed by a member of the Ubuntu Archive
team.
If the above is correct please press [Enter] 

再按下 Enter 到下一步
Currently the report looks as follows:
Summary (one line):
Sync hime 0.9.9-1 (universe) from Debian unstable (main)

Description:
Please sync hime 0.9.9-1 (universe) from Debian unstable (main)

All changelog entries:

hime (0.9.9-1) unstable; urgency=low

  * Initial release (Closes: #652022)

 -- Yao Wei (魏銘廷) <mwei[at]lxde.org>  Sat, 14 Jan 2012 00:24:08 +0800

Do you want to edit the report [y/N]?
並沒有修改的必要,所以還是按下 Enter 到下一步
The final report is:
Summary: Sync hime 0.9.9-1 (universe) from Debian unstable (main)
Description:
Please sync hime 0.9.9-1 (universe) from Debian unstable (main)

All changelog entries:

hime (0.9.9-1) unstable; urgency=low

  * Initial release (Closes: #652022)

 -- Yao Wei (魏銘廷) <mwei[at]lxde.org>  Sat, 14 Jan 2012 00:24:08 +0800


Press [Enter] to continue or [Ctrl-C] to abort.
最後的確認,還是按下 Enter 於是就會產生一個 Launchpad Bug 像是 Bug #923637 in Ubuntu: “Sync hime 0.9.9-1 (universe) from Debian unstable (main)”,之後就是去注意這個 Bug 的變化,適時的去回應 Ubuntu Developer 提出的問題(如果有的話)。

2012年1月16日 星期一

Genie 程式語言

Genie 程式語言是 GNOME 計畫下的一個新的程式語言,跟 Vala 一起開發的,語法類似 Python,跟 Vala 一樣都是借助 GObject 來實現物件導向程式設計,也跟 Vala 一樣都是產生出 C 的程式碼,而且也因為 GObject 的關係可以輕易地產生其它程式語言的 binding。
例如:輸入以下的程式碼儲存成 hello.gs
init
        print "Hello World"
然後再執行以下的指令就可以看到結果了。
$ valac hello.gs
$ ./hello
如果說要看到中間轉譯出來的 C 語言程式碼可以輸入以下指令:
$ valac -C hello.gs
於是就可以看到 hello.c 產生出來了。
/* hello.c generated by valac 0.14.0, the Vala compiler
 * generated from hello.gs, do not modify */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

void _vala_main (gchar** args, int args_length1);

void _vala_main (gchar** args, int args_length1) {
        g_print ("Hello World\n");
}

int main (int argc, char ** argv) {
        g_type_init ();
        _vala_main (argv, argc);
        return 0;
}
看看裡面的內容是不是一般所熟悉的 C 語言程式碼。:)
參考資料:Genie - GNOME Live!