顯示具有 Package 標籤的文章。 顯示所有文章
顯示具有 Package 標籤的文章。 顯示所有文章

2012年12月24日 星期一

Quick - an installation helper for GNU/Linux.

我自己平時都是使用 Debian/Ubuntu 裡面的 APT 來安裝軟體套件,就連自己寫了一些小軟體也是會放到 PPA 上面,然後再透過 APT 下載回來安裝,但是並不是所有的軟體都有 Open Source 或是有人有準備好 PPA 可以直接透過 APT 來安裝。

於是乎,我花了兩三天的時間製作了這個簡單的工具用來管理這些額外的軟體。

Quick - an installation helper for GNU/Linux.

使用方式就是執行下面這段指令來安裝:

$ wget http://bit.ly/quick-installer -O - | bash -

安裝完成之後要先登出,再重新登入系統。

接下來執行以下指令來安裝更新套件列表:

$ quick update

然後再執行以下指令來安裝軟體套件:

$ quick install sublime-text

安裝後,想要移除掉就執行:

$ quick remove sublime-text

其它使用方式執行以下指令來看說明。

$ quick

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 提出的問題(如果有的話)。

2011年7月12日 星期二

使用 pbuilder-dist/cowbuilder-dist 協助編譯及打包 Debian package

在 Debian/Ubuntu 上面寫好程式並且打包成 Debian source package 之後,可以藉由 Launchpad 上的 PPA 服務來編譯打包成 Debian binary package 給 Ubuntu 的使用者使用,但是在 Debian 這邊目前還沒有像是 PPA 這樣的服務可以使用 (不過Debian 官方已經有計劃要做了),於是現在就只能使用 pbuilder/cowbuilder 這樣工具來建立一個乾境的 chroot 環境來編譯打包 Debian binary package 給 Debian 的使用者使用。

最近發現在 ubuntu-dev-tools 裡面有 pbuilder-dist/cowbuilder-dist 這樣方便的工具,可以透過幾個簡單的指令就完成複雜的動作,雖然它的名稱叫做 ubuntu-dev-tools 其實它也是存在 Debian 官方套件庫裡面可以直接安裝來使用。

例如在 Ubuntu 11.04 (amd64) 底下想要建立 Debian 6.0 squeeze (i386) 的 chroot 環境就可以使用以下的指令:
$ pbuilder-dist stable i386 create

接下來要利用這個環境編譯 Debian 6.0 squeeze (i386) 底下使用的 pcmanx-gtk2,所以要執行以下的指令:
$ pbuilder-dist stable i386 build pcmanx-gtk2_1.0-svn577-1~squeeze1.dsc

最後就可以在 ~/pbuilder/stable-i386_result/ 底下看到編譯好的 pcmanx-gtk2_1.0-svn577-1~squeeze1_i386.deb

當然上面的 stable 在 Ubuntu 底下可以代換成 natty,maverick,lucid,... (如果是要編譯打包 Ubuntu 發行套件) 或是 testing, unstable, experimental (如果是要編譯打包 Debian 發行套件);另外就是 i386 可以代換成 amd64 如果搭配 qemubuilder 也許還可以編譯打包出 arm, mipsel, ... 其它 CPU 架構底下的套件出來使用。

此次編譯出來給 Debian 6.0 squeeze i386/amd64 使用的 pcmanx-gtk2 放在 http://archive.sylee.org/deb/ 底下。

參考文件:https://wiki.ubuntu.com/PbuilderHowto

2011年1月31日 星期一

Debian Package - 什麼是 Debian Native Package?

要怎麼去辨別一個 Debian 套件是否為一個 Debian native package 呢?

最簡單方法就是判斷有沒有 (5) - 版本號碼 當中提到的 debian_version
[epoch:]upstream_version[-debian_revision]
如果 Debian 套件的版號沒有看到 debian_version 的部份,那麼它就是一個 Debian native package

那麼接下來問題應該是...

怎樣的套件才可以成為一個 Debian native package?

