Pemaketan Debian Dari Aplikasi Java

Dipublikasikan oleh El Cicko pada

cropped blake connally IKUYGCFmfw4 unsplash

pemaketan_debian_javaAlhamdulillah, saya masih dikasih ilham dan ilmu buat nulis di Blog ini. Setelah kemarin bermalas-malasan karena lagi ga ada kegiatan yang bener-bener bikin sibuk. Dan akhirnya saya keingetan untuk membuat paket Debian dari aplikasi java. Ini adalah lanjutan dari artikel lama saya yaitu Membuat Paket Debian Untuk Aplikasi PHP . Nah bedanya sekarang kita coba buat bikin paket Debian dari sebuah aplikasi java.

Pertama-tama, kita install dulu paket-paket yang dibutuhkan untuk membangun paket Debian dari aplikasi kita, buka terminal dan ketikkan perintah berikut :

sudo apt-get install devscripts build-essential fakeroot debhelper gnupg pbuilder dh-make

Dan karena sekarang kita memakai Java Runtime. maka openjdk-7-jdk dan openjdk-7-jre harus sudah terinstall di mesin Debian / Ubuntu kita. kalo belum silahkan install dulu paketnya

sudo apt-get install openjdk-7jdk javahelper

download program contohnya disini. lalu extract file kompresinya..isinya kira-kaya begini

├── build
│   └── cicko.class
├── build-arch-stamp
├── build-indep-stamp
├── cicko.desktop
├── cicko.jar
├── codecicko.png
├── lib
└── src
    └── cicko.java

Keterangan :

  • build : tempat dimana file class hasil kompilasi source java kita disimpan.
  • lib : tempat library yang dibutuhkan aplikasi tersebut. disini saya kosongkan karena ga pake library :p
  • src : tempat dimana source java kita disimpan
  • cicko.jar : ini adalah aplikasi building java kita
  • cicko.desktop : ini adalah konfigurasi Debian / Ubuntu agar aplikasi kita nanti muncul di menu
  • codecicko.png : ini adalah file gambar untuk ikon aplikasi kita nanti
  • sisanya kosongin aja

Sekarang kita mulai pemaketan ya. Buka terminal dan masuk ke direktori aplikasi kita, ketikkan perintah berikut ini dan ikuti instruksi di bawah ini :

riky-pc% jh_makepkg -m Riky Fahri Hasibuan -e riky.hasibuan@gmail.com
Creating package cicko version 0.1.

Building from source in /home/elcicko/lab/cicko-0.1
Creating orig source tarball: cicko_0.1.orig.tar.gz
Packager: true <true>

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] $ N

Selected: No upstream build system
Which Java runtime does it need? Free runtime, or Sun?
Select:
	[F] Default Free compiler/runtime (Default)
	[G] GCJ
	[6] Sun Java 1.6 (Package must be in contrib)
	[o] OpenJDK 6
[FG6o] $ o

Selected: OpenJDK 6
dch warning: Recognised distributions are:
{hardy,lucid,maverick,natty,oneiric,precise,quantal}{,-updates,-security,-proposed,-backports} 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

Selanjutnya kita melakukan editing file-file penting yang berada di folder debian. Pertama-tama kita edit dulu file rules. Copy-paster script berikut ini

#!/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-7-openjdk-i386

# 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 cicko.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 yang saya komentari karena saya ga pake Ant untuk aplikasi Java saya ini. Abis itu sekarang kita edit file cicko.install

cicko.jar usr/share/cicko
cicko.desktop usr/share/applications
codecicko.png usr/share/cicko

Abis itu sekarang kita melakukan kompilasi…

riky-pc% debuild -us -uc
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor): -D_FORTIFY_SOURCE=2
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor): -Wl,-Bsymbolic-functions -Wl,-z,relro
dpkg-buildpackage: source package cicko
dpkg-buildpackage: source version 0.2-1
dpkg-buildpackage: source changed by true <true>
 dpkg-source --before-build cicko-0.2
