code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>libtdb</Name>
        <Homepage>http://tdb.samba.org</Homepage>
        <Packager>
            <Name>PisiLinux Community</Name>
            <Email>admins@pisilinux.org</Email>
        </Packager>
        <License>LGPLv3+</License>
        <IsA>library</IsA>
        <IsA>app:console</IsA>
        Trivial database library
        <Description>libtdb contains C library and Python bindings to access to a trivial database. TDB is very much like GDBM and BSDDB except that it allows multiple simultaneous writers and uses locking internally to keep writers from trampling on each other.</Description>
        <Archive sha1sum="86fec2b5e698ef15da07be4a26672773575e37cd" type="targz">https://www.samba.org/ftp/tdb/tdb-1.3.12.tar.gz</Archive>
        <BuildDependencies>
            <Dependency>libxslt</Dependency>
            <Dependency>python-devel</Dependency>
            <Dependency>docbook-xsl</Dependency>
            <Dependency>libbsd-devel</Dependency>
        </BuildDependencies>
        <Patches>
        </Patches>
    </Source>

    <Package>
        <Name>libtdb</Name>
        <RuntimeDependencies>
            <Dependency>python</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="executable">/usr/bin</Path>
            <Path fileType="library">/usr/lib</Path>
            <Path fileType="man">/usr/share/man</Path>
            <Path fileType="doc">/usr/share/doc</Path>
        </Files>
    </Package>

    <Package>
        <Name>libtdb-devel</Name>
        Development files for libtdb
        <RuntimeDependencies>
            <Dependency release="current">libtdb</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/lib/pkgconfig</Path>
            <Path fileType="header">/usr/include</Path>
        </Files>
    </Package>

    <History>
        <Update release="4">
            <Date>2017-02-09</Date>
            <Version>1.3.12</Version>
            <Comment>Release bump.</Comment>
            <Name>Stefan Gronewold</Name>
            <Email>groni@pisilinux.org</Email>
        </Update>
        <Update release="3">
            <Date>2016-07-24</Date>
            <Version>1.3.8</Version>
            <Comment>Version Bump</Comment>
            <Name>Ergün Salman</Name>
            <Email>poyraz76@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-06-08</Date>
            <Version>1.3.7</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2015-07-30</Date>
            <Version>1.3.7</Version>
            <Comment>First release</Comment>
            <Name>Ertuğrul Erata</Name>
            <Email>ertugrulerata@gmail.com</Email>
        </Update>
    </History>
</PISI>


code:
<?xml version="1.0" ?>
<PISI>
    <Source>
        <Name>libtdb</Name>
        TDB veritabanına erişim için gerekli kitaplıklar
        <Description xml:lang="tr">libtdb basit bir veritabanı olan TDB ile iletişime geçmek için gerekli C ve Python kitaplıklarını içerir.</Description>
    </Source>

    <Package>
        <Name>libtdb-devel</Name>
        libtdb için geliştirme dosyaları
    </Package>
</PISI>

repo_name: ayhanyalcinsoy/main


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from pisi.actionsapi import get
from pisi.actionsapi import autotools
from pisi.actionsapi import pisitools
from pisi.actionsapi import shelltools

def build():
    shelltools.cd("libraries/liblmdb")
    autotools.make("prefix=/usr")

def install():
    shelltools.cd("libraries/liblmdb")

    pisitools.dodir("/usr/bin")
    pisitools.dodir("/usr/lib")
    pisitools.dodir("/usr/man/man1")
    pisitools.dodir("/usr/share")
    pisitools.dodir("/usr/include")

    autotools.rawInstall("DESTDIR=%s prefix=/usr" % get.installDIR())

    pisitools.domove("/usr/man", "/usr/share")
    pisitools.dodoc("LICENSE", "CHANGES", "COPYRIGHT")


code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>lmdb</Name>
        <Homepage>http://symas.com/mdb/</Homepage>
        <Packager>
            <Name>PisiLinux Community</Name>
            <Email>admins@pisilinux.org</Email>
        </Packager>
        <License>OpenLDAP</License>
        <License>custom</License>
        <IsA>library</IsA>
        <IsA>app:console</IsA>
        Symas Lightning Memory-Mapped Database
        <Description>An ultra-fast, ultra-compact key-value embedded data store.</Description>
        <Archive sha1sum="5f236169298e277241467b0058b1b36a60d087d6" type="targz">https://github.com/LMDB/lmdb/archive/LMDB_0.9.19.tar.gz</Archive>
    </Source>

    <Package>
        <Name>lmdb</Name>
        <Files>
            <Path fileType="executable">/usr/bin</Path>
            <Path fileType="library">/usr/lib</Path>
            <Path fileType="man">/usr/share/man</Path>
            <Path fileType="doc">/usr/share/doc</Path>
        </Files>
    </Package>

    <Package>
        <Name>lmdb-devel</Name>
        Development files for lmdb
        <RuntimeDependencies>
            <Dependency release="current">lmdb</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="header">/usr/include</Path>
        </Files>
    </Package>

    <History>
        <Update release="3">
            <Date>2017-02-09</Date>
            <Version>0.9.19</Version>
            <Comment>Release bump.</Comment>
            <Name>Stefan Gronewold</Name>
            <Email>groni@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-06-08</Date>
            <Version>0.9.16</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2015-08-28</Date>
            <Version>0.9.16</Version>
            <Comment>First release</Comment>
            <Name>Ertuğrul Erata</Name>
            <Email>ertugrulerata@gmail.com</Email>
        </Update>
    </History>
</PISI>


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from pisi.actionsapi import get
from pisi.actionsapi import pisitools
from pisi.actionsapi import shelltools
from pisi.actionsapi import cmaketools

#pisitools.flags.add("-fno-strict-aliasing -DBIG_JOINS=1")
#pisitools.cflags.add("-fomit-frame-pointer")
#pisitools.cxxflags.add("-felide-constructors -fno-rtti -fno-delete-null-pointer-checks")

