+sub patch_config {
+ # Problem: the Config.pm we have in $BUILDROOT\\lib carries the
+ # version number of the Perl we are building, while the Perl
+ # we are running might have some other version. Solution:
+ # temporarily replace the Config.pm with a patched version.
+ #
+ # Reverse patch will be done with this special script
+ my $config_restore_script = "$BUILDROOT\\lib\\symbian_config_restore.pl";
+ # make sure the patch script was not left from previous run
+ unlink $config_restore_script;
+ return unless $CoreBuild;
+ my $V = sprintf "%vd", $^V;
+ # create reverse patch script
+ if (open(RSCRIPT, ">$config_restore_script")) {
+ print RSCRIPT <<__EOF__;
+#!perl -pi.bak
+s:\\Q$V:$R_V_SV:
+__EOF__
+ close RSCRIPT;
+ } else {
+ die "$0: Cannot create $config_restore_script: $!";
+ }
+ # patch the config
+ unlink("$BUILDROOT\\lib\\Config.pm.bak");
+ print "(patching $BUILDROOT\\lib\\Config.pm)\n";
+ system_echo("perl -pi.bak -e \"s:\\Q$R_V_SV:$V:\" $BUILDROOT\\lib\\Config.pm");
+}
+
+sub restore_config {
+ my $config_restore_script = "$BUILDROOT\\lib\\symbian_config_restore.pl";
+ # this function should always return True
+ # because it's commonly used in error handling blocks as
+ # &restore_config and die
+ return 1 unless -f $config_restore_script;
+ unlink("$BUILDROOT\\lib\\Config.pm.bak");
+ print "(restoring $BUILDROOT\\lib\\Config.pm)\n";
+ system_echo("perl -pi.bak $config_restore_script $BUILDROOT\\lib\\Config.pm");
+ unlink "$BUILDROOT\\lib\\Config.pm.bak", $config_restore_script;
+ # above command should always return 2 already,
+ # but i want to be absolutely sure that return value is True
+ return 1;
+}
+