dpkg-buildpackage: host architecture i386
 fakeroot debian/rules clean
dh_testdir
dh_testroot
#ant clean
dh_clean
#rm -f build-stamp cicko.jar
 dpkg-source -b cicko-0.2
dpkg-source: warning: no source format specified in debian/source/format, see dpkg-source(1)
dpkg-source: info: using source format `1.0'
dpkg-source: info: building cicko using existing cicko_0.2.orig.tar.gz
dpkg-source: info: building cicko in cicko_0.2-1.diff.gz
dpkg-source: warning: ignoring deletion of file build-arch-stamp
dpkg-source: warning: ignoring deletion of file build-indep-stamp
dpkg-source: info: building cicko in cicko_0.2-1.dsc
 debian/rules build
dh_testdir
touch build-arch-stamp
dh_testdir
# Build the package
#ant
touch build-indep-stamp
 fakeroot debian/rules binary
dh_testdir
dh_testroot
dh_clean -k
dh_clean: dh_clean -k is deprecated; use dh_prep instead
dh_installdirs
#ant install
# Create the package here
#ant jar	
dh_testdir
dh_testroot
dh_clean -k
dh_clean: dh_clean -k is deprecated; use dh_prep instead
dh_install -i
dh_installdocs -i
dh_installchangelogs -i
#jh_manifest -i
dh_link -i
jh_exec -i
jh_depends -i -j sun6
Warning: Class version too new to recognise (51), might not run with any JVMs
dh_compress -i
dh_fixperms -i
dh_installdeb -i
dh_gencontrol -i
dpkg-gencontrol: warning: package cicko: unused substitution variable ${java:Depends}
dh_md5sums -i
dh_builddeb -i
dpkg-deb: building package `cicko' in `../cicko_0.2-1_all.deb'.
# Java packages are arch: all, nothing to do here
 dpkg-genchanges  >../cicko_0.2-1_i386.changes
dpkg-genchanges: including full source code in upload
 dpkg-source --after-build cicko-0.2
dpkg-buildpackage: full upload (original source is included)
Now running lintian...
E: cicko changes: changed-by-address-malformed true <true>
W: cicko source: debhelper-but-no-misc-depends cicko
W: cicko source: dh-clean-k-is-deprecated
E: cicko source: maintainer-address-malformed true <true>
W: cicko source: superfluous-clutter-in-homepage <homepage>
W: cicko source: bad-homepage <homepage>
W: cicko source: boilerplate-copyright-format-uri [URI OF THE FORMAT SPECIFICATION, SUCH AS http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=REVISION]
W: cicko source: out-of-date-standards-version 3.9.2 (current is 3.9.3)
W: cicko: new-package-should-close-itp-bug
W: cicko: wrong-bug-number-in-closes l3:#XXXXXX
E: cicko: maintainer-address-malformed true <true>
W: cicko: superfluous-clutter-in-homepage <homepage>
W: cicko: bad-homepage <homepage>
E: cicko: missing-dep-on-jarwrapper
W: cicko: binary-without-manpage usr/bin/cicko
W: cicko: executable-not-elf-or-script usr/share/cicko/cicko.jar
Finished running lintian.

Kalau langkahnya benar, diluar direktori aplikasi kita seharusnya sudah banyak file-file aneh yang bertebaran, salah satunya yang berektensi *.deb. silahkan diinstall 😀

Selamat mencoba dan semoga bermanfaat 😀

 


El Cicko

Nama saya Riky Fahri Hasibuan, Saya yang biasa nulis di blog ini. Blog ini adalah sarana dokumentasi dari apa yang saya kerjakan dan tidak ada salahnya juga saya sebarkan. Jika artikel di blog bermanfaat, kamu bisa memberikan apresiasi pada blog ini dengan memberikan donasi pada blog ini.

0 Komentar

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *