package Cpanel::Easy::OptLib::sqlite;

# cpanel10 - Cpanel/Easy/OptLib/sqlite.pm    Copyright(c) 2005-2008 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited

sub path_installed {
    my ( $easy_obj, $prefix ) = @_;
    $prefix ||= '/opt/sqlite';

    my @command_list = ();

    # we no longer need to pad the number, first part is the version
    # is the full major/minor version of sqlite
    # ex: 3.22 is 322.0.0
    my $version = '322.0.0';
    ( my $zeroed_version = $version ) =~ s/[.]/0/g;

    return {
        'name'         => 'sqlite',
        'install_path' => $prefix,
        'itis_up2date' => sub {
            my $installed_version = qx( $prefix/bin/sqlite3 --version );
            return 0 <= index $installed_version, $version;
        },
        'working_path' => "sqlite-autoconf-$zeroed_version",
        'command_list' => [ [ './configure', "--prefix=$prefix", ], ['make'], [ 'make', 'install' ] ],
    };
}

1;