def setup():
    #pisitools.dosed("storage/tokudb/ft-index/ft/ft-ops.cc", "LEAFENTRY leaf_entry;", "LEAFENTRY leaf_entry = 0;")
    shelltools.export("CFLAGS", get.CFLAGS())
    shelltools.export("CXXFLAGS", get.CXXFLAGS())
    cmaketools.configure("-DBUILD_CONFIG=mysql_release \
                          -DCMAKE_INSTALL_PREFIX=/usr \
                          -DSYSCONFDIR=/etc/mysql \
                          -DMYSQL_DATADIR=/var/lib/mysql \
                          -DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock \
                          -DDEFAULT_CHARSET=utf8 \
                          -DDEFAULT_COLLATION=utf8_general_ci \
                          -DENABLED_LOCAL_INFILE=ON \
                          -DINSTALL_INFODIR=share/mysql/docs \
                          -DINSTALL_MANDIR=share/man \
                          -DINSTALL_PLUGINDIR=lib/mysql/plugin \
                          -DINSTALL_SCRIPTDIR=bin \
                          -DINSTALL_INCLUDEDIR=include/mysql \
                          -DINSTALL_DOCREADMEDIR=share/mysql \
                          -DINSTALL_SUPPORTFILESDIR=share/mysql \
                          -DINSTALL_MYSQLSHAREDIR=share/mysql \
                          -DINSTALL_DOCDIR=share/mysql/docs \
                          -DINSTALL_SHAREDIR=share/mysql \
                          -DWITH_READLINE=ON \
                          -DWITH_ZLIB=system \
                          -DWITH_SSL=system \
                          -DWITH_PCRE=system \
                          -DWITH_LIBWRAP=OFF \
                          -DWITH_JEMALLOC=ON \
                          -DWITH_EXTRA_CHARSETS=complex \
                          -DWITH_EMBEDDED_SERVER=ON \
                          -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
                          -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
                          -DWITH_INNOBASE_STORAGE_ENGINE=1 \
                          -DWITH_PARTITION_STORAGE_ENGINE=1 \
                          -DWITHOUT_TOKUDB_STORAGE_ENGINE=1 \
                          -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
                          -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 \
                          -DWITHOUT_PBXT_STORAGE_ENGINE=1 \
                          -DCMAKE_C_FLAGS='-fPIC %s -fno-strict-aliasing -DBIG_JOINS=1 -fomit-frame-pointer -fno-delete-null-pointer-checks' \
                          -DCMAKE_CXX_FLAGS='-fPIC %s -fno-strict-aliasing -DBIG_JOINS=1 -felide-constructors -fno-rtti -fno-delete-null-pointer-checks' \
                          -DWITH_MYSQLD_LDFLAGS='-pie %s,-z,now'" % (get.CFLAGS(), get.CXXFLAGS(), get.LDFLAGS()))
#-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' \
def build():
    cmaketools.make()

def install():
    cmaketools.install("DESTDIR=%s benchdir_root=\"/usr/share/mysql\"" % get.installDIR())

    # Config
    pisitools.insinto("/etc/mysql", "%s/usr/share/mysql/my-medium.cnf" % get.installDIR(), "my.cnf")
    pisitools.insinto("/etc/mysql", "%s/%s/scripts/mysqlaccess.conf" % (get.workDIR(), get.srcDIR()))
    pisitools.insinto("/usr/bin", "%s/%s/scripts/mysql_config" % (get.workDIR(), get.srcDIR()))
    # Data dir
    pisitools.dodir("/var/lib/mysql")

    # Documents
    pisitools.dodoc("%s/%s/support-files/my-*.cnf" % (get.workDIR(), get.srcDIR()))
    pisitools.dodoc("COPYING", "INSTALL-SOURCE", "README", "VERSION")

    # Remove not needed files
    pisitools.removeDir("/usr/data")
    pisitools.removeDir("/usr/mysql-test")
    pisitools.removeDir("/usr/sql-bench")
    pisitools.remove("/usr/share/man/man1/mysql-test-run.pl.1")

    # Remove -lprobes_mysql
    #pisitools.dosed("%s/usr/bin/mysql_config" % get.installDIR(), "-lprobes_mysql")


code:
#!/usr/bin/python

import os, re
import shutil

OUR_ID = 794
OUR_NAME = "mysql"
OUR_DESC = "mysql"

DATADIR = "/var/lib/mysql"
DATADIRMODE = 0755

def postInstall(fromVersion, fromRelease, toVersion, toRelease):
    try:
        os.system ("groupadd -g %d %s" % (OUR_ID, OUR_NAME))
        os.system ("useradd -m -d /var/lib/mysql -r -s /bin/false -u %d -g %d %s -c %s" % (OUR_ID, OUR_ID, OUR_NAME, OUR_DESC))
    except:
        pass

    os.system("/sbin/mudur_tmpfiles.py /usr/lib/tmpfiles.d/mariadb.conf")

        # Create the database
    os.system("/bin/chown -R mysql:mysql %s" % DATADIR)
    os.system("/bin/chown -R mysql:mysql /var/log/mysqld.log")
    os.system("/usr/bin/mysql_install_db --user=mysql --datadir=/var/lib/mysql --basedir=/usr --force")
    os.system("/usr/bin/mysql_upgrade --force")

    # On first install...
    if not os.path.exists(DATADIR):
        os.makedirs(DATADIR, DATADIRMODE)

def postRemove():
    try:
        os.system ("userdel %s" % OUR_NAME)
        os.system ("groupdel %s" % OUR_NAME)
    except:
        pass


code:
# -*- coding: utf-8 -*-
from comar.service import *
import os

serviceType="server"
serviceDesc=_({"en": "MariaDB Database Server",
               "tr": "MariaDB Veritabanı Sunucusu"})

PIDFILE="/run/mysqld/mysqld.pid"
DAEMON="/usr/bin/mysqld"

@synchronized
def start():
    startService(command=DAEMON,
                 pidfile=PIDFILE,
                 detach=True,
                 donotify=True)
    #os.system("pidof mariadb_server + /usr/bin/mysqld > /run/mysqld/mysqld.pid")

@synchronized
def stop():
    stopService(pidfile=PIDFILE,
                donotify=True)

    try:
        os.unlink(PIDFILE)
    except OSError:
        pass

def status():
    return isServiceRunning(PIDFILE)


code:
# The following options will be passed to all MySQL clients
[client]
#password= your_password
port= 3306
socket= /run/mysqld/mysqld.sock

[mysql]
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8

[mysqladmin]
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8

[mysqlcheck]
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8

[mysqldump]
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8

[mysqlimport]
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8

[mysqlshow]
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8

[myisamchk]
character-sets-dir=/usr/share/mysql/charsets

[myisampack]
character-sets-dir=/usr/share/mysql/charsets

# use [safe_mysqld] with mysql-3
[mysqld_safe]
err-log= /var/log/mysql/mysql.err

# add a section [mysqld-4.1] or [mysqld-5.0] for specific configurations
[mysqld]
character-set-server= utf8
user = mysql
port = 3306
socket = /run/mysqld/mysqld.sock
pid-file = /run/mysqld/mysqld.pid
log-error = /var/log/mysql/mysqld.err
basedir 			= /usr
datadir 			= /var/lib/mysql
skip-external-locking
key_buffer 			= 16M
max_allowed_packet 		= 4M
table_open_cache 		= 400
sort_buffer_size 		= 512K
net_buffer_length 		= 16K
read_buffer_size 		= 256K
read_rnd_buffer_size 		= 512K
myisam_sort_buffer_size 	= 8M
lc_messages_dir			= /usr/share/mysql
#Set this to your desired error message language
lc_messages			= en_US

# security:
# using "localhost" in connects uses sockets by default
# skip-networking
bind-address			= 127.0.0.1
log-bin
#log-bin 			= mysqld-bin
server-id 			= 1

# point the following paths to different dedicated disks
tmpdir 				= /tmp/
#log-update 			= /path-to-dedicated-directory/hostname

# you need the debug USE flag enabled to use the following directives,
# if needed, uncomment them, start the server and issue
# #tail -f /tmp/mysqld.sql /tmp/mysqld.trace
# this will show you *exactly* what's happening in your server ;)

#log				= /tmp/mysqld.sql
#gdb
#debug				= d:t:i:o,/tmp/mysqld.trace
#one-thread

# uncomment the following directives if you are using BDB tables
#bdb_cache_size			= 4M
#bdb_max_lock			= 10000

# the following is the InnoDB configuration
# if you wish to disable innodb instead
# uncomment just the next line
#skip-innodb
#
# the rest of the innodb config follows:
# don't eat too much memory, we're trying to be safe on 64Mb boxes
# you might want to bump this up a bit on boxes with more RAM
innodb_buffer_pool_size = 128M
#
# i'd like to use /var/lib/mysql/innodb, but that is seen as a database :-(
# and upstream wants things to be under /var/lib/mysql/, so that's the route
# we have to take for the moment
#innodb_data_home_dir		= /var/lib/mysql/
#innodb_log_arch_dir		= /var/lib/mysql/
#innodb_log_group_home_dir	= /var/lib/mysql/
# you may wish to change this size to be more suitable for your system
# the max is there to avoid run-away growth on your machine
innodb_data_file_path = ibdata1:10M:autoextend:max:128M
# we keep this at around 25% of of innodb_buffer_pool_size
# sensible values range from 1MB to (1/innodb_log_files_in_group*innodb_buffer_pool_size)
innodb_log_file_size = 48M
# this is the default, increase it if you have very large transactions going on
innodb_log_buffer_size = 8M
# this is the default and won't hurt you
# you shouldn't need to tweak it
innodb_log_files_in_group=2
# see the innodb config docs, the other options are not always safe
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
innodb_file_per_table

# Uncomment this to get FEDERATED engine support
#plugin-load=federated=ha_federated.so
loose-federated

[mysqldump]
quick
max_allowed_packet 		= 16M

[mysql]
# uncomment the next directive if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer 			= 20M
sort_buffer_size 		= 20M
read_buffer 			= 2M
write_buffer 			= 2M

[myisamchk]
key_buffer 			= 20M
sort_buffer_size 		= 20M
read_buffer 			= 2M
write_buffer 			= 2M

[mysqlhotcopy]
interactive-timeout

[mariadb]


code: d /run/mysqld 0755 mysql mysql -


code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>mariadb</Name>
        <Homepage>https://mariadb.org</Homepage>
        <Packager>
            <Name>Pisi Linux Admins</Name>
            <Email>admins@pisilinux.org</Email>
        </Packager>
        <License>GPLv2</License>
        <IsA>app:console</IsA>
        MariaDB is a drop-in replacement for MySQL
        <Description>MariaDB strives to be the logical choice for database professionals looking for a robust, scalable, and reliable SQL server.</Description>
        <Archive sha1sum="f9ccaa9881b98eeef68f4dbcf5ab9653c903819f" type="targz">http://mirrors.syringanetworks.net/mariadb/mariadb-10.1.21/source/mariadb-10.1.21.tar.gz</Archive>
        <BuildDependencies>
            <Dependency>ncurses-devel</Dependency>
            <Dependency>zlib-devel</Dependency>
            <Dependency>libxml2-devel</Dependency>
            <Dependency>readline-devel</Dependency>
            <Dependency>libevent-devel</Dependency>
            <Dependency>openssl-devel</Dependency>
            <Dependency>libpcre-devel</Dependency>
            <Dependency>libaio-devel</Dependency>
            <Dependency>unixODBC-devel</Dependency>
            <Dependency>cmake</Dependency>
        </BuildDependencies>
        <Patches>
        </Patches>
    </Source>

    <Package>
        <Name>mariadb-lib</Name>
        <IsA>app:console</IsA>
        <IsA>library</IsA>
        The shared libraries required for MariaDB clients
        <RuntimeDependencies>
            <Dependency>zlib</Dependency>
            <Dependency>bzip2</Dependency>
            <Dependency>libgcc</Dependency>
            <Dependency>libpcre</Dependency>
            <Dependency>libxml2</Dependency>
            <Dependency>openssl</Dependency>
            <Dependency>libaio</Dependency>
            <Dependency>unixODBC</Dependency>
        </RuntimeDependencies>
        <Replaces>
            <Package>mysql-lib</Package>
        </Replaces>
        <Files>
            <Path fileType="executable">/usr/bin/mysql_config</Path>
            <Path fileType="header">/usr/include</Path>
            <Path fileType="library">/usr/lib/libmysqlclient.so</Path>
            <Path fileType="library">/usr/lib/libmysqlclient.so.18</Path>
            <Path fileType="library">/usr/lib/libmysqlclient.so.18.0.0</Path>
            <Path fileType="library">/usr/lib/libmysqlclient_r.so</Path>
            <Path fileType="library">/usr/lib/libmysqlclient_r.so.18</Path>
            <Path fileType="library">/usr/lib/libmysqlclient_r.so.18.0.0</Path>
            <Path fileType="library">/usr/lib/libmysqld.a</Path>
            <Path fileType="library">/usr/lib/libmysqlclient_r.a</Path>
            <Path fileType="library">/usr/lib/libmysqlclient.a</Path>
            <Path fileType="library">/usr/lib/libmysqld.so</Path>
            <Path fileType="library">/usr/lib/libmysqld.so.18</Path>
            <Path fileType="library">/usr/lib/libmysqlservices.a</Path>
            <Path fileType="library">/usr/bin/mysqld_safe_helper</Path>
        </Files>
    </Package>

    <Package>
        <Name>mariadb-client</Name>
        <IsA>app:console</IsA>
        MariaDB client programs
        <RuntimeDependencies>
            <Dependency version="current">mariadb-lib</Dependency>
            <Dependency>libaio</Dependency>
            <Dependency>zlib</Dependency>
            <Dependency>libgcc</Dependency>
            <Dependency>libpcre</Dependency>
            <Dependency>ncurses</Dependency>
            <Dependency>openssl</Dependency>
        </RuntimeDependencies>
        <Replaces>
            <Package>mysql-client</Package>
        </Replaces>
        <Files>
            <Path fileType="executable">/usr/bin/mysql</Path>
            <Path fileType="executable">/usr/bin/mysqladmin</Path>
            <Path fileType="executable">/usr/bin/mysqlcheck</Path>
            <Path fileType="executable">/usr/bin/mysqldump</Path>
            <Path fileType="executable">/usr/bin/mysqlimport</Path>
            <Path fileType="executable">/usr/bin/mysqlshow</Path>
            <Path fileType="executable">/usr/bin/mysqlslap</Path>
        </Files>
    </Package>

    <Package>
        <Name>mariadb-server</Name>
        <IsA>service</IsA>
        The MariaDB server and related files
        <RuntimeDependencies>
            <Dependency version="current">mariadb-lib</Dependency>
            <Dependency version="current">mariadb-client</Dependency>
            <Dependency>zlib</Dependency>
            <Dependency>libgcc</Dependency>
            <Dependency>openssl</Dependency>
            <Dependency>libxml2</Dependency>
            <Dependency>unixODBC</Dependency>
        </RuntimeDependencies>
        <Replaces>
            <Package>mysql-server</Package>
        </Replaces>
        <Files>
            <Path fileType="config">/etc</Path>
            <Path fileType="executable">/usr/bin/aria_chk</Path>
            <Path fileType="executable">/usr/bin/aria_dump_log</Path>
            <Path fileType="executable">/usr/bin/aria_ftdump</Path>
            <Path fileType="executable">/usr/bin/aria_pack</Path>
            <Path fileType="executable">/usr/bin/aria_read_log</Path>
            <Path fileType="executable">/usr/bin/innochecksum</Path>
            <Path fileType="executable">/usr/bin/msql2mysql</Path>
            <Path fileType="executable">/usr/bin/my_print_defaults</Path>
            <Path fileType="executable">/usr/bin/myisam_ftdump</Path>
            <Path fileType="executable">/usr/bin/myisamchk</Path>
            <Path fileType="executable">/usr/bin/myisamlog</Path>
            <Path fileType="executable">/usr/bin/myisampack</Path>
            <Path fileType="executable">/usr/bin/mysql_client_test</Path>
            <Path fileType="executable">/usr/bin/mysql_convert_table_format</Path>
            <Path fileType="executable">/usr/bin/mysql_embedded</Path>
            <Path fileType="executable">/usr/bin/mysql_client_test_embedded</Path>
            <Path fileType="executable">/usr/bin/mysqltest_embedded</Path>
            <Path fileType="executable">/usr/bin/mysql_find_rows</Path>
            <Path fileType="executable">/usr/bin/mysql_fix_extensions</Path>
            <Path fileType="executable">/usr/bin/mysql_install_db</Path>
            <Path fileType="executable">/usr/bin/mysql_plugin</Path>
            <Path fileType="executable">/usr/bin/mysql_secure_installation</Path>
            <Path fileType="executable">/usr/bin/mysql_setpermission</Path>
            <Path fileType="executable">/usr/bin/mysql_tzinfo_to_sql</Path>
            <Path fileType="executable">/usr/bin/mysql_upgrade</Path>
            <Path fileType="executable">/usr/bin/mysql_waitpid</Path>
            <Path fileType="executable">/usr/bin/mysql_zap</Path>
            <Path fileType="executable">/usr/bin/mysqlaccess</Path>
            <Path fileType="executable">/usr/bin/mysqlbinlog</Path>
            <Path fileType="executable">/usr/bin/mysqlbug</Path>
            <Path fileType="executable">/usr/bin/mysqld</Path>
            <Path fileType="executable">/usr/bin/mysqld-post</Path>
            <Path fileType="executable">/usr/bin/mysqld_multi</Path>
            <Path fileType="executable">/usr/bin/mysqld_safe</Path>
            <Path fileType="executable">/usr/bin/mysqldumpslow</Path>
            <Path fileType="executable">/usr/bin/mysqlhotcopy</Path>
            <Path fileType="executable">/usr/bin/mysqltest</Path>
            <Path fileType="executable">/usr/bin/perror</Path>
            <Path fileType="executable">/usr/bin/replace</Path>
            <Path fileType="executable">/usr/bin/resolve_stack_dump</Path>
            <Path fileType="executable">/usr/bin/resolveip</Path>
            <Path fileType="executable">/usr/bin/tokuft_logprint</Path>
            <Path fileType="executable">/usr/bin/tokuftdump</Path>
            <Path fileType="executable">/usr/bin/wsrep_sst_common</Path>
            <Path fileType="executable">/usr/bin/wsrep_sst_mysqldump</Path>
            <Path fileType="executable">/usr/bin/wsrep_sst_rsync</Path>
            <Path fileType="executable">/usr/bin/wsrep_sst_xtrabackup</Path>
            <Path fileType="executable">/usr/bin/wsrep_sst_xtrabackup-v2</Path>
            <Path fileType="executable">/usr/bin/mytop</Path>
            <Path fileType="library">/usr/lib/mysql/plugin</Path>
            <Path fileType="data">/usr/share/mysql</Path>
            <Path fileType="data">/var</Path>
            <Path fileType="doc">/usr/share/doc</Path>
            <Path fileType="config">/usr/lib/tmpfiles.d/mariadb.conf</Path>
            <Path fileType="data">/run/mysqld</Path>
        </Files>
        <AdditionalFiles>
            <AdditionalFile owner="root" permission="0644" target="/etc/mysql/my.cnf">my.cnf</AdditionalFile>
            <AdditionalFile owner="root" permission="0644" target="/usr/lib/tmpfiles.d/mariadb.conf">tmpfiles.conf</AdditionalFile>
        </AdditionalFiles>
        <Provides>
            <COMAR script="service.py">System.Service</COMAR>
            <COMAR script="package.py">System.Package</COMAR>
        </Provides>
    </Package>

    <Package>
        <Name>mariadb-man-pages</Name>
        <IsA>data</IsA>
        Man pages for MariaDB server and client
        <Replaces>
            <Package>mysql-man-pages</Package>
        </Replaces>
        <Files>
            <Path fileType="man">/usr/share/man</Path>
        </Files>
    </Package>

    <History>
        <Update release="3">
            <Date>2017-02-09</Date>
            <Version>10.1.21</Version>
            <Comment>Release bump.</Comment>
            <Name>Stefan Gronewold(groni)</Name>
            <Email>groni@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-06-08</Date>
            <Version>10.1.10</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2016-01-24</Date>
            <Version>10.1.10</Version>
            <Comment>First release</Comment>
            <Name>Alihan Öztürk</Name>
            <Email>alihan@pisilinux.org</Email>
        </Update>
    </History>
</PISI>


code:
<?xml version="1.0" ?>
<PISI>
    <Source>
        <Name>mariadb</Name>
        Hızlı, çok kullanıcılı ve çok görevli SQL veritabanı sunucusu
        <Description xml:lang="tr">MySQL, çoklu iş parçacıklı (multi-threaded), çok kullanıcılı (multi-user), hızlı ve sağlam (robust) bir Veritabanı yönetim sistemidir. Özelllikle basit web uygulamaları için LAMP sistemi içinde sıkça tercih edilmektedir.</Description>
    </Source>

    <Package>
        <Name>mariadb-lib</Name>
        MariaDB client tools
        MySQL istemcileri tarafından gereken paylaşımlı kitaplıklar
    </Package>

    <Package>
        <Name>mariadb-client</Name>
        MariaDB client libraries
        MariaDB istemci uygulamaları
    </Package>
    <Package>
        <Name>mariadb-server</Name>
        MariaDB server and releated files
        MariaDB sunucusu ve ilgili dosyalar
    </Package>
    <Package>
        <Name>mariadb-man-pages</Name>
        MariaDB server and client man pages
        MariaDB sunucu ve istemci uygulamarına ait kılavuz sayfaları
    </Package>
</PISI>


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from pisi.actionsapi import autotools
from pisi.actionsapi import pisitools
from pisi.actionsapi import shelltools
from pisi.actionsapi import get

def setup():
    autotools.configure("--with-python \
                         --with-perl \
                         --include=/usr/include/postgresql \
                         --with-includes=/usr/include/libxml2/ \
                         --with-tcl \
                         --with-krb5 \
                         --with-openssl \
                         --enable-nls \
                         --with-pam \
                         --with-libxml \
                         --with-libxslt \
                         --with-ldap \
                         --enable-integer-datetimes \
                         --enable-thread-safety \
                         --enable-depend \
                         --host=%s \
                         --libdir=/usr/lib \
                         --disable-rpath \
                         --with-docdir=/usr/share/doc/postgresql" % get.CHOST())

def build():
    if get.LDFLAGS():
        ld = "-j1 LD=%s %s" % (get.LD(), get.LDFLAGS())
    else:
        ld = "-j1 LD=%s" % get.LD()

    autotools.make(ld)

    shelltools.cd("contrib")
    autotools.make(ld)
    shelltools.cd("..")

    shelltools.cd("contrib/xml2")
    autotools.make(ld)
    shelltools.cd("../..")

    shelltools.cd("src/interfaces/libpq")
    autotools.make(ld)
    shelltools.cd("../../..")

    shelltools.cd("doc")
    autotools.make(ld)
    shelltools.cd("..")

def install():
    autotools.rawInstall("DESTDIR=%s LIBDIR=%s/usr/lib" % (get.installDIR(), get.installDIR()))

    shelltools.cd("contrib")
    autotools.rawInstall("DESTDIR=%s LIBDIR=%s/usr/lib" % (get.installDIR(), get.installDIR()))
    shelltools.cd("..")

    shelltools.cd("contrib/xml2")
    autotools.rawInstall("DESTDIR=%s LIBDIR=%s/usr/lib" % (get.installDIR(), get.installDIR()))
    shelltools.cd("../..")

    shelltools.cd("src/interfaces/libpq")
    autotools.rawInstall("DESTDIR=%s LIBDIR=%s/usr/lib" % (get.installDIR(), get.installDIR()))
    shelltools.cd("../../..")

    shelltools.cd("doc")
    autotools.rawInstall("DESTDIR=%s LIBDIR=%s/usr/lib" % (get.installDIR(), get.installDIR()))
    shelltools.cd("..")

    # No static libs
    pisitools.remove("/usr/lib/*.a")

    pisitools.dodoc("README", "HISTORY", "COPYRIGHT")
    pisitools.dodoc("doc/MISSING_FEATURES", "doc/KNOWN_BUGS", "doc/TODO", "doc/bug.template")
    pisitools.dodir("/var/lib/postgresql")
    pisitools.dodir("/var/lib/postgresql/data")
    pisitools.dodir("/var/lib/postgresql/backups")


code:
#!/usr/bin/python

import os

def postInstall(fromVersion, fromRelease, toVersion, toRelease):
    os.system("/bin/chown -R postgres:postgres /var/lib/postgresql")
    os.system("/bin/chmod -R 0700 /var/lib/postgresql/data")
    os.system("/bin/chmod -R 0700 /var/lib/postgresql/backups")

    # On first install...
    if not os.path.exists("/var/lib/postgresql/data/base"):
        for i in ["LANG", "LANGUAGE", "LC_ALL"]:
            os.environ[i] = "en_US.UTF-8"

        os.system('/bin/su postgres -s /bin/sh -p -c "/usr/bin/initdb --pgdata /var/lib/postgresql/data"')


code:
# -*- coding: utf-8 -*-

from comar.service import *

serviceType="server"

serviceDesc = _({"en": "PostgreSQL Database Server",
                 "tr": "PostgreSQL Veritabanı Sunucusu"})

serviceConf = "postgresql"

MSG_ERR_PGSQLNOTINST = _({"en": "PostgreSQL is not configured properly, please re-install the package.",
                          "tr": "PostgreSQL düzgün yapılandırılmamış, lütfen paketi tekrar yükleyin.",
                          })

def check_postgresql():
    import os
    if not os.path.exists(config.get("PGDATA", "/var/lib/postgresql/data")):
        fail(MSG_ERR_PGSQLNOTINST)

PIDFILE = "%s/postmaster.pid" % config.get("PGDATA", "/var/lib/postgresql/data")

@synchronized
def start():
    check_postgresql()
    startService(command="/usr/bin/pg_ctl",
                 args=["start", "-D", config.get("PGDATA", "/var/lib/postgresql/data"), "-l", config.get("PGLOG", "/var/lib/postgresql/data/postgresql.log"), "-o", config.get("PGOPTS", "")],
                 pidfile=PIDFILE,
                 chuid=config.get("PGUSER", "postgres"),
                 donotify=True)

@synchronized
def stop():
    stopService(command="/usr/bin/pg_ctl",
                args=["stop", "-D", config.get("PGDATA", "/var/lib/postgresql/data"), "-s", "-m", "fast"],
                chuid=config.get("PGUSER", "postgres"),
                donotify=True)

def reload():
    stopService(command="/usr/bin/pg_ctl",
                args=["reload", "-D", config.get("PGDATA", "/var/lib/postgresql/data"), "-s"],
                donotify=True)

def status():
    return isServiceRunning(PIDFILE)


code:
# PostgreSQL's Database Directory
PGDATA=/var/lib/postgresql/data

# Logfile path: (NOTE: This must be uid/gid owned by the value of $PGUSER!)
PGLOG=/var/lib/postgresql/data/postgresql.log

# Run the PostgreSQL user as:
PGUSER=postgres

# Extra options to run postmaster with.
# If you want to enable TCP/IP for PostgreSQL, add -i to the following:
# PGOPTS="-N 1024 -B 2048 -i"
PGOPTS=""


code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>postgresql</Name>
        <Homepage>http://www.postgresql.org/</Homepage>
        <Packager>
            <Name>PisiLinux Community</Name>
            <Email>admins@pisilinux.org</Email>
        </Packager>
        <License>GPLv2</License>
        <IsA>service</IsA>
        A powerful, open source relational database system
        <Description>PostgreSQL is a powerful, open source relational database system.</Description>
        <Archive sha1sum="0ff14271b42233666c4831ac0152b2ea069fdf9d" type="tarbz2">https://ftp.postgresql.org/pub/source/v9.6.2/postgresql-9.6.2.tar.bz2</Archive>
        <BuildDependencies>
            <Dependency>mit-kerberos</Dependency>
            <Dependency>e2fsprogs-devel</Dependency>
            <Dependency>pam-devel</Dependency>
            <Dependency>readline-devel</Dependency>
            <Dependency>zlib-devel</Dependency>
            <Dependency>python-devel</Dependency>
            <Dependency>openssl-devel</Dependency>
            <Dependency>tcl-devel</Dependency>
            <Dependency>libxslt-devel</Dependency>
            <Dependency>libxml2-devel</Dependency>
            <Dependency>openldap-server</Dependency>
        </BuildDependencies>
        <Patches>

        </Patches>
    </Source>

    <Package>
        <Name>postgresql-lib</Name>
        <IsA>library</IsA>
        Essential shared libraries for any PostgreSQL client program or interface
        <RuntimeDependencies>
            <Dependency>mit-kerberos</Dependency>
            <Dependency>python</Dependency>
            <Dependency>zlib</Dependency>
            <Dependency>libxml2</Dependency>
            <Dependency>openssl</Dependency>
            <Dependency>e2fsprogs</Dependency>
            <Dependency>libxslt</Dependency>
            <Dependency>openldap-client</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib</Path>
            <Path fileType="header">/usr/include</Path>
            <Path fileType="library">/usr/lib/pkgconfig</Path>
            <Path fileType="data">/usr/share/postgresql</Path>
            <Path fileType="executable">/usr/bin/pg_config</Path>
        </Files>
    </Package>

    <Package>
        <Name>postgresql-doc</Name>
        <IsA>data:doc</IsA>
        Postgresql documents
        <Description>Additional documentation for PostgreSQL.</Description>
        <RuntimeDependencies>
            <Dependency release="current">postgresql-lib</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="doc">/usr/share/doc</Path>
        </Files>
    </Package>

    <Package>
        <Name>postgresql-server</Name>
        <IsA>service</IsA>
        <RuntimeDependencies>
            <Dependency release="current">postgresql-lib</Dependency>
            <Dependency>pam</Dependency>
            <Dependency>zlib</Dependency>
            <Dependency>libxml2</Dependency>
            <Dependency>openssl</Dependency>
            <Dependency>readline</Dependency>
            <Dependency>e2fsprogs</Dependency>
            <Dependency>mit-kerberos</Dependency>
            <Dependency>openldap-client</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="config">/etc</Path>
            <Path fileType="executable">/usr/bin</Path>
            <Path fileType="localedata">/usr/share/locale</Path>
            <Path fileType="data">/usr/share/postgresql/contrib</Path>
            <Path fileType="man">/usr/share/man</Path>
            <Path fileType="data">/var/lib</Path>
        </Files>
        <AdditionalFiles>
            <AdditionalFile target="/etc/conf.d/postgresql" owner="root" permission="0644">postgresql.conf-8</AdditionalFile>
        </AdditionalFiles>
        <Provides>
            <COMAR script="package.py">System.Package</COMAR>
            <COMAR script="service.py">System.Service</COMAR>
        </Provides>
    </Package>

    <Package>
        <Name>postgresql-pl</Name>
        <RuntimeDependencies>
            <Dependency release="current">postgresql-lib</Dependency>
            <Dependency>tcl</Dependency>
            <Dependency>perl</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="executable">/usr/bin/pltcl_listmod</Path>
            <Path fileType="executable">/usr/bin/pltcl_loadmod</Path>
            <Path fileType="executable">/usr/bin/pltcl_delmod</Path>
            <Path fileType="library">/usr/lib/postgresql/plperl.so</Path>
            <Path fileType="library">/usr/lib/postgresql/plpython.so</Path>
            <Path fileType="library">/usr/lib/postgresql/pltcl.so</Path>
            <Path fileType="data">/usr/share/postgresql/unknown.pltcl</Path>
        </Files>
    </Package>

    <History>
        <Update release="3">
            <Date>2017-09-20</Date>
            <Version>9.6.2</Version>
            <Comment>Release bump.</Comment>
            <Name>Stefan Gronewold</Name>
            <Email>groni@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-06-08</Date>
            <Version>9.3.9</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2015-07-03</Date>
            <Version>9.3.9</Version>
            <Comment>First release</Comment>
            <Name>Ertuğrul Erata</Name>
            <Email>ertugrulerata@gmail.com</Email>
        </Update>
    </History>
</PISI>


code:
<?xml version="1.0" ?>
<PISI>
    <Source>
        <Name>postgresql</Name>
        Güçlü bir açık kaynaklı ilişkisel veritabanı sistemi
        <Description xml:lang="tr">PostgreSQL, açık kaynak kodlu, güçlü bir ilişkisel veritabanıdır</Description>
    </Source>

    <Package>
        <Name>postgresql-doc</Name>
        Postegresql belgeleri
        <Description xml:lang="tr">PostegreSQL için ek belgelendirme</Description>
    </Package>
</PISI>


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/copyleft/gpl.txt

from pisi.actionsapi import autotools
from pisi.actionsapi import shelltools
from pisi.actionsapi import pisitools
from pisi.actionsapi import get

def setup():
    shelltools.export("CFLAGS", "%s -DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2" % get.CFLAGS())
    shelltools.export("LDFLAGS", "%s -lcrypto" % get.LDFLAGS())
    autotools.configure("--prefix=/usr \
                         --enable-tempstore=yes \
                         --enable-readline \
                         --enable-threadsafe \
                         --enable-cross-thread-connections \
                         --enable-releasemode \
                         --disable-static \
                         --with-crypto-lib")

    #for unused
    pisitools.dosed("libtool", " -shared ", " -Wl,-O1,--as-needed -shared ")

def build():
    autotools.make()

def install():
    autotools.rawInstall("DESTDIR=%s" % get.installDIR())

    pisitools.dodoc("CHANGELOG*", "README*", "VERSION", "LICENSE")


code:
<PISI>
    <Source>
        <Name>sqlcipher</Name>
        <Homepage>https://www.zetetic.net/sqlcipher/</Homepage>
        <Packager>
            <Name>Alihan Öztürk</Name>
            <Email>alihan@pisilinux.org</Email>
        </Packager>
        <License>BSD</License>
        <IsA>data</IsA>
        SQLite extension that provides transparent 256-bit AES encryption of database files
        <Description>SQLCipher is an SQLite extension that provides transparent 256-bit AES encryption of database files. Pages are encrypted before being written to disk and are decrypted when read back. Due to the small footprint and great performance it’s ideal for protecting embedded application databases and is well suited for mobile development.</Description>
        <BuildDependencies>
            <Dependency>readline-devel</Dependency>
            <Dependency>tcl-devel</Dependency>
            <Dependency>openssl-devel</Dependency>
            <Dependency>sqlite-devel</Dependency>
            <Dependency>ncurses-devel</Dependency>
        </BuildDependencies>
        <Archive sha1sum="9380db7bd1d304b9db59c5d9c26c449ee57bfe01" type="targz">https://github.com/sqlcipher/sqlcipher/archive/v3.4.0.tar.gz</Archive>
    </Source>

    <Package>
        <Name>sqlcipher</Name>
        SQLite extension that provides transparent 256-bit AES encryption of database files.
        <RuntimeDependencies>
            <Dependency>openssl</Dependency>
            <Dependency>readline</Dependency>
            <Dependency>sqlite</Dependency>
            <Dependency>tcl</Dependency>
            <Dependency>ncurses</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="executable">/usr/bin</Path>
            <Path fileType="library">/usr/lib/tcl8.6</Path>
            <Path fileType="library">/usr/lib/lib*</Path>
            <Path fileType="doc">/usr/share/doc</Path>
        </Files>
    </Package>

    <Package>
        <Name>sqlcipher-devel</Name>
        Development files for sqlcipher.
        <RuntimeDependencies>
            <Dependency release="current">sqlcipher</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="header">/usr/include</Path>
            <Path fileType="library">/usr/lib/pkgconfig</Path>
        </Files>
    </Package>

    <History>
        <Update release="3">
            <Date>2017-02-09</Date>
            <Version>3.4.0</Version>
            <Comment>Release bump.</Comment>
            <Name>Stefan Gronewold</Name>
            <Email>groni@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-06-08</Date>
            <Version>3.3.1</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2016-03-22</Date>
            <Version>3.3.1</Version>
            <Comment>First release.</Comment>
            <Name>Alihan Öztürk</Name>
            <Email>alihan@pisilinux.org</Email>
        </Update>
    </History>
</PISI>


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from pisi.actionsapi import autotools
from pisi.actionsapi import pisitools
from pisi.actionsapi import shelltools
from pisi.actionsapi import get

def setup():
    shelltools.export("CFLAGS", "%s -D_GNU_SOURCE -fPIC" % get.CFLAGS())
#in some troff man pages
    #for i in ["dhclient.conf.5", "dhclient.leases.5", "dhclient-script.8", "dhclient.8"]:
    #    pisitools.dosed("client/%s" % i, "CLIENTBINDIR", "/sbin")
    #   pisitools.dosed("client/%s" % i, "RUNDIR", "/run")
    #  pisitools.dosed("client/%s" % i, "DBDIR", "/var/lib/dhcpd")
    # pisitools.dosed("client/%s" % i, "ETCDIR", "/etc/dhcp")

    #for i in ["dhcpd.conf.5", "dhcpd.leases.5", "dhcpd.8"]:
    #    pisitools.dosed("server/%s" % i, "CLIENTBINDIR", "/sbin")
    #   pisitools.dosed("server/%s" % i, "RUNDIR", "/run")
    #    pisitools.dosed("server/%s" % i, "DBDIR", "/var/lib/dhcpd")
    #   pisitools.dosed("server/%s" % i, "ETCDIR", "/etc/dhcp")

    pisitools.dosed("client/scripts/linux", "/etc/dhclient-exit-hooks", "/etc/dhcp/dhclient-exit-hooks")
    pisitools.dosed("client/scripts/linux", "/etc/dhclient-enter-hooks", "/etc/dhcp/dhclient-enter-hooks")

    autotools.autoreconf("-vfi")
    autotools.configure("--with-srv-lease-file=/var/lib/dhcpd/dhcpd.leases \
                         --with-srv6-lease-file=/var/lib/dhcpd/dhcpd6.leases \
                         --with-cli-lease-file=/var/lib/dhclient/dhclient.leases \
                         --with-cli6-lease-file=/var/lib/dhclient/dhclient6.leases \
                         --with-srv-pid-file=/run/dhcpd.pid \
                         --with-srv6-pid-file=/run/dhcpd6.pid \
                         --with-cli-pid-file=/run/dhclient.pid \
                         --with-cli6-pid-file=/run/dhclient6.pid \
                         --with-relay-pid-file=/run/dhcrelay.pid \
                         --with-ldap \
                         --with-ldapcrypto")

def build():
    autotools.make("-j1")

def install():
    autotools.rawInstall("DESTDIR=%s" % get.installDIR())

    # Remove files we don't want
    pisitools.remove("/etc/dhcpd.conf.example")
    pisitools.remove("/etc/dhclient.conf.example")

    # Install dhcp.schema for LDAP configuration
    pisitools.insinto("/etc/openldap/schema", "contrib/ldap/dhcp.schema")

    # dhclient configuration per service support is not ready yet, no need to create this directory for now
    # Install empty directory for dhclient.d scripts
    #pisitools.dodir("/etc/dhcp/dhclient.d")

    # Create directory hierarchy in /var
    pisitools.dodir("/var/lib/dhcpd")
    pisitools.dodir("/var/lib/dhclient")

    # Sample configuration files
    pisitools.insinto("/usr/share/doc/dhcp", "client/dhclient.conf.5", "dhclient.conf.exsample")
    pisitools.insinto("/usr/share/doc/dhcp", "server/dhcpd.conf.5", "dhcpd.conf.example")
    pisitools.insinto("/usr/share/doc/dhcp", "doc/examples/dhclient-dhcpv6.conf")
    pisitools.insinto("/usr/share/doc/dhcp", "doc/examples/dhcpd-dhcpv6.conf")

    pisitools.dodoc("LICENSE", "README", "RELNOTES")


code:
# -*- coding: utf-8 -*-
from comar.service import *

serviceType = "server"
serviceDesc = _({"en": "DHCP Daemon",
                 "tr": "DHCP Servisi"})

serviceConf = "dhcpd"

MSG_NM_NOT_RUNNING = _({"en": "NetworkManager service is not running",
                        "tr": "NetworkManager hizmeti çalışmıyor",
                       })

PIDFILE = "/run/dhcpd.pid"
TIMEOUT = config.get("TIMEOUT", 10)

@synchronized
def start():
    try:
        startDependencies("NetworkManager")
        # Prevent race condition between NM and dhcpd
        if run("/usr/bin/nm-online -q -t %s" % TIMEOUT) != 0:
            # NM is not running
            fail(MSG_NM_NOT_RUNNING)
    except:
        pass

    startService(command="/usr/sbin/dhcpd",
                 args="-cf %s %s %s" % (config.get("DHCPD_CONF", "/etc/dhcp/dhcpd.conf"), config.get("DHCPD_ARGS", ""), config.get("INTERFACES", "")),
                 pidfile=PIDFILE,
                 donotify=True)

@synchronized
def stop():
    stopService(pidfile=PIDFILE,
                donotify=True)

def status():
    return isServiceRunning(PIDFILE)


code:
# -*- coding: utf-8 -*-
from comar.service import *

serviceType = "server"
serviceDesc = _({"en": "DHCPv6 Daemon",
                 "tr": "DHCPv6 Servisi"})

serviceConf = "dhcpd6"

MSG_NM_NOT_RUNNING = _({"en": "NetworkManager service is not running",
                        "tr": "NetworkManager hizmeti çalışmıyor",
                       })

PIDFILE = "/run/dhcpd6.pid"
TIMEOUT = config.get("TIMEOUT", 10)

@synchronized
def start():
    try:
        startDependencies("NetworkManager")
        # Prevent race condition between NM and dhcpd
        if run("/usr/bin/nm-online -q -t %s" % TIMEOUT) != 0:
            # NM is not running
            fail(MSG_NM_NOT_RUNNING)
    except:
        pass

    startService(command="/usr/sbin/dhcpd",
                 args="-6 -cf %s %s %s" % (config.get("DHCPD_CONF", "/etc/dhcp/dhcpd.conf"), config.get("DHCPD_ARGS", ""), config.get("INTERFACES", "")),
                 pidfile=PIDFILE,
                 donotify=True)

@synchronized
def stop():
    stopService(pidfile=PIDFILE,
                donotify=True)

def status():
    return isServiceRunning(PIDFILE)


code:
# -*- coding: utf-8 -*-
from comar.service import *

serviceType = "server"
serviceDesc = _({"en": "DHCP Relay Server",
                 "tr": "DHCP Relay Servisi"})
serviceConf = "dhcrelay"

pidfile = "/run/dhcrelay.pid"

@synchronized
def start():
    startService(command="/usr/sbin/dhcrelay",
                 args="%s %s" % (config.get("DHCPD_ARGS", ""), config.get("INTERFACES", "")),
                 donotify=True)

@synchronized
def stop():
    stopService(command="/usr/sbin/dhcpd",
                pidfile=pidfile,
                donotify=True)

def status():
    return isServiceRunning(pidfile)


code:
#!/usr/bin/python

import os

def postInstall(fromVersion, fromRelease, toVersion, toRelease):
    if not os.path.exists("/var/lib/dhcpd/dhcpd.leases"):
        os.system("/bin/touch /var/lib/dhcpd/dhcpd.leases")

    if not os.path.exists("/var/lib/dhcpd/dhcpd6.leases"):
        os.system("/bin/touch /var/lib/dhcpd/dhcpd6.leases")


code:
diff -up dhcp-4.3.0a1/client/dhc6.c.honor-expired dhcp-4.3.0a1/client/dhc6.c
--- dhcp-4.3.0a1/client/dhc6.c.honor-expired	2013-12-19 16:00:28.062183037 +0100
+++ dhcp-4.3.0a1/client/dhc6.c	2013-12-19 16:00:28.076182842 +0100
@@ -1351,6 +1351,32 @@ start_info_request6(struct client_state
 		go_daemon();
 }

+/* Run through the addresses in lease and return true if there's any unexpired.
+ * Return false otherwise.
+ */
+isc_boolean_t
+unexpired_address_in_lease(struct dhc6_lease *lease)
+{
+	struct dhc6_ia *ia;
+	struct dhc6_addr *addr;
+
+	for (ia = lease->bindings ; ia != NULL ; ia = ia->next) {
+		for (addr = ia->addrs ; addr != NULL ; addr = addr->next) {
+			if (addr->flags & DHC6_ADDR_EXPIRED)
+				continue;
+
+			if (addr->starts + addr->max_life > cur_time) {
+				return ISC_TRUE;
+			}
+		}
+	}
+
+	log_info("PRC: Previous lease is devoid of active addresses."
+		 "  Re-initializing.");
+
+	return ISC_FALSE;
+}
+
 /*
  * start_confirm6() kicks off an "init-reboot" version of the process, at
  * startup to find out if old bindings are 'fair' and at runtime whenever
@@ -1363,8 +1389,10 @@ start_confirm6(struct client_state *clie

 	/* If there is no active lease, there is nothing to check. */
 	if ((client->active_lease == NULL) ||
-	    !active_prefix(client) ||
-	    client->active_lease->released) {
+		!active_prefix(client) ||
+		client->active_lease->released ||
+		!unexpired_address_in_lease(client->active_lease)) {
+		dhc6_lease_destroy(&client->active_lease, MDL);
 		start_init6(client);
 		return;
 	}


code:
#!/bin/bash
# run dhclient.d scripts in an emulated environment

PATH=/bin:/usr/bin:/sbin
SAVEDIR=/var/lib/dhclient
ETCDIR=/etc/dhcp
interface=$1

eval "$(
declare | LC_ALL=C grep '^DHCP4_[A-Z_]*=' | while read opt; do
    optname=${opt%%=*}
    optname=${optname,,}
    optname=new_${optname#dhcp4_}
    optvalue=${opt#*=}
    echo "$optname=$optvalue"
done
)"

[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network

[ -f /etc/sysconfig/network-scripts/ifcfg-$interface ] && \
    . /etc/sysconfig/network-scripts/ifcfg-$interface

if [ -d $ETCDIR/dhclient.d ]; then
    for f in $ETCDIR/dhclient.d/*.sh; do
        if [ -x $f ]; then
            subsystem="${f%.sh}"
            subsystem="${subsystem##*/}"
            . ${f}
            if [ "$2" = "up" ]; then
                "${subsystem}_config"
            elif [ "$2" = "down" ]; then
                "${subsystem}_restore"
            fi
        fi
    done
fi


code:
#!/bin/bash
export LC_ALL=C

[ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd

# restart dhcpd whenever $1 interface is brought up by NM (rhbz #565921)
if [ "$2" = "up" ]; then
	# exit if the service is not configured to be started in the current runlevel
	/sbin/chkconfig dhcpd || exit 0

	# exit if dhcpd is not defined to listen on $1
	# i.e. if there are interfaces defined in DHCPDARGS and $1 is not among them
	if [ -n "${DHCPDARGS}" ] &&
	   [[ "${DHCPDARGS}" == *eth* ]] &&
	   [[ "${DHCPDARGS}" != *$1* ]]; then
		exit 0
	fi

	# restart service
	/sbin/service dhcpd restart || :
fi


code:
#!/bin/sh
# If we are running dhclient, shutdown running instances cleanly and
# bring them back up on resume.

. "${PM_FUNCTIONS}"

PM_DHCLIENT_RUNDIR="${PM_UTILS_RUNDIR}/network"
PM_DHCLIENT_SUSPEND="${PM_DHCLIENT_RUNDIR}/dhclient.suspend"

suspend_dhclient() {
    [ ! -d /etc/sysconfig/network-scripts ] && return
    [ ! -x /sbin/ifdown ] && return

    [ ! -d ${PM_DHCLIENT_RUNDIR} ] && /bin/mkdir -p ${PM_DHCLIENT_RUNDIR}
    [ -f ${PM_DHCLIENT_SUSPEND} ] && /bin/rm -f ${PM_DHCLIENT_SUSPEND}

    cd /etc/sysconfig/network-scripts
    for ifcfg in ifcfg-* ; do
        # Clear relevant parameters set by previous interface
        # (lo doesn't set them)
        NM_CONTROLLED=
        BOOTPROTO=

        . ./${ifcfg}

        if [ "${NM_CONTROLLED}" = "no" ] || [ "${NM_CONTROLLED}" = "n" ] || [ "${NM_CONTROLLED}" = "false" ]; then
            if [ "${BOOTPROTO}" = "bootp" ] || [ "${BOOTPROTO}" = "dhcp" ] || [ -z "${BOOTPROTO}" ]; then
                # device is not NetworkManager controlled and uses dhcp,
                # now see if it's actually up at the moment
                /sbin/ip link show ${DEVICE} | /bin/grep -qE "state (UP|UNKNOWN)" >/dev/null 2>&1
                if [ $? -eq 0 ]; then
                    echo "${DEVICE}" >> ${PM_DHCLIENT_SUSPEND}
                    /sbin/ifdown ${DEVICE}
                fi
            fi
        fi
    done
}

resume_dhclient() {
    [ ! -f ${PM_DHCLIENT_SUSPEND} ] && return
    [ ! -x /sbin/ifup ] && return

    cd /etc/sysconfig/network-scripts
    while read device ; do
        /sbin/ifup ${device}
    done < ${PM_DHCLIENT_SUSPEND}

    /bin/rm -f ${PM_DHCLIENT_SUSPEND}
}

case "$1" in
    hibernate|suspend)
        suspend_dhclient
        ;;
    thaw|resume)
        resume_dhclient
        ;;
    *) exit $NA
        ;;
