Pemaketan Paket berdatabase dalam Debian


Paket sudah terinstall, namun database yang merupakan bagian terpenting belum ter-generate secara otomatis sepertinya kurang afdhol. Masak usernya yang diminta bikin database sendiri.

Saya juga sudah buat contoh programnya disini

Yuk kita buat installernya sekarang dengan bantuan dbconfig, bismillahūüôā

#apt-get install dh_make dbconfig-common

1. buat direktori paket kita. Ingat nama direktori formatnya seperti ini : namapaket-versi. Sebagai contoh nama paket kita iin dan versi 3.0, maka nama direktorinya iin-3.0

#mkdir iin-3.0
#cd iin-3.0

2. seperti biasa kita jalankan dh_make
#dh_make -n

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

Maintainer name : Nur Aini Rakhmawati
Email-Address   : aini@darqueenice
Date            : Sat, 10 Jan 2009 14:56:39 +0700
Package Name    : iin
Version         : 3.0
License         : gpl
Using dpatch    : 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 iin Makefiles install into $DESTDIR and not in / .

3. buat direktori web dan db (sembarang sih, hanya untuk mengelompok file2 web dan script SQL aja)
#mkdir web
#mkdir db

4. buat file tes.php. di web tersebut. isinya apa ya ? hhhmm biar simple isinya begini aja deh :
mysql_connect(“localhost”, “root”, “rahasiadonk”) or die(mysql_error());
mysql_select_db(“iin”) or die(mysql_error());
$hasil = mysql_query(“SELECT * FROM mytable”)
or die(mysql_error());
while ($record = mysql_fetch_array($hasil))
{
echo “No: “.$record[‘id’]. ”
“;
echo “Nama: “.$record[‘name’]. “

“;
}
?>

5. buat file mysql.sql di folder db
create table mytable (
id    int not null primary key,
name    varchar(32)
);
insert into mytable values (1, ‘foo’);
insert into mytable values (2, ‘bar’);

6. Ubah isi dirs di dalam direktori debian menjadi :
etc/iin
usr/share/iin
usr/share/dbconfig-common/data/iin/install/

Catatan :
1.menurut aturan yang ditetapkan debian kita harus meletakkan file2 web kita di /usr/share/namapaket. Tidak boleh langsung ditetap di /var/www meskipun /var/www adalah dokumen root web default di debian.
2. dalam dbconfig kita harus meletakkan script sql kita di usr/share/dbconfig-common/data/namapaket/install/tipedatabase sehingga untuk contoh paket iin dengan database mysql, direktorinya diberi nama /usr/share/dbconfig-common/data/iin/install/mysql

7. Ganti isi file rules yang terdapat di dalam direktori debian dengan isi berikut (ini lebih simpleūüėÄ )
#!/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
dh_install /web/* usr/share/iin
cp db/mysql.sql debian/iin/usr/share/dbconfig-common/data/iin/install/mysql
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

7. Mengganti file control dalam folder debian menjadi :
Source: iin
Section: web
Priority: extra
Maintainer: Nur Aini Rakhmawati
Build-Depends: debhelper (>= 7)
Standards-Version: 3.7.3
Homepage: https://ai23.wordpress.com

Package: iin
Architecture: all
Depends: apache2, debconf (>= 1.2.0), mysql-client | virtual-mysql-client, php5, php5-mysql
Description: contoh paket web berdatabase
Semangatūüôā

8. Membuat file postinst yang diletakkan di folder debian
#!/bin/sh
# postinst script for iin
#
# see: dh_installdeb(1)

set -e
. /usr/share/debconf/confmodule
. /usr/share/dbconfig-common/dpkg/postinst.mysql
dbc_go iin $@

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

cat > $aliasfile <
Alias /iin /usr/share/iin

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

DirectoryIndex index.php

iin_alias_end

chmod 644 $aliasfile;

}

case “$1” in
configure)

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

exit 0

9. Membuat file config yang diletakkan di folder debian juga
#!/bin/sh

set -e
#set -x

. /usr/share/debconf/confmodule
if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
. /usr/share/dbconfig-common/dpkg/config.mysql
dbc_go iin $@
fi

10. Kita bangun aplikasi kita :
aini@aini-desktop:~/debian/iin-3.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 iin
dpkg-buildpackage: source version 3.0
dpkg-buildpackage: source changed by Nur Aini Rakhmawati
dpkg-buildpackage: host architecture i386
fakeroot debian/rules clean
dh clean
dh_testdir
dh_auto_clean
dh_clean
dpkg-source -b iin-3.0
dpkg-source: building iin in iin_3.0.tar.gz
dpkg-source: building iin in iin_3.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_installcatalogs
dh_installemacsen
dh_installifupdown
dh_installinfo
dh_installinit
dh_installmenu
dh_installmime
dh_installmodules
dh_installlogcheck
dh_installlogrotate
dh_installpam
dh_installppp
dh_installudev
dh_installwm
dh_installxfonts
dh_lintian
dh_desktop
dh_gconf
dh_icons
dh_perl
dh_pysupport
dh_scrollkeeper
dh_usrlocal
dh_link
dh_compress
dh_fixperms
touch install-stamp
dh_install /web/* usr/share/iin
cp db/mysql.sql debian/iin/usr/share/dbconfig-common/data/iin/install/mysql
dh binary-arch
dh_strip -a
dh_makeshlibs -a
dh_shlibdeps -a
dh_installdeb -a
dh_gencontrol -a
dpkg-gencontrol: warning: unknown substitution variable ${shlibs:Depends}
dh_md5sums -a
dh_builddeb -a
dpkg-deb: building package `iin’ in `../iin_3.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
dpkg-gencontrol: warning: unknown substitution variable ${shlibs:Depends}
dh_md5sums
dh_builddeb
dpkg-deb: building package `iin’ in `../iin_3.0_i386.deb’.
dpkg-genchanges  >../iin_3.0_i386.changes
dpkg-genchanges: warning: duplicate files list entry for file iin_3.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…
Finished running lintian.

Hoopla Alhamdulillah sudah jadi paket debian kitaūüôā
Silahkan diinstall ….

  1. I do not even know the way I finished up here, however I assumed this publish was
    good. I do not recognise who you are but
    certainly you’re going to a well-known blogger should you aren’t
    already. Cheers!

  1. No trackbacks yet.

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