Re: CVS GNOME



   From: "Chris Jones" <chris@black-sun.co.uk>
   Date: Mon, 23 Aug 1999 13:33:18 +0100

   I'm beginning to wish I had installed GNOME from source so I could
   have specified where it should live. It does seem to be spread fairly
   randomly over the system. I should probably remove the RPMs, nuke
   anything related to GNOME and re-install the whole lot, but I don't
   really want to disrupt my system for that long.

I do have the RPM's installed (SuSE 6.1), but since updates aren't
coming out very frequently, I wrote a script to suck down the .tgz
files and build and install them.  The script is enclosed at the
bottom.  It's very much a work in progress, and obviously rather
rough.  Most of the packages build just fine, but there are a few
exceptions (packages that don't follow the <name>-<version>.tar.gz
reasonably closely, those that don't have either a configure script or
a normal makefile, and such -- it isn't many).  It's also sensitive to
inconsistencies on the ftp site (e. g. on gnomeftp.wgn.net the
freetype stuff isn't hooked up right).

Basically, what it does is combine everything it can extract from the
build-from-source page on the Gnome site with everything it finds on
gnomeftp.wgn.net (the mirror I prefer), and picks the latest version
of each.  It then runs configure, make, and make install on each
package.  It keeps a permanent record of everything it has managed to
download and build, so it doesn't repeat things that it doesn't need
to.

It doesn't really handle dependencies very well (i. e. at all,
although there's some very skeletal code in there).  But it did manage
to update my system, albeit with a few glitches.


#!/usr/bin/perl
# Copyright 1999 Robert Krawitz <rlk@alum.mit.edu>
# This program is licensed under the GNU Public License.  See
# www.gnu.org for details.


$sourcedir="/src/Packages/GNOME-src";
$builddir="/mnt1/sandbox";
$instdir="/mnt1/gnome";
@gnomeurls=qw(ftp://gnomeftp.wgn.net/pub/gnome/sources/latest/
	      http://www.gnome.org/start/gnometar.phtml
	      ftp://gnomeftp.wgn.net/pub/gnome/sources/latest/
	      );



$logfile="$sourcedir/build.log";
$tmplogfile="$sourcedir/build.log.tmp";

$ftppattern='<a\s+href="(ftp:\/\/[^\/]+\/[^">]+\.t(ar\.)?gz)">';
$pathpattern='^.*\/(([^\/]+[^\/[\-\/0-9.])(-|([0-9]*\.))(([a-z_0-9]+\.)*[a-z_0-9]+))\.t(ar\.)?gz';
$localfilepattern='.*\/([^\/]+)';

# Assume that if any mandatory component needs to be rebuilt that
# everything following it must be.  For optional components, don't assume
# that.  Maybe what we'll do in the future is keep the sandboxes around
# and just let make do its thing.

$globalforcedrebuild = 0;

@ordering=qw(freetype
	     audiofile
	     esound
	     gsl
	     guile
	     glib
	     gtk+
	     imlib
	     gtk-engines
	     fnlib
	     ORBit
	     gnome-libs
	     libgtop
	     libxml
	     libghttp
	     gnome-objc
	     gnome-python
	     control-center
	     enlightenment-conf
	     gnome-core
	     users-guide
	     mc);

%files = ();
%built = ();

sub get_filelist {
    %files = ();
    foreach $gnomeurl(@gnomeurls) {
	open GNOMEURL, "wget -q -O - $gnomeurl |" or
	    die "Cannot get list of files\n";
	while (<GNOMEURL>) {
	    if (/$ftppattern/) {
		$path=$1;
		$path =~ /$pathpattern/i;
		$filebase = $2;
		$version = "$4$5";
		if (! defined($versions{$filebase}) ||
		    $version ge $versions{$filebase}) {
		    $versions{$filebase} = $version;
		    $files{$filebase} = $path;
		    if (defined $built{$filebase}) {
			my($version, $url, $downloaded, $built) = @{$built{$filebase}}[0..3];
			$built{$filebase} = [ ($version, $path, $downloaded, $built) ];
		    }
		}
	    }
	}
	close GNOMEURL;
    }
}

#    $filename = "$2$3$5";
#    $filebase = $2;

sub read_logfile {
    open LOGFILE, $logfile or return;
    while (<LOGFILE>) {
	chomp;
	($component, $version, $url, $downloaded, $built) = split;
	$built{$component} = [ ($version, $url, $downloaded, $built) ];
    }
    close LOGFILE;
}

sub write_logfile {
    open OUTFILE, ">$tmplogfile" or die "Can't create build log: $!\n";
    foreach $component(keys %built) {
	my($version, $url, $downloaded, $built) = @{$built{$component}}[0..3];
	print OUTFILE "$component $version $url $downloaded $built\n" or
	    die "Can't write to build log: $!\n";
    }
    close OUTFILE or die "Can't close build log: $!\n";
    rename $tmplogfile, $logfile or die "Can't rename temporary log file: $!\n";
}

sub build {
    my ($component) = @_;
    chdir $builddir or die "Can't chdir $builddir: $!\n";
    my($version, $url, $downloaded, $built) = @{$built{$component}}[0..3];
    $url =~ /$localfilepattern/;
    my($filename) = $1;
    my($localfile) = "$sourcedir/$filename";
    my($dirname) = $1;
    $dirname =~ s/\.t(ar\.)?gz$//;
    if ($built ne "yes" || ! -d "$builddir/$dirname") {
	if (-d "$builddir/$dirname") {
	    system("chmod -R u+w $builddir/$dirname 2>/dev/null");
	}
	if (system("tar xzf $localfile")) {
	    warn "Cannot unpack $localfile\n";
	    return 0;
	}
	if (! chdir "$builddir/$dirname") {
	    warn "Can't chdir $builddir/$dirname: $!\n";
	    return 0;
	}
	$ENV{"CFLAGS"} = "-O2";
	if (-f "./configure" && system("./configure --prefix='$instdir' --with-glib-prefix='$instdir' --with-gtk-prefix='$instdir' --with-gnome='$instdir'")) {
	    warn "Cannot configure $dirname\n";
	    return 0;
	}
	if (system("make")) {
	    warn "Cannot build $dirname\n";
	    return 0;
	}
	if (system("make install")) {
	    warn "Cannot install $dirname\n";
	    return 0;
	}
	$built{$component} = [ ($version, $url, $downloaded, "yes") ];
	write_logfile;
    }
    return 1;
}

sub download {
    my($component) = @_;
    my($version, $url, $downloaded, $built) = @{$built{$component}}[0..3];
    $url =~ /$localfilepattern/;
    my($localfile) = $1;
    if ($downloaded ne "yes" || ! -f "$sourcedir/$localfile") {
	my($getcommand) = "wget -q -O $sourcedir/$localfile $url";
	print "Will get file by $getcommand\n";
	if (system($getcommand) != 0) {
	    print "Failed to retrieve $component";
	    return 0;
	}
	$built{$component} = [ ($version, $url, "yes", "no") ];
	write_logfile;
    }
    return 1;
}

sub get_and_build_one_component {
    my($component, $mandatory) = @_;
    if (! defined $built{$component}) {
	print "Do not yet have $component\n";
	$built{$component} = [ ($versions{$component}, $files{$component}, "no", "no") ];
	write_logfile;
    } else {
	my($version, $url, $downloaded, $built) = @{$built{$component}}[0..3];
	if ($version ne $versions{$component}) {
	    print "Updating version from $version to $versions{$component}\n";
	    $built{$component} = [ ($versions{$component}, $files{$component}, "no", "no") ];
	    write_logfile;
	}
    }
    my($version, $url, $downloaded, $built) = @{$built{$component}}[0..3];
    print "Version of $component is $version\n";
    if (! &download($component)) {
	print "Cannot download $component from $url\n";
	return 0;
    }
    if (! &build($component, $mandatory)) {
	print "Cannot build $component\n";
	return 0;
    }
    return 1;
}

sub do_build_everything {
    my(%tfiles) = %files;
    my($component);
    if (defined $ENV{"LD_LIBRARY_PATH"}) {
	my($libpath) = $ENV{"LD_LIBRARY_PATH"};
	$ENV{"LD_LIBRARY_PATH"} = "$instdir/lib:$libpath";
    } else {
	$ENV{"LD_LIBRARY_PATH"} = "$instdir/lib";
    }
    my($path) = $ENV{"PATH"};
    $ENV{"PATH"} = "$instdir/bin:$path";
    foreach $component(@ordering) {
	if (defined $tfiles{$component}) {
#	    print "Get and build mandatory ", $component, " version ", $versions{$component}, " from ", $files{$component}, "\n";
	    if (! &get_and_build_one_component($component, 1)) {
		warn "Cannot complete Gnome build\n";
	    }
	    delete $tfiles{$component};
	} else {
	    die "Cannot find $component\n";
	}
    }

    foreach $component(keys %tfiles) {
	if (defined $tfiles{$component}) {
#	    print "Get and build optional ", $component, " version ", $versions{$component}, " from ", $tfiles{$component}, "\n";
	    if (! &get_and_build_one_component($component, 0)) {
		warn "Gnome build will continue\n";
	    }
	}
    }
}

read_logfile;
chdir $sourcedir or die "Can't chdir to $sourcedir: $!\n";
get_filelist;
write_logfile;
do_build_everything;

-- 
Robert Krawitz <rlk@alum.mit.edu>      http://www.tiac.net/users/rlk/

Tall Clubs International  --  http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail lpf@uunet.uu.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]