File: Setup

package info (click to toggle)
pilot-manager 1.107.0pre108-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze, wheezy
  • size: 872 kB
  • ctags: 562
  • sloc: perl: 17,807; sh: 456; makefile: 36
file content (216 lines) | stat: -rw-r--r-- 4,391 bytes parent folder | download | duplicates (4)
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/sh
# ident "@(#)Setup 1.9     99/01/12 Bharat Mediratta"
#
# Configure PilotManager for the user's environment.
#
# 1. Find a version of Perl 5.  Warn the user if it is not
#    up to date.  Update PilotMgr.pm to use this version.
#
# 2. Run a series of tests on the user's environment to determine
#    whether or not PilotManager is going to be effective 
#

cat <<EOF

Welcome to the PilotManager setup utility.  Setup will be invoked
automatically the first time you run PilotManager.  After that, if you
wish to reconfigure PilotManager, you can run Setup by hand.

Setup will configure your installation of PilotManager.  It will
attempt to locate an appropriate version of Perl and configure
PilotManager to use that version.

Then, it will run a series of tests on your environment to determine
whether or not you will be able to run PilotManager without
difficulty.

Tips:
	- If you see a "relocation error" on any perl symbols then most
	  likely the binary packages you are using were not compiled for
	  your version of perl.  Return to the PilotManager web page and
	  make sure you retrieve the right binary packages.

EOF

echo "Press <RETURN> to continue";
read foo

VERS="5.003"
PERL=

echo "Locating Perl 5..."
for dir in `echo $PATH | sed -e 's/:/ /g'`
do
	for cmd in perl5 perl
	do
		if [ -n "$dir" -a -x "$dir/$cmd" ]
		then
			MAYBE=`$dir/$cmd -e 'print $^X'`
	
			if [ "$MAYBE" != "" ]
			then
				`$MAYBE -e "eval{require $VERS}; \
					    exit 0 if \\$@; exit 1"`
			fi

			if [ $? -eq 1 ]
			then
				PERL=$MAYBE
				break 2
			fi
		fi
	done
done

# Now, either we've found the right version of Perl and we 
# can continue, or we haven't and we should fail.
#

if [ -z "$PERL" ]
then
	cat<<EOF
Setup was unable to locate an appropriate version of
Perl from your path.  You need to have Perl v5.003 or
later in your path for PilotManager to work.
EOF
	exit 1;
fi

echo "Perl 5 found [at $PERL]"
echo "Please wait..."

cat > /tmp/pmgr-setup.pl <<EOF

use Config;

BEGIN
{
    use Cwd;
    my (\$PWD);
    \$PWD = Cwd::cwd();

    unshift(@INC, "\$PWD/lib/perl5/\$Config::Config{archname}/\$]");
    unshift(@INC, "\$PWD/lib/perl5/\$Config::Config{archname}");
    unshift(@INC, "\$PWD/lib/perl5");
    unshift(@INC, "\$PWD");
}

require 5.003;

package Setup;

$| = 1;

sub complain
{
    my (\$mod, \$err) = @_;

    print qq|
	You do not have the correct binary of the \$mod module
	installed in either your PilotManager distribution or your
	perl installation.

	Please read README.porting for information about how to 
        download and install this module.

        Error details:
-----------------------------------------------------------------------------
\$err-----------------------------------------------------------------------------
	    \n|;
    exit;
}

print "Configuring PilotManager...";

eval "use Tk;";
&complain("Tk", \$@) if (\$@);

eval "use PDA::Pilot;";
&complain("PDA::Pilot", \$@) if (\$@);

eval "use Data::Dumper;";
&complain("Data::Dumper", \$@) if (\$@);

if (! -f "PilotMgr.pm.$$")
{
    unless(rename("PilotMgr.pm", "PilotMgr.pm.$$"))
    {
	print "Unable to rename PilotMgr.pm\n";
	exit;
    }
}

if (open(IFD, "<PilotMgr.pm.$$"))
{
    if (open(OFD, ">PilotMgr.pm"))
    {
	# Replace the top line with our new perl exec binary
	#
	<IFD>;
	print OFD "#!$PERL\n";
	print OFD <IFD>;
	close(OFD);
    }
    else
    {
	print "\nError: Unable to write to PilotMgr.pm\n";
	rename("PilotMgr.pm.$$", "PilotMgr.pm");
	exit;
    }
    close(IFD);
}
else
{
    print "\nError: Unable to read from PilotMgr.pm.$$\n";
    exit;
}
chmod(0755, "PilotMgr.pm");
unlink("PilotMgr.pm.$$");

\$SIG{'INT'} = bail;

print "done.\n";
print qq|
PilotManager will now test your system to make sure
that all your conduits will function properly.

Press ^C at any time to abort the tests.

Press <RETURN> to continue.
|;
<STDIN>;

foreach \$file (<lib/test/*.t>)
{
    (\$name = \$file) =~ s|lib/test/(.*)\.t$|\$1|;

    print ">> \$name <<\n";

    do \$file;
}

sub bail
{
    print "Aborting tests\n";
    print "Your installation is complete, but not fully tested.\n";

    &done;
}

&done; 

sub done
{
    print qq|
Your PilotManager installation is complete.  You can invoke it 
by typing 'PilotManager' at your shell prompt.

Please file all bugs and feedback via the 'Feedback'
menu in PilotManager.
|; 
}

EOF

$PERL /tmp/pmgr-setup.pl