diff --git a/scripts/check-installed b/scripts/check-installed new file mode 100755 index 000000000..d588ef84c --- /dev/null +++ b/scripts/check-installed @@ -0,0 +1,75 @@ +#! /usr/bin/perl + +# This script can be used to compare the bee packages installed in the system with +# the bee files in the current working directory, which is assumend to be the checked +# out master branch of git@github.molgen.mpg.de:mariux64/bee-files.git +# +# git checkout master +# git pull +# scripts/check-installed + +use strict; +use warnings; + +sub scandir { + my ($dirname)=@_; + opendir my $dir,$dirname or die "$dirname: $!\n"; + return sort grep !/^\./,readdir $dir; +} + +sub save_qx { + my (@cmd)=@_; + my $pid=open my $pipe,'-|'; + defined $pid or die "$!\n"; + unless ($pid) { + exec @cmd or die "$!"; + exit(1); + } + return join('',<$pipe>); +} + +our %GIT_FILE; + +for my $beefile (scandir('.')) { + $beefile=~/\.(bee|be0)$/ or next; + $beefile eq 'TEMPLATE.be0' and next; + -f $beefile or next; + my $pkg=save_qx('beeversion','--format','%A',$beefile); + chomp($pkg); + unless ($pkg) { + print "# can't parse version of $beefile\n"; + next; + } + unless ($pkg =~ /.x86_64$/) { + if ($pkg =~ '^(iana-etc-2.30-0|lesspipe-1-0)$') { + $pkg.='.noarch'; + } else { + $pkg.='.x86_64'; + } + } + if (exists($GIT_FILE{$pkg})) { + print "# bee file $beefile overwrites package $pkg from $GIT_FILE{$pkg}\n"; + } + $GIT_FILE{$pkg}=$beefile; +} + +%GIT_FILE or die "no bee files here. Are you sitting in a checked out bee-files repository (git\@github.molgen.mpg.de:mariux64/bee-files.git) ?\n"; + +for my $dir (scandir('/usr/share/bee')) { + my $pkg=$dir; + my $beefile=save_qx('beeversion','--format','%F',"$pkg.bee"); + unless (-e "/usr/share/bee/$pkg/$beefile.bee") { + print "# no such file /usr/share/bee/$pkg/$beefile\n"; + next; + } + unless (exists($GIT_FILE{$pkg})) { + print "# package in system but not in git: $pkg\n"; + } + delete $GIT_FILE{$pkg}; +} + +for my $pkg (sort(keys(%GIT_FILE))) { + my $beefile=$GIT_FILE{$pkg}; + print "# package in git but not in system: $pkg ($beefile)\n"; +} +