bug-coreutils
[Top][All Lists]
Advanced

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

Re: Patch to check for required programs when building from source check


From: Pádraig Brady
Subject: Re: Patch to check for required programs when building from source checkout
Date: Wed, 22 Oct 2008 11:03:35 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Eric Blake wrote:
> According to Pádraig Brady on 10/21/2008 4:04 PM:
>>     echo "$ver" | sed '
>>       s/^\([0-9]\{,\}\)\.\([0-9]\{,\}\)[.0]*$/\1.\2.0/;         #1.10  -> 
>> 1.10.0
>>       s/^\([0-9]\{,\}\)\.\([0-9]\{,\}\)\([a-z]\)/\1.\2.99\3/;   #1.10a -> 
>> 1.10.99a
> 
> For what it's worth, Autoconf does this by converting \([0-9]+\)\([a-z]+\)
> to \1+1, -1, radix36(\2).  In other words, 1.10a becomes 1.11.-1.10.
> 
> - From there, it is a simple numerical comparison, supplying a 0 for any
> implicit field, and declaring results at the left-most field that differs:
>  1.10.x < 1.11.-1.x, but 1.11.-1 < 1.11.0
> 
> Hmm.  Since bootstrap requires the existence of autoconf, why not just use
> autoconf, instead of reimplementing this in sed?
> 
> echo 'm4_divert(0)m4_version_compare('$ver,$prereq')' \
>   | autom4te --language=m4sugar -
> 
> outputs -1 if $ver is smaller, 0 if equal, 1 if greater than $prereq.

Cool tip, thanks!

There's a bit of a chicken and egg scenario here though :)
bootstrap does call autoconf but it doesn't explicitly depend on it.
Also if I use the above then I need to special case autoconf checking
which further complicates things. So leaving as is for now,
but I'll think more about it. If we want to be fully compatible
with old version format checking, then I agree we should not use sed,
and use something like:

#-1 if $ver1 < $ver2
# 0 if $ver1 = $ver2
# 1 if $ver1 > $ver2
#-2 on error
version_compare() {
  ver1="$1"
  ver2="$2"

  echo "m4_divert(0)m4_version_compare($ver1,$ver2)" |
  autom4te --language=m4sugar - 2>/dev/null || echo -2
}

latest version is attached
(minor tweaks compared to previous).

cheers,
Pádraig.

>From b9e5fe8076e7a55f152e5ffbd841310ba4994838 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?P=C3=A1draig=20Brady?= <address@hidden>
Date: Tue, 21 Oct 2008 22:40:12 +0100
Subject: [PATCH] Add better checks and docs for build tools

Prompted by a report from Ed Avis:
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14710>

* README-hacking: Organise LZMA and Valgrind as
as optional requirements rather than in their own sections.
Mention bootstrap will now check tool versions.
* README-prereq: Make a start on specific instructions
for optaining build tools. Currently we just have notes
for Fedora linux.
* bootstrap.conf: Add the list of tools and versions required.
* bootstrap: Add the logic to check for the required tools,
and list all required tools and versions if any are missing.
---
 README-hacking |   35 +++++++++++++---------
 README-prereq  |   30 +++++++++++++++++++
 bootstrap      |   86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 bootstrap.conf |   17 +++++++++++
 4 files changed, 154 insertions(+), 14 deletions(-)
 create mode 100644 README-prereq

diff --git a/README-hacking b/README-hacking
index 2e3c83a..f51bb01 100644
--- a/README-hacking
+++ b/README-hacking
@@ -8,8 +8,8 @@ These requirements do not apply when building from a 
distribution tarball.
 We've opted to keep only the highest-level sources in the GIT repository.
 This eases our maintenance burden, (fewer merges etc.), but imposes more
 requirements on anyone wishing to build from the just-checked-out sources.
-For example, you have to use the latest stable versions of the maintainer
-tools we depend upon, including:
+Specific tools and versions will be checked for and listed by the
+bootstrap script shown below, and will include:
 
 - Automake <http://www.gnu.org/software/automake/>
 - Autoconf <http://www.gnu.org/software/autoconf/>
@@ -22,13 +22,15 @@ tools we depend upon, including:
 - Rsync <http://samba.anu.edu.au/rsync/>
 - Tar <http://www.gnu.org/software/tar/>
 
