From: Ben Pfaff Date: Wed, 17 Feb 2010 18:21:06 +0000 (-0800) Subject: Work on not forcing build-pspp to be invoked from its own directory. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90ef37bd9c3b35a462364e14a087ae507ff10834;p=pspp Work on not forcing build-pspp to be invoked from its own directory. not tested --- diff --git a/build-pspp b/build-pspp index d4ce1f8b16..d8e4a794cb 100755 --- a/build-pspp +++ b/build-pspp @@ -1,6 +1,7 @@ #! /usr/bin/env perl use Cwd; +use File::Basename; use File::Spec; use Getopt::Long qw(:config bundling no_ignore_case); use IO::Handle; @@ -25,25 +26,33 @@ usage () if $help; die "$0: exactly one or two nonoption arguments are required\n" if @ARGV != 1 && @ARGV != 2; +my $tarball; +if (@ARGV == 1) { + $tarball = File::Spec->rel2abs ($ARGV[0]); +} else { + # Tarball will be generated later. +} + # Select build number. if (!defined ($build_number)) { $build_number = POSIX::strftime("%Y%m%d%H%M%S", localtime); } -my $topdir = getcwd (); +my $topdir = dirname ($0); +$topdir = cwd () . "/$topdir" if $topdir !~ m%^/%; # Create build directory. if (!defined ($builddir)) { $builddir = "builds/$build_number"; mkdir "builds" or die "builds: mkdir: $!\n" if ! -d "builds"; } +$builddir = File::Spec->rel2abs ($builddir); -d $builddir or mkdir $builddir or die "$builddir: mkdir: $!\n"; -my $abs_builddir = File::Spec->rel2abs ($builddir); +chdir ($builddir) or die "$builddir: chdir: $!\n"; our $resultsdir = "$builddir/results"; mkdir $resultsdir or die "$resultsdir: mkdir: $!\n"; mkdir "$resultsdir/vars" or die "$resultsdir/vars: mkdir: $!\n"; -my $abs_resultsdir = File::Spec->rel2abs ($resultsdir); my $varsfile = "$resultsdir/VARS"; open (VARS, '>', $varsfile) or die "creating $varsfile failed: $!\n"; @@ -106,27 +115,28 @@ sub save_result_if_exists { } } -my $tarball; +my $GIT = "git --git-dir=$topdir/.git"; + if (@ARGV == 2) { my ($repo, $branch) = @ARGV; # Fetch branch start_step ("Fetch $repo, branch $branch"); - run ("git fetch $repo +$branch:refs/builds/$build_number/pspp"); + run ("$GIT fetch $repo +$branch:refs/builds/$build_number/pspp"); # Get revision number. - my $revision = `git rev-parse refs/builds/$build_number/pspp`; + my $revision = `$GIT rev-parse refs/builds/$build_number/pspp`; chomp $revision; set_var ("pspp_commit", $revision); my $abbrev_commit = substr ($revision, 0, 6); # Extract source. start_step ("Extract branch into source directory"); - run ("git archive --format=tar --prefix=pspp$build_number/ refs/builds/$build_number/pspp | (cd $builddir && tar xf -)"); + run ("$GIT archive --format=tar --prefix=pspp$build_number/ refs/builds/$build_number/pspp | tar xf -"); # Extract version number. start_step ("Extract repository version number"); - my $trace = `cd $builddir/pspp$build_number && autoconf -t AC_INIT`; + my $trace = `cd pspp$build_number && autoconf -t AC_INIT`; chomp $trace; my ($file, $line, $macro, $package, $repo_version, @rest) = split (':', $trace); @@ -134,7 +144,7 @@ if (@ARGV == 2) { # Is this a "gnits" mode tree? start_step ("Checking Automake mode"); - open (MAKEFILE_AM, '<', "$builddir/pspp$build_number/Makefile.am"); + open (MAKEFILE_AM, '<', "pspp$build_number/Makefile.am"); my $am_mode = "gnu"; while () { if (/gnits/) { @@ -156,7 +166,7 @@ if (@ARGV == 2) { # Append -g012345 to configure.ac version number. start_step ("Updating version number in $file"); - my $fullname = "$builddir/pspp$build_number/$file"; + my $fullname = "pspp$build_number/$file"; open (OLDFILE, '<', $fullname) or die "opening $fullname failed: $!\n"; open (NEWFILE, '>', "$fullname.new") @@ -178,7 +188,7 @@ if (@ARGV == 2) { # Get Gnulib commit number. start_step ("Reading README.Git to find Gnulib commit number"); my $gnulib_commit; - $fullname = "$builddir/pspp$build_number/README.Git"; + $fullname = "pspp$build_number/README.Git"; open (README_GIT, '<', $fullname) or die "opening $fullname failed: $!\n"; while () { @@ -190,7 +200,7 @@ if (@ARGV == 2) { # Add note to beginning of NEWS (otherwise "make dist" fails). start_step ("Updating NEWS"); - $fullname = "$builddir/pspp$build_number/NEWS"; + $fullname = "pspp$build_number/NEWS"; open (OLDFILE, '<', $fullname) or die "opening $fullname failed: $!\n"; open (NEWFILE, '>', "$fullname.new") @@ -217,43 +227,41 @@ EOF or die "rename $fullname.new to $fullname failed: $!\n"; # If we don't already have that Gnulib commit, update Gnulib. - system ("git rev-parse --verify --quiet $gnulib_commit"); + system ("$GIT rev-parse --verify --quiet $gnulib_commit"); if ($? != 0) { start_step ("Updating Gnulib to obtain commit"); - run ("git fetch gnulib"); + run ("$GIT fetch gnulib"); } - run ("git update-ref refs/builds/$build_number/gnulib $gnulib_commit"); + run ("$GIT update-ref refs/builds/$build_number/gnulib $gnulib_commit"); # Extract gnulib source. start_step ("Extract Gnulib source"); - run ("git archive --format=tar --prefix=gnulib/ $gnulib_commit | (cd $builddir && tar xf -)"); + run ("$GIT archive --format=tar --prefix=gnulib/ $gnulib_commit | tar xf -"); # Bootstrap. start_step ("Bootstrap (make -f Smake)"); - run ("cd $builddir/pspp$build_number && make -f Smake", "bootstrap"); + run ("cd pspp$build_number && make -f Smake", "bootstrap"); # Configure. start_step ("Configure source"); - run ("cd $builddir/pspp$build_number && mkdir _build && cd _build && ../configure", "configure"); + run ("cd pspp$build_number && mkdir _build && cd _build && ../configure", "configure"); # Distribute. start_step ("Make source tarball"); - run ("cd $builddir/pspp$build_number/_build && make dist", "dist"); + run ("cd pspp$build_number/_build && make dist", "dist"); my $tarname = "pspp-$version.tar.gz"; - $tarball = save_result ("source distribution", "$builddir/pspp$build_number/_build/$tarname", 1); + $tarball = save_result ("source distribution", "pspp$build_number/_build/$tarname", 1); # Build user manual start_step ("Build user manual"); - run ("cd $builddir/pspp$build_number && cp _build/doc/*.texi doc/"); - run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp.texinfo -o $abs_resultsdir/user-manual --email bug-gnu-pspp\@gnu.org pspp \"GNU PSPP User Manual\"", "user-manual"); + run ("cd pspp$build_number && cp _build/doc/*.texi doc/"); + run ("cd pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp.texinfo -o $resultsdir/user-manual --email bug-gnu-pspp\@gnu.org pspp \"GNU PSPP User Manual\"", "user-manual"); saved_result ("User Manual", "user-manual"); # Build developer's guide start_step ("Build developers guide"); - run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp-dev.texinfo -o $abs_resultsdir/dev-guide --email bug-gnu-pspp\@gnu.org pspp-dev \"GNU PSPP Developers Guide\"", "dev-guide"); + run ("cd pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp-dev.texinfo -o $resultsdir/dev-guide --email bug-gnu-pspp\@gnu.org pspp-dev \"GNU PSPP Developers Guide\"", "dev-guide"); saved_result ("Developers Guide", "dev-guide"); -} else { - $tarball = $ARGV[0]; } if ($build_binary) { @@ -415,5 +423,5 @@ sub write_timing { } sub fail { - die "Build failed, refer to:\n\t$topdir/$logfile\nfor details.\n"; + die "Build failed, refer to:\n\t$logfile\nfor details.\n"; }