其實就是該套件只為了 Debian 系統而製作的。
在終端機下輸入以下指令
$ dpkg-query -W | awk '{ if ($2 !~ /-/) print $0; }'
就可以看到系統上目前裝了哪些 Debian native package

舉個例子
Package: cdbs
...
Version: 0.4.62+nmu1ubuntu9
...
Description: common build system for Debian packages
 This package contains the Common Debian Build System, an abstract
 build system based on Makefile inheritance which is completely
 extensible and overridable.  In other words, CDBS provides a sane set
 of default rules upon which packages can build; any or all rules may
 be overridden as needed.
...

這個 Debian 套件就是用來製作 Debian 套件的工具之一,所以它只能使用在 Debian 系統上面,像這樣的套件就一定是 Debian native package

相反的,如果你所製作的 Debian 套件並不限於只使用在 Debian 系統上面的話,請不要用 Debian native package 的版號命名規則,也就是不要省略掉 debian_version,如果想要上傳套件至 Debian 官方套件庫裡面,這點一定要注意一下。

另外如果你就是上游的軟體開發者,即使軟體本身在製作時就已經順便做好 Debian 套件的相關工作,也不要在釋出 source code tar ball 裡面包含 debian 這個目錄。

2010年9月27日 星期一

Debian Package (6) - 使用 pbuilder - personal package builder 個人 Debian Package 製作工具

目標是編譯在 Ubuntu 10.04 上面使用的 Debian Package

首先是安裝需要的軟體套件還有修正一些小問題
sudo apt-get install pbuilder cowdancer ccache
sudo mkdir -p /var/cache/ccache # To avoid error of "special device /var/cache/ccache does not exist"

然後編輯設定檔 ~/.pbuilderrc 加入
MIRRORSITE=http://tw.archive.ubuntu.com/ubuntu/
COMPONENTS="main restricted universe multiverse"
DISTRIBUTION=lucid
OTHERMIRROR="deb http://tw.archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse|deb http://tw.archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse|deb http://tw.archive.ubuntu.com/ubuntu/ lucid-proposed main restricted universe multiverse|deb http://tw.archive.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse"
PDEBUILD_PBUILDER=cowbuilder
BUILDRESULT=~/deb/

接者開始產生一個編譯用的基本環境
sudo cowbuilder --create

然後就可以在原本使用 debuild 編譯 Debian Package 的目錄裡面
改用 pdebuild 來編譯 Debian Package
程式會自動透過網路下載相依的軟體套件然後將 Debian Package 編譯到 ~/deb/ 底下

或是像下面的使用方法
apt-get source --download-only hello
下載 hello_2.4-3.diff.gz hello_2.4-3.dsc hello_2.4.orig.tar.gz 後,再執行
sudo cowbuilder --build hello_2.4-3.dsc
來編譯 Debian Package

參考資料:

2010年6月17日 星期四

Debian Package (5) - 版本號碼

關於 Debian Package 的版本號碼規則全都寫在 Debian Policy Manual 上面的 5.6.12 Version
基本格式就只有一段
[epoch:]upstream_version[-debian_revision]
其中的 epoch 就是紀元,epoch 為大於或等於零的整數,如果不特別指定 epoch 就是零,這讓我想到以前有學過:前寒武紀/寒武紀/奧陶紀/志留紀/泥盆紀/石碳紀/二疊紀/三疊紀/侏儸紀/白堊紀/第三紀/第四紀,前寒武紀一定是最古老的,所以無論後面的 upstream_version 跟 debian_version 寫的是什麼,侏儸紀的版號一定大於前寒武紀,例如:
0:9527 < 1:7
一看就知道 9527 一定比 7 還要大的啊!不過因為 9527 在比較舊的紀元,所以多大都沒有用的!


接著是 upstream_version 照字面上翻譯就是上游軟體的版本號碼,例如 PCManX GTK+ 目前最新的正式釋出版本號碼為 0.3.9,不過如果接下來的 PCManX GTK+ 0.3.10 有一些測試 alpha/beta/rc 的版號就可能會長得像是 0.3.10-alpha1 / 0.3.10-beta2 / 0.3.10-rc3 之類的。


