Pemaketan Java Aplication di Debian


Alhamdulillah finally … tutorial ini dapat ditulis hari ini.
Well, ternyata pemaketan java di debian is little bit different dengan paket lainnya.

Ok, let’s move … bismillah

Program contohnya dapat didonlot disini

Misalnya kita punya program kita beri nama foo dengan versi 1.0, kita buat dulu direktorinya
#mkdir foo-1.0

Di dalam direktori foo-1.0 kita buat susunan direktori seperti ini :
foo-1.0
–> lib : tempat file-file  library jar
–> src : tempat file-file  java yang perlu dikompilasi
– build.xml : file yang dipanggil ant untuk membangun paket
– foo.desktop : file shortcut aplikasi foo
– fooshrek.png : file gambar icon

Untuk membuat packaging java kita dapat menggunakan paket java-helper meskipun masih ada bug yang perlu kita koreksi nanti.

#apt-get install java-helper sun-java6-bin sun-java6-jdk

#cd foo-1.0

Isi file build.xml :

Sekarang kita mulai pemaketan🙂
#jh_makepkg -m Nur Aini Rakhmawati -e aini@aini.net
Creating package foo version 1.0.

Building from source in /home/aini/debian/foo-1.0
Creating orig source tarball: foo_1.0.orig.tar.gz
Packager: Nur Aini Rakhmawati

What type of package is it? Application, or Library?
Select:
[A] Application (Default)
[L] Library
[Al] $ A

Selected: Application
What type of build system does it have? Ant, Makefiles, or None?
Select:
[A] Ant
[M] Makefiles
[V] Maven
[N] None—make one for me (Default)
[Namv] $ A

Selected: Ant
Which Java runtime does it need? Free runtime, or Sun?
Select:
[F] Free compiler/runtime (Default)
[5] Sun Java 1.5 (Package must be in contrib)
[6] Sun Java 1.6 (Package must be in contrib)
[I] Iced Tea
[F56i] $ 6

Selected: Sun 1.6
dch warning: Recognised distributions are:
{warty,hoary,breezy,dapper,edgy,feisty,gutsy,hardy,intrepid,jaunty}{,-updates,-security,-proposed} and UNRELEASED.
Using your request anyway.
dch: Did you see that warning?  Press RETURN to continue…

Packaging created. You will have to edit most or all of the files in debian/ before it works

Untuk tutorial kali ini saya memilih application, ant sebagai sistem pembangunnya dan Sun Java 1.6 sebagai JRE-nya.

Selanjutnya kita melakukan editing file-file penting yang berada di folder debian.
Edit file rules

#!/usr/bin/make -f
#
# Sample debian/rules that uses javahelper.
# This file was generated by jh_makepkg and may be used
# without restriction. It was inspired by the dh-make
# sample debian/rules

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export JAVA_HOME=/usr/lib/jvm/java-6-sun

# Put depended upon jars in here
# export CLASSPATH=

build: build-arch-stamp build-indep-stamp
build-arch: build-arch-stamp
build-arch-stamp:
dh_testdir
touch $@

build-indep: build-indep-stamp
build-indep-stamp:
dh_testdir
# Build the package
ant
touch $@

clean:
dh_testdir
dh_testroot
ant clean
dh_clean
rm -f build-stamp foo.jar

install-indep: build-indep
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs

#ant install

binary-arch: build-arch
# Java packages are arch: all, nothing to do here

binary-indep: build-indep install-indep
# Create the package here
ant jar
dh_testdir
dh_testroot
dh_clean -k
dh_install -i
dh_installdocs -i
dh_installchangelogs -i
#jh_manifest -i
dh_link -i
jh_exec -i
jh_depends -i -j sun6
dh_compress -i
dh_fixperms -i
dh_installdeb -i
dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i

binary: binary-indep binary-arch
.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep

