Skip to content

Commit

Permalink
Add perl registry-fixing script from trac
Browse files Browse the repository at this point in the history
  • Loading branch information
System Administrator committed Feb 6, 2013
1 parent fc938c2 commit 653c2ff
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
1 change: 1 addition & 0 deletions Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ build {}
destroot {
xinstall -d -m 755 ${destroot}${prefix}/bin
eval xinstall -m 755 [glob ${worksrcpath}/*.sh] ${destroot}${prefix}/bin
eval xinstall -m 755 [glob ${worksrcpath}/*.pl] ${destroot}${prefix}/bin
}

livecheck.type none
7 changes: 4 additions & 3 deletions Portfile.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- Portfile.orig 2013-01-29 18:44:01.000000000 -0500
+++ Portfile 2013-01-29 18:20:20.000000000 -0500
@@ -1,24 +1,27 @@
--- Portfile.orig 2013-02-06 12:13:10.000000000 -0500
+++ Portfile 2013-02-06 12:15:53.000000000 -0500
@@ -1,24 +1,28 @@
-# $Id$
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
+# $Id: Portfile 78632 2011-05-14 22:50:58Z [email protected] $
Expand Down Expand Up @@ -35,6 +35,7 @@
xinstall -d -m 755 ${destroot}${prefix}/bin
- eval xinstall -m 755 [glob ${worksrcpath}/*] ${destroot}${prefix}/bin
+ eval xinstall -m 755 [glob ${worksrcpath}/*.sh] ${destroot}${prefix}/bin
+ eval xinstall -m 755 [glob ${worksrcpath}/*.pl] ${destroot}${prefix}/bin
}

livecheck.type none
81 changes: 81 additions & 0 deletions macports_34482_fix.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env perl

use strict;
use warnings;

sub regfiles {

my ($top,$regfile) = @_;

my $fast = 1;

my @regs;

if ($fast) {
push(@regs,"$top/local/var/macports/registry/$regfile");
}

# in case this bug ever comes up again and $regfile moves
else {
@regs = `find /opt -name '$regfile'`;
return undef unless @regs;
chomp @regs;
}


return \@regs;

}

my $sqlite3 = '/opt/local/bin/sqlite3';
die "Please do a 'port install sqlite3' and try again\n" if (! -x $sqlite3);

my $top = '/opt';
my $regfile = 'registry.db';
my $regs = regfiles($top,$regfile);
die "Unable to locate $regfile in $top\n" if (! $regs);

my $cmd;

foreach my $dbfile (@$regs) {

$cmd = "$sqlite3 $dbfile 'SELECT * FROM dependencies WHERE id NOT IN (SELECT DISTINCT id FROM ports);'";
print $cmd, "\n";
my @tofix = `$cmd`;

if (! @tofix) {
warn "Registry file $regfile format is correct...\n";
}
else {

chomp @tofix;

my $ids = {};
foreach my $entry (@tofix) {
my @parts = split /\|/, $entry;
my $id = shift @parts;
$ids->{$id} = 1;
}
foreach my $id (sort keys %$ids) {
$cmd = "$sqlite3 $dbfile 'DELETE FROM files WHERE id = $id'";
print $cmd, "\n";
system($cmd);
$cmd = "$sqlite3 $dbfile 'DELETE FROM dependencies WHERE id = $id'";
print $cmd, "\n";
system($cmd);
}
}
}
my @inactive = `port list inactive`;
if (@inactive) {
$cmd = 'port uninstall inactive';
print $cmd, "\n";
system($cmd);
}

0 comments on commit 653c2ff

Please sign in to comment.