summaryrefslogtreecommitdiffstats
path: root/khelpcenter/searchhandlers/khc_beagle_index.pl
blob: 02f1b93305ffe25c9acfd3d7e1ae720dc15bf660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
# vim:sw=4:et

use warnings;

sub getKDEDocDir() 
{
    my $prefix = `kde-config --prefix`;
    chomp $prefix;

    $prefix = "/opt/kde" if (not defined($prefix));
    return "$prefix/share/doc";
}

sub addRoot() 
{
    my $kdedocdir = &getKDEDocDir;

    open (IN, "-|") || exec "beagle-config", "indexing", "ListRoots";

    my $kdedoc_found = 0;
    while(<IN>) {
        if (/^$kdedocdir/o) {
            $kdedoc_found = 1;
            last;
        }
    }
    close(IN);

    if (not $kdedoc_found) {
        `beagle-config indexing AddRoot $kdedocdir`;
        `beagle-config indexing AddRoot $kdedocdir-bundle`;
    }
}

sub createExistsFile($$)
{
    my ($idir, $ident) = @_;

    open(OUT, ">", "$idir/$idir");
    close(OUT);
}

my $idir = $ARGV[0];
my $ident = $ARGV[1];

if (addRoot) {
    createExistsFile($idir, $ident);
}