[PATCH] Support for DESTDIR, cp -f

Pavel Roskin proski
Tue Oct 15 12:53:48 PDT 2002


Hello!

I'm working on the new forked version of OpenAP.  The idea is not just do
something that works, but something that can be reliably rebuilt by every
user from the source by the simple "make all" without suid mknod or
anything like that.  I'm trying to use the latest software and feed the
necessary patches back to the developers.  Below is one of such patches.

This patch makes it possible to install HostAP to a "staging area", i.e.  
prepend some path before every installed file.  Most software (and all
software using Automake) calls this variable DESTDIR, so that was the
obvious choice.

I also could not ignore the fact that "cp" is used without "-f".  Note
that cp without "-f" can ask questions.  It is not guaranteed to be
non-interactive.  On some systems, "cp" is an alias to "cp -i" for root,
which explicitly means to be intaractive.  I have repaced "cp" with "cp
-f" in the top-level Makefile.

The patch is against CVS version of HostAP.

==============================================
--- Makefile
+++ Makefile
@@ -11,6 +11,9 @@
 # Leave this blank for kernel-tree PCMCIA compilations (CONFIG_PCMCIA):
 PCMCIA_PATH=
 
+# This path will be prepended to every installed file
+DESTDIR=
+
 CC=gcc
 CFLAGS=-O2 -D__KERNEL__ -DMODULE -Wall -c $(EXTRA_CFLAGS)
 
@@ -20,7 +23,7 @@
 	else uname -r; fi)
 KERNELVER := $(shell echo "$(KERNELRELEASE)" | \
 	sed "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/")
-MODPATH := /lib/modules/$(KERNELRELEASE)
+MODPATH := $(DESTDIR)/lib/modules/$(KERNELRELEASE)
 MODULE_CS := hostap_cs.o
 MODULE_PLX := hostap_plx.o
 MODULE_PCI := hostap_pci.o
@@ -145,36 +148,38 @@
 install_hostap: $(MSRC)/hostap.o
 	@echo "Installing hostap.o to $(MODPATH_PCI)"
 	mkdir -p $(MODPATH_PCI)
-	cp $(MSRC)/hostap.o $(MODPATH_PCI)
+	cp -f $(MSRC)/hostap.o $(MODPATH_PCI)
 
 install_crypt: $(MSRC)/hostap_crypt.o $(MSRC)/hostap_crypt_wep.o
 	@echo "Installing hostap_crypt*.o to $(MODPATH_PCI)"
 	mkdir -p $(MODPATH_PCI)
-	cp $(MSRC)/hostap_crypt*.o $(MODPATH_PCI)
+	cp -f $(MSRC)/hostap_crypt*.o $(MODPATH_PCI)
 
 install_pccard: install_check install_crypt install_hostap
 	@echo "Installing $(MODULE_CS) to $(MODPATH_CS)"
 	mkdir -p $(MODPATH_CS)
-	cp $(MSRC)/$(MODULE_CS) $(MODPATH_CS)
+	cp -f $(MSRC)/$(MODULE_CS) $(MODPATH_CS)
+ifndef DESTDIR
 	/sbin/depmod -a
-	@if [ ! -r /etc/pcmcia/hostap_cs.conf ]; then \
-		echo "Installing /etc/pcmcia/hostap_cs.conf"; \
-		cp driver/etc/hostap_cs.conf /etc/pcmcia/hostap_cs.conf; \
+endif
+	@if [ ! -r $(DESTDIR)/etc/pcmcia/hostap_cs.conf ]; then \
+		echo "Installing $(DESTDIR)/etc/pcmcia/hostap_cs.conf"; \
+		cp -f driver/etc/hostap_cs.conf $(DESTDIR)/etc/pcmcia/hostap_cs.conf; \
 	fi
-	@if [ -r /etc/pcmcia/prism2.conf ]; then \
-		echo "You may need to remove old /etc/pcmcia/prism2.conf"; \
+	@if [ -r $(DESTDIR)/etc/pcmcia/prism2.conf ]; then \
+		echo "You may need to remove old $(DESTDIR)/etc/pcmcia/prism2.conf"; \
 	fi
 
 install_plx: install_check install_crypt install_hostap
 	@echo "Installing $(MODULE_PLX) to $(MODPATH_PLX)"
 	mkdir -p $(MODPATH_PLX)
-	cp $(MSRC)/$(MODULE_PLX) $(MODPATH_PLX)
+	cp -f $(MSRC)/$(MODULE_PLX) $(MODPATH_PLX)
 	/sbin/depmod -a
 
 install_pci: install_check install_crypt install_hostap
 	@echo "Installing $(MODULE_PCI) to $(MODPATH_PCI)"
 	mkdir -p $(MODPATH_PCI)
-	cp $(MSRC)/$(MODULE_PCI) $(MODPATH_PCI)
+	cp -f $(MSRC)/$(MODULE_PCI) $(MODPATH_PCI)
 	/sbin/depmod -a
 
 
==============================================

-- 
Regards,
Pavel Roskin





More information about the Hostap mailing list