summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Merge.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-03-17 04:08:34 +0000
committerfukachan <fukachan>2004-03-17 04:08:34 +0000
commit3e50d26abd731ec8246593dbea21a4b4e0615f4d (patch)
tree9feefcd295644effdf8b60a3c768fa7bcea9e003 /fml/lib/FML/Merge.pm
parentaabdc4b4dac01019d594793f6f5ad36f62712eed (diff)
downloadfml8-3e50d26abd731ec8246593dbea21a4b4e0615f4d.tar.gz
fml8-3e50d26abd731ec8246593dbea21a4b4e0615f4d.tar.bz2
fml8-3e50d26abd731ec8246593dbea21a4b4e0615f4d.zip
implement actual conversion codes.
Diffstat (limited to 'fml/lib/FML/Merge.pm')
-rw-r--r--fml/lib/FML/Merge.pm61
1 files changed, 51 insertions, 10 deletions
diff --git a/fml/lib/FML/Merge.pm b/fml/lib/FML/Merge.pm
index dcc8d649..edaa3c1e 100644
--- a/fml/lib/FML/Merge.pm
+++ b/fml/lib/FML/Merge.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: @template.pm,v 1.8 2004/01/01 07:29:27 fukachan Exp $
+# $FML: Merge.pm,v 1.1.1.1 2004/03/16 12:58:20 fukachan Exp $
#
package FML::Merge;
@@ -47,12 +47,17 @@ sub new
};
# back up to $ml_home_dir/.fml4rc/ directory.
+ # $ml_home_dir/.fml4rc/
+ # $ml_home_dir/.fml4rc/etc/
use File::Spec;
my $ml_home_dir = $params->{ ml_home_dir } || '';
if ($ml_home_dir) {
my $x_dir = File::Spec->catfile($ml_home_dir, ".fml4rc");
$me->{ _backup_dir } = $x_dir;
$curproc->mkdir($x_dir, "mode=private") unless -d $x_dir;
+
+ $x_dir = File::Spec->catfile($ml_home_dir, ".fml4rc", "etc");
+ $curproc->mkdir($x_dir, "mode=private") unless -d $x_dir;
}
else {
croak("specify \$ml_home_dir");
@@ -95,14 +100,19 @@ sub backup_old_config_files
my $src = $self->old_file_path($f);
my $dst = $self->backup_file_path($f);
- if ($mode eq 'move') {
- printf STDERR "mv %-30s %-30s\n", $src, $dst;
- }
- elsif ($mode eq 'copy') {
- printf STDERR "cp %-30s %-30s\n", $src, $dst;
- }
- else {
- print STDERR "unknown mode (DO NOTHING).\n";
+ if (-f $src) {
+ if ($mode eq 'move') {
+ printf STDERR "moving %-30s -> %-30s\n", $src, $dst;
+ rename($src, $dst) || croak("cannot rename $src $dst");
+ }
+ elsif ($mode eq 'copy') {
+ printf STDERR "copying %-30s -> %-30s\n", $src, $dst;
+ use IO::Adapter::AtomicFile;
+ IO::Adapter::AtomicFile->copy($src, $dst);
+ }
+ else {
+ print STDERR "unknown mode (DO NOTHING).\n";
+ }
}
}
}
@@ -145,7 +155,7 @@ For example, the value of NetBSD follows.
=cut
-sub disable_include_files
+sub disable_old_include_files
{
my ($self) = @_;
@@ -156,6 +166,37 @@ sub disable_include_files
for my $f (@$files) {
my $file = $self->old_file_path($f);
print STDERR "disable $file\n";
+ print STDERR " cp $file $file.bak\n";
+ use IO::Adapter::AtomicFile;
+ IO::Adapter::AtomicFile->copy($file, "$file.bak");
+ my $wh = new FileHandle "> $file.tmp";
+ if (defined $wh) {
+ print $wh "exit 75\n"; # EX_TEMPFAIL
+ $wh->close();
+
+ unless (rename("$file.tmp", $file)) {
+ croak("fail to rename $file.tmp to $file");
+ }
+ }
+ else {
+ croak("fail to create $file.tmp");
+ }
+ }
+}
+
+
+sub enable_old_include_files
+{
+ my ($self) = @_;
+
+ use FML::Merge::FML4::Config;
+ my $config = new FML::Merge::FML4::Config;
+ my $files = $config->get_old_include_files();
+
+ for my $f (@$files) {
+ my $file = $self->old_file_path($f);
+ print STDERR "enable $file\n";
+ print STDERR " mv $file.bak $file\n";
}
}