source: trunk/server/common/oursrc/execsys/upd-execsys @ 1134

Last change on this file since 1134 was 944, checked in by geofft, 14 years ago
Add xaml and xap as static files for Silverlight, per [help.mit.edu #788683]
File size: 2.7 KB
Line 
1#!/usr/bin/perl -w
2use strict;
3
4# upd-execsys
5# Copyright (C) 2006  Jeff Arnold <jbarnold@mit.edu>
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License
9# as published by the Free Software Foundation; either version 2
10# of the License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
20#
21# See /COPYRIGHT in this repository for more information.
22
23my @dynamic = qw(
24 pl
25 php
26 py
27 cgi
28 scm
29 exe
30);
31
32my @static = qw(
33 html
34 css
35 gif
36 jpg
37 png
38 htm
39 jpeg
40 js
41 ico
42 xml
43 xsl
44 tiff
45 tif
46 tgz
47 tar
48 jar
49 zip
50 pdf
51 ps
52 doc
53 xls
54 ppt
55 swf
56 mp3
57 mov
58 wmv
59 mpg
60 mpeg
61 avi
62 il
63 JPG
64 xhtml
65 svg
66 xaml
67 xap
68);
69
70my %map;
71open(TYPES, "./mime.types");
72while(my $line = <TYPES>) {
73        next if($line =~ /^\#/ or $line =~ /^\s*$/);
74        my ($type, $exts) = ($line =~ /^(\S*)\s+(.*)$/);
75        next if($exts =~ /^\s*$/);
76       
77        foreach my $ext (split " ", $exts) {
78                $map{$ext} = $type;
79                $map{uc($ext)} = $type;
80        }
81}
82close(TYPES);
83
84undef $/;
85my $regexp = '(.*[\/\#]+\sSTART-AUTOGENERATED:[^!]*!).*\s([\/\#]+\sEND-AUTOGENERATED.*)';
86
87# Read existing binfmt file
88
89open(BINFMT, "./execsys-binfmt.pre");
90my $file = <BINFMT>;
91my ($fstart, $fend) = ($file =~ /$regexp/s);
92close(BINFMT);
93
94# Write new binfmt file
95
96open(BINFMT, ">./execsys-binfmt");
97print BINFMT $fstart, "\n";
98
99foreach my $ext (@dynamic) {
100  my $path = $ENV{"${ext}_path"};
101  print BINFMT "echo \":${ext}:E::${ext}::${path}:\" > /proc/sys/fs/binfmt_misc/register\n" if($path);
102}
103
104#foreach my $ext (@static) {
105#       print BINFMT "echo \":${ext}:E::${ext}::$ENV{syscat_path}:\" > /proc/sys/fs/binfmt_misc/register\n";
106#}
107print BINFMT $fend;
108close(BINFMT);
109
110open(CONF, ">./execsys.conf");
111
112foreach my $ext (@dynamic, @static) {
113        print CONF <<END
114<Files *.$ext>
115        SetHandler cgi-script
116        Options +ExecCGI
117</Files>
118
119END
120}
121close(CONF);
122
123open(CAT, "./static-cat.c.pre");
124$file = <CAT>;
125($fstart, $fend) = ($file =~ /$regexp/s);
126close(CAT);
127
128open(CAT, ">./static-cat.c");
129print CAT $fstart, "\n";
130print CAT '#define NEXTS ', scalar(@static), "\n";
131print CAT "const char *map[2 * NEXTS] = {\n";
132for(my $i = 0; $i < scalar(@static); $i++) {
133        my $comma = ( $i < scalar(@static)-1 ? "," : "" );
134        print CAT "\t\"$static[$i]\", \"$map{$static[$i]}\"$comma\n";
135}
136print CAT "};\n";
137print CAT $fend;
138close(CAT);
Note: See TracBrowser for help on using the repository browser.