Perl Guru, please help with Britannica

JD xifilsuf at yahoo.com
Mon Jul 3 07:03:53 UTC 2006


Can you modify this perl code please? This perl code is for running 
Britannica 2004 from: http://support.britannica.com/linux/linux.htm and 
I wish to modify it for Britannica 2006 in my HD (not cdrom). It's 
already running on my windows, so that would be nice if Linux can also 
access it. Anyway, there is no problem with fs, because it's under ext2.
Thanks a lot!

perl_code_begin (http://support.britannica.com/linux/linux-launch2.0.pl):

#!/usr/bin/perl -X
#
# Copyright (C) 2004 Encyclopaedia Britannica, Inc.
#
# Perl script to install and run any single disc,
# 2004 Encyclopaedia Britannica product on a modern
# Linux installation. 
#
# This Perl script, including the source code, documentation
# and related data, is placed into the public domain.
#
# The original author is Benjamin Gimpert.
# Modifications by Brian Schultz and Kevin Boers.
#
# THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY
# OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF
# MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE,
# ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE
# RESULTING FROM THE USE, MODIFICATION, OR
# REDISTRIBUTION OF THIS SOFTWARE.
#
# For more information, contact:
#
#     Encyclopaedia Britannica, Inc.
#     Attn: Software Development
#     310 South Michigan Ave
#     Chicago, IL 60604, U.S.A.
#     http://support.britannica.com/
#

#
# KNOWN BUGS
# - many Java VM messages of the form "Font specified in font.properties not
#   found", fixed by replacing your .../jdk/jre/lib/font.properties with:
#       http://java.sun.com/j2se/1.3/font.properties
# - preferences must be edited manually under:
#       ~/britannica/[product]/conf/[user].[product].preferences.properties
# - on the first .show(), marketing dialogs are too small
#

print "Enter location of the Britannica Software (/mnt/cdrom):";
my $input = <STDIN>;
chomp ($input);
if ($input)
	{
	$BCDDIR = $input;
	}
else 
	{
	$BCDDIR = ("/mnt/cdrom");
	}

my %PRODUCTS = (
    'Children\'s Edition CD', 'BcdChildApp.jar',
    'Concise CD', 'BcdConciseApp.jar',
    'Britannica Deluxe Edition 2004', 'BcdDeluxe.jar',
    'Homework Essential', 'BcdKids.jar',
    'Ready Reference CD', 'BcdReadyRefApp.jar',
    'Britannica Standard Edition 2004', 'BcdStandard.jar',
    'Homework Essential Plus', 'BcdStudent.jar',
    'Ultimate Reference Suite', 'URSApp.jar',
    'Ultimate Reference Suite CD-ROM', 'URSCDApp.jar',
);

my $start_dir = `pwd`;
chomp($start_dir);
#eval <<'EOF_CHDIR_EVAL';
print "Changing to home directory...";
chdir or die "\n  failed";
print " done\n";
if (! (-e 'britannica')) {
    print "Making work directory ~/britannica/...";
    mkdir('britannica') or die "\n  failed";
    print " done\n";
}
print "Changing to work directory...";
chdir('britannica') or die "\n  failed";
print " done\n";

print "Searching for product JAR...";
my $product = '';
open (AUTORUN_INF, "< $BCDDIR/autorun.inf") or die "\n  failed";
while (<AUTORUN_INF>) {
    chomp;
    $product = $1 if (/^value=([^\n\r]*)/);
}
close (AUTORUN_INF) or die "\n  failed";
my $product_jar = $PRODUCTS{$product};
die "\n  failed" if ($product_jar eq '');
print " found \"$product_jar\"\n";

print "Searching for default preferences file name in product JAR...";
`$ENV{JAVA_HOME}/bin/jar tf $BCDDIR/jars/$product_jar` =~ /^(\w+)\.preferences\.properties\.default/m;
my $product_id = $1;
my $default_preferences_file = $product_id . '.preferences.properties.default';
print " found \"$default_preferences_file\"\n";

if (! (-e $product_id)) {
    print "Making a work directory for this product...";
    mkdir($product_id) or die "\n  failed";
    print " done\n";
}
print "Changing to work directory for this product...";
chdir($product_id) or die "\n failed";
print " done\n";

print "Checking for version 1.3 of the Java VM...";
die "\n  failed" if (! (-e $ENV{JAVA_HOME}));
my $java_version_string = `$ENV{JAVA_HOME}/bin/java -version 2>&1`;
$java_version_string =~ /java version \"([0-9\._]+)\"/;
my $java_version = $1;
die "\n  failed, found \"$java_version\"" if (! ($java_version =~ /^1\.3/));
print " found \"$java_version\"\n";
                                                                                  
print "Constructing launch CLASSPATH...";
my $classpath = '';
my @jars = <$BCDDIR/jars/*.jar>;
if (scalar(@jars) > 0) {
    $classpath = ".";
    foreach $jar (@jars) {
      $classpath .= ":$jar";
    }
}
$classpath .= ":$BCDDIR/imagefiles/";
print " done\n";
                                                                                  
print "Constructing system properties for the Java VM command line...";
my $options = '';
$options .= '-Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser';
$options .= ' -Djava.protocol.handler.pkgs=com.britannica.net\|org.apache.naming.resources';
$options .= ' -Dcom.britannica.configurator.configuratorPropFile=britannica.ini';
$options .= ' -Dcom.britannica.lucene.search.searchPropFile=britannica.ini';
$options .= ' -Djdbc.drivers=com.britannica.cd.db.AxionCDConnectionDriver:oracle.jdbc.driver.OracleDriver:org.apache.commons.dbcp.PoolingDriver:com.britannica.db.proxy.ConnectionProxyDriver:org.axiondb.jdbc.AxionDriver';
$options .= ' -Dorg.axiondb.engine.TransactionManagerImpl.NEVER_APPLY=true';
$options .= ' -Djava.class.path=' . $classpath;
print " done\n";

if (! (-e 'britannica.ini')) {
    print "Extracting the application configuration file from product JAR...";
    `$ENV{JAVA_HOME}/bin/jar xf $BCDDIR/jars/$product_jar britannica.ini`; die "\n  failed: $!" if $?;
    print " done\n";

    print "Altering the application configuration file with local settings...";
    my $britannica_ini = '';
    open (BRITANNICA_INI_FILE, "< britannica.ini") or die "\n  failed";
    while (<BRITANNICA_INI_FILE>) {
      $britannica_ini .= $_;
    }
    close (BRITANNICA_INI_FILE) or die "\n  failed";

    # regexp's to modify britannica.ini here:
    $britannica_ini =~ s/^LOCAL=.*/LOCAL=\./m;
    $britannica_ini =~ s/^BCDDEV=.*/BCDDEV=$BCDDIR/m;

    open (BRITANNICA_INI_FILE, "> britannica.ini") or die "\n  failed";
    print BRITANNICA_INI_FILE $britannica_ini;
    close (BRITANNICA_INI_FILE) or die "\n  failed";
    print " done\n";
}

