home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / plinstal.zip / edit_cfg.pl < prev    next >
Perl Script  |  1997-12-02  |  5KB  |  108 lines

  1. #!perl -p -i0
  2.  
  3. # We expect the following arguments:
  4. #
  5. # privlib    - which file to edit (the directory part - new privlib)
  6.  
  7. BEGIN {
  8.   ($perllib_new) = @ARGV;
  9.   $config_long = 'f:/perllib/lib/os2/5.00455';    # Hardwired during creation
  10.   $config_short = 'f:/perllib/lib';    # Hardwired during creation
  11.   $dirs{shell} = 'F:/BIN';    # Hardwired during creation
  12.   $dirs{privlib} = 'f:/perllib/lib';    # Hardwired during creation
  13.   $dirs{bin} = 'f:/perllib/bin';    # Hardwired during creation
  14.   $dirs{emx} = 'f:/emx';    # Hardwired during creation
  15.   $dirs{man1dir} = 'f:/perllib/man/man1';    # Hardwired during creation
  16.   $dirs{sitelib} = 'f:/perllib/lib/site_perl';    # Hardwired during creation
  17.   $dirs{man3dir} = 'f:/perllib/man/man3';    # Hardwired during creation
  18.   $change_from{scriptdirexp} = 'bin';    # Hardwired during creation
  19.   $change_from{libpth} = 'emx';    # Hardwired during creation
  20.   $change_from{binexp} = 'bin';    # Hardwired during creation
  21.   $change_from{strings} = 'emx';    # Hardwired during creation
  22.   $change_from{sitelib} = 'sitelib';    # Hardwired during creation
  23.   $change_from{man1dir} = 'man1dir';    # Hardwired during creation
  24.   $change_from{installarchlib} = 'privlib';    # Hardwired during creation
  25.   $change_from{man3dir} = 'man3dir';    # Hardwired during creation
  26.   $change_from{emxpath} = 'emx';    # Hardwired during creation
  27.   $change_from{privlib} = 'privlib';    # Hardwired during creation
  28.   $change_from{sitelibexp} = 'sitelib';    # Hardwired during creation
  29.   $change_from{man1direxp} = 'man1dir';    # Hardwired during creation
  30.   $change_from{bin} = 'bin';    # Hardwired during creation
  31.   $change_from{libc} = 'emx';    # Hardwired during creation
  32.   $change_from{man3direxp} = 'man3dir';    # Hardwired during creation
  33.   $change_from{perlpath} = 'bin';    # Hardwired during creation
  34.   $change_from{sitearchexp} = 'sitelib';    # Hardwired during creation
  35.   $change_from{libemx} = 'emx';    # Hardwired during creation
  36.   $change_from{archlibexp} = 'privlib';    # Hardwired during creation
  37.   $change_from{installman1dir} = 'man1dir';    # Hardwired during creation
  38.   $change_from{installsitelib} = 'sitelib';    # Hardwired during creation
  39.   $change_from{privlibexp} = 'privlib';    # Hardwired during creation
  40.   $change_from{installman3dir} = 'man3dir';    # Hardwired during creation
  41.   $change_from{startsh} = 'shell';    # Hardwired during creation
  42.   $change_from{installsitearch} = 'sitelib';    # Hardwired during creation
  43.   $change_from{installscript} = 'bin';    # Hardwired during creation
  44.   $change_from{installprivlib} = 'privlib';    # Hardwired during creation
  45.   $change_from{installbin} = 'bin';    # Hardwired during creation
  46.   $change_from{sitearch} = 'sitelib';    # Hardwired during creation
  47.   $change_from{scriptdir} = 'bin';    # Hardwired during creation
  48.   $change_from{usrinc} = 'emx';    # Hardwired during creation
  49.   $change_from{archlib} = 'privlib';    # Hardwired during creation
  50.   $change_from{timeincl} = 'emx';    # Hardwired during creation
  51.   $change_from{sh} = 'shell';    # Hardwired during creation
  52.   $config_dat = "$perllib_new/config.dat";
  53.   open DAT, $config_dat or die "Cannot open $config_dat: $!";
  54.   while (<DAT>) {
  55.     $newdir{$1} = $2 if /^(\w+)\s+(.*)$/;
  56.   }
  57.   close DAT or die "Cannot close $config_dat: $!";
  58.   for $key (keys %newdir) {
  59.     $newdir{$key} =~ s,\\,/,g;
  60.   }
  61.   $config_rest = substr $config_long, length $config_short;
  62.   $newconfig_long = $perllib_new . $config_rest;
  63.   @ARGV = $newconfig_long . '/Config.pm';
  64.   # Try to find emx location:
  65.   if (exists $ENV{C_INCLUDE_PATH}) {
  66.     for $dir (split ';', $ENV{C_INCLUDE_PATH}) {
  67.       $dir =~ s,\\,/,g ;
  68.       $dir =~ s,/[^/]+/?$,,;
  69.       $emx = $dir, last if -f "$dir/bin/emxrev.cmd";    # Random check.
  70.     }
  71.   }
  72.   unless (defined $emx) {
  73.     for $dir (split ';', $ENV{PATH}) {
  74.       next unless $dir =~ /^[a-z]:\\emx\\bin\\?$/i ;
  75.       $dir =~ s,\\,/,g ;
  76.       $dir =~ s,/[^/]+/?$,,;
  77.       $emx = $dir, last if -f "$dir/bin/emxrev.cmd";    # Random check.
  78.     }
  79.   }
  80.   $newdir{emx} = $emx if defined $emx;
  81. }
  82.  
  83. # Called inside -p loop
  84. if (/^(\w+)='(.*)'$/ and exists $change_from{$1} 
  85.     and exists $newdir{$change_from{$1}}) {
  86.   # Need to substitute
  87.   my ($key, $val, $from, $to) 
  88.     = ($1, $2, $dirs{$change_from{$1}}, $newdir{$change_from{$1}});
  89.   $val =~ s/\Q$from\E/$to/g;        # g for the sake of libs - which is not edited now
  90.   $_ = "$key='$val'\n";
  91. }
  92.  
  93. ## Called inside -p loop
  94. #s{
  95. #  = \'                # start of value
  96. #  # Spaces are not allowed below:
  97. #  \Q$from_name\E        # the leading part of the value - as string.
  98. #  (?=
  99. #   [\'/]            # As whole or before slash, but do not
  100. #                                # substitute this.
  101. #  )
  102. # }
  103. #{=\'$to}xo;
  104.  
  105. ##   = \'                # Copy it.
  106. ##     $to            # Now substitute.
  107. ## }xo ;
  108.