Re: Inital Deb Filter
- From: "Kevin Kubasik" <kevin kubasik net>
- To: "Joe Shaw" <joeshaw novell com>
- Cc: "dashboard-hackers gnome org" <dashboard-hackers gnome org>
- Subject: Re: Inital Deb Filter
- Date: Mon, 3 Apr 2006 18:32:13 -0400
Starting the cleanup now, I'll post an updated version later tonight
or tomorrow morning. My only real question that remains is where to
draw the line for unsearchable keywords. For example, its easy to say
that Version will remain unsearchable, but what about Section? If I
search for 'e-mail client' if i have a package from the e-mail
section, even if its title is 'mozilla-thunderbird' I would still
expect it to be returned.
And I was just planning on adding description as one big keyword, but
since some descriptions can get rather long, is that an issue?
Cheers,
Kevin Kubasik
Ok, here is some sample dpkg-deb output:
kevin igloo:~/pkgdir$ dpkg-deb -I ./sun-j2sdk1.5_1.5.0+update06_i386.deb
new debian package, version 2.0.
size 65468844 bytes: control archive= 65555 bytes.
1153 bytes, 23 lines control
223663 bytes, 2284 lines md5sums
1847 bytes, 73 lines * postinst #!/bin/bash
1229 bytes, 59 lines * prerm #!/bin/bash
Package: sun-j2sdk1.5
Version: 1.5.0+update06
Section: non-free/devel
Priority: optional
Architecture: i386
Depends: libasound2 (>> 1.0.10), libc6 (>= 2.3.4-1), libx11-6,
libxext6, libxi6, libxp6, libxt6, libxtst6
Recommends: netbase, libx11-6 | xlibs, libasound2, libgtk1.2
Replaces: sun-j2sdk1.5debian
Provides: java-common, java-virtual-machine, java-runtime,
java2-runtime, java-browser-plugin, java-compiler, java2-compiler,
j2sdk1.5, j2re1.5
Installed-Size: 143292
Maintainer: Debian Java Maintainers
<pkg-java-maintainers lists alioth debian org>
Description: Java(TM) 2 SDK, Standard Edition, Sun Microsystems(TM)
The Java(TM) 2 SDK is a development environment for building
applications, applets, and components that can be deployed on the
Java(TM) platform.
.
The Java(TM) 2 SDK software includes tools useful for developing and
testing programs written in the Java programming language and running
on the Java platform. These tools are designed to be used from the
command line. Except for appletviewer, these tools do not provide a
graphical user interface.
.
This package has been automatically created with java-package (0.26).
kevin igloo:~/pkgdir$ dpkg-deb -I ./automatix_5.6-2_i386.deb
new debian package, version 2.0.
size 32722 bytes: control archive= 335 bytes.
264 bytes, 8 lines * control
Package: Automatix
Priority: optional
Section: base
Maintainer: arnieboy
Architecture: i386
Depends: zenity, xterm
Version: 5.6.2
Description: Automatix installs a host of popular softwares and
tweaks your Ubuntu Breezy system to get it up and running in minutes.
On 4/3/06, Joe Shaw <joeshaw novell com> wrote:
> Hi,
>
> On Fri, 2006-03-31 at 00:08 -0500, Kevin Kubasik wrote:
> > Let me know what you all think. This is my first shot, hope it works
> > out. I looked into using one of Mono's decompression libs to extract the
> > actual description information, but .deb's are in the somewhat obscure
> > ar archive format. So dpkg-deb it was. If anyone can think of a property
> > I missed, please let me know, they are quite easy to add.
>
> Can you attach some sample dpkg-deb output? I don't have a Debian or
> Ubuntu box, so it's hard to see if we're doing the right thing with
> regards to parsing.
>
> > Also, is there a major objection to just adding the Description field as
> > text? and furthermore, is it ok that this happens in DoPullProperties()?
> > as opposed to DoPull()?
>
> That's fine.
>
> > public FilterDeb (){
> > AddSupportedFlavor (FilterFlavor.NewFromMimeType ("application/x-deb"));
> > AddSupportedFlavor (FilterFlavor.NewFromExtension(".deb") );
> > }
>
> Are both of these necessary? I prefer to avoid setting NewFromExtension
> unless there's a chance that the mime type detection won't work without
> it.
>
> > StreamReader pout = pc.StandardOutput;
> > string str = null;
> > string[] tokens = null;
> > string strMetaTag = null;
> > bool bKeyword = false;
> > bool listWords = false;
> > char[] splits = {',','|'};
> > string[] list = null;
> > while ((str = pout.ReadLine ()) != null) {
> > bKeyword = false;
> > listWords = false;
> > strMetaTag = null;
> > tokens = str.Split (':');
> > if (tokens.Length > 1) {
> > switch (tokens[0].Trim()) {
> > case "Package":
> > strMetaTag = "dc:title";
> > break;
> > case "Maintainer":
> > strMetaTag = "dc:author";
> > break;
> > case "Version":
> > strMetaTag = "fixme:version";
> > bKeyword = true;
> > break;
> > case "Section":
> > strMetaTag = "fixme:section";
> > bKeyword = true;
> > break;
> > case "Architecture":
> > strMetaTag = "fixme:arch";
> > bKeyword = true;
> > break;
> > case "Depends":
> > listWords = true;
> > list = tokens[1].Split(splits);
> > foreach(string s in list){
> > AddProperty (Beagle.Property.NewKeyword ("fixme:dep",
> > s.Trim()));
> > }
> > break;
> > case "Recommends":
> > listWords = true;
> > list = tokens[1].Split(splits);
> > foreach(string s in list){
> > AddProperty (Beagle.Property.NewKeyword ("fixme:recommend",
> > s.Trim()));
> > }
> > break;
> > case "Conflicts":
> > listWords = true;
> > list = tokens[1].Split(splits);
> > foreach(string s in list){
> > AddProperty (Beagle.Property.NewKeyword ("fixme:conflict",
> > s.Trim()));
> > }
> > break;
> > case "Replaces":
> > listWords = true;
> > list = tokens[1].Split(splits);
> > foreach(string s in list){
> > AddProperty (Beagle.Property.NewKeyword ("fixme:replace",
> > s.Trim()));
> > }
> > break;
> > case "Provides":
> > listWords = true;
> > list = tokens[1].Split(splits);
> > foreach(string s in list){
> > AddProperty (Beagle.Property.NewKeyword ("fixme:provide",
> > s.Trim()));
> > }
> > break;
> > case "Installed-Size":
> > strMetaTag = "fixme:size";
> > bKeyword= true;
> > break;
> > case "Description":
> > listWords=true;
> > AppendText(tokens[1]);
> > AppendStructuralBreak ();
> > while ((str = pout.ReadLine ()) != null) {
> > if(str.Trim()==".")
> > AppendStructuralBreak();
> > else
> > AppendText(str);
> > }
> > break;
> > }
> > if (strMetaTag != null) {
> > if(!listWords){
> > if (bKeyword){
> > AddProperty (Beagle.Property.NewKeyword (strMetaTag,
> > tokens[1].Trim()));
> > }
> > else{
> > AddProperty (Beagle.Property.New (strMetaTag,
> > tokens[1].Trim()));
> > }
> > }
> > }
>
> Sorry for quoting such a big block. A few things here. First, the
> entire code block is within a "if (tokens.Length > 1)" block. We can
> remove an entire level of indentation by just saying "if (tokens.Length
> <= 1) continue;" here, assuming it's not an error.
>
> Also, rather than setting strMetaTag, bKeyword, listWords and a handfull
> of other variables and carrying that state through, I think it'd be lot
> easier to just add a AddProp() and AddKeyword() method and just call
> those when you need to. Method overhead is negligible. And that
> removes the nasty special case you do for listWords anyway.
>
> Joe
>
>
--
Cheers,
Kevin Kubasik
http://blog.kubasik.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]