File tree 3 files changed +35
-5
lines changed
3 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ PKG(8) - System Manager's Manual
11
11
\[ * info*   ; * package* ]
12
12
\[ * install*   ; * package* ]
13
13
\[ * pkginfo*   ; * package* ]
14
+ \[ * regen* ]
14
15
\[ * search*   ; * string* ]
15
16
16
17
# DESCRIPTION
@@ -67,6 +68,12 @@ The options are as follows:
67
68
> Aliased to
68
69
> ** pi** .
69
70
71
+ * regen*
72
+
73
+ > Regenerate the full text index.
74
+ > Aliased to
75
+ > ** re** .
76
+
70
77
* search string*
71
78
72
79
> Search a packages
Original file line number Diff line number Diff line change 26
26
.Op Ar info Ar package
27
27
.Op Ar install Ar package
28
28
.Op Ar pkginfo Ar package
29
+ .Op Ar regen
29
30
.Op Ar search Ar string
30
31
.Sh DESCRIPTION
31
32
.Nm
@@ -73,6 +74,10 @@ for a given
73
74
.Nm FULLPKGNAME .
74
75
Aliased to
75
76
.Nm pi .
77
+ .It Ar regen
78
+ Regenerate the full text index.
79
+ Aliased to
80
+ .Nm re .
76
81
.It Ar search string
77
82
Search a packages
78
83
.Nm COMMENT
Original file line number Diff line number Diff line change 22
22
23
23
$| = 1;
24
24
25
- my @l = qw( add check create delete info search pkginfo) ;
25
+ my @l = qw( add check create delete info search pkginfo regen) ;
26
+
27
+ # Commands that we wrap.
26
28
my %a = (
27
29
" del" => " delete" ,
28
30
" i" => " add" ,
29
31
" install" => " add" ,
30
32
" rm" => " delete" ,
33
+ " inf" => " info" ,
34
+ );
31
35
32
- " inf" => " info" ,
33
- " pi" => " pkginfo" ,
34
- " s" => " search"
36
+ # Commands that are unique to pkg.
37
+ my %b = (
38
+ " pi" => " pkginfo" ,
39
+ " re" => " regen" ,
40
+ " s" => " search"
35
41
);
36
42
37
43
my $srcDBfile = ' /usr/local/share/sqlports' ;
@@ -46,7 +52,7 @@ sub run_sql {
46
52
return $sth ;
47
53
}
48
54
49
- if ( ! -e $dbfile ) {
55
+ sub createIDX {
50
56
print STDERR " Creating full text database..." ;
51
57
my $dbh = DBI-> connect ( " dbi:SQLite:dbname=:memory:" , " " , " " );
52
58
run_sql( $dbh , " ATTACH DATABASE '$srcDBfile ' AS ports;" );
@@ -84,10 +90,17 @@ sub run_sql {
84
90
print STDERR " Done.\n " ;
85
91
}
86
92
93
+ my $db_built = 0;
94
+ if ( !-e $dbfile ) {
95
+ $db_built = 1;
96
+ createIDX();
97
+ }
98
+
87
99
$dbh = DBI-> connect ( " dbi:SQLite:dbname=$dbfile " , " " , " " );
88
100
89
101
sub run {
90
102
my ( $cmd , $name ) = @_ ;
103
+ return if $b {$name };
91
104
my $module = " OpenBSD::Pkg\u $cmd " ;
92
105
eval " require $module ;" ;
93
106
if ($@ ) {
@@ -107,6 +120,11 @@ sub run {
107
120
$ARGV [0] = $a { $ARGV [0] } if defined $a { $ARGV [0] };
108
121
if ( $ARGV [0] eq $i ) {
109
122
shift ;
123
+ if ( $i eq " regen" && $db_built == 0 ) {
124
+ unlink ($dbfile );
125
+ createIDX();
126
+ exit ();
127
+ }
110
128
if ( $i eq " pkginfo" ) {
111
129
112
130
# Take a FULLPKGNAME and return DESCR_CONTENTS and COMMENT
You can’t perform that action at this time.
0 commit comments