• Publicity: Public Only All

tsearch2-driver-install-procs.tcl

tsearch2 search engine driver installation procedures

Location:
packages/tsearch2-driver/tcl/tsearch2-driver-install-procs.tcl
Created:
2004-06-05
Author:
Dave Bauer <dave@thedesignexperience.org>
CVS Identification:
$Id: tsearch2-driver-install-procs.tcl,v 1.9.2.4 2021/04/30 17:42:53 antoniop Exp $

Procedures in this file

Detailed information

[ hide source ] | [ make this the default ]

Content File Source

ad_library {

    tsearch2 search engine driver installation procedures

    @author Dave Bauer (dave@thedesignexperience.org)
    @creation-date 2004-06-05
    @cvs-id $Id: tsearch2-driver-install-procs.tcl,v 1.9.2.4 2021/04/30 17:42:53 antoniop Exp $
}

namespace eval tsearch2_driver::install {}


d_proc -private tsearch2_driver::install::preinstall_checks {

} {

    Make sure postgresql_contrib and tsearch are installed
    before allowing the installation of tsearch2_package

    @author Hamilton Chua (hchua@8tons.dyndns.biz)
    @creation-date 2004-07-02

} {

    ns_log Notice " ********** STARTING BEFORE-INSTALL CALLBACK ****************"

    # check if tsearch2 is installed
    # in psql we do this by checking the presence of a data type tsvector
    # select typname from pg_type where typename='tsvector';

    if { [db_0or1row tsearch_compile_check {
        select distinct(typname) from pg_type where typname='tsvector'
    }] } {
        # if tsearch is installed
        ns_log Notice "******* Tsearch2 is compiled and installed. ***********"
        # continue with installation
    } else {

        # tsearch not installed
        ns_log Notice "******* Tsearch2 is not installed. ***********"

        # RPM, Debian, source default locations
        set locs [list "/usr/share/pgsql/contrib/tsearch2.sql" \
                      "/usr/local/pgsql/contrib/tsearch2.sql" \
                      "/usr/local/pgsql/share/contrib/tsearch2.sql" \
                      "/usr/share/postgresql/contrib/tsearch2.sql"]
        foreach loc $locs {
            if { [file exists $loc] } {
                set sql_file_loc $loc
                break
            }
        }
        # Check if we've found it, run the SQL file
        if { [info exists sql_file_loc] && $sql_file_loc ne "" } {
            # we found tsearch2.sql let's run it
            db_source_sql_file $sql_file_loc
        } else {
            # we could not find tserach2.sql, abort the install
            ns_log Notice "************************************************"
            ns_log Notice "********* Can't locate tsearch2.sql. ***********"
            ns_log Notice "********* Install tsearch2.sql manually ********"
            ns_log Notice "************************************************"
            ad_script_abort
        }

    }
    ns_log Notice " ********** ENDING BEFORE-INSTALL CALLBACK ****************"

}

d_proc -private tsearch2_driver::install::package_install {
} {

    Installation callback for tsearch2 search engine driver

    @author Dave Bauer (dave@thedesignexperience.org)
    @creation-date 2004-06-05

    @error
} {
    tsearch2_driver::install::register_fts_impl
}

d_proc -private tsearch2_driver::install::register_fts_impl {
} {

    Register FtsEngineDriver service contract implementation
    @author Dave Bauer (dave@thedesignexperience.org)
    @creation-date 2004-06-05

    @return

    @error
} {

    set spec {
        name "tsearch2-driver"
        aliases {
            search tsearch2::search
            index tsearch2::index
            unindex tsearch2::unindex
            update_index tsearch2::index
            summary tsearch2::summary
            info tsearch2::driver_info
        }
        contract_name "FtsEngineDriver"
        owner "tsearch2-driver"
    }

    acs_sc::impl::new_from_spec -spec $spec

}

d_proc -private tsearch2_driver::install::before_uninstall {
} {
    Remove FtsEngineDriver service contract implementation
} {
    acs_sc::impl::delete \
        -contract_name "FtsEngineDriver" \
        -impl_name "tsearch2-driver"
}

#
# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: