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 12:04:49 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Jim Meyering wrote:
> Pádraig Brady <address@hidden> wrote:
>> Jim Meyering wrote:
> ...
>>> Are you interested in doing something like that?
>> Well all missing dependencies are currently reported I think,
>> but it can be minutes into the build before this happens.
>> I'll add a list to bootstrap.conf to give immediate feedback.
> 
> Great!
> 
>>> Regarding your build recipe, maybe we need a wiki?
>>> New file?
>> Perhaps we need a README-{fedora,debian,solaris,mingw,...}
>> ./bootstrap should just work, but the above files would
>> detail how best to get the prerequisites.
> 
> Or a README-prereq, and put them all in there?
> Either one is fine with me.

How about the attached.

Note it only checks for versions >= specifed
I.E. you can specify a min version, not a max.

Note also I was only guessing at specific versions
configured in bootstrap.conf, and specified most as
don't care.

cheers,
Pádraig.
>From 5072e68adb3b4ac462e45efc416fc10188d59fbe Mon Sep 17 00:00:00 2001
From: =?utf-8?q?P=C3=A1draig=20Brady?= <address@hidden>
Date: Tue, 21 Oct 2008 11:56:39 +0100
Subject: [PATCH] Add better checks and docs for build tools

* 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. We've just notes on
Fedora linux at present.
* bootstrap.conf: Add the list of tools and versions required.
* bootstrap: Add the logic to check the for the required tools,
and list all required tools and versions if any are missing.
---
 README-hacking |   19 +++++++-----
 README-prereq  |   30 ++++++++++++++++++++
 bootstrap      |   81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 bootstrap.conf |   14 +++++++++
 4 files changed, 136 insertions(+), 8 deletions(-)
 create mode 100644 README-prereq

diff --git a/README-hacking b/README-hacking
index 2e3c83a..07c87b7 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
@@ -41,9 +43,10 @@ from <http://tukaani.org/lzma/>.
 You can get a copy of the source repository like this:
 
        $ 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
 
diff --git a/README-prereq b/README-prereq
new file mode 100644
index 0000000..6ee8c34
--- /dev/null
+++ b/README-prereq
@@ -0,0 +1,30 @@
+Sometimes even the latest stable versions of certain tools do not suffice
+thus requiring you get them directly from the repository and build them
+to a location available to coreutils. Detailed below are concrete examples
+for getting the prerequisites for particular systems.
+
+- linux - fedora
+
+  This details obtaining the required tools to build coreutils 7.0
+  on a Fedora 8 system. We try to use official packages where possible:
+
+  Make sure offical git is installed
+    # yum install git
+
+  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.
+
+  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 below, as
+  long as $PATH starts with $HOME/coreutils/deps
diff --git a/bootstrap b/bootstrap
index 0895eb7..987a34a 100755
--- a/bootstrap
+++ b/bootstrap
@@ -222,6 +222,87 @@ if test ! -d $build_aux; then
   done
 fi
 
+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
+                echo $p1 $p2
+                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 |
+    sed -n 's/.*[v ]\([0-9]\{1,\}\.[.a-z0-9-]\{,\}\).*/\1/p;T;q'
+}
+
+check_versions() {
+    ret=0
+
+    while read app reqver; do
+        if [ "$reqver" = "-" ]; then
+            #any version suffices
+            if ! $app --version >/dev/null 2>&1; then
+                echo "Error: '$app' is required" >&2
+                ret=1
+            fi
+        else
+            instver=$(get_version $app)
+            latestver=$(sort_ver $reqver $instver | tr ' ' '\n' | tail -n1)
+            if [ ! "$latestver" = "$instver" ]; then
+                echo "Error: '$app' version >= $reqver is required" >&2
+                ret=1
+            fi
+        fi
+    done
+
+    return $ret
+}
+
+print_versions() {
+    echo "Program    Min_version"
+    echo "----------------------"
+    echo "$buildreq"
+    echo "----------------------"
+    #can't depend on column -t
+}
+
+if ! echo "$buildreq" | check_versions; then
+    [ -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..c7023d4 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -161,5 +161,19 @@ fi
 
 gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
 
+# Build prerequisites
+buildreq="\
+autoconf   2.61
+automake   1.10a
+bison      -
+gettext    -
+git        1.4.4
+gperf      -
+gzip       -
+lzma       -
+perl       5.8
+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]