最後就是 debian_version 例如 Ubuntu 10.04 所提供的 PCManX GTK+ 套件版號為 0.3.9-2ubuntu2
$ apt-cache policy pcmanx-gtk2
...
0.3.9-2ubuntu2 0
500 http://tw.archive.ubuntu.com/ubuntu/ lucid/universe Packages
這邊的 debian_version 就是 2ubuntu2


知道版本號碼的組成元素之後就是要開始比較大小,軟體套件能不能夠升級就是要靠版號比大小。


指令 dpkg 有提供一個參數可以用來比對版號的大小
dpkg --compare-versions
例如:
$ dpkg --compare-versions 0:9527-2ubuntu2 '<' 1:7-2ubuntu2; echo $?
0
$ dpkg --compare-versions 0:9527-2ubuntu2 '<' 0:9527-2ubuntu2~3small; echo $?
1
不知道看倌有沒有注意到 0:9527-2ubuntu2 '<' 0:9527-2ubuntu2~3small 比較的結果是失敗的
0:9527-2ubuntu2~3small
---------------^------
Debian Package Version 有一個特別的地方,就是 '~' 開頭的版號比空字串還要小,什麼!'~' 比什麼都沒寫的虛無還要小!
所以可以做個有趣的實驗
$ dpkg --compare-versions 1-1~ '<' 1-1; echo $?
0
$ dpkg --compare-versions 1-1~~ '<' 1-1~; echo $?
0
看到沒有~ 尾巴長的越長的版號反而是越小的~ >w<


最後再聊一些約定俗成的慣例。


慣例一:
debian_version 可以省略不寫,如果要寫的話,結尾一定要是數字,而且這個數字不可為零。


慣例二:
除了該 Debian Package 的 Maintainer 之外,其他人不可以使用 debian_version 全為數字的版號,例如:假設今天有 PCManX GTK+ 0.3.10 的正式釋出版本,我們自己私下在打包 Debian Package 時就不可以使用 0.3.10-1 這樣的版號,不過根據慣例一,我們可以使用 0.3.10-0ubuntu1 這樣的版號,不過 0ubuntu1 這樣的 debian_version 只有上傳 Package 到 Ubuntu 的 Maintainer 才可以這樣使用,如果把 Debian 跟 Ubuntu 都當上游的話,那麼就應該使用 0ubuntu0ppa1 這樣的版號,當然 ppa 也可以換成其它自己偏好的字串。


慣例三:
如果是使用 apt-get source pcmanx-gtk2 抓下來改的 Debian Package,在改完後要直接在原本的版號後面加上自己的版號,像是原本是 0.3.9-2ubuntu2 就會變成 0.3.9-2ubuntu2fourdollars1

2010年6月14日 星期一

Debian Package (4) - 製作一個簡單但是有點用處的 Debian Package (續)

前一篇文章只能完成了 Debian Package 的打包但是並沒有上傳至 Debian 官方的套件庫
如果想要上傳到 Debian 官方的套件庫就必需尋求 Debian Developer (以下簡稱 DD) 的協助了
另外就是還要準備一把已經被 DD 簽過的金鑰才行 (可能要數個 DD 簽過才行)
如果沒有熟識的 DD 幫忙,其實還可以到 http://lists.debian.org/debian-mentors 上面尋求 DD 的協助
不過建議先看過 The debian-mentors FAQ 這份文件後再去尋求 DD 的協助

另外一種方式是自己維護 Debian Packages Archives 不過這真的很麻煩~ ^^b
如果是在 Ubuntu 上面的話可以考慮使用 Launchpad 上的 PPA 服務
以下將以 Launchpad PPA 為例

首先要建立自己的 Launchpad PPA 才行
會有一些申請的動作要自己去完成
可以參考 https://help.launchpad.net/Packaging/PPA 上面的說明

以下會假設已經完成 Launchpad PPA 的設定並且也準備好 SSH 金鑰跟 GPG 金鑰,只剩下要上傳 Debian Source Package 的動作要做。

