5 #=================================================================================
7 #=================================================================================
9 # This launcher should work, but I cannot guarantee that,
10 # it was written on Arch Linux and not tried anywhere else
11 # if you want to use it on other system, adjust configuration
12 # below and keep your fingers crossed!
14 # Run it with "--help" option to get help.
16 # Remember that you use it at your own risk :-)
18 #=================================================================================
20 #=================================================================================
21 # Copyright (C) 2011 by Andrzej Giniewicz <gginiu@gmail.com>
23 # Permission is hereby granted, free of charge, to any person obtaining a copy
24 # of this software and associated documentation files (the "Software"), to deal
25 # in the Software without restriction, including without limitation the rights
26 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27 # copies of the Software, and to permit persons to whom the Software is
28 # furnished to do so, subject to the following conditions:
30 # The above copyright notice and this permission notice shall be included in
31 # all copies or substantial portions of the Software.
33 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
41 #=================================================================================
42 # Configuration variables
43 #=================================================================================
44 my $user_group = 'games';
45 my $arena_path = "/usr/share/games/arena";
46 my $license = "/usr/share/licenses/arena/license";
47 my $dosbox = "/usr/bin/dosbox";
48 my $dosbox_config = "arena.conf";
49 my $arena_dir = "ARENA";
50 my $license_lock = "terms-accepted";
51 my $passwords_file = "passwords.txt";
53 #=================================================================================
54 # Declarations and description of available functions
55 #=================================================================================
57 # check if terms of use were accepted
64 # returns array of lines
72 # run Arena, requires that terms of use are already accepted
77 # run sound setup utility
82 #=================================================================================
84 #=================================================================================
86 use File
::Copy
qw(copy move);
87 use File
::Find
qw(find);
88 use File
::Path
qw(remove_tree);
89 use File
::Spec
::Functions
qw(catfile);
90 use List
::Util
qw(min max);
92 my $gid = getgrnam($user_group);
96 return ( -e catfile
($arena_path, $license_lock) );
101 my $file = catfile
($arena_path, $license_lock);
102 open(FILE
, ">$file") or die "Cannot create license lock";
105 chown -1, $gid, $file;
110 open(FILE
, "<$license") or die "Cannot open license";
118 my $file = catfile
($arena_path, $passwords_file);
119 open(FILE
, "<$file") or die "Cannot open passwords file";
130 chown -1, $gid, $path;
131 opendir(DIR
, $path) or die "Cannot access target directory";
132 my @files = readdir(DIR
);
134 @files = grep(!/\./, @files);
135 foreach my $file (@files) {
136 my $full = catfile
($path, $file);
141 chown -1, $gid, $full;
148 my ($app, $exit) = @_;
149 terms_accepted
or die "Terms of usage not accepted";
150 my $run = catfile
($arena_path, $arena_dir, $app);
151 ( -e
$run) or die "Cannot find requested application";
152 my $cfg = catfile
($arena_path, $dosbox_config);
153 ( -e
$cfg) or die "Cannot find dosbox config file";
155 system($dosbox." ".$run." -exit -conf ".$cfg);
157 system($dosbox." ".$run." -conf ".$cfg);
159 fix_dirs catfile
($arena_path, $arena_dir);
164 run_dosbox
"ARENA.BAT", 1;
169 run_dosbox
"INSTALL.EXE", 1;
172 #=================================================================================
173 # Command line interface, options parsing
174 #=================================================================================
179 my $opt_force_run_arena=0;
181 my $opt_accept_terms=0;
183 my $opt_show_passwords=0;
185 Getopt
::Long
::Configure
('pass_through');
187 'help' => \
$opt_help,
188 'accept-terms' => \
$opt_accept_terms,
189 'run-arena' => \
$opt_force_run_arena,
190 'run-setup' => \
$opt_run_setup,
191 'show-passwords' => \
$opt_show_passwords,
195 foreach my $arg (@ARGV) {
196 print "Unknown option: $arg\n";
201 #=================================================================================
202 # Command line interface, commands
203 #=================================================================================
208 The Elder Scrolls: Arena launcher
213 available conflicting options:
215 --run-setup run the sound setup utility
216 --run-arena when any option is specified Arena will not be started by
217 launcher. This options forces start of game when all other
219 --show-passwords show the spell costs, answers to copy-protection questions
221 --accept-terms accept Arena terms of use
223 --help display this help message
228 if ($opt_accept_terms) {
233 if ($opt_run_setup) {
238 if ($opt_show_passwords) {
240 foreach (get_passwords
) { print $_ }
243 $opt_run_arena or $opt_force_run_arena or exit;
245 if ( ! terms_accepted
) {
246 foreach (get_terms
) { print $_ }
248 until ($ans =~ /yes|no/) {
249 print "Do you accept the license? (yes/no) ";
251 ($ans =~ /yes|no/) or print "Please answer with \"yes\" or \"no\"\n";
256 print "You should uninstall Arena at once!\n";