คอมไพล์ GNOME ใช้เองด้วย JHBuild - เรียกใช้โปรแกรม

10 September, 2007 - 10:30
Submitted by thep

build กันเสร็จแล้ว ก็มาเริ่มใช้โปรแกรมที่ build กันนะครับ

เรื่องของ DBus

ก่อนจะเริ่มใช้ มีประเด็นเรื่อง DBus ที่เราวางแผนไว้ว่าจะใช้ของระบบ ปัญหาก็คือ โดยปกติ DBus จะรู้จัก service เฉพาะของระบบเท่านั้น ถ้าบังเอิญ GNOME รุ่นใหม่ที่เรา build มีการสร้าง service ใหม่โดยไม่ได้ register กับ DBus โปรแกรมบางโปรแกรมที่เรา build ก็จะเรียกไม่ขึ้น หรือไม่ก็ crash ไปดื้อ ๆ

เราทำให้ DBus รู้จัก service ของเราได้โดยเพิ่มแฟ้ม /etc/dbus-1/session-local.conf และ /etc/dbus-1/system-local.conf โดยมีเนื้อหาดังนี้:

/etc/dbus-1/session-local.conf:

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- Include jhbuild gnome session services -->
  <servicedir>/home/gnome-svn/share/dbus-1/services</servicedir>

</busconfig>

/etc/dbus-1/system-local.conf:

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- Our well-known bus type, do not change this -->
  <type>system</type>

  <!-- Include jhbuild gnome system services -->
  <includedir>/home/gnome-svn/etc/dbus-1/system.d</includedir>

</busconfig>

(ตรงชื่อไดเรกทอรี ผมทำตัวเอนไว้ เพื่อให้แก้เป็นชื่อไดเรกทอรีที่คุณใช้ได้สะดวกนะครับ)

ถ้าสงสัยว่าผมได้สองแฟ้มนี้มายังไง ก็ลองอ่าน /etc/dbus-1/session.conf กับ /etc/dbus-1/system.conf ดูละกันครับ แฟ้ม *-local.conf นี้ ควรจะถูก include มาจากสองแฟ้มนั้น ส่วน syntax ก็ดัดแปลงโค้ด XML เท่านั้นเอง

restart DBus เพื่อให้การแก้ไขมีผล:

# /etc/init.d/dbus restart

ต่อไปนี้ก็พร้อมเรียกโปรแกรมละ

การเรียกโปรแกรมที่ build

ตระเตรียมทุกอย่างเสร็จแล้ว จะทดสอบโปรแกรมที่ build ก็อาจเรียกเป็นรายโปรแกรม หรือเข้า GNOME session ไปเลย

เนื่องจากคุณมี environment สองแบบ คือของ distro และจาก JHBuild การเรียกโปรแกรมที่ build จึงต้องมีการกำหนด environment ต่างหาก ซึ่ง JHBuild ช่วยคุณได้ โดยสั่ง:

$ jhbuild run command-line

จะเรียก command-line ภายใต้ environment ที่กำหนด $PATH ให้ไปชี้ที่ bin และ $LD_LIBRARY_PATH ไปที่ lib ที่ติดตั้งโดย JHBuild รวมถึง environment อื่นที่เกี่ยวข้องด้วย

หรือสั่งอีกแบบ:

$ jhbuild shell

จะสร้าง shell ที่กำหนด environment เหล่านี้ให้เสร็จ จากนั้น command line ที่คุณเรียก ก็จะไปหาโปรแกรมและไลบรารีในแหล่งที่ติดตั้งโดย JHBuild ก่อน

คุณใช้หลักการเดียวกันนี้ในการเข้า GNOME session ทั้ง session จากแหล่งที่ติดตั้งโดย JHBuild ได้ โดยกำหนดใน ~/.xsession ของ user account ที่ใช้ทดสอบ:

#!/bin/sh

exec /home/thep/bin/jhbuild run gnome-session

(ในที่นี้ สมมุติว่าใช้ account "thep" ในการ build ซึ่ง jhbuild จะติดตั้งไว้ที่ $HOME/bin ของ account "thep")

อย่าลืม chmod ให้สคริปต์ executable ด้วยนะครับ

จากนั้น ก็ล็อกอินเป็น user account ที่ใช้ทดสอบนั้น (โดย switch user ที่ logout dialog แทนที่จะ logout หรือใช้ gdm ใน nested window ตามที่กล่าวไปแล้ว) โดยเลือกวาระ (session) เป็น X session (จากปกติที่เป็น GNOME session ซึ่งจะเป็น GNOME ของระบบ)

จบแล้ว ไม่ยากเกินไปใช่ไหมครับ เห็นยาว ๆ นี่ เป็นเกร็ดเล็กเกร็ดน้อยซะเยอะ

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <img> <blockquote> <h3> <h4>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is used to make sure you are a human visitor and to prevent spam submissions.
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.