因為 Launchpad PPA 只支援 Debian Source Package 的上傳,Launchpad 會再從 Debian Source Package 把 Debian Binary Package 給編譯產生出來,而之前的指令 dpkg-buildpackage -rfakeroot -uc -us -tc 其實會同時把 Debian Binary/Source Package 給產生出來,不過因為 -uc -us 這兩個參數就是指定不要使用 GPG 簽章,所以產生出來的 Debian Package 應該也無法上傳到 PPA 上使用。

如果要建立有簽章的 Debian Source Package 就要使用下面的指令
$ export DEBFULLNAME="First-Name Family-Name (Nickname)"
$ export DEBEMAIL="username@foo.bar"
$ dpkg-buildpackage -rfakeroot -S
這樣就可以在目錄上層建立牽過的 Debian Source Package 由以下三個檔案組成
taiwan-radio-tuner_0.1.dsc
taiwan-radio-tuner_0.1_source.changes
taiwan-radio-tuner_0.1.tar.gz
不過目前這樣的 Debian Source Package 就算上傳到 PPA 也會是失敗收場。

因為 Ubuntu 有一些規則要依循才行,首先修改 debian/changelog
taiwan-radio-tuner (0.1) lucid; urgency=low                                            

  * Initial release.

 -- First-Name Family-Name (Nickname) <username@foo.bar>  Mon, 14 Jun 2010 12:47:29 +0800
原本的 experimental 要改成 lucid 因為要給 Ubuntu 10.04 使用

另外就是如果要嚴格一點通過 lintian - Debian package checker 的測試,這是上傳到 Debian 官方套件庫必定要通過的測試,雖然在 Launchpad PPA 並沒有要求要通過 lintian 的測試,執行 debuild -S 後會發現有一些錯誤跟警告訊息出現。
W: taiwan-radio-tuner source: debhelper-but-no-misc-depends taiwan-radio-tuner
E: taiwan-radio-tuner source: package-uses-debhelper-but-lacks-build-depends
W: taiwan-radio-tuner source: package-lacks-versioned-build-depends-on-debhelper 7
W: taiwan-radio-tuner source: missing-debian-source-format
這些訊息其實只要 Google 一下就可以輕易地找到解決方法。
  • 首先是 debhelper-but-no-misc-depends 只要在 Depends 這個欄位多加上 ${misc:Depends} 就可以解決
  • 再來是 package-uses-debhelper-but-lacks-build-depends 跟 package-lacks-versioned-build-depends-on-debhelper 要多加上一個欄位 Build-Depends: debhelper (>= 7)
  • 剩下的 missing-debian-source-format 要多一個檔案在 debian/source/format 內容為 3.0 (native),因為這是一個原生的 Debian Package,如果是從上游的 tarball 而來的話就應該要使用 3.0 (quilt) 才行。
修改過後的 debian/control 如下:
Source: taiwan-radio-tuner
Maintainer: First-Name Family-Name (nickname) <username@foo.bar>
Section: contrib/web
Priority: extra
Build-Depends: debhelper (>= 7)
Standards-Version: 3.8.4
Homepage: https://chrome.google.com/extensions/detail/hacebidkncpkfenhpapdbkcefalehepa

Package: taiwan-radio-tuner
Architecture: all
Depends: ${misc:Depends}, google-chrome, alltray, gstreamer0.10-plugins-bad, gstreamer0.10-plugins-ugly, gstreamer0.10-ffmpeg
Description: Listen to the radio of Taiwan.
 The easiest way to listen to Internet Radio of Taiwan.
修改成這樣再去執行 debuild -S 應該就不會再有任何的錯誤訊息或是警告訊息的出現了。

最後就可以用 dput 上傳到 PPA 裡面啦~ :)
$ dput ppa:username/lucid taiwan-radio-tuner_0.1_source.changes
現在在 https://launchpad.net/~fourdollars/+archive/lucid
上面應該可以看到已經上傳到 Launchpad PPA 上的 Debian Package 了~
如果想要使用的朋友可以在 Ubuntu 10.04 上面執行 sudo add-apt-repository ppa:fourdollars/lucid
然後再執行 sudo apt-get update && sudo apt-get install taiwan-radio-tuner 應該就可以安裝好了~ :)

