/[suikacvs]/www/namazu/filter/rpm.pl
Suika

Contents of /www/namazu/filter/rpm.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Fri Nov 30 07:56:45 2001 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN, wakaba
CVS Tags: initial, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain

1 #
2 # -*- Perl -*-
3 # $Id: rpm.pl,v 1.4 2001/06/24 09:36:35 rug Exp $
4 # Copyright (C) 2000 Namazu Project All rights reserved ,
5 # This is free software with ABSOLUTELY NO WARRANTY.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either versions 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # 02111-1307, USA
21 #
22 # This file must be encoded in EUC-JP encoding
23 #
24
25 package rpm;
26 use strict;
27 require 'util.pl';
28 require 'gfilter.pl';
29
30 my $rpmpath = undef;
31
32 sub mediatype() {
33 return ('application/x-rpm');
34 }
35
36 sub status() {
37 $rpmpath = util::checkcmd('rpm');
38 return 'no' unless (defined $rpmpath);
39 return 'yes';
40 }
41
42 sub recursive() {
43 return 0;
44 }
45
46 sub pre_codeconv() {
47 return 0;
48 }
49
50 sub post_codeconv () {
51 return 0;
52 }
53
54 sub add_magic ($) {
55 my ($magic) = @_;
56
57 $magic->addFileExts('\\.rpm$', 'application/x-rpm');
58 return;
59 }
60
61 sub filter ($$$$$) {
62 my ($orig_cfile, $cont, $weighted_str, $headings, $fields)
63 = @_;
64 my $cfile = defined $orig_cfile ? $$orig_cfile : '';
65
66 my $tmpfile = util::tmpnam('NMZ.rpm');
67
68 util::vprint("Processing rpm file ... (using '$rpmpath')\n");
69
70 #FIXME: needed more smart solutions.
71 system("env LC_ALL=$util::LANG LANGUAGE=$util::LANG $rpmpath -qpi $cfile > $tmpfile");
72
73 my $fh = util::efopen("$tmpfile");
74 my $size = util::filesize($fh);
75 if ($size > $conf::FILE_SIZE_MAX) {
76 return 'too_large_rpm_file';
77 }
78 $$cont = util::readfile($fh);
79 undef $fh;
80 unlink($tmpfile);
81
82 rpm_filter($cont, $weighted_str, $fields, $headings);
83
84 gfilter::line_adjust_filter($cont);
85 gfilter::line_adjust_filter($weighted_str);
86 gfilter::white_space_adjust_filter($cont);
87 gfilter::show_filter_debug_info($cont, $weighted_str,
88 $fields, $headings);
89
90 return undef;
91 }
92
93 sub rpm_filter ($$$$) {
94 my ($contref, $weighted_str, $fields, $headings) = @_;
95
96 rpm::get_title($contref, $weighted_str, $fields);
97 rpm::get_author($contref, $fields);
98 rpm::get_date($contref, $fields);
99 rpm::get_size($contref, $fields);
100 rpm::get_summary($contref, $fields);
101
102 return;
103 }
104
105
106 # Below is the sample result of 'rpm -qi rpm'.
107 #
108 # Name : rpm Relocations: (not relocateable)
109 # Version : 3.0.5 Vendor: (none)
110 # Release : 3k Build Date: Fri Jun 30 10:12:19 2000
111 # Install date: Thu Sep 14 21:32:32 2000 Build Host: omoi.kondara.org
112 # Group : System Environment/Base Source RPM: rpm-3.0.5-3k.nosrc.rpm
113 # Size : 3111493 License: GPL
114 # URL : http://www.rpm.org/
115 # Summary : The Red Hat package management system.
116 # Description :
117 # The RPM Package Manager (RPM) is a powerful command line driven
118 # package management system capable of installing, uninstalling,
119 # verifying, querying, and updating software packages. Each software
120 # package consists of an archive of files along with information about
121 # the package like its version, a description, etc.
122
123
124 sub get_title ($$$) {
125 my ($contref, $weighted_str, $fields) = @_;
126
127 if ($$contref =~ /Summary : (.*)/) {
128 my $tmp = $1;
129 $fields->{'title'} = $tmp;
130 my $weight = $conf::Weight{'html'}->{'title'};
131 $$weighted_str .= "\x7f$weight\x7f$tmp\x7f/$weight\x7f\n";
132 }
133 }
134
135 sub get_author ($$) {
136 my ($contref, $fields) = @_;
137
138 if ($$contref =~ /Vendor: (.*)/) {
139 my $tmp = $1;
140 $fields->{'author'} = $tmp;
141 }
142 }
143
144 sub get_date ($$) {
145 my ($contref, $fields) = @_;
146
147 if ($$contref =~ /Build Date: (.*)/) {
148 my $tmp = $1;
149 $fields->{'date'} = $tmp;
150 }
151 }
152
153 sub get_size ($$) {
154 my ($contref, $fields) = @_;
155
156 if ($$contref =~ /Size\s+: (.*)$/) {
157 my $tmp = $1;
158 $fields->{'size'} = $tmp;
159 }
160 }
161
162 sub get_summary ($$) {
163 my ($contref, $fields) = @_;
164
165 $$contref =~ s/^.*Description ://is;
166 if ($$contref =~ /Description : (.*)/) {
167 my $tmp = $1;
168 $fields->{'summary'} = $tmp;
169 }
170 }
171
172 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24