[arch-projects] [mkinitcpio][PATCH 02/12] mkinitcpio: deprecate install() in install hooks

Dave Reisner d at falconindy.com
Thu Jun 9 16:09:56 EDT 2011


This is an unfortunate name clash with a common utility and should be
avoided. Rename the install function to 'build' and warn the user when
we discover a hook using an 'install' function.

Signed-off-by: Dave Reisner <d at falconindy.com>
---
 install/autodetect  |    2 +-
 install/base        |    2 +-
 install/btrfs       |    2 +-
 install/consolefont |    2 +-
 install/dmesg       |    5 +++--
 install/dsdt        |    2 +-
 install/filesystems |    2 +-
 install/fw          |    2 +-
 install/ide         |    2 +-
 install/keymap      |    2 +-
 install/memdisk     |    2 +-
 install/net         |    2 +-
 install/pata        |    2 +-
 install/pcmcia      |    2 +-
 install/resume      |    3 ++-
 install/sata        |    2 +-
 install/scsi        |    2 +-
 install/sleep       |    2 +-
 install/udev        |    2 +-
 install/usb         |    2 +-
 install/usbinput    |    2 +-
 mkinitcpio          |   21 +++++++++++++--------
 22 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/install/autodetect b/install/autodetect
index 70fac56..118c9a5 100644
--- a/install/autodetect
+++ b/install/autodetect
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULE_FILE="${TMPDIR}/autodetect_modules"
     #blegh, we'll let /tmp clean itself up
diff --git a/install/base b/install/base
index 4a0ff14..87d789d 100644
--- a/install/base
+++ b/install/base
@@ -1,6 +1,6 @@
 # vim:set ft=sh:
 
-install ()
+build()
 {
     add_dir "/proc"
     add_dir "/sys"
diff --git a/install/btrfs b/install/btrfs
index 60dc2ac..c156bb0 100644
--- a/install/btrfs
+++ b/install/btrfs
@@ -1,6 +1,6 @@
 # vim:set ft=sh:
 
-install()
+build()
 {
     MODULES="$(all_modules btrfs)"
     BINARIES="/sbin/btrfs"
diff --git a/install/consolefont b/install/consolefont
index 7a3e73f..395387b 100644
--- a/install/consolefont
+++ b/install/consolefont
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=""
     BINARIES=""
diff --git a/install/dmesg b/install/dmesg
index d25deba..9482874 100644
--- a/install/dmesg
+++ b/install/dmesg
@@ -1,5 +1,6 @@
 # vim: set ft=sh:
-install ()
+
+build()
 {
     MODULES=""
     BINARIES=""
@@ -15,4 +16,4 @@ cat<<HELPEOF
   with the boot process during early userspace
   (like when entering a passphrase).
 HELPEOF
-}
\ No newline at end of file
+}
diff --git a/install/dsdt b/install/dsdt
index 138ee47..f1345d0 100644
--- a/install/dsdt
+++ b/install/dsdt
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=""
     BINARIES=""
diff --git a/install/filesystems b/install/filesystems
index cd1a4cb..337a6a5 100644
--- a/install/filesystems
+++ b/install/filesystems
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     if [ "${autodetect_fs_detection_failed}" = "1" ]; then
         MODULES=" $(all_modules '/kernel/fs' | grep -v "nls")"
diff --git a/install/fw b/install/fw
index 9f4ed26..a5a77cb 100644
--- a/install/fw
+++ b/install/fw
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules "/firewire/") "
 
diff --git a/install/ide b/install/ide
index f3bee4e..fa0da51 100644
--- a/install/ide
+++ b/install/ide
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules "/ide/" | grep -v "legacy") ";
 
diff --git a/install/keymap b/install/keymap
index 65990dd..4038c87 100644
--- a/install/keymap
+++ b/install/keymap
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=""
     BINARIES=""
diff --git a/install/memdisk b/install/memdisk
index d2a844d..69c996f 100644
--- a/install/memdisk
+++ b/install/memdisk
@@ -1,6 +1,6 @@
 # vim:set ft=sh:
 
-install ()
+build()
 {
     MODULES="phram mtdblock"
     BINARIES="/usr/bin/memdiskfind"
diff --git a/install/net b/install/net
index 6016ed5..2c816ba 100644
--- a/install/net
+++ b/install/net
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES="nfs $(checked_modules "/drivers/net/") "
 
diff --git a/install/pata b/install/pata
index af3c106..1d750dc 100644
--- a/install/pata
+++ b/install/pata
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules "ata/pata_*") $(checked_modules "ata/ata_generic") 
               $(checked_modules "ata/ata_piix")"
