#!/usr/bin/perl ## This file is copyright (c) 2007-2008 Bruce Ravel and ## licensed under The Creative Commons Attribution-ShareAlike License. ## use this script to install a local copy of the Athena User's Guide ## into the location expected by Athena on this machine. ## Ifeffit::FindFile is used to determine that location, thus Athena ## must already be installed on the machine. ## ## The contents of the pod/, html/, and images/ directories are copied ## to the location that Athena expects. ## ## Running this script will likely require root/sudo/administrator ## privileges. use warnings; use strict; use Ifeffit::FindFile; use File::Copy; use File::Path; use File::Spec; $| = 1; print "Installing a local copy of the Athena User's Guide\n"; my $install_dir = Ifeffit::FindFile -> find("athena", "aug"); my $pod_dir = File::Spec->catfile($install_dir, "pod"); my $html_dir = File::Spec->catfile($install_dir, "html"); my $im_dir = File::Spec->catfile($install_dir, "images"); my $data_dir = File::Spec->catfile($install_dir, "data"); print " initializing space under $install_dir\n"; mkpath($install_dir) if not (-e $install_dir); mkpath($pod_dir) if not (-e $pod_dir); mkpath($html_dir) if not (-e $html_dir); mkpath($im_dir) if not (-e $im_dir); mkpath($data_dir) if not (-e $data_dir); opendir POD, "pod"; my @files = readdir POD; closedir POD; print " copying "; ## we know that the hierarchy of files is only two levels deep. this ## simplifies the chore of recursively copying the pod and html files. foreach my $f (@files) { next if ($f =~ m{^\.}); if ($f =~ m{pod$}) { copy(File::Spec->catfile("pod",$f), $pod_dir); (my $h = $f) =~ s{pod$}{html}; copy(File::Spec->catfile("html",$h), $html_dir); } else { print "$f/ "; ## make the subdirectories my $pd = File::Spec->catfile($pod_dir, $f); mkpath($pd) if not (-e $pd); my $hd = File::Spec->catfile($html_dir, $f); mkpath($hd) if not (-e $hd); ## drop into each subdir and copy the files opendir SUB, "pod/$f"; my @these = readdir SUB; closedir SUB; foreach my $s (@these) { next if ($s =~ m{^\.}); my $this = File::Spec->catfile("pod", $f, $s); copy($this, $pd); (my $t = $s) =~ s{pod$}{html}; $this = File::Spec->catfile("html", $f, $t); copy($this, $hd); }; }; }; print "\n copying style sheets\n"; copy(File::Spec->catfile("html","ab.css"), $html_dir); copy(File::Spec->catfile("html","perl.css"), $html_dir); print " copying images ("; opendir IM, "images"; my @images = readdir IM; closedir IM; my $count = 1; foreach my $i (@images) { next if ($i =~ m{^\.}); print "$count " if ($count % 20 == 0); ++$count; my $this = File::Spec->catfile("images", $i); copy($this, $im_dir); }; print ")\n"; print " copying data"; opendir IM, "data"; my @data = readdir IM; closedir IM; foreach my $i (@images) { next if ($i =~ m{^\.}); ++$count; my $this = File::Spec->catfile("data", $i); copy($this, $data_dir); }; print "\nDone!\n";