Skip to content

Commit

Permalink
Add scripts/check-installed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
donald committed Feb 7, 2018
1 parent 9264d44 commit 878548a
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions scripts/check-installed
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit 878548a

Please sign in to comment.