Skip to contentSkip to conversation

autoconf: check for wget and ftp

PATCH In review Roger Pau Monne 2 participants 8 messages Oct 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 autoconf: check for wget and ftp

Some OSes don't come with wget by default, so ftp should be choosen on those. Add an autoconf check to check for wget and ftp, and replace the usage of hardcoded wget in tools.

---
Please run autoconf after applying this patch.

---
 config/StdGNU.mk                  |    2 --
 config/Tools.mk.in                |    1 +
 tools/configure.ac                |    2 ++
 tools/firmware/etherboot/Makefile |    2 +-
 tools/m4/fetcher.m4               |   14 ++++++++++++++
 5 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 tools/m4/fetcher.m4
config/StdGNU.mk +0 -2
index b6adbbe..3febe8d 100644
@@ -22,8 +22,6 @@ MSGMERGE   = msgmerge
 # Allow git to be wrappered in the environment
 GIT        ?= git
 
-WGET       ?= wget -c
-
 INSTALL      = install
 INSTALL_DIR  = $(INSTALL) -d -m0755 -p
 INSTALL_DATA = $(INSTALL) -m0644 -p
config/Tools.mk.in +1 -0
index a6ecf48..a78f211 100644
@@ -22,6 +22,7 @@ AS86                := @AS86@
 LD86                := @LD86@
 BCC                 := @BCC@
 IASL                := @IASL@
+FETCHER             := @FETCHER@
 
 # Extra folder for libs/includes
 PREPEND_INCLUDES    := @PREPEND_INCLUDES@
tools/configure.ac +2 -0
index 3318fea..e708f01 100644
@@ -35,6 +35,7 @@ m4_include([m4/curses.m4])
 m4_include([m4/pthread.m4])
 m4_include([m4/ptyfuncs.m4])
 m4_include([m4/extfs.m4])
+m4_include([m4/fetcher.m4])
 
 # Enable/disable options
 AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP])
@@ -117,6 +118,7 @@ esac
  AX_CHECK_UUID
  AX_CHECK_CURSES
 PKG_CHECK_MODULES(glib, [glib-2.0 >= 2.12])
+AX_CHECK_FETCHER
 
 # Checks for libraries.
 AC_CHECK_HEADER([bzlib.h], [
tools/firmware/etherboot/Makefile +1 -1
index a195888..15561fc 100644
@@ -28,7 +28,7 @@ all: $(ROMS)
 	$(MAKE) -C $D/src bin/$(*F).rom
 
 $T:
-	if ! wget -O _$T $(IPXE_TARBALL_URL); then \
+	if ! $(FETCHER) _$T $(IPXE_TARBALL_URL); then \
 		$(GIT) clone $(IPXE_GIT_URL) $D.git; \
 		(cd $D.git && $(GIT) archive --format=tar --prefix=$D/ \
 		$(IPXE_GIT_TAG) | gzip >../_$T); \
tools/m4/fetcher.m4 new file +14 -0
new file mode 100644
index 0000000..86f33b3
@@ -0,0 +1,14 @@
+AC_DEFUN([AX_CHECK_FETCHER], [
+AC_PATH_PROG([WGET],[wget], [no])
+AS_IF([test x"$WGET" != x"no"], [
+    FETCHER="$WGET -c -O"
+], [
+    AC_PATH_PROG([FTP],[ftp], [no])
+    AS_IF([test x"$FTP" != x"no"], [
+        FETCHER="$FTP -o"
+    ], [
+        AC_MSG_ERROR([cannot find wget or ftp])
+    ])
+])
+AC_SUBST(FETCHER)
+])
Signature · 1 line
1.7.7.5 (Apple Git-26)
#1 lore raw

PATCH 2/2 autoconf: bash is not needed on NetBSD

Remove check for bash on NetBSD, since it is not needed for hotplug scripts (NetBSD hotplug scripts use sh) or the build system.

---
 tools/configure.ac |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
tools/configure.ac +5 -1
index e708f01..47607ae 100644
@@ -93,7 +93,11 @@ AS_IF([test "x$ocamltools" = "xy"], [
         ocamltools="n"
     ])
 ])
-AX_PATH_PROG_OR_FAIL([BASH], [bash])
+case "$host_os" in
+linux*)
+    AX_PATH_PROG_OR_FAIL([BASH], [bash])
+    ;;
+esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
Signature · 1 line
1.7.7.5 (Apple Git-26)
#2 lore raw

Re: [PATCH 2/2] autoconf: bash is not needed on NetBSD

