4 # Copyright (c) 2014 Warner Losh. All Rights Reserved.
5 # Copyright (c) 2010-2011 iXsystems, Inc., All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # 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 the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL iXsystems, Inc. OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # This file is heavily derived from both Sam Leffler's Avilia config,
29 # as well as the BSDRP project's config file. Neither of these have
30 # an explicit copyright/license statement, but are implicitly BSDL. This
31 # example has been taken from the FreeNAS project and simplified to meet
32 # the needs of the example.
35 # Pull in common definitions.
38 NANO_BOOT0CFG="-o packet -s 1 -m 3 -t 18"
40 # /var -> ~10MB (look through rc.initdiskless for the formula of how this
41 # number is calculated out). Since we hope to run
42 NANO_RAM_TMPVARSIZE=10240
45 FlashDevice generic 2g
47 if [ "$DEBUG" = 1 ]; then
57 CONF_INSTALL="$CONF_BUILD
60 CONF_INSTALL="$CONF_INSTALL
64 add_port security/sudo
67 if [ "${NANO_PACKAGE_ONLY}" -eq 1 ]; then
68 CONF_INSTALL="${CONF_INSTALL}
71 echo "Automatically building a thin image with packages"
73 echo "Automatically building a * * F A T * * image so we can build ports"
76 VARS="MASTER_SITE_BACKUP MASTER_SITE_OVERRIDE PACKAGEROOT PACKAGESITE"
79 val=$(eval echo "\$$var")
80 if [ -n "$val" ]; then
81 CONF_INSTALL="${CONF_INSTALL}
86 if [ "$PACKAGE_PREP_BUILD" = 1 ]; then
87 echo "Skipping post-package customize steps"
91 hack_nsswitch_conf ( )
93 # Remove all references to NIS in the nsswitch.conf file
94 # Not sure this is still needed, but FreeNAS has it...
95 sed -i.bak -es/nis/files/g ${NANO_WORLDDIR}/etc/nsswitch.conf
96 rm -f ${NANO_WORLDDIR}/etc/nsswitch.conf.bak
98 customize_cmd hack_nsswitch_conf
102 VERSION_FILE=${NANO_WORLDDIR}/etc/version
103 if [ "${SVNREVISION}" = "${REVISION}" ]; then
104 echo "${NANO_NAME}" > "${VERSION_FILE}"
106 echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}"
109 customize_cmd save_build
111 remove_patch_divots ( )
113 find ${NANO_WORLDDIR} -name \*.orig -or -name \*.rej -delete
115 customize_cmd remove_patch_divots
119 mkdir -m 755 -p ${NANO_WORLDDIR}/conf/base/mnt
120 echo 2048 > ${NANO_WORLDDIR}/conf/base/mnt/md_size
122 customize_cmd configure_mnt_md
126 # We have a lot of little files on our memory disks. Let's decrease
127 # the block and frag size to fit more little files on them (this
128 # halves our space requirement by ~50% on /etc and /var on 8.x --
129 # and gives us more back on 9.x as the default block and frag size
130 # are 4 times larger).
131 sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \
132 ${NANO_WORLDDIR}/etc/rc.initdiskless
134 customize_cmd shrink_md_fbsize
136 if [ "${DEBUG}" = 1 ]; then
138 unmute_console_logging()
140 # /var is small. Don't fill it up with messages from console.log
141 # because it's a chatty log.
142 sed -i '' -e 's/#console.info/console.info/' \
143 "${NANO_WORLDDIR}/etc/syslog.conf"
145 customize_cmd unmute_console_logging
151 gzip -v9 ${NANO_WORLDDIR}/boot/kernel/kernel
153 # kill includes (saves 14MB)
154 find ${NANO_WORLDDIR}/usr/local/include \! -name 'pyconfig.h' -type f | xargs rm -f
156 # kill docs (saves 22MB)
157 rm -rf ${NANO_WORLDDIR}/usr/local/share/doc
158 rm -rf ${NANO_WORLDDIR}/usr/local/share/gtk-doc
161 rm -rf ${NANO_WORLDDIR}/usr/local/info
163 # and man pages (4.4MB)
164 rm -rf ${NANO_WORLDDIR}/usr/local/man
166 # and examples (1.7M)
167 rm -rf ${NANO_WORLDDIR}/usr/local/share/examples
169 # and groff_fonts junk (3MB)
170 rm -rf ${NANO_WORLDDIR}/usr/share/groff_font
171 rm -rf ${NANO_WORLDDIR}/usr/share/tmac
172 rm -rf ${NANO_WORLDDIR}/usr/share/me
174 # Kill all .a's and .la's that are installed (20MB+)
175 find ${NANO_WORLDDIR} -name \*.a -or -name \*.la -delete
177 # magic.mgc is just a speed optimization. Kill it for 1.7MB
178 rm -f ${NANO_WORLDDIR}/usr/share/misc/magic.mgc
181 chown -R root:wheel ${NANO_WORLDDIR}/root
182 chmod 0755 ${NANO_WORLDDIR}/root/*
183 chmod 0755 ${NANO_WORLDDIR}/*
184 chown -R root:wheel ${NANO_WORLDDIR}/etc
185 chown -R root:wheel ${NANO_WORLDDIR}/boot
186 chown root:wheel ${NANO_WORLDDIR}/
187 chown root:wheel ${NANO_WORLDDIR}/usr
188 find ${NANO_WORLDDIR} -type f -name "*~" -delete
189 find ${NANO_WORLDDIR}/usr/local -type f -name "*.po" -delete
190 find ${NANO_WORLDDIR} -type f -name "*.service" -delete
192 late_customize_cmd product_custom
194 fi # [ $PACKAGE_PREP_BUILD = 1 ]