
Hi everybody
this is a small script taht may be useful for everybody who develops
add-ons for OTRS (aka. OPM packages). This script checks the "manifest"
(file list) in the .sopm file.
It gets the filelist from the XML and gets a list of files in the
subdirectories of the OPM package. Then it checks if all the files
mentioned in the manifest can be found on disk and if all files that
were found on disk were listed in the sopm file.
This is a sample output if anything goes wrong:
C:\>check_manifest.pl path\to\your.sopm
1..1
not ok 1
# Failed test at C:\check_manifest.pl line 66.
# Structures begin differing at:
# $got->{Kernel/System/AnyFile.pm} = Does not exist
# $expected->{Kernel/System/AnyFile.pm} = '1'
# Looks like you failed 1 test of 1.
And when you have added AnyFile.pm everything is ok:
C:\>check_manifest.pl path\to\your.sopm
1..1
ok 1
Everything that "does not exist" in the "$got" hashref must be added in
the .sopm file and any files that does not exist in the "$expected"
hashref are files that are mentioned in the manifest and no according
file could be found.
This test can be helpful before you create the OPM package to check if
your manifest is up to date.
I hope this is helpful to anybody out there.
Cheers,
Renee
--
Perl-Magazin: http://perl-magazin.de
Perl-Nachrichten: http://perl-nachrichten.de
#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple ();
use File::Spec;
use File::Basename ();
use File::Find::Rule;
use Test::More tests => 1;
my $path = $ARGV[0];
print_usage() unless $path and -e $path and substr( $path, -5 ) eq '.sopm';
my @listed_files = get_listed_files( $path );
my @real_files = get_real_files( $path );
check_filelist( \@listed_files, \@real_files );
sub print_usage {
plan tests => 0;
print <<"USAGE";
Usage: $0