Roger Pau Monne writes ("[Xen-devel] [PATCH 2/2] autoconf: bash is not needed on NetBSD"):

Quoted 2 lines

Remove check for bash on NetBSD, since it is not needed for hotplug scripts (NetBSD hotplug scripts use sh) or the build system.

Is it really the case that we have no bashisms in our build system ? I'm not convinced that even if this is true it's a property worth the effort to preserve.

Ian.

#3 lore raw
In reply to Roger Pau Monne

Roger Pau Monne writes ("[Xen-devel] [PATCH 1/2] autoconf: check for wget and ftp"):

Quoted 3 lines

Some OSes don't come with wget by default, so ftp should be choosen on those. Add an autoconf check to check for wget and ftp, and replace the usage of hardcoded wget in tools.

I don't think this can be right; wget is used in many more places. At the very least it looks like it will break the stubdom build since that is full of WGET. Did you grep for WGET ?

Does "ftp -o blah.tar.gz http://xenbits.xen.org/xen-extfiles/blah.tar.gz"
really work on NetBSD and download to the local file "blah.tar.gz" ?

Ian.

#4 lore raw
Quoted 8 lines · Ian Jackson

Roger Pau Monne writes ("[Xen-devel] [PATCH 1/2] autoconf: check for wget and ftp"):

Quoted 3 lines

Some OSes don't come with wget by default, so ftp should be choosen on those. Add an autoconf check to check for wget and ftp, and replace the usage of hardcoded wget in tools.

I don't think this can be right; wget is used in many more places. At the very least it looks like it will break the stubdom build since that is full of WGET. Did you grep for WGET ?

Does stubdom build import config/Tools.mk? I thought it was only used to build the tools directory. If that's the case I don't think it will break anything, since we define a new variable $FETCHER, that shouldn't be used anywhere else, so the rest will continue to use the hardcoded wget, or whatever it was using prior to this patch.

Quoted 2 lines

Does "ftp -o blah.tar.gz http://xenbits.xen.org/xen-extfiles/blah.tar.gz"
really work on NetBSD and download to the local file "blah.tar.gz" ?

Yes.

#5 lore raw

Roger Pau Monné writes ("Re: [Xen-devel] [PATCH 1/2] autoconf: check for wget and ftp"):

Quoted 10 lines · Ian Jackson
Quoted 3 lines

I don't think this can be right; wget is used in many more places. At the very least it looks like it will break the stubdom build since that is full of WGET. Did you grep for WGET ?

Does stubdom build import config/Tools.mk? I thought it was only used to build the tools directory. If that's the case I don't think it will break anything, since we define a new variable $FETCHER, that shouldn't be used anywhere else, so the rest will continue to use the hardcoded wget, or whatever it was using prior to this patch.

Err, yes, it seems stubdom/Makefile has its own definition of wget. But stubdom builds are still going to be broken without wget then ?

Ian.

#6 lore raw
Quoted 6 lines · Ian Jackson

Roger Pau Monné writes ("Re: [Xen-devel] [PATCH 1/2] autoconf: check for wget and ftp"):

Quoted 5 lines · Ian Jackson
Quoted 3 lines

I don't think this can be right; wget is used in many more places. At the very least it looks like it will break the stubdom build since that is full of WGET. Did you grep for WGET ?

Quoted 8 lines
Quoted 5 lines

Does stubdom build import config/Tools.mk? I thought it was only used to build the tools directory. If that's the case I don't think it will break anything, since we define a new variable $FETCHER, that shouldn't be used anywhere else, so the rest will continue to use the hardcoded wget, or whatever it was using prior to this patch.

Err, yes, it seems stubdom/Makefile has its own definition of wget. But stubdom builds are still going to be broken without wget then ?

Yes, but I don't think we should check for the requirements of stubdoms build process if we are not going to include config/Tools.mk to build them. For example NetBSD cannot build stubdoms (for other reasons), so we shouldn't enforce wget presence in configure.

Acked-by
#7 lore raw

Roger Pau Monne writes ("Re: [Xen-devel] [PATCH 1/2] autoconf: check for wget and ftp"):

Quoted 8 lines · Ian Jackson
Quoted 2 lines

Err, yes, it seems stubdom/Makefile has its own definition of wget. But stubdom builds are still going to be broken without wget then ?

Yes, but I don't think we should check for the requirements of stubdoms build process if we are not going to include config/Tools.mk to build them. For example NetBSD cannot build stubdoms (for other reasons), so we shouldn't enforce wget presence in configure.

Fair enough, thanks for the explanation.