Membuat Paket Debian Untuk Aplikasi PHP

Setelah 1 minggu sibuk mempelajari dan bereksperimen dengan referensi-referensi yang ala kadarnya, alhamdulillah akhirnya berhasil juga. Sekarang kita coba buat ngebuild paket debian dari source PHP.

install paket-paket yang dibutuhkan :

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

abis itu kita bikin 1 file php, isinya…kaya gini aja lah

di simpan dengan nama index.php, lalu taruh di folder aplikasimu…rename dengan format penamaan seperti ini “application-ver”. Studi kasus disini aku pakai nama “cicko-1.0”.

buka terminal dan masuk ke direktori dimana aplikasimu berada…lalu ketikkan perintah ini :

[~/cicko-1.0] [12:57:30 cicko]$ dh_make -n

Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch or cdbs?
 [s/i/m/l/k/n/b] s

Maintainer name : El Cicko
Email-Address    : riky.hasibuan@gmail.com 
Date                   : Fri, 07 Dec 2012 12:57:51 +0700
Package Name    : cicko
Version               : 1.0
License               : gpl3
Using dpatch       : no
Using quilt           : no
Type of Package : Single
Hit  to confirm: 
Currently there is no top level Makefile. This may require additional tuning.
Done. Please edit the files in the debian/ subdirectory now. You should also
check that the cicko Makefiles install into $DESTDIR and not in / .

setelah selesai, bakal muncul direktori bernama “debian”, masuk kedalam direktori tersebut dan hapus file-file berikut ini :

[~/cicko-1.0/debian] [12:58:11 cicko]$ rm -rf *.ex
[~/cicko-1.0/debian] [12:58:26 cicko]$ rm -rf *.EX
[~/cicko-1.0/debian] [12:58:36 cicko]$ rm -rf *.Debian
[~/cicko-1.0/debian] [12:58:51 cicko]$ rm -rf *.source

abis itu buka file control dan edit isinya jadi seperti ini :

Source: cicko
Section: web
Priority: extra
Maintainer: El Cicko <riky.hasibuan@gmail.com>
Build-Depends: debhelper (>= 7)
Standards-Version: 3.8.3
Homepage: https://elcicko.com

Package: cicko
Architecture: any
Depends: apache2
Description: Tes Program Aplikasi Web 
 Tes Program Aplikasi Web

abis itu buka file rules dan copy paste script ini :

#!/usr/bin/make -f

build: build-stamp
build-stamp:
	dh build
	touch build-stamp

clean:
	dh clean

install: build install-stamp
install-stamp:
	dh install
	touch install-stamp

binary-arch: install
        # perintah untuk copy file index.php ke target instalasi
	dh_install index.php usr/share/cicko
	dh binary-arch

binary-indep: install
	dh_testdir
	dh_testroot
	dh_installdebconf	
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_perl
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-arch binary-indep

bikin file bernama dirs dan isi seperti ini :

usr/share/cicko

ini berfungsi untuk membuat temporary dir yang nantinya dijadikan destinasi dimana pada proses instalasi, script kita akan di copy ke direktori tersebut. Dalam struktur filesystem linux, script web kita biasanya disimpan di /var/www/nama_aplikasi, nah berhubung aplikasi kita terinstall di /usr/share/cicko, sekarang kita bikin script untuk membuat sebuah konfigurasi apache sendiri agar aplikasi kita dapat di akses via /usr/share/cicko, sekarang kita bikin file bernama postinst, copy-paste script berikut :

#!/bin/sh
# postinst script for cicko
#
# see: dh_installdeb(1)

alias_config()
{
. /usr/share/debconf/confmodule || exit
aliasfile=/etc/cicko/apache.conf

cat > $aliasfile << cicko_alias_end
Alias /cicko /usr/share/cicko

Options +FollowSymLinks
AllowOverride None
order deny,allow
allow from all

        DirectoryIndex index.php

cicko_alias_end

chmod 644 $aliasfile;

}

