lintian: r300 - in trunk: frontend lib
Author: jeroen
Date: 2004-06-29 17:24:12 +0200 (Tue, 29 Jun 2004)
New Revision: 300
Modified:
trunk/frontend/lintian
trunk/lib/Lab.pm
Log:
Revert changes to frontend/lintian and lib/Lab.pm that were accidentally
committed in r299
Modified: trunk/frontend/lintian
===================================================================
--- trunk/frontend/lintian 2004-06-29 15:21:09 UTC (rev 299)
+++ trunk/frontend/lintian 2004-06-29 15:24:12 UTC (rev 300)
@@ -1,14 +1,8 @@
-remove: unpack level -> altijd 1
-setup-lab , remove-lab
-LAB_FORMAT
-lab_mode -> altijd temp
-
#!/usr/bin/perl -w
# {{{ Legal stuff
# Lintian -- Debian package checker
#
# Copyright (C) 1998 Christian Schwarz and Richard Braakman
-# 2004 Jeroen van Wolffelaar
#
# This program is free software. It is distributed under the terms of
# the GNU General Public License as published by the Free Software
@@ -32,13 +26,16 @@
use Getopt::Long;
use FileHandle;
-use File::Temp ( tempdir );
# }}}
# {{{ Global Variables
my $lintian_info_cmd = 'lintian-info'; #Command to run for ?
my $LINTIAN_VERSION = "<VERSION>"; #External Version number
my $BANNER = "Lintian v$LINTIAN_VERSION"; #Version Banner - text form
+my $LAB_FORMAT = 7; #Lab format Version Number
+ #increased whenever incompatible
+ #changes are done to the lab
+ #so that all packages are re-unpacked
# Variables used to record commandline options
# Commented out variables have "defined" checks somewhere to determine if
@@ -52,11 +49,13 @@
my $check_everything = 0; #flag for -a|--all switch
my $lintian_info = 0; #flag for -i|--info switch
our $display_infotags = 0; #flag for -I|--display-info switch
+my $unpack_level = undef; #flag for -l|--unpack-level switch
our $no_override = 0; #flag for -o|--no-override switch
our $show_overrides = 0; #flag for --show-overrides switch
my $check_md5sums = 0; #flag for -m|--md5sums switch
my $allow_root = 0; #flag for --allow-root swtich
my $packages_file = 0; #string for the -p option
+my $OPT_LINTIAN_LAB = ""; #string for the --lab option
my $OPT_LINTIAN_ARCHIVEDIR = "";#string for the --archivedir option
my $OPT_LINTIAN_DIST = ""; #string for the --dist option
my $OPT_LINTIAN_ARCH = ""; #string for the --arch option
@@ -70,9 +69,11 @@
my $action;
my $checks;
my $dont_check;
+my $unpack_info;
my $cwd;
my $cleanup_filename;
my $exit_code;
+my $lab_mode = 'static';
my %collection_info;
my %already_scheduled;
@@ -82,8 +83,10 @@
my %check_info;
# reset configuration variables
+my $LINTIAN_LAB = undef;
my $LINTIAN_ARCHIVEDIR = undef;
my $LINTIAN_DIST = undef;
+my $LINTIAN_UNPACK_LEVEL = undef;
my $LINTIAN_ARCH = undef;
my $LINTIAN_SECTION = undef;
# }}}
@@ -118,9 +121,13 @@
print <<"EOT-EOT-EOT";
Syntax: lintian [action] [options] [--] [packages] ...
Actions:
+ -S, --setup-lab set up static lab
+ -R, --remove-lab remove static lab
-c, --check check packages (default action)
-C X, --check-part X check only certain aspects
-X X, --dont-check-part X don\'t check certain aspects
+ -u, --unpack only unpack packages in the lab
+ -r, --remove remove package from the lab
General options:
-h, --help display short help text
-v, --verbose verbose messages
@@ -130,12 +137,15 @@
Behaviour options:
-i, --info give detailed info about tags
-I, --display-info display "I:" tags (normally suppressed)
+ -l X, --unpack-level X set default unpack level to X
-o, --no-override ignore overrides
--show-overrides output tags that have been overriden
+ -U X, --unpack-info X specify which info should be collected
-m, --md5sums check md5sums when processing a .changes file
--allow-root suppress lintian\'s warning when run as root
Configuration options:
--cfg CONFIGFILE read CONFIGFILE for configuration
+ --lab LABDIR use LABDIR as permanent laboratory
--archivedir ARCHIVEDIR location of Debian archive to scan for packages
--dist DIST scan packages in this distribution (e.g. sid)
--section RELEASE scan packages in this section (e.g. main)
@@ -205,6 +215,14 @@
}
+# Process for -U|--unpack-info flag
+sub record_unpack_info {
+ if ($unpack_info) {
+ die("multiple -U or --unpack-info options not allowed");
+ }
+ $unpack_info = $_[1];
+}
+
# Record what type of data is specified
# Options: -b|--binary, -s|--source, --udeb
sub record_pkgmode {
@@ -215,9 +233,13 @@
# Hash used to process commandline options
my %opthash = ( # ------------------ actions
+ "setup-lab|S" => \&record_action,
+ "remove-lab|R" => \&record_action,
"check|c" => \&record_action,
"check-part|C=s" => \&record_check_part,
"dont-check-part|X=s" => \&record_dont_check_part,
+ "unpack|u" => \&record_action,
+ "remove|r" => \&record_action,
# ------------------ general options
"help|h" => \&syntax,
@@ -230,13 +252,16 @@
# ------------------ behaviour options
"info|i" => \$lintian_info,
"display-info|I" => \$display_infotags,
+ "unpack-level|l=i" => \$unpack_level,
"no-override|o" => \$no_override,
"show-overrides" => \$show_overrides,
+ "unpack-info|U=s" => \&record_unpack_info,
"md5sums|m" => \$check_md5sums,
"allow-root" => \$allow_root,
# ------------------ configuration options
"cfg=s" => \$LINTIAN_CFG,
+ "lab=s" => \$OPT_LINTIAN_LAB,
"archivedir=s" => \$OPT_LINTIAN_ARCHIVEDIR,
"dist=s" => \$OPT_LINTIAN_DIST,
"section=s" => \$OPT_LINTIAN_SECTION,
@@ -323,10 +348,14 @@
s,\$HOME/,$ENV{'HOME'}/,go;
s,\~/,$ENV{'HOME'}/,go;
- if (m/^\s*LINTIAN_ARCHIVEDIR\s*=\s*(.*\S)\s*$/i) {
+ if (m/^\s*LINTIAN_LAB\s*=\s*(.*\S)\s*$/i) {
+ $LINTIAN_LAB = $1;
+ } elsif (m/^\s*LINTIAN_ARCHIVEDIR\s*=\s*(.*\S)\s*$/i) {
$LINTIAN_ARCHIVEDIR = $1;
} elsif (m/^\s*LINTIAN_DIST\s*=\s*(.*\S)\s*$/i) {
$LINTIAN_DIST = $1;
+ } elsif (m/^\s*LINTIAN_UNPACK_LEVEL\s*=\s*(.*\S)\s*$/i) {
+ $LINTIAN_UNPACK_LEVEL = $1;
} elsif (/^\s*LINTIAN_SECTION\s*=\s*(.*\S)\s*$/i) {
$LINTIAN_SECTION = $1;
} elsif (m/^\s*LINTIAN_ARCH\s*=\s*(.*\S)\s*$/i) {
@@ -339,12 +368,15 @@
}
# environment variables overwrite settings in conf file:
+$LINTIAN_LAB = $ENV{'LINTIAN_LAB'} if $ENV{'LINTIAN_LAB'};
$LINTIAN_ARCHIVEDIR = $ENV{'LINTIAN_ARCHIVEDIR'} if $ENV{'LINTIAN_ARCHIVEDIR'};
$LINTIAN_DIST = $ENV{'LINTIAN_DIST'} if $ENV{'LINTIAN_DIST'};
+$LINTIAN_UNPACK_LEVEL = $ENV{'LINTIAN_UNPACK_LEVEL'} if $ENV{'LINTIAN_UNPACK_LEVEL'};
$LINTIAN_SECTION = $ENV{'LINTIAN_SECTION'} if $ENV{'LINTIAN_SECTION'};
$LINTIAN_ARCH = $ENV{'LINTIAN_ARCH'} if $ENV{'LINTIAN_ARCH'};
# command-line options override everything
+$LINTIAN_LAB = $OPT_LINTIAN_LAB if $OPT_LINTIAN_LAB;
$LINTIAN_ARCHIVEDIR = $OPT_LINTIAN_ARCHIVEDIR if $OPT_LINTIAN_ARCHIVEDIR;
$LINTIAN_DIST = $OPT_LINTIAN_DIST if $OPT_LINTIAN_DIST;
$LINTIAN_SECTION = $OPT_LINTIAN_SECTION if $OPT_LINTIAN_SECTION;
@@ -372,6 +404,21 @@
$ENV{'LINTIAN_CFG'} = "";
}
+if ($LINTIAN_LAB) {
+ # LINTIAN_LAB defined => advanced mode (static lab)
+ $lab_mode = 'static';
+} else {
+ # LINTIAN_LAB not defined => basic mode (temporary lab)
+ $lab_mode = 'temporary';
+
+ if ($ENV{'TMPDIR'}) {
+ $LINTIAN_LAB = "$ENV{'TMPDIR'}/lintian-lab.$$";
+ } else {
+ $LINTIAN_LAB = "/tmp/lintian-lab.$$";
+ }
+}
+$ENV{'LINTIAN_LAB'} = $LINTIAN_LAB;
+
if ($LINTIAN_ARCHIVEDIR) {
$ENV{'LINTIAN_ARCHIVEDIR'} = $LINTIAN_ARCHIVEDIR;
} else {
@@ -401,6 +448,27 @@
$ENV{'LINTIAN_DEBUG'} = $debug;
+# determine requested unpack level
+if (defined($unpack_level)) {
+ # specified through command line
+} elsif (defined($LINTIAN_UNPACK_LEVEL)) {
+ # specified via configuration file or env variable
+ $unpack_level = $LINTIAN_UNPACK_LEVEL;
+} else {
+ # determine by action
+ if (($action eq 'unpack') or ($action eq 'check')) {
+ $unpack_level = 1;
+ } else {
+ $unpack_level = 0;
+ }
+}
+unless (($unpack_level == 0) or ($unpack_level == 1) or ($unpack_level == 2)) {
+ fail("bad unpack level $unpack_level specified");
+}
+
+$LINTIAN_UNPACK_LEVEL = $unpack_level;
+$ENV{'LINTIAN_UNPACK_LEVEL'} = $LINTIAN_UNPACK_LEVEL;
+
# }}}
# {{{ Loading lintian's own libraries (now LINTIAN_ROOT is known)
@@ -426,8 +494,10 @@
print "N: $BANNER\n";
print "N: Lintian root directory: $LINTIAN_ROOT\n";
print "N: Configuration file: $LINTIAN_CFG\n";
+ print "N: Laboratory: $LINTIAN_LAB\n";
print "N: Archive directory: $LINTIAN_ARCHIVEDIR\n";
print "N: Distribution: $LINTIAN_DIST\n";
+ print "N: Default unpack level: $LINTIAN_UNPACK_LEVEL\n";
print "N: Architecture: $LINTIAN_ARCH\n";
print "N: ----\n";
}
@@ -441,7 +511,51 @@
# {{{ Create/Maintain Lab and add any specified Debian Archives (*.debs)
-if ($action ne 'check')
+# sanity check:
+if (($action ne 'setup-lab') and ($lab_mode eq 'static')) {
+
+ # LINTIAN_LAB has to exist in this mode
+ fail("lintian lab has not been set up correctly (run lintian --setup-lab)")
+ unless Lab::is_lab($LINTIAN_LAB);
+}
+
+#######################################
+# Process -S option
+if ($action eq 'setup-lab') {
+ if ($#ARGV+1 > 0) {
+ print STDERR "warning: ignoring additional command line arguments\n";
+ }
+
+ if ($lab_mode eq 'temporary') {
+ fail("no laboratory specified (need to define LINTIAN_LAB)");
+ }
+
+ Lab::setup($LINTIAN_LAB, $lab_mode);
+
+ # No idea what this is needed here, but it used to be in the code, so I'll
+ # leave it untouched for the moment
+ Lab::populate_with_dist($LINTIAN_LAB, $LINTIAN_DIST) if $LINTIAN_DIST;
+
+ exit 0;
+
+#######################################
+# Process -R option
+} elsif ($action eq 'remove-lab') {
+ if ($#ARGV+1 > 0) {
+ print STDERR "warning: ignoring additional command line arguments\n";
+ }
+
+ if ($lab_mode eq 'temporary') {
+ fail("no laboratory specified (need to define LINTIAN_LAB)");
+ }
+
+ Lab::delete($LINTIAN_LAB, $lab_mode);
+
+ exit 0;
+
+#######################################
+# Check for non deb specific actions
+} elsif (not (($action eq 'unpack') or ($action eq 'check')
or ($action eq 'remove'))) {
fail("bad action $action specified");
}
@@ -833,7 +947,18 @@
# }}}
-# {{{ create check_abbrev hash
+# {{{ Again some lone code the author just dumped where his cursor just happened to be
+if ($unpack_info) {
+ # determine which info has been requested
+ for my $i (split(/,/,$unpack_info)) {
+ unless ($collection_info{$i}) {
+ fail("unknown info specified: $i");
+ }
+ $unpack_infos{$i} = 1;
+ }
+}
+
+# create check_abbrev hash
for my $c (keys %check_info) {
$check_abbrev{$check_info{$c}->{'abbrev'}} = $c;
}
@@ -953,6 +1078,7 @@
printf "N: Processing %d packages...\n",$#packages+1 if $verbose;
if ($debug) {
print "N: Selected action: $action\n";
+ print "N: Requested unpack level: $unpack_level\n";
printf "N: Requested data to collect: %s\n",join(',',keys %unpack_infos);
printf "N: Selected checks: %s\n",join(',',keys %checks);
}
@@ -1244,6 +1370,7 @@
exit $exit_code;
# {{{ Some subroutines
+
sub unpack_pkg {
my ($type,$base,$file,$cur_level,$new_level) = @_;
Modified: trunk/lib/Lab.pm
===================================================================
--- trunk/lib/Lab.pm 2004-06-29 15:21:09 UTC (rev 299)
+++ trunk/lib/Lab.pm 2004-06-29 15:24:12 UTC (rev 300)
@@ -1,7 +1,7 @@
# Lab -- Perl laboratory functions for lintian
# $Id$
-# Copyright (C) 2004 Jeroen van Wolffelaar
+# Copyright (C) 1998-2004 Various authors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,7 +23,6 @@
use strict;
use Pipeline;
-use File::Temp ( tempdir );
my $LINTIAN_ROOT = $::LINTIAN_ROOT;
@@ -32,32 +31,68 @@
my $verbose = $::verbose;
my $debug = $::debug;
-my $tempdir = undef;
+sub is_lab {
+ my $labdir = shift;
-sub unpack {
+ return -d "$labdir/binary"
+ && -d "$labdir/udeb"
+ && -d "$labdir/source"
+ && -d "$labdir/info";
+}
- unless (defined $tempdir) {
- $tempdir = tempdir("lintian.XXXXXX",
- TMPDIR => 1, CLEANUP => 1) or
- die("Couldn't create temporary directory for examining
- package(s)");
- }
+sub setup {
+ my $LINTIAN_LAB = shift;
+ my $lab_mode = shift;
- my ($type, $package) = @_;
+ print "N: Setting up lab in $LINTIAN_LAB ...\n" if $verbose;
- if ($type eq 'b' || $type eq 'u') {
- spawn("$LINTIAN_ROOT/unpack/unpack-binpkg-l1", $tempdir, $file) == 0
- or die("Failed unpacking $file to level 1");
- spawn("$LINTIAN_ROOT/unpack/unpack-binpkg-l2", $tempdir, $file) == 0
- or die("Failed unpacking $file to level 2");
- } else {
- spawn("$LINTIAN_ROOT/unpack/unpack-srcpkg-l1", $tempdir, $file) == 0
- or die("Failed unpacking $file to level 1");
- spawn("$LINTIAN_ROOT/unpack/unpack-srcpkg-l2", $tempdir, $file) == 0
- or die("Failed unpacking $file to level 2");
- }
+ # create lab directory
+ if (not -d "$LINTIAN_LAB" or ($lab_mode eq 'temporary')) {
+ # (Note, that the mode 0777 is reduced by the current umask.)
+ mkdir($LINTIAN_LAB,0777) or fail("cannot create lab directory $LINTIAN_LAB");
+ }
+
+ # create base directories
+ if (not -d "$LINTIAN_LAB/binary") {
+ mkdir("$LINTIAN_LAB/binary",0777) or fail("cannot create lab directory $LINTIAN_LAB/binary");
+ }
+ if (not -d "$LINTIAN_LAB/source") {
+ mkdir("$LINTIAN_LAB/source",0777) or fail("cannot create lab directory $LINTIAN_LAB/source");
+ }
+ if (not -d "$LINTIAN_LAB/udeb") {
+ mkdir("$LINTIAN_LAB/udeb",0777) or fail("cannot create lab directory $LINTIAN_LAB/udeb");
+ }
+ if (not -d "$LINTIAN_LAB/info") {
+ mkdir("$LINTIAN_LAB/info",0777) or fail("cannot create lab directory $LINTIAN_LAB/info");
+ }
+ # just create empty files
+ _touch("$LINTIAN_LAB/info/binary-packages")
+ or fail("cannot create binary package list");
+ _touch("$LINTIAN_LAB/info/source-packages")
+ or fail("cannot create source package list");
+ _touch("$LINTIAN_LAB/info/udeb-packages")
+ or fail("cannot create udeb package list");
}
+sub populate_with_dist {
+ my $LINTIAN_LAB = shift;
+ my $LINTIAN_DIST = shift;
+
+ print STDERR "spawning list-binpkg, list-udebpkg and list-srcpkg since LINTIAN_DIST=$LINTIAN_DIST\n" if ($debug >= 2);
+
+ my $v = $verbose ? '-v' : '';
+
+ spawn("$LINTIAN_ROOT/unpack/list-binpkg",
+ "$LINTIAN_LAB/info/binary-packages", $v) == 0
+ or fail("cannot create binary package list");
+ spawn("$LINTIAN_ROOT/unpack/list-srcpkg",
+ "$LINTIAN_LAB/info/source-packages", $v) == 0
+ or fail("cannot create source package list");
+ spawn("$LINTIAN_ROOT/unpack/list-udebpkg",
+ "$LINTIAN_LAB/info/udeb-packages", $v) == 0
+ or fail("cannot create udeb package list");
+}
+
# Remove is apparantly some reserved name...
sub delete {
my $LINTIAN_LAB = shift;
@@ -110,6 +145,16 @@
}
}
+# create an empty file
+# --okay, okay, this is not exactly what `touch' does :-)
+sub _touch {
+ open(T,">$_[0]") or return 0;
+ close(T) or return 0;
+
+ return 1;
+}
+
+
1;
# vim: ts=4 sw=4 noet
Reply to: