4 // Copyright (C) 2006 Kevin Kubasik <kevin@kubasik.net>
8 // Permission is hereby granted, free of charge, to any person obtaining a
9 // copy of this software and associated documentation files (the "Software"),
10 // to deal in the Software without restriction, including without limitation
11 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 // and/or sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 // DEALINGS IN THE SOFTWARE.
28 using System
.Diagnostics
;
33 namespace Beagle
.Filters
{
34 public class FilterDeb
: Beagle
.Filters
.FilterPackage
{
38 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("application/x-deb"));
41 protected override void PullPackageProperties ()
43 SafeProcess pc
= new SafeProcess ();
44 pc
.Arguments
= new string [] { "dpkg-deb", "-I", FileInfo.FullName}
;
45 pc
.RedirectStandardOutput
= true;
49 } catch (SafeProcessException e
) {
55 StreamReader pout
= new StreamReader (pc
.StandardOutput
);
58 string[] tokens
= null;
59 char[] splits
= { ',', '|'}
;
62 while ((str
= pout
.ReadLine ()) != null) {
63 tokens
= str
.Split (':');
64 if (tokens
.Length
<= 1)
67 switch (tokens
[0].Trim ()) {
70 PackageName
= tokens
[1];
74 list
= tokens
[1].Split ('<');
75 PackagerName
= list
[0];
77 PackagerEmail
= list
[1].Replace ('>', ' ');
81 PackageVersion
= tokens
[1];
85 Category
= tokens
[1];
89 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:arch", tokens
[1]));
93 list
= tokens
[1].Split (splits
);
94 foreach (string s
in list
)
95 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:depends", s
));
99 list
= tokens
[1].Split (splits
);
100 foreach (string s
in list
)
101 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:recommend", s
));
105 list
= tokens
[1].Split (splits
);
106 foreach (string s
in list
)
107 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:conflict", s
));
111 list
= tokens
[1].Split (splits
);
112 foreach (string s
in list
)
113 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:replaces", s
));
117 list
= tokens
[1].Split (splits
);
118 foreach (string s
in list
)
119 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:provides", s
));
122 case "Installed-Size":
123 // Installed-Size is given in number of KBs
124 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:size", tokens
[1] + "000"));
128 AppendText (tokens
[1]);
129 AppendStructuralBreak ();
130 while ((str
= pout
.ReadLine ()) != null) {
131 if(str
.Trim () == ".")
132 AppendStructuralBreak ();