esac


code:
#!/bin/bash
#
# dhclient-script: Network interface configuration script run by
#                  dhclient based on DHCP client communication
#
# Copyright (C) 2008, 2009, 2010  Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): David Cantrell <dcantrell@redhat.com>
#
# ----------
# This script is a rewrite/reworking on dhclient-script originally
# included as part of dhcp-970306:
# dhclient-script for Linux. Dan Halbert, March, 1997.
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
# Modified by David Cantrell <dcantrell@redhat.com> for Fedora and RHEL
# ----------
#

PATH=/bin:/usr/bin:/sbin
SAVEDIR=/var/lib/dhclient

LOGFACILITY="local7"
LOGLEVEL="notice"

ETCDIR="/etc/dhcp"

logmessage() {
    msg="${1}"
    logger -p ${LOGFACILITY}.${LOGLEVEL} -t "NET" "dhclient: ${msg}"
}

fix_context() {
    if [ -x /sbin/restorecon ]; then
        /sbin/restorecon ${1} >/dev/null 2>&1
    fi
}

save_previous() {
    origfile="${1}"
    savefile="${SAVEDIR}/${origfile##*/}.predhclient.${interface}"

    if [ ! -d ${SAVEDIR} ]; then
        mkdir -p ${SAVEDIR}
    fi

    if [ -e ${origfile} ]; then
        contents="$(< ${origfile})"
        echo "${contents}" > ${savefile}
        rm -f ${origfile}
    else
        echo > ${savefile}
    fi

    fix_context ${savefile}
}

