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: Tue, 21 Oct 2008 23:04:48 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Version 2 of bootstrap requirements checking patch attached.

Note if one wanted to fully support all (old) version formats
as automake does, one could normalize them before comparison
with something like the following:

normalize_version() {
    ver="$1"

    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
      s/^\([0-9]\{,\}\)\.\([0-9]\{,\}\)-p\([0-9].*\)/\1.\2.\3/; #1.10-p1a -> 
1.10.1a
    '
}

I don't think the extra complexity is worth it though.

cheers,
Pádraig.
>From 80305d49505b7383123afe0ce0c2f8e073f96afd 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      |   85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 bootstrap.conf |   17 +++++++++++
 4 files changed, 153 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..ca44a13 100755
--- a/bootstrap
+++ b/bootstrap
@@ -222,6 +222,91 @@ 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.
+# You could normalize version formats with sed if necessary.
+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 | tr ' ' '\n' | tail -n1)
+            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]