4 # Copyright (c) 2014 M. Warner Losh <imp@FreeBSD.org>
5 # Copyright (c) 2010 iXsystems, Inc.
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
29 # This file is heavily derived from both Sam Leffler's Avilia config,
30 # as well as the BSDRP project's config file. Neither of these have
31 # an explicit copyright/license statement, but are implicitly BSDL. This
32 # example has been taken from the FreeNAS project (an early version) and
33 # simplified to meet the needs of the example.
36 # NB: You want the other file
38 NANO_PMAKE="make -j $(sysctl -n hw.ncpu)"
41 NANO_CFG_BASE=${NANO_CFG_BASE%/dhcpd}
43 NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/dhcpd}
44 NANO_OBJ=${NANO_SRC}/../dhcpd/obj
45 # Where cust_pkg() finds packages to install
46 #XXX: Is this the right place?
47 #NANO_PORTS=$(realpath ${NANO_SRC}/../ports)
49 NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
50 NANO_DATADIR=${NANO_OBJ}/_.data
53 unset MAKEOBJDIRPREFIX
55 # this to go into nanobsd.sh
56 NANO_PORTS=${NANO_PORTS:-/usr/ports}
58 customize_cmd cust_allow_ssh_root
62 touch ${NANO_WORLDDIR}/etc/make.conf
64 customize_cmd add_etc_make_conf
68 LOCAL_DIR=${NANO_WORLDDIR}/usr/local
69 pprint 2 "Clean and create world directory (${LOCAL_DIR})"
70 if rm -rf ${LOCAL_DIR}/ > /dev/null 2>&1 ; then
73 chflags -R noschg ${LOCAL_DIR}/
76 for f in bin etc lib libdata libexec sbin share; do
77 mkdir -p ${LOCAL_DIR}/$f
80 customize_cmd clean_usr_local
82 cust_install_machine_files()
84 echo "cd ${NANO_CFG_BASE}/Files"
85 cd ${NANO_CFG_BASE}/Files
86 find . -print | grep -Ev '/(CVS|\.git|\.hg|\.svn)' | cpio -dumpv ${NANO_WORLDDIR}
88 customize_cmd cust_install_files
89 customize_cmd cust_install_machine_files
94 env __MAKE_CONF=${NANO_MAKE_CONF_BUILD} DESTDIR=${NANO_WORLDDIR} make buildenv
97 NANO_MAKEFS="makefs -B big \
98 -o bsize=4096,fsize=512,density=8192,optimization=space"
101 # NB: leave c++ enabled so devd can be built
106 WITHOUT_BLUETOOTH=true
107 WITHOUT_CALENDAR=true
109 WITHOUT_EXAMPLES=true
113 WITHOUT_IPFILTER=true
120 WITHOUT_NS_CACHING=true
122 WITHOUT_SENDMAIL=true
123 WITHOUT_SHAREDOCS=true
127 CONF_INSTALL="$CONF_BUILD
130 NO_INSTALL_MANPAGES=t
132 # The following would help...
133 # WITHOUT_TOOLCHAIN=true can't build ports
134 # WITHOUT_INSTALLLIB=true libgcc.a
136 WITHOUT_TOOLCHAIN=true
137 WITHOUT_INSTALLLIB=true
142 # install a package from a pre-built binary
145 # Need to create ${NANO_OBJ}/ports in this add_pkg_${port} function
147 mkdir -p ${NANO_OBJ}/ports/distfiles
148 mkdir -p ${NANO_OBJ}/ports/packages
149 mkdir -p ${NANO_WORLDDIR}/usr/ports/packages
150 mkdir -p ${NANO_WORLDDIR}/usr/ports/distfiles
151 mount -t nullfs -o noatime ${NANO_OBJ}/ports/packages \
152 ${NANO_WORLDDIR}/usr/ports/packages
153 mount -t nullfs -o noatime ${NANO_OBJ}/ports/distfiles \
154 ${NANO_WORLDDIR}/usr/ports/distfiles
155 CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /usr/ports/packages/All/$1.txz
156 umount ${NANO_WORLDDIR}/usr/ports/distfiles
157 umount ${NANO_WORLDDIR}/usr/ports/packages
158 rmdir ${NANO_WORLDDIR}/usr/ports/packages
159 rmdir ${NANO_WORLDDIR}/usr/ports/distfiles
160 rmdir ${NANO_WORLDDIR}/usr/ports
164 # Build a port (with the side effect of creating a package)
171 # Need to create ${NANO_OBJ}/ports in this add_port_${port} function
172 mkdir -p ${NANO_OBJ}/ports/distfiles
173 mkdir -p ${NANO_OBJ}/ports/packages
174 mkdir -p ${NANO_PORTS}/packages
175 mkdir -p ${NANO_PORTS}/distfiles
176 mkdir -p ${NANO_WORLDDIR}/usr/src
177 mkdir -p ${NANO_WORLDDIR}/usr/ports
178 mount -t nullfs -o noatime ${NANO_SRC} ${NANO_WORLDDIR}/usr/src
179 mount -t nullfs -o noatime ${NANO_PORTS} ${NANO_WORLDDIR}/usr/ports
180 mount -t nullfs -o noatime ${NANO_OBJ}/ports/packages \
181 ${NANO_WORLDDIR}/usr/ports/packages
182 mount -t nullfs -o noatime ${NANO_OBJ}/ports/distfiles \
183 ${NANO_WORLDDIR}/usr/ports/distfiles
184 mkdir -p ${NANO_WORLDDIR}/dev
185 mount -t devfs devfs ${NANO_WORLDDIR}/dev
186 mkdir -p ${NANO_WORLDDIR}/usr/workdir
187 cp /etc/resolv.conf ${NANO_WORLDDIR}/etc/resolv.conf
188 # OK, a little inefficient, but likely not enough to worry about.
189 CR ldconfig /lib /usr/lib /usr/local/lib
192 # Improvement: Don't know why package-recursive don't works here
193 CR "env UNAME_p=${NANO_ARCH} TARGET=${NANO_ARCH} \
194 TARGET_ARCH=${NANO_ARCH} PORTSDIR=${NANO_PORTS} make \
195 __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
196 WRKDIRPREFIX=/usr/workdir -C /usr/ports/$port_path \
197 package-recursive BATCH=yes $* clean FORCE_PKG_REGISTER=t"
198 rm ${NANO_WORLDDIR}/etc/resolv.conf
199 rm -rf ${NANO_WORLDDIR}/usr/obj
200 rm -rf ${NANO_WORLDDIR}/usr/workdir
201 umount ${NANO_WORLDDIR}/dev
202 umount ${NANO_WORLDDIR}/usr/ports/packages
203 umount ${NANO_WORLDDIR}/usr/ports/distfiles
204 umount ${NANO_WORLDDIR}/usr/ports
205 umount ${NANO_WORLDDIR}/usr/src
209 # Need to check if this function works with cross-compiling architecture!!!!
210 # Recursive complex fonction: Generate one function for each ports
213 local port=`echo $1 | sed -e 's/\//_/'`
215 # Check if package already exist
217 # 1. check ARCH of this package!
219 cd ${NANO_PORTS}/${port_path}
220 PKG_NAME=`env PORTSDIR=${NANO_PORTS} make __MAKE_CONF=${NANO_MAKE_CONF_BUILD} package-name`
221 if [ -f ${NANO_OBJ}/ports/packages/All/${PKG_NAME}.txz ]; then
222 # Pkg file found: Generate add_pkg_NAME function
225 do_add_pkg ${PKG_NAME}
227 customize_cmd add_pkg_${port}
230 # No pkg file: Generate add_port_NAME function
232 add_port_${port} () {
233 do_add_port ${port_path} $*
235 customize_cmd add_port_${port}
247 # Automatically include the packaging port here so it is always first so it
248 # builds the port and adds the package so we can add other packages.
249 add_port ports-mgmt/pkg
251 rp=$(realpath ${NANO_OBJ}/)
252 __a=`mount | grep ${rp} | awk '{print length($3), $3;}' | sort -rn | awk '{$1=""; print;}'`
253 if [ -n "$__a" ]; then
254 echo "unmounting $__a"
258 NANO_BOOTLOADER="boot/boot0"