make_resolv_conf() {
    [ "${PEERDNS}" = "no" ] && return

    if [ "${reason}" = "RENEW" ] &&
       [ "${new_domain_name}" = "${old_domain_name}" ] &&
       [ "${new_domain_name_servers}" = "${old_domain_name_servers}" ]; then
        return
    fi

    if [ -n "${new_domain_name}" ] ||
       [ -n "${new_domain_name_servers}" ] ||
       [ -n "${new_domain_search}" ]; then
        save_previous /etc/resolv.conf
        rscf="$(mktemp /tmp/XXXXXX)"
        echo "; generated by /sbin/dhclient-script" > ${rscf}

        if [ -n "${SEARCH}" ]; then
            echo "search ${SEARCH}" >> $rscf
        else
            if [ -n "${new_domain_search}" ]; then
                echo "search ${new_domain_search//\\032/ }" >> ${rscf}
            elif [ -n "${new_domain_name}" ]; then
                # Note that the DHCP 'Domain Name Option' is really just a domain
                # name, and that this practice of using the domain name option as
                # a search path is both nonstandard and deprecated.
                echo "search ${new_domain_name//\\032/ }" >> ${rscf}
            fi
        fi

        if [ -n "${RES_OPTIONS}" ]; then
            echo "options ${RES_OPTIONS}" >> ${rscf}
        fi

        for nameserver in ${new_domain_name_servers} ; do
            echo "nameserver ${nameserver}" >> ${rscf}
        done

        change_resolv_conf ${rscf}
        rm -f ${rscf}

        fix_context /etc/resolv.conf
    elif [ -n "${new_dhcp6_name_servers}" ] ||
         [ -n "${new_dhcp6_domain_search}" ]; then
        save_previous /etc/resolv.conf
        rscf="$(mktemp /tmp/XXXXXX)"
        echo "; generated by /sbin/dhclient-script" > ${rscf}

        if [ -n "${SEARCH}" ]; then
            echo "search ${SEARCH}" >> $rscf
        else
            if [ -n "${new_dhcp6_domain_search}" ]; then
                echo "search ${new_dhcp6_domain_search//\\032/ }" >> ${rscf}
            fi
        fi

        if [ -n "${RES_OPTIONS}" ]; then
            echo "options ${RES_OPTIONS}" >> ${rscf}
        fi

        for nameserver in ${new_dhcp6_name_servers} ; do
            echo "nameserver ${nameserver}" >> ${rscf}
        done

        change_resolv_conf ${rscf}
        rm -f ${rscf}

        fix_context /etc/resolv.conf
    fi
}

