~ubuntu-branches/ubuntu/lucid/libopenoffice-oodoc-perl/lucid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#------------------------------------------------------
# OpenOffice::OODoc packaging & installation 2010-01-05
#------------------------------------------------------

use 5.008;
use Getopt::Long;
use Encode;
use ExtUtils::MakeMaker;

#------------------------------------------------------

GetOptions
	(
	'config!'	=> \(my $config = 1),
	'prompt!'	=> \(my $prompt = 1),
	'encoding=s'	=> \(my $encoding = 'utf8'),
	'colormap=s'	=> \(my $colormap = ''),
	'workdir=s'	=> \(my $workdir = '.'),
	'format=s'	=> \(my $format = 2),
	'build'		=> \(my $build = undef)
	);

#------------------------------------------------------

print "OpenOffice::OODoc Installation\n";
	
if ($config)
	{
	my $config_file = 'OODoc/config.xml';
	print	"\nNow you will be prompted for some configuration options.\n"	.
		"These options are intended to define default values only.\n"	.
		"Each option may be overridden by the applications.\n"		.
		"You can change these default options later; to do so, you\n"	.
		"can either replay this installation procedure or manually\n"	.
		"edit the <installation path>/$config_file file.\n"		.
		"(See INSTALL for details)\n"
		if ($prompt);
	while ($prompt)
		{
		my $answer;
		print "\nPresent configuration:\n";
		print "- Your local character set is now [$encoding]\n";
		unless (Encode::find_encoding($encoding))
			{
			warn	"\tWARNING: Unsupported character set.\n";
			}
		unless ($colormap)
			{
			print "- There is no colour map file\n";
			}
		else
			{
			print "- Your colour map file is now [$colormap]\n";
			unless (-f $colormap)
				{
				warn "\tWARNING: This file doesn't exist.\n";
				}
			}
		print "- Your working directory for temporary files is now [$workdir]\n";
		unless (-d $workdir)
			{
			warn	"\tWARNING: This directory doesn't exist.\n";
			}
		print "- Your preferred file format is [$format] (OOo=1 ODF=2).\n";
		$answer = lc (prompt("Is that OK (y/n) ?", "y"));
		$prompt = '' unless $answer ne "y";
		last unless $prompt;
		$encoding	= prompt
			(
			"What is your preferred local character set ?",
			$encoding
			);
		$colormap	= prompt
			(
			"What is the full path of your RGB colour map file (optional) ?",
			$colormap
			);
		$workdir	= prompt
			(
			"What is your working directory for temporary files ?",
			$workdir
			);
		$format		= prompt
			(
			"What is your preferred format for new documents (OOo=1, ODF=2) ?",
			$format
			);
		unless ($format eq "1" or $format eq "2")
			{
			warn "\tWARNING: Unknown format $format\n";
			$format = 2;
			}
		$encoding = '' unless $encoding gt ' ';
		$colormap = '' unless $colormap gt ' ';
		$workdir  = '' unless $workdir gt ' ';
		}
	
	Encode::from_to($workdir, $encoding, 'utf8');

#------------------------------------------------------

	my @lt = localtime();
	my $current_date = sprintf
		(
		"%04d-%02d-%02dT%02d:%02d:%02d",
		$lt[5] + 1900, $lt[4] + 1, $lt[3], $lt[2], $lt[1], $lt[0]
		);
	my $install_date	= undef;
	my $build_date	= undef;
	if ($build)
		{
		open TS, ">", "build_date";
		print TS $current_date;
		close TS;
		$build_date = $current_date;
		$install_date	= "N/A";
		}
	else
		{
		open TS, "<", "build_date";
		$build_date	= <TS>;
		close TS;
		$install_date	= $current_date;
		}

#------------------------------------------------------

	open CF, ">", $config_file;
	print CF '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
	print CF "<config>\n";
	print CF "\t<comment>OpenOffice::OODoc local configuration file</comment>\n";
	print CF "\t<OpenOffice-OODoc>\n";
	print CF "\t\t<File-DEFAULT_OFFICE_FORMAT>$format</File-DEFAULT_OFFICE_FORMAT>\n";
	print CF "\t\t<XPath-LOCAL_CHARSET>$encoding</XPath-LOCAL_CHARSET>\n";
	print CF "\t\t<File-WORKING_DIRECTORY>$workdir</File-WORKING_DIRECTORY>\n";
	print CF "\t\t<Styles-COLORMAP>$colormap</Styles-COLORMAP>\n";
	print CF "\t\t<BUILD_DATE>$build_date</BUILD_DATE>\n";
	print CF "\t\t<INSTALLATION_DATE>$install_date</INSTALLATION_DATE>\n";
	print CF "\t</OpenOffice-OODoc>\n";
	print CF "</config>";
	close CF;
	}

#------------------------------------------------------

WriteMakefile
	(
    	'NAME'		=> 'OpenOffice::OODoc',
	'VERSION_FROM'	=> 'OODoc.pm',
	'ABSTRACT_FROM'	=> 'OODoc.pod',
    	'AUTHOR'	=> 'Jean-Marie Gouarne <jmgdoc@cpan.org>',
	'LICENSE'	=> 'LGPL',
    	'PREREQ_PM'	=>
    		{
		'XML::Twig'		=> '3.32',
		'Archive::Zip'		=> '1.18',
		'File::Temp'		=> '0.12',
		'File::Find'		=> '1.01',
		'Time::Local'		=> '1.07',
		'IO::File'		=> '1.14'
		},
	'EXE_FILES'	=>
		[
		'oodoc_version',
		'examples/odfhighlight',
		'examples/odfextract',
		'examples/odffilesearch',
		'examples/text2odf',
		'examples/text2table',
		'examples/odf2pod',
		'examples/odfbuild',
		'examples/odfmetadoc',
		'examples/odffindbasic',
		'examples/odfsearch',
		'examples/odf_set_fields',
		'examples/odf_set_title',
		'examples/oodoc_test'
		]
	);

#------------------------------------------------------