#!/bin/bash
set -e
-set -x
USER=frank
+MODULES_DIR="/lib/modules"
echo_action() {
action="$1"
TARG_LAST=${TARG}-last
-echo "Creating initramfs ..."
cd $( dirname $0 ) || exit 1
+echo "Creating makefile.tmpl ..."
+cp makefile-core.tmpl makefile.tmpl
+
+COUNTER=0
+
+mdir="${MODULES_DIR}"/"${KERNEL_VERSION}"
+
+# Clean file and write header
+for n in $( find "${mdir}" ) ; do
+ [ -d $n ] && echo "dir $n 700 0 0"
+ [ -f $n ] && {
+ echo "file $n $n 600 0 0"
+ # Test extension to count modules
+ [ "${n##*.}" = "ko" ] && : $((COUNTER++))
+ }
+done >> makefile.tmpl
+
+cat << EOF
+
+$COUNTER modules found for $KERNEL_VERSION
+
+EOF
+
+echo "Creating initramfs ..."
+
uid=$( id -u )
username=$( id -un )
gid=$( id -g )
--- /dev/null
+# -*- mode: conf -*-
+# init script (damn important!!!)
+file /init ${package}/init.sh 755 0 0
+
+# directory structure
+dir /proc 755 0 0
+dir /sys 755 0 0
+dir /dev 755 0 0
+dir /lib 755 0 0
+dir /bin 755 0 0
+dir /sbin 755 0 0
+dir /mnt 755 0 0
+dir /etc 755 0 0
+dir /usr 755 0 0
+dir /usr/share 755 0 0
+
+# basic tools
+file /bin/busybox /bin/busybox 755 0 0
+slink /sbin/mdev /bin/busybox 755 0 0
+
+# lvm support
+dir /dev/mapper 755 0 0
+file /sbin/lvm /sbin/lvm.static 755 0 0
+dir /etc/lvm 755 0 0
+file /etc/lvm/lvm.conf /etc/lvm/lvm.conf 644 0 0
+
+# framebuffer support
+#file /sbin/v86d /sbin/v86d 755 0 0
+
+# cryptsetup support
+#file /sbin/cryptsetup /sbin/cryptsetup 755 0 0
+
+# console font
+dir /usr/share/consolefonts 755 0 0
+file /usr/share/consolefonts/ter-v16n.psf.gz /usr/share/consolefonts/ter-v16n.psf.gz 644 0 0
+
+# keymap
+file /etc/keymap ${package}/keymap 644 0 0
+
+# uswsusp support
+#file /sbin/resume /usr/lib/suspend/resume 755 0 0
+#file /etc/suspend.conf /etc/suspend.conf 644 0 0
+
+# splash support
+#dir /lib/splash 644 0 0
+#dir /lib/splash/sys 644 0 0
+#dir /lib/splash/proc 644 0 0
+#file /sbin/fbcondecor_helper /sbin/fbcondecor_helper 755 0 0
+#slink /sbin/splash_helper /sbin/fbcondecor_helper 755 0 0
+#file /etc/initrd.splash /usr/share/splashutils/initrd.splash 644 0 0
+
+# splash theme
+#dir /etc/splash 755 0 0
+#dir /etc/splash/natural_gentoo 755 0 0
+#file /etc/splash/natural_gentoo/1280x800.cfg /etc/splash/natural_gentoo/1280x800.cfg 644 0 0
+#dir /etc/splash/natural_gentoo/images 755 0 0
+#file /etc/splash/natural_gentoo/images/silent-1280x800.jpg /etc/splash/natural_gentoo/images/silent-1280x800.jpg 644 0 0
+#file /etc/splash/natural_gentoo/images/verbose-1280x800.jpg /etc/splash/natural_gentoo/images/verbose-1280x800.jpg 644 0 0
+
+# important device files
+nod /dev/mem 600 0 0 c 1 1
+nod /dev/null 666 0 0 c 1 3
+nod /dev/zero 600 0 0 c 1 5
+nod /dev/console 600 0 0 c 5 1
+nod /dev/tty0 620 0 0 c 4 0
+nod /dev/tty1 600 0 0 c 4 1
+
+# device directories
+dir /dev/fb 755 0 0
+dir /dev/misc 755 0 0
+dir /dev/vc 755 0 0
+
+++ /dev/null
-# -*- mode: conf -*-
-# init script (damn important!!!)
-file /init ${package}/init.sh 755 0 0
-
-# directory structure
-dir /proc 755 0 0
-dir /sys 755 0 0
-dir /dev 755 0 0
-dir /lib 755 0 0
-dir /bin 755 0 0
-dir /sbin 755 0 0
-dir /mnt 755 0 0
-dir /etc 755 0 0
-dir /usr 755 0 0
-dir /usr/share 755 0 0
-
-# basic tools
-file /bin/busybox /bin/busybox 755 0 0
-slink /sbin/mdev /bin/busybox 755 0 0
-
-# lvm support
-dir /dev/mapper 755 0 0
-file /sbin/lvm /sbin/lvm.static 755 0 0
-dir /etc/lvm 755 0 0
-file /etc/lvm/lvm.conf /etc/lvm/lvm.conf 644 0 0
-
-# framebuffer support
-#file /sbin/v86d /sbin/v86d 755 0 0
-
-# cryptsetup support
-#file /sbin/cryptsetup /sbin/cryptsetup 755 0 0
-
-# console font
-dir /usr/share/consolefonts 755 0 0
-file /usr/share/consolefonts/ter-v16n.psf.gz /usr/share/consolefonts/ter-v16n.psf.gz 644 0 0
-
-# keymap
-file /etc/keymap ${package}/keymap 644 0 0
-
-# uswsusp support
-#file /sbin/resume /usr/lib/suspend/resume 755 0 0
-#file /etc/suspend.conf /etc/suspend.conf 644 0 0
-
-# splash support
-#dir /lib/splash 644 0 0
-#dir /lib/splash/sys 644 0 0
-#dir /lib/splash/proc 644 0 0
-#file /sbin/fbcondecor_helper /sbin/fbcondecor_helper 755 0 0
-#slink /sbin/splash_helper /sbin/fbcondecor_helper 755 0 0
-#file /etc/initrd.splash /usr/share/splashutils/initrd.splash 644 0 0
-
-# splash theme
-#dir /etc/splash 755 0 0
-#dir /etc/splash/natural_gentoo 755 0 0
-#file /etc/splash/natural_gentoo/1280x800.cfg /etc/splash/natural_gentoo/1280x800.cfg 644 0 0
-#dir /etc/splash/natural_gentoo/images 755 0 0
-#file /etc/splash/natural_gentoo/images/silent-1280x800.jpg /etc/splash/natural_gentoo/images/silent-1280x800.jpg 644 0 0
-#file /etc/splash/natural_gentoo/images/verbose-1280x800.jpg /etc/splash/natural_gentoo/images/verbose-1280x800.jpg 644 0 0
-
-# important device files
-nod /dev/mem 600 0 0 c 1 1
-nod /dev/null 666 0 0 c 1 3
-nod /dev/zero 600 0 0 c 1 5
-nod /dev/console 600 0 0 c 5 1
-nod /dev/tty0 620 0 0 c 4 0
-nod /dev/tty1 600 0 0 c 4 1
-
-# device directories
-dir /dev/fb 755 0 0
-dir /dev/misc 755 0 0
-dir /dev/vc 755 0 0
-