exit_with_hooks() {
    exit_status="${1}"

    if [ -x ${ETCDIR}/dhclient-exit-hooks ]; then
        . ${ETCDIR}/dhclient-exit-hooks
    fi

    exit ${exit_status}
}

quad2num() {
    if [ $# -eq 4 ]; then
        let n="${1} << 24 | ${2} << 16 | ${3} << 8 | ${4}"
        echo "${n}"
        return 0
    else
        echo "0"
        return 1
    fi
}

ip2num() {
    IFS="." quad2num ${1}
}

num2ip() {
    let n="${1}"
    let o1="(n >> 24) & 0xff"
    let o2="(n >> 16) & 0xff"
    let o3="(n >> 8) & 0xff"
    let o4="n & 0xff"
    echo "${o1}.${o2}.${o3}.${o4}"
}

get_network_address() {
# get network address for the given IP address and (netmask or prefix)
    ip="${1}"
    nm="${2}"

    if [ -n "${ip}" -a -n "${nm}" ]; then
        if [[ "${nm}" = *.* ]]; then
            ipcalc -s -n ${ip} ${nm} | cut -d '=' -f 2
        else
            ipcalc -s -n ${ip}/${nm} | cut -d '=' -f 2
        fi
    fi
}

get_prefix() {
# get prefix for the given IP address and mask
    ip="${1}"
    nm="${2}"

    if [ -n "${ip}" -a -n "${nm}" ]; then
        ipcalc -s -p ${ip} ${nm} | cut -d '=' -f 2
    fi
}

class_bits() {
    let ip=$(IFS='.' ip2num $1)
    let bits=32
    let mask='255'
    for ((i=0; i <= 3; i++, 'mask<<=8')); do
        let v='ip&mask'
        if [ "$v" -eq 0 ] ; then
             let bits-=8
        else
             break
        fi
    done
    echo $bits
}

is_router_reachable() {
    # handle DHCP servers that give us a router not on our subnet
    router="${1}"
    routersubnet="$(get_network_address ${router} ${new_subnet_mask})"
    mysubnet="$(get_network_address ${new_ip_address} ${new_subnet_mask})"
    unreachable=0

    if [ ! "${routersubnet}" = "${mysubnet}" ]; then
        unreachable=1
        if arping -f -q -I ${interface} -w2 ${router}; then
            ip -4 route add ${router}/32 dev ${interface}
            if [ $? -eq 0 ]; then
                unreachable=0
            else
                logmessage "failed to create host router for unreachable router ${router} not on subnet ${mysubnet}"
            fi
        else
            unreachable=1
            logmessage "DHCP router ${router} is unreachable on DHCP subnet ${mysubnet} router subnet ${routersubnet}"
        fi
    fi

    return ${unreachable}
}

add_default_gateway() {
    router="${1}"
    metric=""

    if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then
        metric="metric ${2}"
    fi

    if is_router_reachable ${router} ; then
        ip -4 route replace default via ${router} dev ${interface} ${metric}
        if [ $? -ne 0 ]; then
            logmessage "failed to create default route: ${router} dev ${interface} ${metric}"
            return 1
        else
            return 0
        fi
    fi

    return 1
}

dhconfig() {
    if [ -n "${old_ip_address}" ] && [ -n "${alias_ip_address}" ] &&
       [ ! "${alias_ip_address}" = "${old_ip_address}" ]; then
        # possible new alias, remove old alias first
        ip -4 addr del ${old_ip_address} dev ${interface}:0
    fi

    if [ -n "${old_ip_address}" ] &&
       [ ! "${old_ip_address}" = "${new_ip_address}" ]; then
        # IP address changed.  Bringing down the interface will delete all
        # routes, and clear the ARP cache.
        ip -4 addr flush dev ${interface} >/dev/null 2>&1
    fi

    if [ "${reason}" = "BOUND" ] || [ "${reason}" = "REBOOT" ] ||
       [ ! "${old_ip_address}" = "${new_ip_address}" ] ||
       [ ! "${old_subnet_mask}" = "${new_subnet_mask}" ] ||
       [ ! "${old_network_number}" = "${new_network_number}" ] ||
       [ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] ||
       [ ! "${old_routers}" = "${new_routers}" ] ||
       [ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
        ip -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
        ip link set dev ${interface} up

        # The 576 MTU is only used for X.25 and dialup connections
        # where the admin wants low latency.  Such a low MTU can cause
        # problems with UDP traffic, among other things.  As such,
        # disallow MTUs from 576 and below by default, so that broken
        # MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
        if [ -n "${new_interface_mtu}" ] && [ ${new_interface_mtu} -gt 576 ]; then
            ip link set ${interface} mtu ${new_interface_mtu}
        fi

        if [ -x ${ETCDIR}/dhclient-${interface}-up-hooks ]; then
            . ${ETCDIR}/dhclient-${interface}-up-hooks
        elif [ -x ${ETCDIR}/dhclient-up-hooks ]; then
            . ${ETCDIR}/dhclient-up-hooks
        fi

        # static routes
        if [ -n "${new_classless_static_routes}" ] ||
           [ -n "${new_static_routes}" ]; then
            if [ -n "${new_classless_static_routes}" ]; then
                IFS=', |' static_routes=(${new_classless_static_routes})

                # If the DHCP server returns both a Classless Static Routes option and
                # a Router option, the DHCP client MUST ignore the Router option. (RFC3442)
                new_routers=""
            else
                IFS=', |' static_routes=(${new_static_routes})
            fi
            route_targets=()

            for((i=0; i<${#static_routes[@]}; i+=2)); do
                target=${static_routes[$i]}
                if [ -n "${new_classless_static_routes}" ]; then
                    prefix=$(echo ${target} | cut -d "." -f 1)
                    target=$(echo ${target} | cut -d "." -f 2-)
                    IFS="." target_arr=(${target})
                    unset IFS
                    ((pads=4-${#target_arr[@]}))
                    for j in $(seq $pads); do
                        target=${target}".0"
                    done

                    # Client MUST zero any bits in the subnet number where the corresponding bit in the mask is zero.
                    # In other words, the subnet number installed in the routing table is the logical AND of
                    # the subnet number and subnet mask given in the Classless Static Routes option. (RFC3442)
                    target="$(get_network_address ${target} ${prefix})"
                else
                    prefix=$(class_bits ${target})
                fi
                gateway=${static_routes[$i+1]}

                metric=''
                for t in ${route_targets[@]}; do
                    if [ ${t} = ${target} ]; then
                        if [ -z "${metric}" ]; then
                            metric=1
                        else
                            ((metric=metric+1))
                        fi
                    fi
                done

                if [ -n "${metric}" ]; then
                    metric="metric ${metric}"
                fi

                if is_router_reachable ${gateway}; then
                    ip -4 route replace ${target}/${prefix} via ${gateway} dev ${interface} ${metric}

                    if [ $? -ne 0 ]; then
                        logmessage "failed to create static route: ${target}/${prefix} via ${gateway} dev ${interface} ${metric}"
                    else
                        route_targets=(${route_targets[@]} ${target})
                    fi
                fi
            done
        fi

        # gateways
        if [[ ( "${DEFROUTE}" != "no") &&
              (( -z "${GATEWAYDEV}" ) ||
               ( "${GATEWAYDEV}" = "${interface}" )) ]]; then
            if [[ ( -z "$GATEWAY" ) ||
                  (( -n "$DHCLIENT_IGNORE_GATEWAY" ) &&
                   ( "$DHCLIENT_IGNORE_GATEWAY" = [Yy]* )) ]]; then
                metric="${METRIC:-}"
                let i="${METRIC:-0}"
                default_routers=()

                for router in ${new_routers} ; do
                    added_router=-

                    for r in ${default_routers[@]} ; do
                        if [ "${r}" = "${router}" ]; then
                            added_router=1
                        fi
                    done

                    if [ -z "${router}" ] ||
                       [ "${added_router}" = "1" ] ||
                       [ $(IFS=. ip2num ${router}) -le 0 ] ||
                       [[ ( "${router}" = "${new_broadcast_address}" ) &&
                          ( "${new_subnet_mask}" != "255.255.255.255" ) ]]; then
                        continue
                    fi

                    default_routers=(${default_routers[@]} ${router})
                    add_default_gateway ${router} ${metric}
                    let i=i+1
                    metric=${i}
                done
            elif [ -n "${GATEWAY}" ]; then
                routersubnet=$(get_network_address ${GATEWAY} ${new_subnet_mask})
                mysubnet=$(get_network_address ${new_ip_address} ${new_subnet_mask})

                if [ "${routersubnet}" = "${mysubnet}" ]; then
                    ip -4 route replace default via ${GATEWAY} dev ${interface}
                fi
            fi
        fi

    fi

    if [ ! "${new_ip_address}" = "${alias_ip_address}" ] &&
       [ -n "${alias_ip_address}" ]; then
        ip -4 addr flush dev ${interface}:0 >/dev/null 2>&1
        ip -4 addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
        ip -4 route replace ${alias_ip_address}/32 dev ${interface}:0
    fi

    make_resolv_conf

    if [ -n "${new_host_name}" ] && need_hostname; then
        hostname ${new_host_name} || echo "See -nc option in dhclient(8) man page."
    fi

    if [ -n "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" ] &&
       [[ "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ]]; then
        if [ -n "${new_time_offset}" ]; then
            # DHCP option "time-offset" is requested by default and should be
            # handled.  The geographical zone abbreviation cannot be determined
            # from the GMT offset, but the $ZONEINFO/Etc/GMT$offset file can be
            # used - note: this disables DST.
            ((z=new_time_offset/3600))
            ((hoursWest=$(printf '%+d' $z)))

            if (( $hoursWest < 0 )); then
                # tzdata treats negative 'hours west' as positive 'gmtoff'!
                ((hoursWest*=-1))
            fi

            tzfile=/usr/share/zoneinfo/Etc/GMT$(printf '%+d' ${hoursWest})
            if [ -e ${tzfile} ]; then
                save_previous /etc/localtime
                cp -fp ${tzfile} /etc/localtime
                touch /etc/localtime
                fix_context /etc/localtime
            fi
        fi
    fi

    # execute any additional client side configuration scripts we have
    if [ -d ${ETCDIR}/dhclient.d ]; then
        for f in ${ETCDIR}/dhclient.d/*.sh ; do
            if [ -x ${f} ]; then
                subsystem="${f%.sh}"
                subsystem="${subsystem##*/}"
                . ${f}
                "${subsystem}_config"
            fi
        done
    fi
}

# Section 18.1.8. (Receipt of Reply Messages) of RFC 3315 says:
# The client SHOULD perform duplicate address detection on each of
# the addresses in any IAs it receives in the Reply message before
# using that address for traffic.
add_ipv6_addr_with_DAD() {
            ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
                dev ${interface} scope global

            # repeatedly test whether newly added address passed
            # duplicate address detection (DAD)
            for i in $(seq 5); do
                sleep 1 # give the DAD some time

                # tentative flag = DAD is still not complete or failed
                duplicate=$(ip -6 addr show dev ${interface} tentative \
                              | grep ${new_ip6_address}/${new_ip6_prefixlen})

                # if there's no tentative flag, address passed DAD
                if [ -z "${duplicate}" ]; then
                    break
                fi
            done

            # if there's still tentative flag = address didn't pass DAD =
            # = it's duplicate = remove it
            if [ -n "${duplicate}" ]; then
                ip -6 addr del ${new_ip6_address}/${new_ip6_prefixlen} dev ${interface}
                exit_with_hooks 3
            fi
}

dh6config() {
    case "${reason}" in
        BOUND6)
            if [ -z "${new_ip6_address}" ] &&
               [ -z "${new_ip6_prefixlen}" ]; then
                exit_with_hooks 2
            fi

            add_ipv6_addr_with_DAD

            make_resolv_conf
            ;;

        RENEW6|REBIND6)
            if [ -n "${new_ip6_prefixlen}" ] &&
               [ -n "${new_ip6_address}" ] &&
               [  ! "${new_ip6_address}" = "${old_ip6_address}" ]; then
                add_ipv6_addr_with_DAD
            fi

            if [ ! "${new_dhcp6_name_servers}" = "${old_dhcp6_name_servers}" ] ||
               [ ! "${new_dhcp6_domain_search}" = "${old_dhcp6_domain_search}" ]; then
                make_resolv_conf
            fi
            ;;

        DEPREF6)
            if [ -z "${new_ip6_prefixlen}" ]; then
                exit_with_hooks 2
            fi

            ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
                dev ${interface} scope global preferred_lft 0
            ;;
    esac

    # execute any additional client side configuration scripts we have
    if [ -d ${ETCDIR}/dhclient.d ]; then
        for f in ${ETCDIR}/dhclient.d/*.sh ; do
            if [ -x ${f} ]; then
                subsystem="${f%.sh}"
                subsystem="${subsystem##*/}"
                . ${f}
                "${subsystem}_config"
            fi
        done
    fi
}

#
# ### MAIN
#

if [ -x ${ETCDIR}/dhclient-enter-hooks ]; then
    exit_status=0

    # dhclient-enter-hooks can abort dhclient-script by setting
    # the exit_status variable to a non-zero value
    . ${ETCDIR}/dhclient-enter-hooks
    if [ ${exit_status} -ne 0 ]; then
        exit ${exit_status}
    fi
fi

if [ ! -r /etc/sysconfig/network-scripts/network-functions ]; then
    echo "Missing /etc/sysconfig/network-scripts/network-functions, exiting." >&2
    exit 1
fi

if [ ! -r /etc/rc.d/init.d/functions ]; then
    echo "Missing /etc/rc.d/init.d/functions, exiting." >&2
    exit 1
fi

. /etc/sysconfig/network-scripts/network-functions
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/network ]; then
    . /etc/sysconfig/network
fi

if [ -f /etc/sysconfig/networking/network ]; then
    . /etc/sysconfig/networking/network
fi

cd /etc/sysconfig/network-scripts
CONFIG="ifcfg-${interface}"
need_config ${CONFIG}
source_config >/dev/null 2>&1

new_prefix="$(get_prefix ${new_ip_address} ${new_subnet_mask})"
old_prefix="$(get_prefix ${old_ip_address} ${old_subnet_mask})"
alias_prefix="$(get_prefix ${alias_ip_address} ${alias_subnet_mask})"

case "${reason}" in
    MEDIUM)
        # Linux doesn't handle mediums (media)
        exit_with_hooks 0
        ;;

    PREINIT)
        if [ -n "${alias_ip_address}" ]; then
            # Bring down alias interface, its routes will disappear too.
            ip link set ${interface}:0 down
        fi

        if [ "${keep_old_ip}" = "yes" ]; then
            ip link set ${interface} up
        else
            ip -4 addr flush dev ${interface} >/dev/null 2>&1
            ip link set ${interface} up
        fi

        if [ -n "${DHCLIENT_DELAY}" ] && [ ${DHCLIENT_DELAY} -gt 0 ]; then
            sleep ${DHCLIENT_DELAY}
        fi

        exit_with_hooks 0
        ;;

    PREINIT6)
        # ensure interface is up
        ip link set ${interface} up

        # remove any stale addresses from aborted clients
        ip -6 addr flush dev ${interface} scope global permanent

        exit_with_hooks 0
        ;;

    ARPCHECK|ARPSEND)
        if [ -z "${new_ip_address}" ] || [ -z "${interface}" ] ||
           arping -q -f -c 2 -w 3 -D -I ${interface} ${new_ip_address}; then
            exit_with_hooks 0
        else
            exit_with_hooks 1
        fi
        ;;

    BOUND|RENEW|REBIND|REBOOT)
        dhconfig
        exit_with_hooks 0
        ;;

    BOUND6|RENEW6|REBIND6|DEPREF6)
        dh6config
        exit_with_hooks 0
        ;;

    EXPIRE6|RELEASE6|STOP6)
        if [ -z "${old_ip6_address}" ] || [ -z "${old_ip6_prefixlen}" ]; then
            exit_with_hooks 2
        fi

        ip -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
            dev ${interface}

        # execute any additional client side configuration scripts we have
        if [ -d ${ETCDIR}/dhclient.d ]; then
            for f in ${ETCDIR}/dhclient.d/*.sh ; do
                if [ -x ${f} ]; then
                    subsystem="${f%.sh}"
                    subsystem="${subsystem##*/}"
                    . ${f}
                    "${subsystem}_restore"
                fi
            done
        fi

        if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
            . ${ETCDIR}/dhclient-${interface}-down-hooks
        elif [ -x ${ETCDIR}/dhclient-down-hooks ]; then
            . ${ETCDIR}/dhclient-down-hooks
        fi

        exit_with_hooks 0
        ;;

    EXPIRE|FAIL|RELEASE|STOP)
        # only restore config files if there are no other dhclient processes
        # running (#306381)
        any_other_clients="$(ps -eo pid,ppid,comm | grep dhclient | grep -v ${PPID})"
        if [ -n "${any_other_clients}" ]; then
            if [ -f ${SAVEDIR}/resolv.conf.predhclient.${interface} ]; then
                change_resolv_conf ${SAVEDIR}/resolv.conf.predhclient.${interface}
                rm -f ${SAVEDIR}/resolv.conf.predhclient.${interface}
            fi

            if [ -n "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" ] &&
               [[ "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ]]; then
                if [ -e ${SAVEDIR}/localtime.predhclient.${interface} ]; then
                    rm -f /etc/localtime
                    contents="$(< ${SAVEDIR}/localtime.predhclient.${interface})"
                    echo "${contents}" > /etc/localtime
                    rm -f ${SAVEDIR}/localtime.predhclient.${interface}
                    touch /etc/localtime
                    fix_context /etc/localtime
                fi
            fi
        fi

        # execute any additional client side configuration scripts we have
        if [ -d ${ETCDIR}/dhclient.d ]; then
            for f in ${ETCDIR}/dhclient.d/*.sh ; do
                if [ -x ${f} ]; then
                    subsystem="${f%.sh}"
                    subsystem="${subsystem##*/}"
                    . ${f}
                    "${subsystem}_restore"
                fi
            done
        fi

        if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
            . ${ETCDIR}/dhclient-${interface}-down-hooks
        elif [ -x ${ETCDIR}/dhclient-down-hooks ]; then
            . ${ETCDIR}/dhclient-down-hooks
        fi

        if [ -n "${alias_ip_address}" ]; then
            # Turn off alias interface
            ip link set ${interface}:0 down
        fi

        if [ -n "${old_ip_address}" ]; then
            # Shut down interface, which will delete routes and clear arp cache.
            ip -4 addr flush dev ${interface} >/dev/null 2>&1
            ip link set ${interface} down
        fi

        if [ -n "${alias_ip_address}" ]; then
            ip -4 addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
            ip -4 route replace ${alias_ip_address}/32 ${interface}:0
        fi

        exit_with_hooks 0
        ;;

    TIMEOUT)
        if [ -n "${new_routers}" ]; then
            if [ -n "${alias_ip_address}" ]; then
                ip -4 addr flush dev ${interface}:0 >/dev/null 2>&1
            fi

            ip -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
            set ${new_routers}

            if ping -q -c 1 -w 10 -I ${interface} ${1}; then
                dhconfig
                exit_with_hooks 0
            fi

            ip -4 addr flush dev ${interface} >/dev/null 2>&1
            ip link set ${interface} down
            exit_with_hooks 1
        else
            exit_with_hooks 1
        fi
        ;;

    *)
        logmessage "unhandled state: ${reason}"
        exit_with_hooks 1
        ;;