Debian Package (3) - 製作一個簡單但是有點用處的 Debian Package

Taiwan Radio Tuner 為例
現在要製作一個利用 Google Chrome 的 App Mode 來收聽網路廣播的程式
另外還要利用 Alltray 讓這個網頁應用程式可以隱藏在系統狀態列裡面
所以只要製作一個 taiwan-radio-tuner.desktop 安裝到 /usr/share/applications/ 底下就可以了
[Desktop Entry]
Name=Taiwan Radio Tuner
Exec=alltray google-chrome --app=http://fd.idv.tw/radio/
Icon=google-chrome
Type=Application
Categories=GTK;Application;AudioVideo;Audio;Player;
不過因為這個廣播程式會需要安裝一些額外的 codecs 才能夠正常地播放音樂
所以要額外安裝 gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-ffmpeg 這幾個套件

但是這些步驟也許對一般的使用者來說太過複雜了,所以製作一個 Debian Package
首先準備好 taiwan-radio-tuner 的目錄
$ mkdir taiwan-radio-tuner-0.1
把上面的 taiwan-radio-tuner.desktop 放進去
$ mv taiwan-radio-tuner.desktop taiwan-radio-tuner-0.1
然後在 taiwan-radio-tuner-0.1 底下產生 debian 這個目錄
$ cd taiwan-radio-tuner-0.1
$ mkdir debian
接下來開始準備 debian/control
Source: taiwan-radio-tuner
Maintainer: Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
Section: contrib/web
Priority: extra
Standards-Version: 3.8.4
Homepage: https://chrome.google.com/extensions/detail/hacebidkncpkfenhpapdbkcefalehepa

Package: taiwan-radio-tuner
Architecture: all
Depends: google-chrome, alltray, gstreamer0.10-plugins-bad, gstreamer0.10-plugins-ugly, gstreamer0.10-ffmpeg
Description: Listen to the radio of Taiwan.
 The easiest way to listen to Internet Radio of Taiwan.
這邊要注意到 Section 這欄寫的是 contrib/web 寫成 contrib 是因為這個套件相依到 google-chrome 這個 non-free 的套件

規則如下:
  • 如果本身是 free 的套件卻相依到 non-free 的套件就應該放在 contrib 底下。
  • 如果本身是 non-free 的套件當然就是直接放在 non-free 底下,這種情況會是 non-free/web
  • 如果本身是 free 的套件也沒有相依到 non-free 的套件,那麼寫成 web 就可以了。
這是參考 Debian Policy Manual - 2.4 Sections 來分類的,如果在 Ubuntu 上可能會有另外的分類方式。

還有準備 debian/compat
$ echo 7 > debian/compat
準備 debian/rules
$ cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
最後使用 dch --create 來產生一個 debian/changelog
taiwan-radio-tuner (0.1) experimental; urgency=low                                            

  * Initial release.

 -- Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>  Mon, 14 Jun 2010 12:47:29 +0800
不過還有一個很重要的檔案要準備 debian/install 內容如下
taiwan-radio-tuner.desktop /usr/share/applications/
也就是要把 taiwan-radio-tuner.desktop 安裝到 /usr/share/applications/ 底下的意思
如果沒有這個 debian/install 來指定安裝的地方,dpkg 就不會知道這個 taiwan-radio-tuner.desktop 要安裝到哪裡
所以也就不會把 taiwan-radio-tuner.desktop 包裝在 Debian Package 裡面

以上都準備好,最後就可以執行 dpkg-buildpackage -rfakeroot -uc -us -tc 來產生 Debian Package 了~

把產生出來的 Debian Package 安裝進系統後就應該可以在 GNOME 系統選單裡面看到一個 Taiwan Radio Tuner 的 Icon 可以點選了~

Debian Package (2) - 從基本開始製作一個簡單的 Debian Package (續)

延續前一篇文章 Debian Package (1) - 從基本開始製作一個簡單的 Debian Package

