forked from derphilipp/macportsscripts
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add perl registry-fixing script from trac
- Loading branch information
System Administrator
committed
Feb 6, 2013
1 parent
fc938c2
commit 653c2ff
Showing
3 changed files
with
86 additions
and
3 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
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 |
---|---|---|
@@ -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] $ | ||
|
@@ -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 |
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,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); | ||
} |