esac

exit_with_hooks 0

path: server/dhcp/files/dhclient-script


code:
#Please refer to dhclient.conf(5) man page

#send host-name "pisilinux";
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;

#request subnet-mask, broadcast-address, time-offset, routers,
#	domain-name, domain-name-servers, host-name;

#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "ep0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "ep0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}


code:
diff -up dhcp-4.2.0/server/dhcpd.c.ifnamsiz dhcp-4.2.0/server/dhcpd.c
--- dhcp-4.2.0/server/dhcpd.c.ifnamsiz	2010-07-21 14:31:39.000000000 +0200
+++ dhcp-4.2.0/server/dhcpd.c	2010-07-21 16:05:49.000000000 +0200
@@ -409,7 +409,7 @@ main(int argc, char **argv) {
 				log_fatal ("Insufficient memory to %s %s: %s",
 					   "record interface", argv [i],
 					   isc_result_totext (result));
-			strcpy (tmp -> name, argv [i]);
+			strncpy (tmp -> name, argv [i], sizeof (tmp -> name));
 			if (interfaces) {
 				interface_reference (&tmp -> next,
 						     interfaces, MDL);


code:
diff -up dhcp-4.2.0-P2/omapip/protocol.c.omapi dhcp-4.2.0-P2/omapip/protocol.c
--- dhcp-4.2.0-P2/omapip/protocol.c.omapi	2009-11-20 02:49:02.000000000 +0100
+++ dhcp-4.2.0-P2/omapip/protocol.c	2011-01-03 16:30:25.000000000 +0100
@@ -386,7 +386,7 @@ isc_result_t omapi_protocol_signal_handl
 	/* Should only receive these when opening the initial authenticator. */
 	if (!strcmp (name, "status")) {
 		status = va_arg (ap, isc_result_t);
-		if (status != ISC_R_SUCCESS) {
+		if ((status != ISC_R_SUCCESS) && (status >= ISC_RESULTCLASS_DHCP)) {
 			omapi_signal_in (h -> inner, "status", status,
 					 (omapi_object_t *)0);
 			omapi_disconnect (p -> outer, 1);


code:
diff -up dhcp-4.2.0-P1/client/dhc6.c.PPP dhcp-4.2.0-P1/client/dhc6.c
--- dhcp-4.2.0-P1/client/dhc6.c.PPP	2010-11-05 10:47:37.000000000 +0100
+++ dhcp-4.2.0-P1/client/dhc6.c	2010-11-09 15:54:12.000000000 +0100
@@ -129,7 +129,7 @@ extern int stateless;
  * is not how it is intended.  Upcoming rearchitecting the client should
  * address this "one daemon model."
  */
-void
+isc_result_t
 form_duid(struct data_string *duid, const char *file, int line)
 {
 	struct interface_info *ip;
@@ -141,6 +141,15 @@ form_duid(struct data_string *duid, cons
 	if (ip == NULL)
 		log_fatal("Impossible condition at %s:%d.", MDL);

+	while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
+		/* Try the other interfaces */
+		log_debug("Cannot form default DUID from interface %s.", ip->name);
+		ip = ip->next;
+	}
+	if (ip == NULL) {
+		return ISC_R_UNEXPECTED;
+	}
+
 	if ((ip->hw_address.hlen == 0) ||
 	    (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
 		log_fatal("Impossible hardware address length at %s:%d.", MDL);
@@ -176,6 +185,8 @@ form_duid(struct data_string *duid, cons
 		memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1,
 		       ip->hw_address.hlen - 1);
 	}
+
+	return ISC_R_SUCCESS;
 }

 /*
@@ -5289,7 +5300,8 @@ make_client6_options(struct client_state
 	 */
 	if ((oc = lookup_option(&dhcpv6_universe, *op,
 				D6O_CLIENTID)) == NULL) {
-		if (!option_cache(&oc, &default_duid, NULL, clientid_option,
+		if (default_duid.len == 0 ||
+		    !option_cache(&oc, &default_duid, NULL, clientid_option,
 				  MDL))
 			log_fatal("Failure assembling a DUID.");

diff -up dhcp-4.2.0-P1/client/dhclient.c.PPP dhcp-4.2.0-P1/client/dhclient.c
--- dhcp-4.2.0-P1/client/dhclient.c.PPP	2010-11-05 10:47:37.000000000 +0100
+++ dhcp-4.2.0-P1/client/dhclient.c	2010-11-09 15:37:26.000000000 +0100
@@ -911,8 +911,8 @@ main(int argc, char **argv) {
 			if (default_duid.buffer != NULL)
 				data_string_forget(&default_duid, MDL);

-			form_duid(&default_duid, MDL);
-			write_duid(&default_duid);
+			if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
+				write_duid(&default_duid);
 		}

 		for (ip = interfaces ; ip != NULL ; ip = ip->next) {
diff -up dhcp-4.2.0-P1/common/bpf.c.PPP dhcp-4.2.0-P1/common/bpf.c
--- dhcp-4.2.0-P1/common/bpf.c.PPP	2010-11-05 10:47:37.000000000 +0100
+++ dhcp-4.2.0-P1/common/bpf.c	2010-11-09 15:42:42.000000000 +0100
@@ -599,6 +599,22 @@ get_hw_addr(const char *name, struct har
                         memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
                         break;
 #endif /* IFT_FDDI */
+#if defined(IFT_PPP)
+                case IFT_PPP:
+                        if (local_family != AF_INET6)
+                             log_fatal("Unsupported device type %d for \"%s\"",
+                                        sa->sdl_type, name);
+                        hw->hlen = 0;
+                        hw->hbuf[0] = HTYPE_RESERVED;
+                        /* 0xdeadbeef should never occur on the wire,
+                         *  and is a signature that something went wrong.
+                         */
+                        hw->hbuf[1] = 0xde;
+                        hw->hbuf[2] = 0xad;
+                        hw->hbuf[3] = 0xbe;
+                        hw->hbuf[4] = 0xef;
+                        break;
+#endif
                 default:
                         log_fatal("Unsupported device type %d for \"%s\"",
                                   sa->sdl_type, name);
diff -up dhcp-4.2.0-P1/common/lpf.c.PPP dhcp-4.2.0-P1/common/lpf.c
--- dhcp-4.2.0-P1/common/lpf.c.PPP	2010-11-05 10:47:37.000000000 +0100
+++ dhcp-4.2.0-P1/common/lpf.c	2010-11-09 15:45:40.000000000 +0100
@@ -502,6 +502,22 @@ get_hw_addr(const char *name, struct har
 			hw->hbuf[0] = HTYPE_FDDI;
 			memcpy(&hw->hbuf[1], sa->sa_data, 16);
 			break;
+#if defined(ARPHRD_PPP)
+		case ARPHRD_PPP:
+			if (local_family != AF_INET6)
+				log_fatal("Unsupported device type %d for \"%s\"",
+				           sa->sa_family, name);
+			hw->hlen = 0;
+			hw->hbuf[0] = HTYPE_RESERVED;
+			/* 0xdeadbeef should never occur on the wire,
+			 * and is a signature that something went wrong.
+			 */
+			hw->hbuf[1] = 0xde;
+			hw->hbuf[2] = 0xad;
+			hw->hbuf[3] = 0xbe;
+			hw->hbuf[4] = 0xef;
+			break;
+#endif
 		default:
 			log_fatal("Unsupported device type %ld for \"%s\"",
 				  (long int)sa->sa_family, name);
diff -up dhcp-4.2.0-P1/includes/dhcpd.h.PPP dhcp-4.2.0-P1/includes/dhcpd.h
--- dhcp-4.2.0-P1/includes/dhcpd.h.PPP	2010-11-05 10:47:37.000000000 +0100
+++ dhcp-4.2.0-P1/includes/dhcpd.h	2010-11-09 15:46:58.000000000 +0100
@@ -2733,7 +2733,7 @@ void dhcpv4_client_assignments(void);
 void dhcpv6_client_assignments(void);

 /* dhc6.c */
-void form_duid(struct data_string *duid, const char *file, int line);
+isc_result_t form_duid(struct data_string *duid, const char *file, int line);
 void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
 void start_init6(struct client_state *client);
 void start_info_request6(struct client_state *client);
diff -up dhcp-4.2.0-P1/includes/dhcp.h.PPP dhcp-4.2.0-P1/includes/dhcp.h
--- dhcp-4.2.0-P1/includes/dhcp.h.PPP	2010-11-05 10:47:37.000000000 +0100
+++ dhcp-4.2.0-P1/includes/dhcp.h	2010-11-09 15:48:53.000000000 +0100
@@ -80,6 +80,8 @@ struct dhcp_packet {
 #define HTYPE_IEEE802	6               /* IEEE 802.2 Token Ring...	*/
 #define HTYPE_FDDI	8		/* FDDI...			*/

+#define HTYPE_RESERVED  0               /* RFC 5494 */
+
 /* Magic cookie validating dhcp options field (and bootp vendor
    extensions field). */
 #define DHCP_OPTIONS_COOKIE	"\143\202\123\143"
diff -up dhcp-4.2.0-P1/server/dhcpv6.c.PPP dhcp-4.2.0-P1/server/dhcpv6.c
--- dhcp-4.2.0-P1/server/dhcpv6.c.PPP	2010-11-05 10:47:37.000000000 +0100
+++ dhcp-4.2.0-P1/server/dhcpv6.c	2010-11-09 15:50:17.000000000 +0100
@@ -300,6 +300,9 @@ generate_new_server_duid(void) {
 		if (p->hw_address.hlen > 0) {
 			break;
 		}
+		if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
+			log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
+		}
 	}
 	if (p == NULL) {
 		return ISC_R_UNEXPECTED;


code:
diff -up dhcp-4.2.0/common/dispatch.c.dracut dhcp-4.2.0/common/dispatch.c
--- dhcp-4.2.0/common/dispatch.c.dracut	2010-06-01 19:29:59.000000000 +0200
+++ dhcp-4.2.0/common/dispatch.c	2010-07-21 16:10:09.000000000 +0200
@@ -189,6 +189,10 @@ void add_timeout (when, where, what, ref
 	isc_interval_t interval;
 	isc_time_t expires;

+	if (when == NULL) {
+		return;
+	}
+
 	/* See if this timeout supersedes an existing timeout. */
 	t = (struct timeout *)0;
 	for (q = timeouts; q; q = q->next) {


code:
diff -up dhcp-4.2.0/client/clparse.c.requested dhcp-4.2.0/client/clparse.c
--- dhcp-4.2.0/client/clparse.c.requested	2010-07-21 13:29:05.000000000 +0200
+++ dhcp-4.2.0/client/clparse.c	2010-07-21 13:50:29.000000000 +0200
@@ -37,7 +37,7 @@

 struct client_config top_level_config;

-#define NUM_DEFAULT_REQUESTED_OPTS	9
+#define NUM_DEFAULT_REQUESTED_OPTS	14
 struct option *default_requested_options[NUM_DEFAULT_REQUESTED_OPTS + 1];

 static void parse_client_default_duid(struct parse *cfile);
@@ -111,6 +111,31 @@ isc_result_t read_client_conf ()
 	option_code_hash_lookup(&default_requested_options[8],
 				dhcpv6_universe.code_hash, &code, 0, MDL);

+	/* 10 */
+	code = DHO_NIS_DOMAIN;
+	option_code_hash_lookup(&default_requested_options[9],
+				dhcp_universe.code_hash, &code, 0, MDL);
+
+	/* 11 */
+	code = DHO_NIS_SERVERS;
+	option_code_hash_lookup(&default_requested_options[10],
+				dhcp_universe.code_hash, &code, 0, MDL);
+
+	/* 12 */
+	code = DHO_NTP_SERVERS;
+	option_code_hash_lookup(&default_requested_options[11],
+				dhcp_universe.code_hash, &code, 0, MDL);
+
+	/* 13 */
+	code = DHO_INTERFACE_MTU;
+	option_code_hash_lookup(&default_requested_options[12],
+				dhcp_universe.code_hash, &code, 0, MDL);
+
+	/* 14 */
+	code = DHO_DOMAIN_SEARCH;
+	option_code_hash_lookup(&default_requested_options[13],
+				dhcp_universe.code_hash, &code, 0, MDL);
+
 	for (code = 0 ; code < NUM_DEFAULT_REQUESTED_OPTS ; code++) {
 		if (default_requested_options[code] == NULL)
 			log_fatal("Unable to find option definition for "


code:
diff -up dhcp-4.2.0/client/dhclient.c.backoff dhcp-4.2.0/client/dhclient.c
--- dhcp-4.2.0/client/dhclient.c.backoff	2010-07-21 13:37:03.000000000 +0200
+++ dhcp-4.2.0/client/dhclient.c	2010-07-21 13:38:31.000000000 +0200
@@ -1208,6 +1208,8 @@ void state_init (cpp)
 	void *cpp;
 {
 	struct client_state *client = cpp;
+	enum dhcp_state init_state = client->state;
+	struct timeval tv;

 	ASSERT_STATE(state, S_INIT);

@@ -1220,9 +1222,18 @@ void state_init (cpp)
 	client -> first_sending = cur_time;
 	client -> interval = client -> config -> initial_interval;

-	/* Add an immediate timeout to cause the first DHCPDISCOVER packet
-	   to go out. */
-	send_discover (client);
+	if (init_state != S_DECLINED) {
+		/* Add an immediate timeout to cause the first DHCPDISCOVER packet
+		   to go out. */
+		send_discover(client);
+	} else {
+		/* We've received an OFFER and it has been DECLINEd by dhclient-script.
+		 * wait for a random time between 1 and backoff_cutoff seconds before
+		 * trying again. */
+		tv . tv_sec = cur_time + ((1 + (random() >> 2)) %  client->config->backoff_cutoff);
+		tv . tv_usec = 0;
+		add_timeout(&tv, send_discover, client, 0, 0);
+	}
 }

 /*
@@ -1501,6 +1512,7 @@ void bind_lease (client)
 		send_decline (client);
 		destroy_client_lease (client -> new);
 		client -> new = (struct client_lease *)0;
+		client -> state = S_DECLINED;
 		state_init (client);
 		return;
 	}
@@ -3711,6 +3723,7 @@ void client_location_changed ()
 			      case S_INIT:
 			      case S_REBINDING:
 			      case S_STOPPED:
+			      case S_DECLINED:
 				break;
 			}
 			client -> state = S_INIT;
diff -up dhcp-4.2.0/includes/dhcpd.h.backoff dhcp-4.2.0/includes/dhcpd.h
--- dhcp-4.2.0/includes/dhcpd.h.backoff	2010-07-21 13:29:05.000000000 +0200
+++ dhcp-4.2.0/includes/dhcpd.h	2010-07-21 13:38:31.000000000 +0200
@@ -1056,7 +1056,8 @@ enum dhcp_state {
 	S_BOUND = 5,
 	S_RENEWING = 6,
 	S_REBINDING = 7,
-	S_STOPPED = 8
+	S_STOPPED = 8,
+	S_DECLINED = 9
 };

 /* Authentication and BOOTP policy possibilities (not all values work


code:
diff -up dhcp-4.2.0/omapip/errwarn.c.errwarn dhcp-4.2.0/omapip/errwarn.c
--- dhcp-4.2.0/omapip/errwarn.c.errwarn	2009-07-23 20:52:21.000000000 +0200
+++ dhcp-4.2.0/omapip/errwarn.c	2010-07-21 13:23:47.000000000 +0200
@@ -76,20 +76,13 @@ void log_fatal (const char * fmt, ... )

 #if !defined (NOMINUM)
   log_error ("%s", "");
-  log_error ("If you did not get this software from ftp.isc.org, please");
-  log_error ("get the latest from ftp.isc.org and install that before");
-  log_error ("requesting help.");
+  log_error ("This version of ISC DHCP is based on the release available");
+  log_error ("on ftp.isc.org.  Features have been added and other changes");
+  log_error ("have been made to the base software release in order to make");
+  log_error ("it work better with this distribution.");
   log_error ("%s", "");
-  log_error ("If you did get this software from ftp.isc.org and have not");
-  log_error ("yet read the README, please read it before requesting help.");
-  log_error ("If you intend to request help from the dhcp-server@isc.org");
-  log_error ("mailing list, please read the section on the README about");
-  log_error ("submitting bug reports and requests for help.");
-  log_error ("%s", "");
-  log_error ("Please do not under any circumstances send requests for");
-  log_error ("help directly to the authors of this software - please");
-  log_error ("send them to the appropriate mailing list as described in");
-  log_error ("the README file.");
+  log_error ("Please report for this software via the Red Hat Bugzilla site:");
+  log_error ("    http://bugzilla.redhat.com");
   log_error ("%s", "");
   log_error ("exiting.");
 #endif


code:
diff -up dhcp-4.2.0/common/tables.c.garbage dhcp-4.2.0/common/tables.c
--- dhcp-4.2.0/common/tables.c.garbage	2009-11-20 02:49:01.000000000 +0100
+++ dhcp-4.2.0/common/tables.c	2010-07-21 14:40:56.000000000 +0200
@@ -207,7 +207,7 @@ static struct option dhcp_options[] = {
 	{ "netinfo-server-tag", "t",		&dhcp_universe, 113, 1 },
 	{ "default-url", "t",			&dhcp_universe, 114, 1 },
 	{ "subnet-selection", "I",		&dhcp_universe, 118, 1 },
-	{ "domain-search", "Dc",		&dhcp_universe, 119, 1 },
+	{ "domain-search", "D",		&dhcp_universe, 119, 1 },
 	{ "vivco", "Evendor-class.",		&dhcp_universe, 124, 1 },
 	{ "vivso", "Evendor.",			&dhcp_universe, 125, 1 },
 #if 0


code:
diff -up dhcp-4.2.0/client/dhc6.c.honor-expired dhcp-4.2.0/client/dhc6.c
--- dhcp-4.2.0/client/dhc6.c.honor-expired	2010-10-07 12:55:37.000000000 +0200
+++ dhcp-4.2.0/client/dhc6.c	2010-10-07 12:56:43.000000000 +0200
@@ -1405,6 +1405,35 @@ start_info_request6(struct client_state
 		go_daemon();
 }

+/* Run through the addresses in lease and return true if there's any unexpired.
+ * Return false otherwise.
+ */
+isc_boolean_t
+unexpired_address_in_lease(struct dhc6_lease *lease)
+{
+	struct dhc6_ia *ia;
+	struct dhc6_addr *addr;
+
+	if (lease == NULL)
+		return;
+
+	for (ia = lease->bindings ; ia != NULL ; ia = ia->next) {
+		for (addr = ia->addrs ; addr != NULL ; addr = addr->next) {
+			if (addr->flags & DHC6_ADDR_EXPIRED)
+				continue;
+
+			if (addr->starts + addr->max_life > cur_time) {
+				return ISC_TRUE;
+			}
+		}
+	}
+
+	log_info("PRC: Previous lease is devoid of active addresses."
+		 "  Re-initializing.");
+
+	return ISC_FALSE;
+}
+
 /*
  * start_confirm6() kicks off an "init-reboot" version of the process, at
  * startup to find out if old bindings are 'fair' and at runtime whenever
@@ -1417,8 +1446,10 @@ start_confirm6(struct client_state *clie

 	/* If there is no active lease, there is nothing to check. */
 	if ((client->active_lease == NULL) ||
-	    !active_prefix(client) ||
-	    client->active_lease->released) {
+		!active_prefix(client) ||
+		client->active_lease->released ||
+		!unexpired_address_in_lease(client->active_lease)) {
+		dhc6_lease_destroy(&client->active_lease, MDL);
 		start_init6(client);
 		return;
 	}


code:
diff -up dhcp-4.2.0/client/dhclient.c.inherit dhcp-4.2.0/client/dhclient.c
--- dhcp-4.2.0/client/dhclient.c.inherit	2010-07-21 14:33:44.000000000 +0200
+++ dhcp-4.2.0/client/dhclient.c	2010-07-21 14:40:05.000000000 +0200
@@ -2322,6 +2322,7 @@ void send_request (cpp)
 {
 	struct client_state *client = cpp;

+	int i;
 	int result;
 	int interval;
 	struct sockaddr_in destination;
@@ -2381,6 +2382,22 @@ void send_request (cpp)
 		/* Now do a preinit on the interface so that we can
 		   discover a new address. */
 		script_init (client, "PREINIT", (struct string_list *)0);
+
+		/* Has an active lease */
+		if (client -> interface -> addresses != NULL) {
+			for (i = 0; i < client -> interface -> address_count; i++) {
+				if (client -> active &&
+				    client -> active -> is_bootp &&
+				    client -> active -> expiry > cur_time &&
+				    client -> interface -> addresses[i].s_addr != 0 &&
+				    client -> active -> address.len == 4 &&
+				    memcpy (client -> active -> address.iabuf, &(client -> interface -> addresses[i]), 4) == 0) {
+					client_envadd (client, "", "keep_old_ip", "%s", "yes");
+					break;
+				}
+			}
+		}
+
 		if (client -> alias)
 			script_write_params (client, "alias_",
 					     client -> alias);


code:
diff -up dhcp-4.2.0/client/dhclient.c.logpid dhcp-4.2.0/client/dhclient.c
--- dhcp-4.2.0/client/dhclient.c.logpid	2010-07-21 16:13:52.000000000 +0200
+++ dhcp-4.2.0/client/dhclient.c	2010-07-21 16:16:51.000000000 +0200
@@ -154,7 +154,7 @@ main(int argc, char **argv) {
 	else if (fd != -1)
 		close(fd);

-	openlog("dhclient", LOG_NDELAY, LOG_DAEMON);
+	openlog("dhclient", LOG_NDELAY | LOG_PID, LOG_DAEMON);

 #if !(defined(DEBUG) || defined(__CYGWIN32__))
 	setlogmask(LOG_UPTO(LOG_INFO));


code:
diff -up dhcp-4.2.0/includes/dhcpd.h.paths dhcp-4.2.0/includes/dhcpd.h
--- dhcp-4.2.0/includes/dhcpd.h.paths	2010-07-21 13:55:42.000000000 +0200
+++ dhcp-4.2.0/includes/dhcpd.h	2010-07-21 14:29:57.000000000 +0200
@@ -1390,15 +1390,15 @@ typedef unsigned char option_mask [16];
 #else /* !DEBUG */

 #ifndef _PATH_DHCPD_CONF
-#define _PATH_DHCPD_CONF	"/etc/dhcpd.conf"
+#define _PATH_DHCPD_CONF	"/etc/dhcp/dhcpd.conf"
 #endif /* DEBUG */

 #ifndef _PATH_DHCPD_DB
-#define _PATH_DHCPD_DB		LOCALSTATEDIR"/db/dhcpd.leases"
+#define _PATH_DHCPD_DB		LOCALSTATEDIR"/dhcpd/dhcpd.leases"
 #endif

 #ifndef _PATH_DHCPD6_DB
-#define _PATH_DHCPD6_DB		LOCALSTATEDIR"/db/dhcpd6.leases"
+#define _PATH_DHCPD6_DB		LOCALSTATEDIR"/dhcpd/dhcpd6.leases"
 #endif

 #ifndef _PATH_DHCPD_PID
@@ -1412,7 +1412,7 @@ typedef unsigned char option_mask [16];
 #endif /* DEBUG */

 #ifndef _PATH_DHCLIENT_CONF
-#define _PATH_DHCLIENT_CONF	"/etc/dhclient.conf"
+#define _PATH_DHCLIENT_CONF	"/etc/dhcp/dhclient.conf"
 #endif

 #ifndef _PATH_DHCLIENT_SCRIPT
@@ -1428,11 +1428,11 @@ typedef unsigned char option_mask [16];
 #endif

 #ifndef _PATH_DHCLIENT_DB
-#define _PATH_DHCLIENT_DB	LOCALSTATEDIR"/db/dhclient.leases"
+#define _PATH_DHCLIENT_DB	LOCALSTATEDIR"/dhclient/dhclient.leases"
 #endif

 #ifndef _PATH_DHCLIENT6_DB
-#define _PATH_DHCLIENT6_DB	LOCALSTATEDIR"/db/dhclient6.leases"
+#define _PATH_DHCLIENT6_DB	LOCALSTATEDIR"/dhclient/dhclient6.leases"
 #endif

 #ifndef _PATH_RESOLV_CONF