Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-updates-src > by-pkgid > 080db94901af40d7e638c4e1885a075f > files > 11

iceape-2.38-1.mga5.src.rpm

#!/usr/bin/perl

use File::Path;
use File::Copy;
use File::Glob ":glob";
use POSIX ":sys_wait_h";

$timeout = 60;

$ENV{HOME}="/root" if !defined $ENV{HOME};
$ENV{TMP}="/tmp"; 
$ENV{MOZILLA_FIVE_HOME}="LIBDIR/iceape-ICEAPE_VERSION";
$ENV{LD_LIBRARY_PATH}="LIBDIR/iceape-ICEAPE_VERSION";
$ENV{MOZ_DISABLE_GNOME}="1";

umask 022;

if ( -f "LIBDIR/iceape-ICEAPE_VERSION/regxpcom" )
{
    # remove all of the old files
    rmtree("LIBDIR/iceape-ICEAPE_VERSION/chrome/overlayinfo");
    unlink <LIBDIR/iceape-ICEAPE_VERSION/chrome/*.rdf>;
    unlink("LIBDIR/iceape-ICEAPE_VERSION/component.reg");
    unlink("LIBDIR/iceape-ICEAPE_VERSION/components/compreg.dat");
    unlink("LIBDIR/iceape-ICEAPE_VERSION/components/xpti.dat");

    # create a new clean path
    mkpath("LIBDIR/iceape-ICEAPE_VERSION/chrome/overlayinfo");

    # rebuild the installed-chrome.txt file from the installed
    # languages
    if ( -f "LIBDIR/iceape-ICEAPE_VERSION/chrome/lang/installed-chrome.txt" ) {
	rebuild_lang_files();
    }

    # run regxpcom
    $pid = fork();

    # I am the child.
    if ($pid == 0) {
	exec("LIBDIR/iceape-ICEAPE_VERSION/regxpcom > /dev/null 2> /dev/null");
    }
    # I am the parent.
    else {
	my $timepassed = 0;
	do {
	    $kid = waitpid($pid, &WNOHANG);
	    sleep(1);
	    $timepassed++;
        } until $kid == -1 || $timepassed > $timeout;

	# should we kill?
	if ($timepassed > $timeout) {
	    kill (9, $pid);
	    # kill -9 can leave threads hanging around
	    system("/usr/bin/killall -9 regxpcom");
	}
    }

    # and run regchrome for good measure
    $pid = fork();

    # I am the child.
    if ($pid == 0) {
	exec("LIBDIR/iceape-ICEAPE_VERSION/regchrome > /dev/null 2> /dev/null");
    }
    # I am the parent.
    else {
	my $timepassed = 0;
	do {
	    $kid = waitpid($pid, &WNOHANG);
	    sleep(1);
	    $timepassed++;
        } until $kid == -1 || $timepassed > $timeout;

	# should we kill?
	if ($timepassed > $timeout) {
	    kill (9, $pid);
	    # kill -9 can leave threads hanging around
	    system("/usr/bin/killall -9 regchrome");
	}
    }

}


sub rebuild_lang_files {
    unlink("LIBDIR/iceape-ICEAPE_VERSION/chrome/installed-chrome.txt");

    open (OUTPUT, "+>", "LIBDIR/iceape-ICEAPE_VERSION/chrome/installed-chrome.txt")||
	die("Failed to open installed-chrome.txt: $!\n");

    copy("LIBDIR/iceape-ICEAPE_VERSION/chrome/lang/installed-chrome.txt",
	 \*OUTPUT);

    foreach (bsd_glob("LIBDIR/iceape-ICEAPE_VERSION/chrome/lang/lang-*.txt")) {
	copy($_, \*OUTPUT);
    }

    copy("LIBDIR/iceape-ICEAPE_VERSION/chrome/lang/default.txt",
	 \*OUTPUT);
}