if (! (-e 'index/')) {
    print "Unzipping index archive in the local filesystem...";
    `unzip $BCDDIR/index.zip`; die "\n  failed: $!" if $?;
    print " done\n";
}

if (! (-e 'data/')) {
    print "Making data directory in the local filesystem...";
    mkdir('data') or die "\n  failed";
    print " done\nUnzipping autocomplete archive in the data directory...";
    `unzip $BCDDIR/autocomplete.zip -d data`; die "\n  failed: $!" if $?;
    print " done\nCopying local databases to the data directory (slow!)...";
    `cp -R $BCDDIR/data/* data`; die "\n failed: $!" if $?;
    print " done\n";
}

if (! (-e 'conf/')) {
    print "Making preferences directory in the local filesystem...";
    mkdir('conf') or die "\n  failed";
    print " done\n";
}

if (! (-e 'conf/' . $default_preferences_file)) {
    print "Extracting the default preferences file from product JAR...";
    `$ENV{JAVA_HOME}/bin/jar xf $BCDDIR/jars/$product_jar $default_preferences_file`; die "\n  failed: $!" if $?;
    print " done\nMoving default preferences file to the preferences directory...";
    `mv $default_preferences_file conf/`; die "\n  failed: $!" if $?;
    print " done\n";
}

my $command = "java $options com.britannica.cd.AppMain";
print "Launching the Java VM...\n";
system($command);
#EOF_CHDIR_EVAL
print "Changing back to startup directory...";
chdir($start_dir) or die "\n  failed";
print " done\n";


----perl_code_end.









More information about the ubuntu-users mailing list