diff --git a/install/pcmcia b/install/pcmcia
index 8b685c5..a9920c1 100644
--- a/install/pcmcia
+++ b/install/pcmcia
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules '/pcmcia/' | grep -ve 'sound' -e 'net') $(checked_modules '/ide/legacy')"
     MODULES=$(echo ${MODULES}) #trim whitespace
diff --git a/install/resume b/install/resume
index cbef453..dcf6442 100644
--- a/install/resume
+++ b/install/resume
@@ -1,5 +1,6 @@
 # vim:set ft=sh:
-install ()
+
+build()
 {
     MODULES=""
     BINARIES=""
diff --git a/install/sata b/install/sata
index 4ed4d1c..cbd2db2 100644
--- a/install/sata
+++ b/install/sata
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules "scsi/.*ata") $(checked_modules "block/sx8") 
               $(checked_modules "scsi/ahci") $(checked_modules "scsi/pdc_adma") 
diff --git a/install/scsi b/install/scsi
index b831b64..9a97a8c 100644
--- a/install/scsi
+++ b/install/scsi
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules "/scsi/" | grep -ve "imm" -e "pdc_adma" -e "ahci" -e "ata" -e "pcmcia" -e "ide") 
               $(checked_modules "/block/" | grep -e "cciss" -e "cpqarray" -e "DAC960")
diff --git a/install/sleep b/install/sleep
index a59d0c3..c7a8902 100644
--- a/install/sleep
+++ b/install/sleep
@@ -1,6 +1,6 @@
 # vim:set ft=sh:
 
-install ()
+build()
 {
     MODULES=""
     BINARIES=""
diff --git a/install/udev b/install/udev
index 33a13cc..74c9b5e 100644
--- a/install/udev
+++ b/install/udev
@@ -1,6 +1,6 @@
 # vim:set ft=sh:
 
-install ()
+build()
 {
     MODULES=""
     BINARIES=""
diff --git a/install/usb b/install/usb
index 605912c..620f695 100644
--- a/install/usb
+++ b/install/usb
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules "/usb/host" | grep -ve "_cs" -e "sl811-hcd" -e "isp116x-hcd")"
 
diff --git a/install/usbinput b/install/usbinput
index 0d293ae..a90cd15 100644
--- a/install/usbinput
+++ b/install/usbinput
@@ -1,6 +1,6 @@
 # vim: set ft=sh:
 
-install ()
+build()
 {
     MODULES=" $(checked_modules "/usb/host" | grep -ve "_cs" -e "sl811-hcd" -e "isp116x-hcd") "
     MODULES=" $(echo ${MODULES}) $(all_modules "/hid/hid-") "
diff --git a/mkinitcpio b/mkinitcpio
index c6428bb..fc50396 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -239,10 +239,8 @@ parse_hook
 
 for hook in ${HOOKS}; do
     in_array ${hook} ${SKIPHOOKS[@]} && continue
-    unset MODULES
-    unset BINARIES
-    unset FILES
-    install () { msg "${hook}: no install function..."; }
+    unset MODULES BINARIES FILES
+    build () { msg "${hook}: no build function..."; }
     # Deprecation check
     # A hook is considered deprecated if it is a symlink
     # within $INSTDIR.
@@ -257,10 +255,19 @@ for hook in ${HOOKS}; do
             hook="${newhook}"
         fi
     fi
-    if grep -q "install" "${INSTDIR}/${hook}"; then
+    if [[ -r "${INSTDIR}/${hook}" ]]; then
         . "${INSTDIR}/${hook}"
         echo ":: Parsing hook [${hook}]"
-        install
+        if [[ $(type -t install) = 'function' ]]; then
+            echo "  -----------------------------------------------------------------------"
+            echo "  WARNING: Hook '$hook' uses a deprecated 'install' function. This "
+            echo "           should be switched to a 'build' function instead."
+            echo "  -----------------------------------------------------------------------"
+            install
+            unset install
+        else
+            build
+        fi
         parse_hook
     else
         die "Hook '${hook}' can not be found."
@@ -269,8 +276,6 @@ done
 
 if [ "${HAS_MODULES}" = "y" ]; then
     echo ":: Generating module dependencies"
-    # unfortuate name collision between a function and utility program
-    unset install
     for mod in $(grep "file /lib/modules/${KERNELVERSION}" ${FILELIST} | cut -d' ' -f2); do
         install -m 644 -D "${BASEDIR}${mod}" "${TMPDIR}${mod}"
     done
-- 
1.7.5.4



More information about the arch-projects mailing list