Bagian jh_manifest sengaja saya beri tanda pagar (#) karena jh_manifest menimbulkan bug karana akan membuat manifest file yang salah. oleh karena itulah di file build.xml sudah kita definisikan
Edit file foo.install
foo.jar usr/share/foo
foo.desktop usr/share/applications
fooshrek.png usr/share/foo
lib/lala.jar usr/share/foo/lib

Adapun foo.desktop berisi seperti ini :

[Desktop Entry]
Name=Foo
GenericName=Dekstop Application
Comment=la la la ….
Icon=/usr/share/foo/fooshrek.png
Categories=Development;
Exec=/usr/share/foo/foo.jar
Type=Application
StartupNotify=false

Jika sudah diedit, yuk kita mulai melakukan proses “build”
aini@aini-desktop:~/debian/foo-1.0$ debuild -us -uc
dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: set CPPFLAGS to default value:
dpkg-buildpackage: set CFLAGS to default value: -g -O2
dpkg-buildpackage: set CXXFLAGS to default value: -g -O2
dpkg-buildpackage: set FFLAGS to default value: -g -O2
dpkg-buildpackage: set LDFLAGS to default value: -Wl,-Bsymbolic-functions
dpkg-buildpackage: source package foo
dpkg-buildpackage: source version 1.0-1
dpkg-buildpackage: source changed by Nur Aini Rakhmawati
dpkg-buildpackage: host architecture i386
fakeroot debian/rules clean
dh_testdir
dh_testroot
ant clean
Buildfile: build.xml

clean:
[delete] Deleting directory /home/aini/debian/foo-1.0/build

BUILD SUCCESSFUL
Total time: 0 seconds
dh_clean
rm -f build-stamp foo.jar
dpkg-source -b foo-1.0
dpkg-source: building foo using existing foo_1.0.orig.tar.gz
dpkg-source: building foo in foo_1.0-1.diff.gz
dpkg-source: building foo in foo_1.0-1.dsc
debian/rules build
make: Nothing to be done for `build’.
fakeroot debian/rules binary
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
#ant install
# Create the package here
ant jar
Buildfile: build.xml

compile:
[mkdir] Created dir: /home/aini/debian/foo-1.0/build
[javac] Compiling 1 source file to /home/aini/debian/foo-1.0/build

jar:
[jar] Building jar: /home/aini/debian/foo-1.0/foo.jar

BUILD SUCCESSFUL
Total time: 0 seconds
dh_testdir
dh_testroot
dh_clean -k
dh_install -i
dh_installdocs -i
dh_installchangelogs -i
#jh_manifest -i
dh_link -i
jh_exec -i
jh_depends -i -j sun6
dh_compress -i
dh_fixperms -i
dh_installdeb -i
dh_gencontrol -i
dpkg-gencontrol: warning: unknown substitution variable ${misc:Depends}
dh_md5sums -i
dh_builddeb -i
dpkg-deb: building package `foo’ in `../foo_1.0-1_all.deb’.
# Java packages are arch: all, nothing to do here
dpkg-genchanges  >../foo_1.0-1_i386.changes
dpkg-genchanges: including full source code in upload
dpkg-buildpackage: full upload (original source is included)
Now running lintian…
W: foo source: out-of-date-standards-version 3.7.3 (current is 3.8.0)
W: foo source: changelog-should-mention-nmu
W: foo source: source-nmu-has-incorrect-version-number 1.0-1
E: foo source: maintainer-address-malformed Nur Aini Rakhmawati
W: foo source: superfluous-clutter-in-homepage
W: foo source: bad-homepage
W: foo: binary-without-manpage usr/bin/foo
W: foo: executable-not-elf-or-script ./usr/share/foo/foo.jar
E: foo: maintainer-address-malformed Nur Aini Rakhmawati
W: foo: superfluous-clutter-in-homepage
W: foo: bad-homepage
E: foo: debian-changelog-file-contains-invalid-email-address aini@true
W: foo: new-package-should-close-itp-bug
W: foo: wrong-bug-number-in-closes l3:#XXXXXX
Finished running lintian.

Alhamdulillah paket kita sudah jadi😀 . Tinggal kita install. Paket installernya ada di luar folder foo-1.0.

Setelah melakukan beberapa packaging … yuk kita dengerin lagu Sherina ..pendinginan

Semoga hidup ini kulalui dengan hati yang seterang bintang-bintang
Indah bertaburan … tanpa kecewa amarah

    • dhoto
    • Januari 21st, 2009

    wah mantab

    mbak aini tambah jago aja ,… bentar lagi bisa dapet @debian.org tuh

    semangat semangat😀

    salam kenal dari tetangga sebelah😀

    keluarga http://kebo.vlsm.org

  1. waow….

    roger..lgs buka linuxmint and create “.java-deb”

  2. tararengkyu yaaaah,,,,tar klo ada trouble saya konsultasi lagi yaaaaahhhh.boleh kan?????

  3. saya pake ubuntu 9.10,,,,,,java helper-nya koq g bisa di instaLLLLLL.mohon petunjuknya

  4. mba’, di lenny ataupun lucid, namanya javahelper, tanpa tanda “-“. btw, trims petunjuknya

    • davidkaka
    • Oktober 30th, 2010

    wah sangat membantu ini…
    makasi ya mba…

    mampir yah ke http://highschoolscholarships.co.cc/

  5. Ibu, terima kasih bannyak sblmnya informasinya. saya akan mencoba nanti, ini uji coba di debian kn?? d ubuntu apakah sama ajah?

  6. mohon petunjuknya donk.
    saya menemukan error seperti ini:

    ————————————-
    dpkg-checkbuilddeps: Unmet build dependencies: ant
    dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
    dpkg-buildpackage: warning: (Use -d flag to override.)
    debuild: fatal error at line 1340:
    dpkg-buildpackage -rfakeroot -D -us -uc failed
    ————————————-
    apa yang salah yah?
    saya memakai ubuntu 10.04.

    • apt-get install ant

      • terima kasih banyak.
        tetapi masih muncul error seperti ini.
        —————————
        dpkg-buildpackage: host architecture i386
        fakeroot debian/rules clean
        debian/rules:19: *** missing separator. Stop.
        dpkg-buildpackage: error: fakeroot debian/rules clean gave error exit status 2
        debuild: fatal error at line 1340:
        dpkg-buildpackage -rfakeroot -D -us -uc failed
        —————————
        apa yang masih kurang yah instal sesuatu?

  7. Bu Nur, bagaimana jika saya ingin memaketkan JAR beserta dependensinya dalam 1 berkas DEB? Terima kasih…

    Tanya: Isi file build.xml : lalu ditulis apa?

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s