X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=mig-bin%2Fmig-skip-clean;fp=mig-bin%2Fmig-skip-clean;h=0000000000000000000000000000000000000000;hp=5b60cb17a94cd564ecb6686d8452c79bdd434609;hb=155eb9eac077ca803f75d1295e584e7012e1b883;hpb=69588457ab8f70fbb77af29cc0653933d24ed2ac diff --git a/mig-bin/mig-skip-clean b/mig-bin/mig-skip-clean deleted file mode 100755 index 5b60cb1..0000000 --- a/mig-bin/mig-skip-clean +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/perl -w -############################################################################### -=pod - -=head1 NAME - -mig-skip-clean - -Allows you to either use an existing file named .utf8.clean or a -named [cleaned file] as if it were the one created by mig-clean - -Note that the clean file, however specified, should contain headers. The -remaining tools in the chain will expect this. - -=head1 SYNOPSIS - -B [cleaned file] - -=cut - -############################################################################### - -use strict; -use Switch; -use Env qw( - HOME PGHOST PGPORT PGUSER PGDATABASE MIGSCHEMA - MIGBASEWORKDIR MIGBASEGITDIR MIGGITDIR MIGWORKDIR -); -use Pod::Usage; -use DBI; -use Cwd 'abs_path'; -use FindBin; -my $mig_bin = "$FindBin::Bin/"; -use lib "$FindBin::Bin/"; -use Mig; - -pod2usage(-verbose => 2) if ! ($ARGV[0]||$ARGV[1]) || $ARGV[0] eq '--help'; - -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); - -my $file = abs_path($ARGV[0]); -my $clean_file; -if ($ARGV[1]) { - $clean_file = abs_path($ARGV[1]); -} else { - $clean_file = $file; -} -if ($clean_file && ! $clean_file =~ /^$MIGBASEWORKDIR/) { - die "File falls outside of MIGWORKDIR ($MIGWORKDIR): $clean_file\n"; -} - -if ($file =~ /^$MIGBASEWORKDIR/) { - skip_clean($file,$clean_file); -} else { - die "File falls outside of MIGWORKDIR ($MIGWORKDIR): $file\n"; -} - -exit 0; - -############################################################################### - -sub skip_clean { - my $file = shift; - my $clean_file = shift; - - my $tracked_file_id = Mig::check_for_tracked_file($file); - if ($tracked_file_id) { - my $data = Mig::status_this_file($file); - - if (! $data->{'utf8_filename'}) { - die "mig-iconv or mig-skip-iconv needed for UTF8 version of file: $file\n"; - } - - my $utf8_file = $data->{'utf8_filename'}; - if (! -e $utf8_file) { - die "missing file: $utf8_file\n"; - } - - print "skipping cleaning of tracked file: $file\n"; - - my $dbh = Mig::db_connect(); - if (! $clean_file) { - $clean_file = $utf8_file . '.clean'; - } - if (! -e $clean_file) { - die "clean file does not exist: $clean_file\n"; - } - - my $rv = $dbh->do(" - UPDATE $MIGSCHEMA.tracked_file - SET clean_filename = " . $dbh->quote($clean_file) . " - WHERE base_filename = " . $dbh->quote($file) . " - ; - ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); - } else { - die "File not currently tracked: $file\n"; - } -}