File: pkg-nodep

package info (click to toggle)
pkg-order 1.02
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 484 kB
  • ctags: 172
  • sloc: perl: 4,094; makefile: 81
file content (179 lines) | stat: -rwxr-xr-x 4,508 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#! /usr/bin/perl -w
#                              -*- Mode: Perl -*- 
# pkg-nodep --- 
# Author           : Manoj Srivastava ( srivasta@tiamat.datasync.com ) 
# Created On       : Wed Jul 16 01:11:21 1997
# Created On Node  : tiamat.datasync.com
# Last Modified By : Manoj Srivastava
# Last Modified On : Sat Jul 19 00:02:19 1997
# Last Machine Used: tiamat.datasync.com
# Update Count     : 12
# Status           : Unknown, Use with caution!
# HISTORY          : 
# Description      : 
# 
# 

use strict;
use diagnostics;
use Carp;
require 5.001;

use Debian::Package::Dependency_List;
use Debian::Package::Package;
use Debian::Package::List;
use Getopt::Long;

package main;


#Handle The auto generated eval line.
use vars qw($running_under_some_shell);

=head1 NAME

pkg-nodep - List of packages that are not targets.

=cut

=head1 SYNOPSIS

 usage: pkg-node [options] 
 where the options are:

=over 2

=item --nocheck-recommends 

=item --check-recommends   Check Recommends as well [OFF]

=item --nocheck-suggests

=item --check-suggests     Check Suggests as well   [OFF]

=item --installed-packages <Package-file-for-installed-packages> 

=back

=cut

=head1 DESCRIPTION

This utility details out the list of packages installed that have no
other packages that depend on them (optionally also checks Recommends
and Suggestions).

 The default is to assume that the list of installed packages may be
 derived from the file I</var/lib/dpkg/status>, but the user may
 override this by providing a I<Packages> file listing all the
 packages that are assumed to be installed.

=cut 

sub main {
  my $installed;
  my $candidates;
  my $ret;
  my $do_depends = 1;
  my $strict_depends = 1;
  my $do_order = 1;
  my $recommends = 0;
  my $suggests = 0;
  my $consistent = 1;
  my $print_failures = 1;
  my $print_found = 0;
  my $installed_packages = '';
  my $filename;
  my $usage;
  my $MYNAME;
  
  ($MYNAME     = $0) =~ s|.*/||;


  $usage= <<EOUSAGE;
 usage: $MYNAME [options] <Package-file-for-new-packages>
 where the options are:
 --nocheck-recommends
 --check-recommends   Check the Recommends field as well            [OFF]
 --nocheck-suggests
 --check-suggests     Check the Suggests field as well              [OFF]
 --installed-packages <Package-file-for-installed-packages> 
EOUSAGE
  
  $ret = GetOptions("check-recommends!"   => \$recommends,
                    "check-suggests!"     => \$suggests,
		    "installed-packages=s" => \$installed_packages);
  die "$usage" unless $ret;

  ######################################################################
  #                     Phase One: Gather data                         #
  ######################################################################

  # Installed file (default value taken from status file)
  if (-f $installed_packages) {
    $installed = Debian::Package::New->new('filename' => $installed_packages);
  }
  else {
    $installed = Debian::Package::Installed->new();
  }
  
  $installed->get_dependency_information();
  
  ######################################################################
  #                 Phase Two: Check dependencies                      #
  ######################################################################

  # Check Pre-Dependencies
  $installed->check_relations('Consistent' => $consistent,
			      'Installed' => $installed,
			      'Field' => 'Pre-Depends');
  # Check Dependencies
  $installed->check_relations('Consistent' => $consistent,
			      'Installed' => $installed,
			      'Field' => 'Depends');
  # Check Recommendations
  $installed->check_relations('Consistent' => $consistent,
			      'Installed' => $installed,
			      'Warn'       => 'True',
			      'Field' => 'Recommendations')
    if $recommends;
  # Check Suggestions
  $installed->check_relations('Consistent' => $consistent,
			      'Installed'  => $installed,
			      'Warn'       => 'True',
			      'Field'      => 'Suggestions')
    if $suggests;
    
  
  ######################################################################
  #                Phase Three: Gather ordering data                    #
  ######################################################################
  
  print "The non targets are:\n",
            $installed->non_target_as_string('Type' => "All");
  

  exit 0;
}

=head1 CAVEATS

This is very inchoate, at the moment, and needs testing.

=cut

=head1 BUGS

None Known so far.

=cut

=head1 AUTHOR

Manoj Srivastava <srivasta@debian.org>

=cut

&main::main();