Changeset View
Changeset View
Standalone View
Standalone View
tools/tools/nanobsd/defaults.sh
| Show First 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | |||||
| NANO_ARCH=`uname -p` | NANO_ARCH=`uname -p` | ||||
| # CPUTYPE defaults to "" which is the default when CPUTYPE isn't | # CPUTYPE defaults to "" which is the default when CPUTYPE isn't | ||||
| # defined. | # defined. | ||||
| NANO_CPUTYPE="" | NANO_CPUTYPE="" | ||||
| # Directory to populate /cfg from | # Directory to populate /cfg from | ||||
| NANO_CFGDIR="" | NANO_CFGDIR="" | ||||
| NANO_METALOG_CFG="" | |||||
| # Directory to populate /data from | # Directory to populate /data from | ||||
| NANO_DATADIR="" | NANO_DATADIR="" | ||||
| NANO_METALOG_DATA="" | |||||
| # We don't need SRCCONF or SRC_ENV_CONF. NanoBSD puts everything we | # We don't need SRCCONF or SRC_ENV_CONF. NanoBSD puts everything we | ||||
| # need for the build in files included with __MAKE_CONF. Override in your | # need for the build in files included with __MAKE_CONF. Override in your | ||||
| # config file if you really must. We set them unconditionally here, though | # config file if you really must. We set them unconditionally here, though | ||||
| # in case they are stray in the build environment | # in case they are stray in the build environment | ||||
| SRCCONF=/dev/null | SRCCONF=/dev/null | ||||
| SRC_ENV_CONF=/dev/null | SRC_ENV_CONF=/dev/null | ||||
| ▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | make_conf_build() { | ||||
| printenv > ${MAKEOBJDIRPREFIX}/_.env | printenv > ${MAKEOBJDIRPREFIX}/_.env | ||||
| # Make sure we get all the global settings that NanoBSD wants | # Make sure we get all the global settings that NanoBSD wants | ||||
| # in addition to the user's global settings | # in addition to the user's global settings | ||||
| ( | ( | ||||
| nano_global_make_env | nano_global_make_env | ||||
| echo "${CONF_WORLD}" | echo "${CONF_WORLD}" | ||||
| echo "${CONF_BUILD}" | echo "${CONF_BUILD}" | ||||
| if [ -n "${NANO_NOPRIV_BUILD}" ]; then | |||||
| echo NO_ROOT=true | |||||
| echo METALOG="${NANO_METALOG}" | |||||
| fi | |||||
| ) > ${NANO_MAKE_CONF_BUILD} | ) > ${NANO_MAKE_CONF_BUILD} | ||||
| } | } | ||||
| build_world() { | build_world() { | ||||
| pprint 2 "run buildworld" | pprint 2 "run buildworld" | ||||
| pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bw" | pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bw" | ||||
| ( | ( | ||||
| ▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | setup_nanobsd() { | ||||
| # to have the symlink in error though. | # to have the symlink in error though. | ||||
| tgt_dir2symlink usr/local/etc ../../etc/local 0755 | tgt_dir2symlink usr/local/etc ../../etc/local 0755 | ||||
| for d in var etc | for d in var etc | ||||
| do | do | ||||
| # link /$d under /conf | # link /$d under /conf | ||||
| # we use hard links so we have them both places. | # we use hard links so we have them both places. | ||||
| # the files in /$d will be hidden by the mount. | # the files in /$d will be hidden by the mount. | ||||
| mkdir -p conf/base/$d conf/default/$d | tgt_dir conf/base/$d conf/default/$d | ||||
| find $d -print | cpio ${CPIO_SYMLINK} -dumpl conf/base/ | find $d -print | cpio ${CPIO_SYMLINK} -dumpl conf/base/ | ||||
| if [ -n "$NANO_METALOG" ]; then | |||||
| grep "^.\/${d}\/" "${NANO_METALOG}" | | |||||
| sed -e "s=^./${d}=./conf/base/${d}=g" | | |||||
| sort | uniq >> "${NANO_METALOG}.conf" | |||||
| fi | |||||
| done | done | ||||
| if [ -n "$NANO_METALOG" ]; then | |||||
| cat "${NANO_METALOG}.conf" >> "${NANO_METALOG}" | |||||
| rm -f "${NANO_METALOG}.conf" | |||||
| fi | |||||
| echo "$NANO_RAM_ETCSIZE" > conf/base/etc/md_size | echo "$NANO_RAM_ETCSIZE" > conf/base/etc/md_size | ||||
| echo "$NANO_RAM_TMPVARSIZE" > conf/base/var/md_size | echo "$NANO_RAM_TMPVARSIZE" > conf/base/var/md_size | ||||
| tgt_touch conf/base/etc/md_size | |||||
| tgt_touch conf/base/var/md_size | |||||
| # pick up config files from the special partition | # pick up config files from the special partition | ||||
| echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount | echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount | ||||
| tgt_touch conf/default/etc/remount | |||||
| # Put /tmp on the /var ramdisk (could be symlink already) | # Put /tmp on the /var ramdisk (could be symlink already) | ||||
| tgt_dir2symlink tmp var/tmp 1777 | tgt_dir2symlink tmp var/tmp 1777 | ||||
| ) > ${NANO_LOG}/_.dl 2>&1 | ) > ${NANO_LOG}/_.dl 2>&1 | ||||
| } | } | ||||
| setup_nanobsd_etc() { | setup_nanobsd_etc() { | ||||
| Show All 40 Lines | EOF | ||||
| then | then | ||||
| echo "Regular expression pattern not found" | echo "Regular expression pattern not found" | ||||
| exit 2 | exit 2 | ||||
| fi | fi | ||||
| [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf | [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf | ||||
| # save config file for scripts | # save config file for scripts | ||||
| echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf | echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf | ||||
| tgt_touch etc/nanobsd.conf | |||||
| echo "/dev/${NANO_DRIVE}${NANO_ROOT} / ufs ro 1 1" > etc/fstab | echo "/dev/${NANO_DRIVE}${NANO_ROOT} / ufs ro 1 1" > etc/fstab | ||||
| echo "/dev/${NANO_DRIVE}${NANO_SLICE_CFG} /cfg ufs rw,noauto 2 2" >> etc/fstab | echo "/dev/${NANO_DRIVE}${NANO_SLICE_CFG} /cfg ufs rw,noauto 2 2" >> etc/fstab | ||||
| mkdir -p cfg | tgt_touch etc/fstab | ||||
| tgt_dir cfg | |||||
| # Create directory for eventual /usr/local/etc contents | # Create directory for eventual /usr/local/etc contents | ||||
| mkdir -p etc/local | tgt_dir etc/local | ||||
| ) | ) | ||||
| } | } | ||||
| prune_usr() { | prune_usr() { | ||||
| # Remove all empty directories in /usr | # Remove all empty directories in /usr | ||||
| find "${NANO_WORLDDIR}"/usr -type d -depth -print | | find "${NANO_WORLDDIR}"/usr -type d -depth -print | | ||||
| while read d | while read d | ||||
| do | do | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
| cust_install_files() ( | cust_install_files() ( | ||||
| cd "${NANO_TOOLS}/Files" | cd "${NANO_TOOLS}/Files" | ||||
| find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio ${CPIO_SYMLINK} -Ldumpv ${NANO_WORLDDIR} | find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio ${CPIO_SYMLINK} -Ldumpv ${NANO_WORLDDIR} | ||||
| if [ -n "${NANO_CUST_FILES_MTREE}" -a -f ${NANO_CUST_FILES_MTREE} ]; then | if [ -n "${NANO_CUST_FILES_MTREE}" -a -f ${NANO_CUST_FILES_MTREE} ]; then | ||||
| CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE} | CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE} | ||||
| fi | fi | ||||
| tgt_touch $(find * -type f) | |||||
| ) | ) | ||||
| ####################################################################### | ####################################################################### | ||||
| # Install packages from ${NANO_PACKAGE_DIR} | # Install packages from ${NANO_PACKAGE_DIR} | ||||
| cust_pkgng() { | cust_pkgng() { | ||||
| mkdir -p ${NANO_WORLDDIR}/usr/local/etc | mkdir -p ${NANO_WORLDDIR}/usr/local/etc | ||||
| local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf" | local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf" | ||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | pprint() { | ||||
| if [ "$1" -le $PPLEVEL ]; then | if [ "$1" -le $PPLEVEL ]; then | ||||
| runtime=$(( `date +%s` - $NANO_STARTTIME )) | runtime=$(( `date +%s` - $NANO_STARTTIME )) | ||||
| printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3 | printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3 | ||||
| fi | fi | ||||
| } | } | ||||
| usage() { | usage() { | ||||
| ( | ( | ||||
| echo "Usage: $0 [-BbfhIiKknpqvWwX] [-c config_file]" | echo "Usage: $0 [-BbfhIiKknpqUvWwX] [-c config_file]" | ||||
| echo " -B suppress installs (both kernel and world)" | echo " -B suppress installs (both kernel and world)" | ||||
| echo " -b suppress builds (both kernel and world)" | echo " -b suppress builds (both kernel and world)" | ||||
| echo " -c specify config file" | echo " -c specify config file" | ||||
| echo " -f suppress code slice extraction (implies -i)" | echo " -f suppress code slice extraction (implies -i)" | ||||
| echo " -h print this help summary page" | echo " -h print this help summary page" | ||||
| echo " -I build disk image from existing build/install" | echo " -I build disk image from existing build/install" | ||||
| echo " -i suppress disk image build" | echo " -i suppress disk image build" | ||||
| echo " -K suppress installkernel" | echo " -K suppress installkernel" | ||||
| echo " -k suppress buildkernel" | echo " -k suppress buildkernel" | ||||
| echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc" | echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc" | ||||
| echo " -p suppress preparing the image" | echo " -p suppress preparing the image" | ||||
| echo " -q make output more quiet" | echo " -q make output more quiet" | ||||
| echo " -U add -DNO_ROOT to build without root privileges" | |||||
| echo " -v make output more verbose" | echo " -v make output more verbose" | ||||
| echo " -W suppress installworld" | echo " -W suppress installworld" | ||||
| echo " -w suppress buildworld" | echo " -w suppress buildworld" | ||||
| echo " -X make native-xtools" | echo " -X make native-xtools" | ||||
| ) 1>&2 | ) 1>&2 | ||||
| exit 2 | exit 2 | ||||
| } | } | ||||
| Show All 15 Lines | set_defaults_and_export() { | ||||
| : ${MAKEOBJDIRPREFIX:=${NANO_OBJ}} | : ${MAKEOBJDIRPREFIX:=${NANO_OBJ}} | ||||
| : ${NANO_DISKIMGDIR:=${NANO_OBJ}} | : ${NANO_DISKIMGDIR:=${NANO_OBJ}} | ||||
| : ${NANO_WORLDDIR:=${NANO_OBJ}/_.w} | : ${NANO_WORLDDIR:=${NANO_OBJ}/_.w} | ||||
| : ${NANO_LOG:=${NANO_OBJ}} | : ${NANO_LOG:=${NANO_OBJ}} | ||||
| : ${NANO_PMAKE:="${NANO_MAKE} -j ${NANO_NCPU}"} | : ${NANO_PMAKE:="${NANO_MAKE} -j ${NANO_NCPU}"} | ||||
| if ! $do_clean; then | if ! $do_clean; then | ||||
| NANO_PMAKE="${NANO_PMAKE} -DNO_CLEAN" | NANO_PMAKE="${NANO_PMAKE} -DNO_CLEAN" | ||||
| fi | fi | ||||
| if ! $do_root; then | |||||
| NANO_PMAKE="${NANO_PMAKE} -DNO_ROOT" | |||||
| fi | |||||
| NANO_MAKE_CONF_BUILD=${MAKEOBJDIRPREFIX}/make.conf.build | NANO_MAKE_CONF_BUILD=${MAKEOBJDIRPREFIX}/make.conf.build | ||||
| NANO_MAKE_CONF_INSTALL=${NANO_OBJ}/make.conf.install | NANO_MAKE_CONF_INSTALL=${NANO_OBJ}/make.conf.install | ||||
| # Override user's NANO_DRIVE if they specified a NANO_LABEL | # Override user's NANO_DRIVE if they specified a NANO_LABEL | ||||
| [ -n "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}" || true | [ -n "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}" || true | ||||
| # Set a default NANO_TOOLS to NANO_SRC/NANO_TOOLS if it exists. | # Set a default NANO_TOOLS to NANO_SRC/NANO_TOOLS if it exists. | ||||
| [ ! -d "${NANO_TOOLS}" ] && [ -d "${NANO_SRC}/${NANO_TOOLS}" ] && \ | [ ! -d "${NANO_TOOLS}" ] && [ -d "${NANO_SRC}/${NANO_TOOLS}" ] && \ | ||||
| NANO_TOOLS="${NANO_SRC}/${NANO_TOOLS}" || true | NANO_TOOLS="${NANO_SRC}/${NANO_TOOLS}" || true | ||||
| [ -n "${NANO_NOPRIV_BUILD}" ] && [ -z "${NANO_METALOG}" ] && \ | if [ -n "${NANO_NOPRIV_BUILD}" ] && [ -z "${NANO_METALOG}" ]; then | ||||
| NANO_METALOG=${NANO_OBJ}/_.metalog || true | NANO_METALOG=${NANO_OBJ}/_.metalog | ||||
| fi | |||||
| NANO_STARTTIME=`date +%s` | NANO_STARTTIME=`date +%s` | ||||
| : ${NANO_TIMESTAMP:=${NANO_STARTTIME}} | : ${NANO_TIMESTAMP:=${NANO_STARTTIME}} | ||||
| pprint 3 "Exporting NanoBSD variables" | pprint 3 "Exporting NanoBSD variables" | ||||
| export_var MAKEOBJDIRPREFIX | export_var MAKEOBJDIRPREFIX | ||||
| export_var NANO_ARCH | export_var NANO_ARCH | ||||
| export_var NANO_CODESIZE | export_var NANO_CODESIZE | ||||
| export_var NANO_CONFSIZE | export_var NANO_CONFSIZE | ||||
| Show All 32 Lines | |||||