~m-alaa8/ubuntu/raring/im-switch/fix-for-621204

« back to all changes in this revision

Viewing changes to dependscheck.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kenshi Muto
  • Date: 2005-06-17 11:58:42 UTC
  • Revision ID: james.westby@ubuntu.com-20050617115842-wctve6czdep3b8vm
Tags: 1.2
* Modify dependscheck.pl to check libapt-pkg-perl before running.
* Needs -xim instead of +xim for kinput2.
* Replace bashism (xinput.sh). (closes: #316243)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
#  Dependency check.
 
3
#   Copyright (c) 2005 Kenshi Muto <kmuto@debian.org> All rights reserved.
 
4
# This copyrighted material is made available to anyone wishing to use, modify,
 
5
# copy, or redistribute it subject to the terms and conditions of the
 
6
# GNU General Public License version 2.
 
7
#
 
8
# You should have received a copy of the GNU General Public License
 
9
# along with this program; if not, write to the Free Software
 
10
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
11
#
 
12
 
 
13
exit(0) if (@ARGV < 1);
 
14
BEGIN {
 
15
  eval "use AptPkg::Cache";
 
16
  if ($@) {
 
17
    print STDERR "Warning: dependency check won't work because libapt-pkg-perl isn't installed.\n";
 
18
    exit(0);
 
19
  }
 
20
}
 
21
my($cache) = AptPkg::Cache->new;
 
22
 
 
23
sub isInstalled {
 
24
  my($package) = @_;
 
25
  my($p) = $cache->{$package};
 
26
  if ($p) {
 
27
    return 1 if ($p->{CurrentVer});
 
28
  }
 
29
  return 0;
 
30
}
 
31
 
 
32
sub parse {
 
33
  my($packages) = @_;
 
34
  my($missing) = "";
 
35
  my($flag) = 0;
 
36
  $packages =~ s/[[:space:]]+//g;
 
37
  my(@pa) = split(/,/, $packages);
 
38
  foreach (@pa) {
 
39
    my(@pas) = split(/\|/, $_);
 
40
    $flag = 0;
 
41
    foreach (@pas) {
 
42
      if (isInstalled($_)) {
 
43
        $flag = 1;
 
44
        last;
 
45
      }
 
46
    }
 
47
    $missing .= $_ . ", " unless ($flag);
 
48
  }
 
49
  chop($missing); chop($missing);
 
50
  return $missing;
 
51
}
 
52
 
 
53
print &parse($ARGV[0]);