-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #599 from mariux64/add-check-installed
Add scripts/check-installed
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
|