在使用 dpkg-buildpackage -rfakeroot -uc -us 來產生 Debian Package 的時候其會有一些警告訊息
dpkg-source: warning: missing information for output field Standards-Version
dpkg-genchanges: warning: missing Section for binary package foo; using '-'
dpkg-genchanges: warning: missing Priority for binary package foo; using '-'
dpkg-genchanges: warning: missing Section for source files
dpkg-genchanges: warning: missing Priority for source files
我們只要把 debian/control 修改成
Source: foo
Maintainer: foo <foo@bar.com>
Section: misc
Priority: extra             
Standards-Version: 3.8.4

Package: foo
Architecture: all
Description: blah
這樣就不會又那些警告訊息了~
Section 這個欄位標示套件的分類 詳細可以參考 http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
Priority 這個欄位標示套件的重要性 詳細可以參考 http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
Standards-Version 這個欄位則是標示打包 Debian Package 時所參考 Debian Policy 文件的版本號碼
目前最新是 3.8.4.0 在 http://www.debian.org/doc/debian-policy/ 最下面可以看到

不過到目前為止都只是一個無用的 Debian Package 罷了~ :P

但是這個無用的 Debian Package 可以看到一個 Debian Package 最基本的組成要件到底是什麼,說穿了就只是以下的四個檔案
debian/changelog #套件的變更紀錄
debian/compat #套件相容 debhelper 版本
debian/control #套件所有的描述跟分類
debian/rules #製作 Debian Package 時的 Makefile (背後會使用到 debhelper)
那麼接下來開始製作一個有點用處的 Debian Package 吧~ :)

2010年6月11日 星期五

Debian Package (1) - 從基本開始製作一個簡單的 Debian Package

首先要安裝需要的工具組
$ sudo aptitude install debhelper devscripts
然後產生一個目錄
$ mkdir foo-0.1
在裡面準備 debian/control
Source: foo
Maintainer: foo <foo@bar.com>

Package: foo
Architecture: all
Description: blah
然後準備 debian/rules
$ cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
有興趣可以看一下內容
#!/usr/bin/make -f
%:
    dh $@
在 debian/compat 指定一下這是 Debhelper 7 的 Debian Package
$ echo 7 > debian/compat
最後執行一下
$ dch --create --package foo -v 0.1 -D experimental
產生 debian/changelog 內容會像是
foo (0.1) experimental; urgency=low

  * Initial release. (Closes: #XXXXXX)                                   

 -- foo <foo@bar.com>  Fri, 11 Jun 2010 12:01:20 +0800
然後就可以開始打包了
$ dpkg-buildpackage -rfakeroot -uc -us
之後就會在 foo-0.1 這個目錄的上層目錄看到產生出來的 Debian Package 了
foo_0.1_all.deb
foo_0.1_amd64.changes
foo_0.1.dsc
foo_0.1.tar.gz
可以用指令看一下 foo_0.1_all.deb 的內容物
$ dpkg -c foo_0.1_all.deb
drwxr-xr-x root/root         0 2010-06-11 12:07 ./
drwxr-xr-x root/root         0 2010-06-11 12:07 ./usr/
drwxr-xr-x root/root         0 2010-06-11 12:07 ./usr/share/
drwxr-xr-x root/root         0 2010-06-11 12:07 ./usr/share/doc/
drwxr-xr-x root/root         0 2010-06-11 12:07 ./usr/share/doc/foo/
-rw-r--r-- root/root       161 2010-06-11 12:04 ./usr/share/doc/foo/changelog.gz
可以看到裡面只有一個之前寫的檔案 changelog.gz
也可以使用指令看一下這個 Debian Package 的資訊
$ dpkg -I foo_0.1_all.deb
 新式 debian 套件,版本 2.0。
 大小為 982 bytes:control 套件檔=371 bytes。
     218 bytes,    6 行         control
      79 bytes,    1 行         md5sums
 Package: foo
 Version: 0.1
 Architecture: all
 Maintainer: foo <foo@bar.com>
 Installed-Size: 28
 Description: blah
參考資料:http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles