4 # The DragonFly Project. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in
14 # the documentation and/or other materials provided with the
16 # 3. Neither the name of The DragonFly Project nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific, prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 . /etc/defaults/mkinitrd.conf
36 if [ -r /etc/mkinitrd.conf ]; then
38 echo "Loaded configuration from /etc/mkinitrd.conf"
45 if [ ! -d $BUILD_DIR ]; then
47 echo "Created build directory $BUILD_DIR"
49 VN_DEV=`vnconfig -c -S ${INITRD_SIZE} -Z -T vn ${TMP_DIR}/initrd.img | cut -f 2 -d ' '`
50 echo "Configured $VN_DEV"
51 newfs /dev/${VN_DEV}s0
52 echo "Formatted initrd image with UFS"
53 mount /dev/${VN_DEV}s0 $BUILD_DIR
54 echo "Mounted initrd image on ${BUILD_DIR}"
59 umount /dev/${VN_DEV}s0
60 echo "Unmounted initrd image"
62 echo "Unconfigured $VN_DEV"
67 for dir in ${INITRD_DIRS}; do
68 mkdir -p ${BUILD_DIR}/${dir}
71 echo "Created directory structure"
76 for tool in ${BIN_TOOLS}; do
77 objcopy -S /bin/${tool} ${BUILD_DIR}/bin/${tool}
80 for tool in ${SBIN_TOOLS}; do
81 objcopy -S /sbin/${tool} ${BUILD_DIR}/sbin/${tool}
84 echo "Copied essential tools"
89 for dir in ${CONTENT_DIRS}; do
90 cp -R ${dir}/* ${BUILD_DIR}/
103 echo "usage: $0 [-b bootdir] [-t tmpdir]"
107 args=`getopt b:t: $*`
108 test $? -ne 0 && usage
113 -b) BOOT_DIR="$2"; shift; shift;;
114 -t) TMP_DIR="$2"; shift; shift;;
118 test ! -d ${BOOT_DIR} && usage
119 test ! -d ${TMP_DIR} && usage
120 test ! -z $1 && usage
121 BUILD_DIR="${TMP_DIR}/initrd"
129 mv ${TMP_DIR}/initrd.img ${BOOT_DIR}/kernel/initrd.img