-Valgrind <http://valgrind.org/> is also highly recommended, if
-Valgrind supports your architecture.
-
 Only building the initial full source tree will be a bit painful.
 Later, a plain `git pull && make' should be sufficient.
 
-* LZMA
+- Valgrind
+
+Valgrind <http://valgrind.org/> is also highly recommended, if
+Valgrind supports your architecture. See also README-valgrind.
+
+- LZMA
 
 This package's build procedure uses LZMA to create a compressed
 distribution tarball.  Using this feature of Automake requires
@@ -40,23 +42,24 @@ from <http://tukaani.org/lzma/>.
 
 You can get a copy of the source repository like this:
 
-       $ git clone git://git.sv.gnu.org/coreutils
+        $ git clone git://git.sv.gnu.org/coreutils
+        $ cd coreutils
 
-The next step is to get other files needed to build, which are
-extracted from other source packages:
+The next step is to get and check other files needed to build,
+which are extracted from other source packages:
 
-       $ ./bootstrap
+        $ ./bootstrap
 
 And there you are!  Just
 
-       $ ./configure
-       $ make
-       $ make check
+        $ ./configure
+        $ make
+        $ make check
 
 At this point, there should be no difference between your local copy,
 and the GIT master copy:
 
-       $ git diff
+        $ git diff
 
 should output no difference.
 
@@ -78,3 +81,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Local Variables:
+indent-tabs-mode: nil
+End:
diff --git a/README-prereq b/README-prereq
new file mode 100644
index 0000000..7456114
--- /dev/null
+++ b/README-prereq
@@ -0,0 +1,30 @@
+Detailed below are concrete examples for
+getting the prerequisites for particular systems.
+
+- linux - fedora
+
+  This shows the steps for getting the required tools to build coreutils 7.0
+  on a Fedora 8 system. We try to use official packages where possible.
+  The 3 methods described for making these required packages available, should
+  help clarify build requirements on any linux system at least.
+
+  1. Make sure offical distro git package is installed
+    # yum install git
+
+  2. The distro autoconf is too old, but there is a newer one available
+  so we rebuild that and make it available to the full system:
+    # yum install emacs #autoconf build requires emacs (20MB)
+    # rpmbuild --rebuild 
http://download.fedora.redhat.com/pub/fedora/linux/development/source/SRPMS/autoconf-2.63-1.fc10.src.rpm
+    # rpm -Uvh /usr/src/redhat/RPMS/noarch/autoconf-2.63-1.fc8.noarch.rpm
+  Apply the same method to install the lzma package.
+
+  3. The latest released automake (1.10.1) was not new enough, so we download
+  and build automake-1.10a from its repository and make it available
+  just to coreutils:
+    # yum install help2man #required to build automake fully
+    $ git clone git://git.sv.gnu.org/automake.git
+    $ cd automake && ./configure --prefix=$HOME/coreutils/deps
+    $ make install
+
+  Now we can build coreutils as described in README-hacking
+  as long as $PATH starts with $HOME/coreutils/deps
diff --git a/bootstrap b/bootstrap
index 0895eb7..5ba4525 100755
--- a/bootstrap
+++ b/bootstrap
@@ -222,6 +222,92 @@ if test ! -d $build_aux; then
   done
 fi
 
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+sort_ver() { #sort -V is not generally available
+  ver1="$1"
+  ver2="$2"
+
+  #split on '.' and compare each component
+  i=1
+  while : ; do
+    p1=$(echo "$ver1" | cut -d. -f$i)
+    p2=$(echo "$ver2" | cut -d. -f$i)
+    if [ ! "$p1" ]; then
+      echo "$1 $2"
+      break
+    elif [ ! "$p2" ]; then
+      echo "$2 $1"
+      break
+    elif [ ! "$p1" = "$p2" ]; then
+      if [ "$p1" -gt "$p2" ] 2>/dev/null; then #numeric comparision
+        echo "$2 $1"
+      elif [ "$p2" -gt "$p1" ] 2>/dev/null; then #numeric comparision
+        echo "$1 $2"
+      else #numeric, then lexographic comparison
+        lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
+        if [ "$lp" = "$p2" ]; then
+          echo "$1 $2"
+        else
+          echo "$2 $1"
+        fi
+      fi
+      break
+    fi
+    i=$(($i+1))
+  done
+}
+
+get_version() {
+  app=$1
+
+  $app --version >/dev/null 2>&1 || return 1
+
+  $app --version |
+  sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]\{,\}\).*/\1/p;T;q'
+}
+
+check_versions() {
+  ret=0
+
+  while read app req_ver; do
+    inst_ver=$(get_version $app)
+    if [ ! "$inst_ver" ]; then
+      echo "Error: '$app' not found" >&2
+      ret=1
+    elif [ ! "$req_ver" = "-" ]; then
+      latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
+      if [ ! "$latest_ver" = "$inst_ver" ]; then
+        echo "Error: '$app' version == $inst_ver is too old" >&2
+        echo "       '$app' version >= $req_ver is required" >&2
+        ret=1
+      fi
+    fi
+  done
+
+  return $ret
+}
+
+print_versions() {
+  echo "Program    Min_version"
+  echo "----------------------"
+  printf "$buildreq"
+  echo "----------------------"
+  #can't depend on column -t
+}
+
+if ! printf "$buildreq" | check_versions; then
+  test -f README-prereq &&
+  echo "Please see README-prereq for notes on obtaining these prerequisite 
programs:" >&2
+  echo
+  print_versions
+  exit 1
+fi
+
 echo "$0: Bootstrapping from checked-out $package sources..."
 
 # See if we can use gnulib's git-merge-changelog merge driver.
diff --git a/bootstrap.conf b/bootstrap.conf
index c6698f1..a434263 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -161,5 +161,22 @@ fi
 
 gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
 
+# Build prerequisites
+buildreq="\
+autoconf   2.61
+automake   1.10a
+autopoint  -
+bison      -
+gettext    -
+git        1.4.4
+gperf      -
+gzip       -
+lzma       -
+makeinfo   -
+perl       5.5
+rsync      -
+tar        -
+"
+
 # Automake requires that ChangeLog exist.
 touch ChangeLog
-- 
1.5.3.6


reply via email to

[Prev in Thread] Current Thread [Next in Thread]