case "$1" in
	configure)

			alias_config
			#supaya bisa dipanggil lewat browser
			find /usr/share/cicko -type d -exec chmod 755 {} ;
			find /usr/share/cicko -type f -exec chmod 644 {} ;
			chown -R www-data:www-data /usr/share/cicko
			#memasang file alias	
			if [ ! -e /etc/apache2/conf.d/cicko ] && [ -d /etc/apache2/conf.d ] 
			then
	   			ln -s /etc/cicko/apache.conf /etc/apache2/conf.d/cicko
				/etc/init.d/apache2 restart			
			fi
;;
	esac
exit 0

abis itu kita naik 1 level direktori keluar dari direktori debian, lalu ketikkan perintah berikut :

debuild -us -uc

maka sistem akan mulai melakukan proses kompilasi

dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: set CFLAGS to default value: -g -O2
dpkg-buildpackage: set CPPFLAGS to default value: 
dpkg-buildpackage: set LDFLAGS to default value: -Wl,-Bsymbolic-functions
dpkg-buildpackage: set FFLAGS to default value: -g -O2
dpkg-buildpackage: set CXXFLAGS to default value: -g -O2
dpkg-buildpackage: source package cicko
dpkg-buildpackage: source version 1.0
dpkg-buildpackage: source changed by El Cicko <riky.hasibuan@gmail.com>
dpkg-buildpackage: host architecture i386
 fakeroot debian/rules clean
dh clean
   dh_testdir
   dh_auto_clean
   dh_clean
 dpkg-source -b cicko-1.0
dpkg-source: info: using source format `1.0'
dpkg-source: info: building cicko in cicko_1.0.tar.gz
dpkg-source: info: building cicko in cicko_1.0.dsc
 debian/rules build
dh build
   dh_testdir
   dh_auto_configure
   dh_auto_build
   dh_auto_test
touch build-stamp
 fakeroot debian/rules binary
dh install
   dh_testroot
   dh_prep
   dh_installdirs
   dh_auto_install
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_installexamples
   dh_installman
   dh_installcatalogs
   dh_installcron
   dh_installdebconf
   dh_installemacsen
   dh_installifupdown
   dh_installinfo
   dh_pysupport
   dh_installinit
   dh_installmenu
   dh_installmime
   dh_installmodules
   dh_installlogcheck
   dh_installlogrotate
   dh_installpam
   dh_installppp
   dh_installudev
   dh_installwm
   dh_installxfonts
   dh_bugfiles
   dh_lintian
   dh_gconf
   dh_icons
   dh_perl
   dh_usrlocal
   dh_link
   dh_compress
   dh_fixperms
touch install-stamp
dh_install index.php usr/share/cicko
dh binary-arch
   dh_strip -a
   dh_makeshlibs -a
   dh_shlibdeps -a
   dh_installdeb -a
   dh_gencontrol -a
   dh_md5sums -a
   dh_builddeb -a
dpkg-deb: building package `cicko' in `../cicko_1.0_i386.deb'.
dh_testdir
dh_testroot
dh_installdebconf	
dh_installchangelogs
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_perl
dh_gencontrol
dh_md5sums
dh_builddeb
dpkg-deb: building package `cicko' in `../cicko_1.0_i386.deb'.
 dpkg-genchanges  >../cicko_1.0_i386.changes
dpkg-genchanges: warning: duplicate files list entry for file cicko_1.0_i386.deb (line 2)
dpkg-genchanges: including full source code in upload
dpkg-buildpackage: full upload; Debian-native package (full source is included)
Now running lintian...
W: cicko source: debhelper-but-no-misc-depends cicko
W: cicko source: maintainer-script-lacks-debhelper-token debian/postinst
W: cicko source: missing-debian-source-format
W: cicko source: ancient-standards-version 3.8.3 (current is 3.8.4)
E: cicko: helper-templates-in-copyright
W: cicko: copyright-has-url-from-dh_make-boilerplate
E: cicko: copyright-contains-dh_make-todo-boilerplate
E: cicko: description-synopsis-is-duplicated
E: cicko: maintainer-script-calls-init-script-directly postinst:44
W: cicko: maintainer-script-ignores-errors postinst
Finished running lintian.

Kalau langkahnya udah bener..seharusnya di luar folder cicko…ada file-file yang bertebaran dan ada file berekstensi *.deb salah satunya, install aja.

Mudah-mudahan bermanfaat 🙂

Tinggalkan komentar