mirror of
https://github.com/outbackdingo/clonos-build.git
synced 2026-01-27 10:18:35 +00:00
init
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
clonos
|
||||
MANIFEST
|
||||
clonos.txz
|
||||
19
README.txt
Normal file
19
README.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Структура clonos.txz
|
||||
|
||||
clonos\
|
||||
содержит .txz всех пакетов
|
||||
|
||||
clonos\Latest
|
||||
содержит pkg.txz (авто после cbsd-cpr)
|
||||
|
||||
+
|
||||
clonos\bases\base_amd64_amd64_12
|
||||
clonos\bases\cbsd
|
||||
+
|
||||
clono/bases/cbsdpuppet1.img - jexport
|
||||
|
||||
auto from
|
||||
src/usr.sbin/bsdinstall/scripts/auto
|
||||
|
||||
rc.local from
|
||||
/usr/jails/src/src_12/src/release/rc.local
|
||||
500
auto
Executable file
500
auto
Executable file
@@ -0,0 +1,500 @@
|
||||
#!/bin/sh
|
||||
#-
|
||||
# Copyright (c) 2011 Nathan Whitehorn
|
||||
# Copyright (c) 2013 Devin Teske
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD: stable/12/usr.sbin/bsdinstall/scripts/auto 328839 2018-02-04 12:16:36Z allanjude $
|
||||
#
|
||||
############################################################ INCLUDES
|
||||
|
||||
BSDCFG_SHARE="/usr/share/bsdconfig"
|
||||
. $BSDCFG_SHARE/common.subr || exit 1
|
||||
f_include $BSDCFG_SHARE/dialog.subr
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
error() {
|
||||
local msg
|
||||
if [ -n "$1" ]; then
|
||||
msg="$1\n\n"
|
||||
fi
|
||||
test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR
|
||||
test -f $PATH_FSTAB && bsdinstall umount
|
||||
dialog --backtitle "FreeBSD Installer" --title "Abort" \
|
||||
--no-label "Exit" --yes-label "Restart" --yesno \
|
||||
"${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
exec $0
|
||||
fi
|
||||
}
|
||||
|
||||
hline_arrows_tab_enter="Press arrows, TAB or ENTER"
|
||||
msg_gpt_active_fix="Your hardware is known to have issues booting in CSM/Legacy/BIOS mode from GPT partitions that are not set active. Would you like the installer to apply this workaround for you?"
|
||||
msg_lenovo_fix="Your model of Lenovo is known to have a BIOS bug that prevents it booting from GPT partitions without UEFI. Would you like the installer to apply a workaround for you?"
|
||||
msg_no="NO"
|
||||
msg_yes="YES"
|
||||
|
||||
# dialog_workaround
|
||||
#
|
||||
# Ask the user if they wish to apply a workaround
|
||||
#
|
||||
dialog_workaround()
|
||||
{
|
||||
local passed_msg="$1"
|
||||
local title="$DIALOG_TITLE"
|
||||
local btitle="$DIALOG_BACKTITLE"
|
||||
local prompt # Calculated below
|
||||
local hline="$hline_arrows_tab_enter"
|
||||
|
||||
local height=8 width=50 prefix=" "
|
||||
local plen=${#prefix} list= line=
|
||||
local max_width=$(( $width - 3 - $plen ))
|
||||
|
||||
local yes no defaultno extra_args format
|
||||
if [ "$USE_XDIALOG" ]; then
|
||||
yes=ok no=cancel defaultno=default-no
|
||||
extra_args="--wrap --left"
|
||||
format="$passed_msg"
|
||||
else
|
||||
yes=yes no=no defaultno=defaultno
|
||||
extra_args="--cr-wrap"
|
||||
format="$passed_msg"
|
||||
fi
|
||||
|
||||
# Add height for Xdialog(1)
|
||||
[ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 ))
|
||||
|
||||
prompt=$( printf "$format" )
|
||||
f_dprintf "%s: Workaround prompt" "$0"
|
||||
$DIALOG \
|
||||
--title "$title" \
|
||||
--backtitle "$btitle" \
|
||||
--hline "$hline" \
|
||||
--$yes-label "$msg_yes" \
|
||||
--$no-label "$msg_no" \
|
||||
$extra_args \
|
||||
--yesno "$prompt" $height $width
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
f_dprintf "Began Installation at %s" "$( date )"
|
||||
|
||||
rm -rf $BSDINSTALL_TMPETC
|
||||
mkdir $BSDINSTALL_TMPETC
|
||||
|
||||
trap true SIGINT # This section is optional
|
||||
bsdinstall keymap
|
||||
|
||||
trap error SIGINT # Catch cntrl-C here
|
||||
bsdinstall hostname || error "Set hostname failed"
|
||||
|
||||
export DISTRIBUTIONS="base.txz kernel.txz"
|
||||
if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
|
||||
DISTMENU=`awk -F'\t' '!/^(kernel\.txz|base\.txz)/{print $1,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST`
|
||||
DISTMENU="$(echo ${DISTMENU} | sed -E 's/\.txz//g')"
|
||||
|
||||
exec 3>&1
|
||||
EXTRA_DISTS=$( eval dialog \
|
||||
--backtitle \"FreeBSD Installer\" \
|
||||
--title \"Distribution Select\" --nocancel --separate-output \
|
||||
--checklist \"Choose optional system components to install:\" \
|
||||
0 0 0 $DISTMENU \
|
||||
2>&1 1>&3 )
|
||||
for dist in $EXTRA_DISTS; do
|
||||
export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
|
||||
done
|
||||
fi
|
||||
|
||||
LOCAL_DISTRIBUTIONS="MANIFEST"
|
||||
FETCH_DISTRIBUTIONS=""
|
||||
for dist in $DISTRIBUTIONS; do
|
||||
if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
|
||||
FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
|
||||
else
|
||||
LOCAL_DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS $dist"
|
||||
fi
|
||||
done
|
||||
LOCAL_DISTRIBUTIONS=`echo $LOCAL_DISTRIBUTIONS` # Trim white space
|
||||
FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space
|
||||
|
||||
if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then
|
||||
dialog --backtitle "FreeBSD Installer" --title "Network Installation" --msgbox "Some installation files were not found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0
|
||||
bsdinstall netconfig || error
|
||||
NETCONFIG_DONE=yes
|
||||
fi
|
||||
|
||||
if [ -n "$FETCH_DISTRIBUTIONS" ]; then
|
||||
exec 3>&1
|
||||
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
|
||||
MIRROR_BUTTON=$?
|
||||
exec 3>&-
|
||||
test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
|
||||
export BSDINSTALL_DISTSITE
|
||||
fi
|
||||
|
||||
rm -f $PATH_FSTAB
|
||||
touch $PATH_FSTAB
|
||||
|
||||
#
|
||||
# Try to detect known broken platforms and apply their workarounds
|
||||
#
|
||||
|
||||
if f_interactive; then
|
||||
sys_maker=$( kenv -q smbios.system.maker )
|
||||
f_dprintf "smbios.system.maker=[%s]" "$sys_maker"
|
||||
sys_model=$( kenv -q smbios.system.product )
|
||||
f_dprintf "smbios.system.product=[%s]" "$sys_model"
|
||||
sys_version=$( kenv -q smbios.system.version )
|
||||
f_dprintf "smbios.system.version=[%s]" "$sys_version"
|
||||
sys_mb_maker=$( kenv -q smbios.planar.maker )
|
||||
f_dprintf "smbios.planar.maker=[%s]" "$sys_mb_maker"
|
||||
sys_mb_product=$( kenv -q smbios.planar.product )
|
||||
f_dprintf "smbios.planar.product=[%s]" "$sys_mb_product"
|
||||
|
||||
#
|
||||
# Laptop Models
|
||||
#
|
||||
case "$sys_maker" in
|
||||
"LENOVO")
|
||||
case "$sys_version" in
|
||||
"ThinkPad X220"|"ThinkPad T420"|"ThinkPad T520"|"ThinkPad W520"|"ThinkPad X1")
|
||||
dialog_workaround "$msg_lenovo_fix"
|
||||
retval=$?
|
||||
f_dprintf "lenovofix_prompt=[%s]" "$retval"
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
export ZFSBOOT_PARTITION_SCHEME="GPT + Lenovo Fix"
|
||||
export WORKAROUND_LENOVO=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"Dell Inc.")
|
||||
case "$sys_model" in
|
||||
"Latitude E6330"|"Latitude E7440"|"Latitude E7240"|"Precision Tower 5810")
|
||||
dialog_workaround "$msg_gpt_active_fix"
|
||||
retval=$?
|
||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
|
||||
export WORKAROUND_GPTACTIVE=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"Hewlett-Packard")
|
||||
case "$sys_model" in
|
||||
"HP ProBook 4330s")
|
||||
dialog_workaround "$msg_gpt_active_fix"
|
||||
retval=$?
|
||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
|
||||
export WORKAROUND_GPTACTIVE=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
#
|
||||
# Motherboard Models
|
||||
#
|
||||
case "$sys_mb_maker" in
|
||||
"Intel Corporation")
|
||||
case "$sys_mb_product" in
|
||||
"DP965LT"|"D510MO")
|
||||
dialog_workaround "$msg_gpt_active_fix"
|
||||
retval=$?
|
||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
|
||||
export WORKAROUND_GPTACTIVE=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"Acer")
|
||||
case "$sys_mb_product" in
|
||||
"Veriton M6630G")
|
||||
dialog_workaround "$msg_gpt_active_fix"
|
||||
retval=$?
|
||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
|
||||
export WORKAROUND_GPTACTIVE=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#PMODES="\
|
||||
#\"Auto (UFS)\" \"Guided Disk Setup\" \
|
||||
#Manual \"Manual Disk Setup (experts)\" \
|
||||
#Shell \"Open a shell and partition by hand\""
|
||||
|
||||
# ClonOS
|
||||
PMODES="\
|
||||
\"Auto (ZFS)\" \"Guided Root-on-ZFS\" \
|
||||
Manual \"Manual Disk Setup (experts)\" \
|
||||
Shell \"Open a shell and partition by hand\""
|
||||
# ClonOS
|
||||
|
||||
CURARCH=$( uname -m )
|
||||
#case $CURARCH in
|
||||
# amd64|arm64|i386) # Booting ZFS Supported
|
||||
# PMODES="$PMODES \"Auto (ZFS)\" \"Guided Root-on-ZFS\""
|
||||
# ;;
|
||||
# *) # Booting ZFS Unspported
|
||||
# ;;
|
||||
#esac
|
||||
|
||||
exec 3>&1
|
||||
PARTMODE=`echo $PMODES | xargs dialog --backtitle "FreeBSD Installer" \
|
||||
--title "Partitioning" \
|
||||
--menu "How would you like to partition your disk?" \
|
||||
0 0 0 2>&1 1>&3` || exit 1
|
||||
exec 3>&-
|
||||
|
||||
case "$PARTMODE" in
|
||||
"Auto (UFS)") # Guided
|
||||
bsdinstall autopart || error "Partitioning error"
|
||||
bsdinstall mount || error "Failed to mount filesystem"
|
||||
;;
|
||||
"Shell") # Shell
|
||||
clear
|
||||
echo "Use this shell to set up partitions for the new system. When finished, mount the system at $BSDINSTALL_CHROOT and place an fstab file for the new system at $PATH_FSTAB. Then type 'exit'. You can also enter the partition editor at any time by entering 'bsdinstall partedit'."
|
||||
sh 2>&1
|
||||
;;
|
||||
"Manual") # Manual
|
||||
if f_isset debugFile; then
|
||||
# Give partedit the path to our logfile so it can append
|
||||
BSDINSTALL_LOG="${debugFile#+}" bsdinstall partedit || error "Partitioning error"
|
||||
else
|
||||
bsdinstall partedit || error "Partitioning error"
|
||||
fi
|
||||
bsdinstall mount || error "Failed to mount filesystem"
|
||||
;;
|
||||
"Auto (ZFS)") # ZFS
|
||||
bsdinstall zfsboot || error "ZFS setup failed"
|
||||
bsdinstall mount || error "Failed to mount filesystem"
|
||||
;;
|
||||
*)
|
||||
error "Unknown partitioning mode"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
|
||||
ALL_DISTRIBUTIONS="$DISTRIBUTIONS"
|
||||
WANT_DEBUG=
|
||||
|
||||
# Download to a directory in the new system as scratch space
|
||||
BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist"
|
||||
mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST"
|
||||
|
||||
export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS"
|
||||
# Try to use any existing distfiles
|
||||
if [ -d $BSDINSTALL_DISTDIR ]; then
|
||||
DISTDIR_IS_UNIONFS=1
|
||||
mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR"
|
||||
else
|
||||
export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS"
|
||||
export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST"
|
||||
fi
|
||||
|
||||
export FTP_PASSIVE_MODE=YES
|
||||
# Iterate through the distribution list and set a flag if debugging
|
||||
# distributions have been selected.
|
||||
for _DISTRIBUTION in $DISTRIBUTIONS; do
|
||||
case $_DISTRIBUTION in
|
||||
*-dbg.*)
|
||||
[ -e $BSDINSTALL_DISTDIR/$_DISTRIBUTION ] \
|
||||
&& continue
|
||||
WANT_DEBUG=1
|
||||
DEBUG_LIST="\n$DEBUG_LIST\n$_DISTRIBUTION"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Fetch the distributions.
|
||||
bsdinstall distfetch
|
||||
rc=$?
|
||||
|
||||
if [ $rc -ne 0 ]; then
|
||||
# If unable to fetch the remote distributions, recommend
|
||||
# deselecting the debugging distributions, and retrying the
|
||||
# installation, since failure to fetch *-dbg.txz should not
|
||||
# be considered a fatal installation error.
|
||||
msg="Failed to fetch remote distribution"
|
||||
if [ ! -z "$WANT_DEBUG" ]; then
|
||||
# Trim leading and trailing newlines.
|
||||
DEBUG_LIST="${DEBUG_LIST%%\n}"
|
||||
DEBUG_LIST="${DEBUG_LIST##\n}"
|
||||
msg="$msg\n\nPlease deselect the following distributions"
|
||||
msg="$msg and retry the installation:"
|
||||
msg="$msg\n$DEBUG_LIST"
|
||||
fi
|
||||
error "$msg"
|
||||
fi
|
||||
export DISTRIBUTIONS="$ALL_DISTRIBUTIONS"
|
||||
fi
|
||||
|
||||
if [ ! -z "$LOCAL_DISTRIBUTIONS" ]; then
|
||||
# Download to a directory in the new system as scratch space
|
||||
BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist"
|
||||
mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST"
|
||||
# Try to use any existing distfiles
|
||||
if [ -d $BSDINSTALL_DISTDIR ]; then
|
||||
DISTDIR_IS_UNIONFS=1
|
||||
mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR"
|
||||
export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST"
|
||||
fi
|
||||
env DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS" \
|
||||
BSDINSTALL_DISTSITE="file:///usr/freebsd-dist" \
|
||||
bsdinstall distfetch || \
|
||||
error "Failed to fetch distribution from local media"
|
||||
fi
|
||||
|
||||
bsdinstall checksum || error "Distribution checksum failed"
|
||||
bsdinstall distextract || error "Distribution extract failed"
|
||||
|
||||
# Set up boot loader
|
||||
bsdinstall bootconfig || error "Failed to configure bootloader"
|
||||
|
||||
bsdinstall rootpass || error "Could not set root password"
|
||||
|
||||
trap true SIGINT # This section is optional
|
||||
if [ "$NETCONFIG_DONE" != yes ]; then
|
||||
bsdinstall netconfig # Don't check for errors -- the user may cancel
|
||||
fi
|
||||
bsdinstall time
|
||||
bsdinstall services
|
||||
bsdinstall hardening
|
||||
|
||||
dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
|
||||
"Would you like to add users to the installed system now?" 0 0 && \
|
||||
bsdinstall adduser
|
||||
|
||||
finalconfig() {
|
||||
exec 3>&1
|
||||
REVISIT=$(dialog --backtitle "FreeBSD Installer" \
|
||||
--title "Final Configuration" --no-cancel --menu \
|
||||
"Setup of your FreeBSD system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \
|
||||
"Exit" "Apply configuration and exit installer" \
|
||||
"Add User" "Add a user to the system" \
|
||||
"Root Password" "Change root password" \
|
||||
"Hostname" "Set system hostname" \
|
||||
"Network" "Networking configuration" \
|
||||
"Services" "Set daemons to run on startup" \
|
||||
"System Hardening" "Set security options" \
|
||||
"Time Zone" "Set system timezone" \
|
||||
"Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 1>&3)
|
||||
exec 3>&-
|
||||
|
||||
case "$REVISIT" in
|
||||
"Add User")
|
||||
bsdinstall adduser
|
||||
finalconfig
|
||||
;;
|
||||
"Root Password")
|
||||
bsdinstall rootpass
|
||||
finalconfig
|
||||
;;
|
||||
"Hostname")
|
||||
bsdinstall hostname
|
||||
finalconfig
|
||||
;;
|
||||
"Network")
|
||||
bsdinstall netconfig
|
||||
finalconfig
|
||||
;;
|
||||
"Services")
|
||||
bsdinstall services
|
||||
finalconfig
|
||||
;;
|
||||
"System Hardening")
|
||||
bsdinstall hardening
|
||||
finalconfig
|
||||
;;
|
||||
"Time Zone")
|
||||
bsdinstall time
|
||||
finalconfig
|
||||
;;
|
||||
"Handbook")
|
||||
bsdinstall docsinstall
|
||||
finalconfig
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Allow user to change his mind
|
||||
finalconfig
|
||||
|
||||
trap error SIGINT # SIGINT is bad again
|
||||
bsdinstall config || error "Failed to save config"
|
||||
|
||||
if [ -n "$DISTDIR_IS_UNIONFS" ]; then
|
||||
umount -f $BSDINSTALL_DISTDIR
|
||||
fi
|
||||
|
||||
if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
|
||||
rm -rf "$BSDINSTALL_FETCHDEST"
|
||||
fi
|
||||
|
||||
# ClonOS
|
||||
[ ! -d ${BSDINSTALL_CHROOT}/root/bin ] && mkdir -p ${BSDINSTALL_CHROOT}/root/bin
|
||||
cp -a /usr/freebsd-dist/motd.sh ${BSDINSTALL_CHROOT}/root/bin/
|
||||
chmod +x ${BSDINSTALL_CHROOT}/root/bin/motd.sh
|
||||
cp -a /usr/freebsd-dist/cloninst.sh ${BSDINSTALL_CHROOT}/tmp/
|
||||
cp -a /usr/freebsd-dist/sysctl.conf ${BSDINSTALL_CHROOT}/etc/sysctl.conf
|
||||
cat /usr/freebsd-dist/loader.conf >> ${BSDINSTALL_CHROOT}/boot/loader.conf
|
||||
chmod +x ${BSDINSTALL_CHROOT}/tmp/cloninst.sh
|
||||
chroot ${BSDINSTALL_CHROOT} /tmp/cloninst.sh
|
||||
truncate -s0 ${BSDINSTALL_CHROOT}/etc/motd
|
||||
# ClonOS
|
||||
|
||||
dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \
|
||||
--default-button no --yesno \
|
||||
"The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0
|
||||
if [ $? -eq 0 ]; then
|
||||
clear
|
||||
echo This shell is operating in a chroot in the new system. \
|
||||
When finished making configuration changes, type \"exit\".
|
||||
chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
|
||||
fi
|
||||
|
||||
bsdinstall entropy
|
||||
bsdinstall umount
|
||||
|
||||
f_dprintf "Installation Completed at %s" "$( date )"
|
||||
|
||||
################################################################################
|
||||
# END
|
||||
################################################################################
|
||||
175
cloninst.sh
Executable file
175
cloninst.sh
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/bin/sh
|
||||
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
|
||||
clear
|
||||
service netif start > /dev/null 2>&1
|
||||
echo
|
||||
echo " *** ClonOS post-install script *** "
|
||||
echo
|
||||
|
||||
cd /clonos/Latest
|
||||
tar xfz pkg.txz
|
||||
mkdir -p /usr/local/sbin
|
||||
cp -a /clonos/Latest/usr/local/sbin/pkg-static /usr/local/sbin
|
||||
/usr/local/sbin/pkg-static add -f /clonos/Latest/pkg.txz
|
||||
rehash
|
||||
hash -r
|
||||
cd /clonos/
|
||||
pkg add *.txz
|
||||
pkg add clonos.txz > /dev/null 2>&1
|
||||
sleep 2
|
||||
|
||||
echo "=== Initial CBSD setup ==="
|
||||
|
||||
hostname=$( sysrc -n 'hostname' )
|
||||
|
||||
auto_iface=$( /sbin/route -n get 0.0.0.0 | /usr/bin/awk '/interface/{print $2}' )
|
||||
|
||||
if [ -z "${auto_iface}" ]; then
|
||||
for i in $( ifconfig -l ); do
|
||||
case "${i}" in
|
||||
lo*)
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
auto_iface="${i}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
ip4_addr=$( ifconfig ${auto_iface} 2>/dev/null | /usr/bin/awk '/inet [0-9]+/ { print $2}' | /usr/bin/head -n 1 )
|
||||
|
||||
cat > /tmp/initenv.conf <<EOF
|
||||
nodename="${hostname}"
|
||||
nodeip="${ip4_addr}"
|
||||
jnameserver="8.8.8.8 8.8.4.4"
|
||||
nodeippool="10.0.0.0/24"
|
||||
natip="${ip4_addr}"
|
||||
nat_enable="pf"
|
||||
mdtmp="8"
|
||||
ipfw_enable="1"
|
||||
zfsfeat="1"
|
||||
hammerfeat="0"
|
||||
fbsdrepo="1"
|
||||
repo="http://bsdstore.ru"
|
||||
workdir="/usr/jails"
|
||||
jail_interface="${auto_iface}"
|
||||
parallel="5"
|
||||
stable="0"
|
||||
statsd_bhyve_enable="1"
|
||||
statsd_jail_enable="1"
|
||||
statsd_hoster_enable="1"
|
||||
EOF
|
||||
|
||||
env workdir=/usr/jails /usr/local/cbsd/sudoexec/initenv inter=0 /tmp/initenv.conf
|
||||
|
||||
echo "=== Initial ClonOS setup ==="
|
||||
|
||||
[ ! -h /usr/local/bin/python ] && ln -s /usr/local/bin/python2.7 /usr/local/bin/python
|
||||
|
||||
cp /usr/local/etc/sudoers_10_www.clonos.sample /usr/local/etc/sudoers.d/10_www
|
||||
chmod 0440 /usr/local/etc/sudoers.d/10_www
|
||||
|
||||
cp /usr/local/etc/nginx/nginx.conf.clonos.sample /usr/local/etc/nginx/nginx.conf
|
||||
cp /usr/local/etc/nginx/sites-enabled/cbsdweb.conf.clonos.sample /usr/local/etc/nginx/sites-enabled/cbsdweb.conf
|
||||
|
||||
cp /usr/local/etc/supervisor.d/program_vnc2wss.conf.clonos.sample /usr/local/etc/supervisor.d/program_vnc2wss.conf
|
||||
cp /usr/local/etc/supervisor.d/program_ws.conf.clonos.sample /usr/local/etc/supervisor.d/program_ws.conf
|
||||
cp /usr/local/etc/supervisord.conf.clonos.sample /usr/local/etc/supervisord.conf
|
||||
|
||||
cp /usr/local/etc/php.ini.clonos.sample /usr/local/etc/php.ini
|
||||
cp /usr/local/etc/php-fpm.d/www-php-fpm.conf.clonos.sample /usr/local/etc/php-fpm.d/www.conf
|
||||
|
||||
[ ! -d /var/log/supervisor ] && mkdir -p /var/log/supervisor
|
||||
|
||||
sysrc nginx_enable="YES"
|
||||
sysrc php_fpm_enable="YES"
|
||||
sysrc supervisord_enable="YES"
|
||||
sysrc cbsdd_enable="YES"
|
||||
sysrc clear_tmp_enable="YES"
|
||||
sysrc beanstalkd_enable="YES"
|
||||
sysrc beanstalkd_flags="-l 127.0.0.1 -p 11300"
|
||||
sysrc cbsd_statsd_jail_enable="YES"
|
||||
sysrc cbsd_statsd_hoster_enable="YES"
|
||||
sysrc cbsd_statsd_bhyve_enable="YES"
|
||||
sysrc kld_list="if_bridge if_tap nmdm linux linux64"
|
||||
|
||||
sysrc ntpdate_enable="YES"
|
||||
sysrc ntpd_enable="YES"
|
||||
sysrc ntpd_sync_on_start="YES"
|
||||
|
||||
[ ! -d /var/db/clonos ] && mkdir -p /var/db/clonos
|
||||
[ ! -d /usr/jails/modules ] && mkdir -p /usr/jails/modules
|
||||
[ ! -d /usr/local/cbsd/modules ] && mkdir -p /usr/local/cbsd/modules
|
||||
[ ! -d /usr/local/cbsd/forms.d ] && mkdir -p /usr/local/cbsd/forms.d
|
||||
#mv /usr/local/www/clonos/vncterm.d /usr/local/cbsd/modules/
|
||||
#mv /usr/local/www/clonos/cbsd_queue.d /usr/local/cbsd/modules/
|
||||
#mv /usr/local/www/clonos/clonos_database /usr/local/cbsd/modules/forms.d/clonos_database
|
||||
|
||||
[ ! -d /usr/jails/etc ] && mkdir /usr/jails/etc
|
||||
cat > /usr/jails/etc/modules.conf <<EOF
|
||||
pkg.d
|
||||
bsdconf.d
|
||||
zfsinstall.d
|
||||
puppet.d
|
||||
vncterm.d
|
||||
convectix.d
|
||||
tui.d
|
||||
cbsd_queue.d
|
||||
EOF
|
||||
|
||||
/usr/local/bin/cbsd initenv inter=0
|
||||
chown -R www:www /usr/local/www
|
||||
pw groupmod cbsd -M www
|
||||
|
||||
sh /usr/local/cbsd/modules/forms.d/clonos_database/initforms.sh
|
||||
chown -R www:www /var/db/clonos
|
||||
|
||||
#!/bin/sh
|
||||
cat > /etc/rc.local << EOF
|
||||
# insurance for DHCP-based ifaces
|
||||
for i in \$( egrep -E '^ifconfig_[aA-zZ]+[0-9]+="DHCP"' /etc/rc.conf | tr "_=" " " | awk '{printf \$2" "}' ); do
|
||||
/sbin/dhclient \${i}
|
||||
done
|
||||
|
||||
# restore motd
|
||||
if ! grep -q /root/bin/motd.sh /etc/csh.login 2>/dev/null; then
|
||||
echo 'sh /root/bin/motd.sh' >> /etc/csh.login
|
||||
fi
|
||||
|
||||
EOF
|
||||
|
||||
# tmp: update CBSD code to latest
|
||||
#rm -rf /usr/local/cbsd
|
||||
#echo "/usr/local/bin/rsync -avz /clonos/bases/cbsd/ /usr/local/cbsd/"
|
||||
#/usr/local/bin/rsync -az /clonos/bases/cbsd/ /usr/local/cbsd/
|
||||
#/usr/local/bin/cbsd initenv inter=0
|
||||
|
||||
mv /clonos/bases/base_* /usr/jails/basejail/
|
||||
/usr/local/bin/cbsd register_base arch=amd64 target_arch=amd64 ver=12.0 stable=0
|
||||
chflags -R noschg /clonos
|
||||
echo "Importing cbsdpuppet jail..."
|
||||
/usr/local/bin/cbsd version
|
||||
/usr/local/bin/cbsd jimport fs_feat=0 jname=/clonos/bases/cbsdpuppet1.img
|
||||
/usr/local/bin/cbsd jset jname=cbsdpuppet1 protected=1
|
||||
/usr/local/bin/cbsd jset jname=cbsdpuppet1 hidden=1
|
||||
rm -rf /clonos
|
||||
|
||||
mkdir /var/coredumps
|
||||
chmod 0777 /var/coredumps
|
||||
|
||||
# temporary fix perms for CBSD 12.0.2 (remove it after 12.0.3 released)
|
||||
#mkdir /usr/jails/formfile
|
||||
#chown cbsd:cbsd /usr/jails/formfile
|
||||
#chmod 0775 /usr/jails/formfile
|
||||
|
||||
uplink_iface4=$( /sbin/route -n -4 get 0.0.0.0 2>/dev/null | /usr/bin/awk '/interface/{print $2}' )
|
||||
ip=$( /sbin/ifconfig ${uplink_iface4} | /usr/bin/awk '/inet [0-9]+/{print $2}'| /usr/bin/head -n1 )
|
||||
cat > /etc/issue <<EOF
|
||||
|
||||
=== Welcome to ClonOS 18.11 BETA1 ===
|
||||
* UI: http://${ip}
|
||||
* SSH: ${ip}:22222
|
||||
|
||||
EOF
|
||||
42
loader.conf
Normal file
42
loader.conf
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
#vfs.zfs.arc_max = "512M"
|
||||
aesni_load="YES"
|
||||
ipfw_load="YES"
|
||||
net.inet.ip.fw.default_to_accept=1
|
||||
cpuctl_load="YES"
|
||||
pf_load="YES"
|
||||
vmm_load="YES"
|
||||
kern.racct.enable=1
|
||||
ipfw_nat_load="YES"
|
||||
libalias_load="YES"
|
||||
sem_load="YES"
|
||||
coretemp_load="YES"
|
||||
cc_htcp_load="YES"
|
||||
#aio_load="YES"
|
||||
|
||||
kern.ipc.semmnu=120
|
||||
kern.ipc.semume=40
|
||||
kern.ipc.semmns=240
|
||||
kern.ipc.semmni=40
|
||||
kern.ipc.shmmaxpgs=65536
|
||||
|
||||
net.inet.tcp.syncache.hashsize=1024
|
||||
net.inet.tcp.syncache.bucketlimit=512
|
||||
net.inet.tcp.syncache.cachelimit=65536
|
||||
net.inet.tcp.hostcache.hashsize=16384
|
||||
net.inet.tcp.hostcache.bucketlimit=100
|
||||
net.inet.tcp.hostcache.cachelimit=65536
|
||||
|
||||
kern.nbuf=128000
|
||||
net.inet.tcp.tcbhashsize=524288
|
||||
net.inet.tcp.hostcache.bucketlimit=120
|
||||
net.inet.tcp.tcbhashsize=131072
|
||||
|
||||
impi_load="YES"
|
||||
accf_data_load="YES"
|
||||
accf_dns_load="YES"
|
||||
accf_http_load="YES"
|
||||
|
||||
vm.pmap.pti="0"
|
||||
hw.ibrs_disable="1"
|
||||
crypto_load="YES"
|
||||
53
make.sh
Executable file
53
make.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
MYROOT="/rel"
|
||||
|
||||
if [ ! -r "${MYROOT}/clonos.txz" ]; then
|
||||
echo "Put clonos.txz here"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -r "${MYROOT}/auto" ]; then
|
||||
echo "Put auto here"
|
||||
exit
|
||||
fi
|
||||
|
||||
[ -r /scratch/usr/obj/usr/src/amd64.amd64/release/disc1.iso ] && rm -f /scratch/usr/obj/usr/src/amd64.amd64/release/disc1.iso
|
||||
[ -r /scratch/usr/obj/usr/src/amd64.amd64/release/memstick.img ] && rm -f /scratch/usr/obj/usr/src/amd64.amd64/release/memstick.img
|
||||
|
||||
set -o xtrace
|
||||
|
||||
#[ ! -d /scratch/usr/src/sys/amd64/conf ] && mkdir -p /scratch/usr/src/sys/amd64/conf
|
||||
#[ ! -d /scratch/dev ] && mkdir /scratch/dev
|
||||
#mount -t devfs devfs /scratch/dev
|
||||
#cp -a /usr/jails/etc/defaults/FreeBSD-kernel-GENERIC-amd64-12 /scratch/usr/src/sys/amd64/conf/CBSD
|
||||
|
||||
if [ ! -x /scratch/bin/sh ]; then
|
||||
echo "NEW"
|
||||
echo "sh /rel/release.sh -c /rel/release.conf"
|
||||
sh /rel/release.sh -c /rel/release.conf
|
||||
cp -a /usr/jails/etc/defaults/FreeBSD-kernel-GENERIC-amd64-12 /scratch/usr/src/sys/amd64/conf/CBSD
|
||||
else
|
||||
cp -a /usr/jails/etc/defaults/FreeBSD-kernel-GENERIC-amd64-12 /scratch/usr/src/sys/amd64/conf/CBSD
|
||||
[ ! -d /scratch/usr/obj/usr/src/amd64.amd64/release ] && mkdir -p /scratch/usr/obj/usr/src/amd64.amd64/release
|
||||
cp -a ${MYROOT}/clonos.txz /scratch/usr/obj/usr/src/amd64.amd64/release/clonos.txz
|
||||
cd /scratch/usr/obj/usr/src/amd64.amd64/release
|
||||
#/usr/jails/src/src_12/src/release/scripts/make-manifest.sh *.txz > MANIFEST
|
||||
/rel/scripts/make-manifest.sh *.txz > MANIFEST
|
||||
|
||||
cp -a /scratch/usr/obj/usr/src/amd64.amd64/release/*.txz /scratch/usr/obj/usr/src/amd64.amd64/release/disc1/usr/freebsd-dist/
|
||||
cp -a /scratch/usr/obj/usr/src/amd64.amd64/release/MANIFEST /scratch/usr/obj/usr/src/amd64.amd64/release/disc1/usr/freebsd-dist/
|
||||
cp -a ${MYROOT}/auto /scratch/usr/obj/usr/src/amd64.amd64/release/disc1/usr/libexec/bsdinstall/auto
|
||||
cp -a ${MYROOT}/rc.local /scratch/usr/obj/usr/src/amd64.amd64/release/disc1/etc/
|
||||
|
||||
for i in cloninst.sh loader.conf motd.sh rc.local; do
|
||||
cp -a ${MYROOT}/${i} /scratch/usr/obj/usr/src/amd64.amd64/release/disc1/usr/freebsd-dist/
|
||||
done
|
||||
|
||||
echo "sh /rel/release-second.sh -c /rel/release.conf-second"
|
||||
sh /rel/release-second.sh -c /rel/release.conf-second
|
||||
fi
|
||||
|
||||
#umount /scratch/dev || true
|
||||
|
||||
set +o xtrace
|
||||
76
motd.sh
Executable file
76
motd.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
# $1 - size in bytes
|
||||
conv2human()
|
||||
{
|
||||
local lhal="B"
|
||||
local tmpmem="$1"
|
||||
local lval
|
||||
|
||||
human_val=""
|
||||
|
||||
for hval in "Kb" "Mb" "Gb"; do
|
||||
mem=$(( tmpmem / 1024 ))
|
||||
[ "${mem}" = "0" ] && break
|
||||
tmpmem=${mem}
|
||||
lval="${hval}"
|
||||
done
|
||||
|
||||
human_val="${tmpmem} ${lval}"
|
||||
}
|
||||
|
||||
# Calculate free memory
|
||||
realmem=$( sysctl -n hw.realmem )
|
||||
tmpmem=${realmem}
|
||||
page_size=$( sysctl -n vm.stats.vm.v_page_size )
|
||||
active_count=$( sysctl -n vm.stats.vm.v_active_count )
|
||||
wire_count=$( sysctl -n vm.stats.vm.v_wire_count )
|
||||
active_size=$(( page_size * active_count ))
|
||||
wire_size=$(( page_size * wire_count ))
|
||||
conv2human ${tmpmem}
|
||||
TOTAL_MEM="${human_val}"
|
||||
freemem=$(( realmem - active_size - wire_size ))
|
||||
conv2human ${freemem}
|
||||
FREE_MEM="${human_val}"
|
||||
|
||||
|
||||
name=$( hostname )
|
||||
os=$( sysctl -qn kern.ostype )
|
||||
CPUName=$( sysctl -qn hw.model )
|
||||
NCores=$( sysctl -qn hw.ncpu )
|
||||
uplink_iface4=$( /sbin/route -n -4 get 0.0.0.0 2>/dev/null | /usr/bin/awk '/interface/{print $2}' )
|
||||
ip=$( /sbin/ifconfig ${uplink_iface4} | /usr/bin/awk '/inet [0-9]+/{print $2}'|/usr/bin/head -n1 )
|
||||
|
||||
disks=$( sysctl -qn kern.disks )
|
||||
|
||||
mem=$(echo $TOTAL_MEM' total / '$FREE_MEM' free')
|
||||
username=$(whoami)
|
||||
if [ -e /var/lib/puppet/puppet.info ]; then
|
||||
puppetinfo=$(cat /var/lib/puppet/puppet.info)
|
||||
fi
|
||||
echo -e "
|
||||
------------------: System Data :-------------------------------
|
||||
Hostname: \033[1;33m$name\033[0m ($ip)
|
||||
Kernel: $(uname -r) ($os)
|
||||
Uptime: $(uptime | sed 's/.*up ([^,]*), .*/1/')
|
||||
CPU: $CPUName ($NCores cores)
|
||||
Memory(Mb): $mem
|
||||
Disks: ${disks}
|
||||
Puppet info: $puppetinfo
|
||||
------------------------: Logged as: [\033[0;32m$(whoami)\033[0m] ------------------------------
|
||||
Current users:
|
||||
$(who)
|
||||
|
||||
To access hoster UI: http://${ip}/
|
||||
To re-configure CBSD settings: cbsd initenv-tui
|
||||
|
||||
ClonOS/CBSD user group: https://web.telegram.org/#/im?p=%40cbsdofficial
|
||||
ClonOS/CBSD mail-list: cbsd+subscribe@lists.tilda.center
|
||||
ClonOS issues page: https://github.com/clonos/cp/issues
|
||||
CBSD issues page: https://github.com/cbsd/cbsd/issues
|
||||
Please Support Us: https://clonos.tekroutine.com/contact.html
|
||||
|
||||
"
|
||||
if Tx=$(tmux ls 2> /dev/null); then
|
||||
echo -e "\033[0;31mTmux Sessions:\033[0m"
|
||||
echo $Tx
|
||||
fi
|
||||
89
rc.local
Executable file
89
rc.local
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/bin/sh
|
||||
# $ClonOS: stable/12/release/rc.local 312910 2017-01-28 02:22:15Z nyan $
|
||||
|
||||
: ${DIALOG_OK=0}
|
||||
: ${DIALOG_CANCEL=1}
|
||||
: ${DIALOG_HELP=2}
|
||||
: ${DIALOG_EXTRA=3}
|
||||
: ${DIALOG_ITEM_HELP=4}
|
||||
: ${DIALOG_ESC=255}
|
||||
|
||||
MACHINE=`uname -m`
|
||||
|
||||
# resolv.conf from DHCP ends up in here, so make sure the directory exists
|
||||
mkdir /tmp/bsdinstall_etc
|
||||
|
||||
kbdcontrol -d >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
# Syscons: use xterm, start interesting things on other VTYs
|
||||
TERM=xterm
|
||||
|
||||
# Don't send ESC on function-key 62/63 (left/right command key)
|
||||
kbdcontrol -f 62 '' > /dev/null 2>&1
|
||||
kbdcontrol -f 63 '' > /dev/null 2>&1
|
||||
|
||||
if [ -z "$EXTERNAL_VTY_STARTED" ]; then
|
||||
# Init will clean these processes up if/when the system
|
||||
# goes multiuser
|
||||
touch /tmp/bsdinstall_log
|
||||
tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
|
||||
/usr/libexec/getty autologin ttyv3 &
|
||||
EXTERNAL_VTY_STARTED=1
|
||||
fi
|
||||
else
|
||||
# Serial or other console
|
||||
echo
|
||||
echo "Welcome to ClonOS!"
|
||||
echo
|
||||
echo "Please choose the appropriate terminal type for your system."
|
||||
echo "Common console types are:"
|
||||
echo " ansi Standard ANSI terminal"
|
||||
echo " vt100 VT100 or compatible terminal"
|
||||
echo " xterm xterm terminal emulator (or compatible)"
|
||||
echo " cons25w cons25w terminal"
|
||||
echo
|
||||
echo -n "Console type [vt100]: "
|
||||
read TERM
|
||||
TERM=${TERM:-vt100}
|
||||
fi
|
||||
export TERM
|
||||
|
||||
if [ -f /etc/installerconfig ]; then
|
||||
if bsdinstall script /etc/installerconfig; then
|
||||
dialog --backtitle "Welcome to ClonOS" --title "Complete" --no-cancel --ok-label "Reboot" --pause "Installation of ClonOS complete! Rebooting in 10 seconds" 10 30 10
|
||||
reboot
|
||||
else
|
||||
dialog --backtitle "Welcome to ClonOS" --title "Error" --textbox /tmp/bsdinstall_log 0 0
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
dialog --backtitle "Welcome to ClonOS" --title "Welcome" --extra-button --extra-label "Shell" --ok-label "Install" --cancel-label "Live CD" --yesno "Welcome to ClonOS! Would you like to begin an installation or use the live CD?" 0 0
|
||||
|
||||
case $? in
|
||||
$DIALOG_OK) # Install
|
||||
# If not netbooting, have the installer configure the network
|
||||
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
|
||||
if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
|
||||
BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
|
||||
fi
|
||||
|
||||
trap true SIGINT # Ignore cntrl-C here
|
||||
bsdinstall
|
||||
if [ $? -eq 0 ]; then
|
||||
dialog --backtitle "Welcome to ClonOS" --title "Complete" --yes-label "Reboot" --no-label "Live CD" --yesno "Installation of ClonOS complete! Would you like to reboot into the installed system now?" 0 0 && reboot
|
||||
else
|
||||
. /etc/rc.local
|
||||
fi
|
||||
;;
|
||||
$DIALOG_CANCEL) # Live CD
|
||||
exit 0
|
||||
;;
|
||||
$DIALOG_EXTRA) # Shell
|
||||
clear
|
||||
echo "When finished, type 'exit' to return to the installer."
|
||||
/bin/sh
|
||||
. /etc/rc.local
|
||||
;;
|
||||
esac
|
||||
|
||||
457
release-second.sh
Normal file
457
release-second.sh
Normal file
@@ -0,0 +1,457 @@
|
||||
#!/bin/sh
|
||||
#-
|
||||
# Copyright (c) 2013-2018 The FreeBSD Foundation
|
||||
# Copyright (c) 2013 Glen Barber
|
||||
# Copyright (c) 2011 Nathan Whitehorn
|
||||
# All rights reserved.
|
||||
#
|
||||
# Portions of this software were developed by Glen Barber
|
||||
# under sponsorship from the FreeBSD Foundation.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# release.sh: check out source trees, and build release components with
|
||||
# totally clean, fresh trees.
|
||||
# Based on release/generate-release.sh written by Nathan Whitehorn
|
||||
#
|
||||
# $FreeBSD: stable/12/release/release.sh 339980 2018-10-31 23:54:36Z gjb $
|
||||
#
|
||||
|
||||
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
|
||||
|
||||
VERSION=2
|
||||
|
||||
# Prototypes that can be redefined per-chroot or per-target.
|
||||
load_chroot_env() { }
|
||||
load_target_env() { }
|
||||
buildenv_setup() { }
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [-c release.conf]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# env_setup(): Set up the default build environment variables, such as the
|
||||
# CHROOTDIR, VCSCMD, SVNROOT, etc. This is called before the release.conf
|
||||
# file is sourced, if '-c <release.conf>' is specified.
|
||||
env_setup() {
|
||||
# The directory within which the release will be built.
|
||||
CHROOTDIR="/scratch"
|
||||
RELENGDIR="$(dirname $(realpath ${0}))"
|
||||
|
||||
# The default version control system command to obtain the sources.
|
||||
for _dir in /usr/bin /usr/local/bin; do
|
||||
for _svn in svn svnlite; do
|
||||
[ -x "${_dir}/${_svn}" ] && VCSCMD="${_dir}/${_svn}"
|
||||
[ ! -z "${VCSCMD}" ] && break 2
|
||||
done
|
||||
done
|
||||
VCSCMD="${VCSCMD} checkout"
|
||||
|
||||
# The default svn checkout server, and svn branches for src/, doc/,
|
||||
# and ports/.
|
||||
SVNROOT="svn://svn.FreeBSD.org/"
|
||||
SRCBRANCH="base/head@rHEAD"
|
||||
DOCBRANCH="doc/head@rHEAD"
|
||||
PORTBRANCH="ports/head@rHEAD"
|
||||
|
||||
# Set for embedded device builds.
|
||||
EMBEDDEDBUILD=
|
||||
|
||||
# Sometimes one needs to checkout src with --force svn option.
|
||||
# If custom kernel configs copied to src tree before checkout, e.g.
|
||||
SRC_FORCE_CHECKOUT=
|
||||
|
||||
# The default make.conf and src.conf to use. Set to /dev/null
|
||||
# by default to avoid polluting the chroot(8) environment with
|
||||
# non-default settings.
|
||||
MAKE_CONF="/dev/null"
|
||||
SRC_CONF="/dev/null"
|
||||
|
||||
# The number of make(1) jobs, defaults to the number of CPUs available
|
||||
# for buildworld, and half of number of CPUs available for buildkernel.
|
||||
WORLD_FLAGS="-j$(sysctl -n hw.ncpu)"
|
||||
KERNEL_FLAGS="-j$(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2))"
|
||||
|
||||
MAKE_FLAGS="-s"
|
||||
|
||||
# The name of the kernel to build, defaults to GENERIC.
|
||||
KERNEL="GENERIC"
|
||||
|
||||
# Set to non-empty value to disable checkout of doc/ and/or ports/.
|
||||
# Disabling ports/ checkout also forces NODOC to be set.
|
||||
NODOC=
|
||||
NOPORTS=
|
||||
|
||||
# Set to non-empty value to disable distributing source tree.
|
||||
NOSRC=
|
||||
|
||||
# Set to non-empty value to build dvd1.iso as part of the release.
|
||||
WITH_DVD=
|
||||
WITH_COMPRESSED_IMAGES=
|
||||
|
||||
# Set to non-empty value to build virtual machine images as part of
|
||||
# the release.
|
||||
WITH_VMIMAGES=
|
||||
WITH_COMPRESSED_VMIMAGES=
|
||||
XZ_THREADS=0
|
||||
|
||||
# Set to non-empty value to build virtual machine images for various
|
||||
# cloud providers as part of the release.
|
||||
WITH_CLOUDWARE=
|
||||
|
||||
return 0
|
||||
} # env_setup()
|
||||
|
||||
# env_check(): Perform sanity tests on the build environment, such as ensuring
|
||||
# files/directories exist, as well as adding backwards-compatibility hacks if
|
||||
# necessary. This is called unconditionally, and overrides the defaults set
|
||||
# in env_setup() if '-c <release.conf>' is specified.
|
||||
env_check() {
|
||||
chroot_build_release_cmd="chroot_build_release"
|
||||
# Fix for backwards-compatibility with release.conf that does not have
|
||||
# the trailing '/'.
|
||||
case ${SVNROOT} in
|
||||
*svn*)
|
||||
SVNROOT="${SVNROOT}/"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Prefix the branches with the SVNROOT for the full checkout URL.
|
||||
SRCBRANCH="${SVNROOT}${SRCBRANCH}"
|
||||
DOCBRANCH="${SVNROOT}${DOCBRANCH}"
|
||||
PORTBRANCH="${SVNROOT}${PORTBRANCH}"
|
||||
|
||||
if [ -n "${EMBEDDEDBUILD}" ]; then
|
||||
WITH_DVD=
|
||||
WITH_COMPRESSED_IMAGES=
|
||||
NODOC=yes
|
||||
case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in
|
||||
arm:arm*|arm64:aarch64)
|
||||
chroot_build_release_cmd="chroot_arm_build_release"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# If PORTS is set and NODOC is unset, force NODOC=yes because the ports
|
||||
# tree is required to build the documentation set.
|
||||
if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
|
||||
echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
|
||||
echo " and NOPORTS is set."
|
||||
NODOC=yes
|
||||
fi
|
||||
|
||||
# If NOSRC, NOPORTS and/or NODOC are unset, they must not pass to make
|
||||
# as variables. The release makefile verifies definedness of the
|
||||
# NOPORTS/NODOC variables instead of their values.
|
||||
SRCDOCPORTS=
|
||||
if [ -n "${NOPORTS}" ]; then
|
||||
SRCDOCPORTS="NOPORTS=yes"
|
||||
fi
|
||||
if [ -n "${NODOC}" ]; then
|
||||
SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NODOC=yes"
|
||||
fi
|
||||
if [ -n "${NOSRC}" ]; then
|
||||
SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NOSRC=yes"
|
||||
fi
|
||||
|
||||
# The aggregated build-time flags based upon variables defined within
|
||||
# this file, unless overridden by release.conf. In most cases, these
|
||||
# will not need to be changed.
|
||||
CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
|
||||
if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
|
||||
ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
|
||||
else
|
||||
ARCH_FLAGS=
|
||||
fi
|
||||
# Force src checkout if configured
|
||||
FORCE_SRC_KEY=
|
||||
if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
|
||||
FORCE_SRC_KEY="--force"
|
||||
fi
|
||||
|
||||
if [ -z "${CHROOTDIR}" ]; then
|
||||
echo "Please set CHROOTDIR."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
echo "Needs to be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Unset CHROOTBUILD_SKIP if the chroot(8) does not appear to exist.
|
||||
if [ ! -z "${CHROOTBUILD_SKIP}" -a ! -e ${CHROOTDIR}/bin/sh ]; then
|
||||
CHROOTBUILD_SKIP=
|
||||
fi
|
||||
|
||||
CHROOT_MAKEENV="${CHROOT_MAKEENV} \
|
||||
MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
|
||||
CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
|
||||
CHROOT_IMAKEFLAGS="${WORLD_FLAGS} ${CONF_FILES}"
|
||||
CHROOT_DMAKEFLAGS="${WORLD_FLAGS} ${CONF_FILES}"
|
||||
RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} \
|
||||
${CONF_FILES}"
|
||||
RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \
|
||||
KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
|
||||
RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \
|
||||
KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${SRCDOCPORTS} \
|
||||
WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
|
||||
WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}"
|
||||
|
||||
return 0
|
||||
} # env_check()
|
||||
|
||||
# chroot_setup(): Prepare the build chroot environment for the release build.
|
||||
chroot_setup() {
|
||||
load_chroot_env
|
||||
mkdir -p ${CHROOTDIR}/usr
|
||||
|
||||
if [ -z "${SRC_UPDATE_SKIP}" ]; then
|
||||
${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
|
||||
fi
|
||||
if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then
|
||||
${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
|
||||
fi
|
||||
if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then
|
||||
${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
|
||||
fi
|
||||
|
||||
if [ -z "${CHROOTBUILD_SKIP}" ]; then
|
||||
cd ${CHROOTDIR}/usr/src
|
||||
env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld -DNO_CLEAN
|
||||
env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
|
||||
DESTDIR=${CHROOTDIR}
|
||||
env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
|
||||
DESTDIR=${CHROOTDIR}
|
||||
fi
|
||||
|
||||
return 0
|
||||
} # chroot_setup()
|
||||
|
||||
# extra_chroot_setup(): Prepare anything additional within the build
|
||||
# necessary for the release build.
|
||||
extra_chroot_setup() {
|
||||
mkdir -p ${CHROOTDIR}/dev
|
||||
mount -t devfs devfs ${CHROOTDIR}/dev
|
||||
[ -e /etc/resolv.conf -a ! -e ${CHROOTDIR}/etc/resolv.conf ] && \
|
||||
cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
|
||||
# Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
|
||||
# is created. This is needed by ports-mgmt/pkg.
|
||||
eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
|
||||
|
||||
# If MAKE_CONF and/or SRC_CONF are set and not character devices
|
||||
# (/dev/null), copy them to the chroot.
|
||||
if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
|
||||
mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
|
||||
cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
|
||||
fi
|
||||
if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
|
||||
mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
|
||||
cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
|
||||
fi
|
||||
|
||||
if [ -d ${CHROOTDIR}/usr/ports ]; then
|
||||
# Trick the ports 'run-autotools-fixup' target to do the right
|
||||
# thing.
|
||||
_OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
|
||||
REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
|
||||
BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
|
||||
UNAME_r=${REVISION}-${BRANCH}
|
||||
if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
|
||||
PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} WRKDIRPREFIX=/tmp/ports"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} DISTDIR=/tmp/distfiles"
|
||||
chroot ${CHROOTDIR} env ${PBUILD_FLAGS} \
|
||||
OPTIONS_UNSET="AVAHI FOP IGOR" make -C \
|
||||
/usr/ports/textproc/docproj \
|
||||
FORCE_PKG_REGISTER=1 \
|
||||
install clean distclean
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${EMBEDDEDPORTS}" ]; then
|
||||
_OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
|
||||
REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
|
||||
BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
|
||||
PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} WRKDIRPREFIX=/tmp/ports"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} DISTDIR=/tmp/distfiles"
|
||||
for _PORT in ${EMBEDDEDPORTS}; do
|
||||
eval chroot ${CHROOTDIR} env ${PBUILD_FLAGS} make -C \
|
||||
/usr/ports/${_PORT} \
|
||||
FORCE_PKG_REGISTER=1 deinstall install clean distclean
|
||||
done
|
||||
fi
|
||||
|
||||
buildenv_setup
|
||||
|
||||
return 0
|
||||
} # extra_chroot_setup()
|
||||
|
||||
# chroot_build_target(): Build the userland and kernel for the build target.
|
||||
chroot_build_target() {
|
||||
load_target_env
|
||||
if [ ! -z "${EMBEDDEDBUILD}" ]; then
|
||||
RELEASE_WMAKEFLAGS="${RELEASE_WMAKEFLAGS} \
|
||||
TARGET=${EMBEDDED_TARGET} \
|
||||
TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
|
||||
RELEASE_KMAKEFLAGS="${RELEASE_KMAKEFLAGS} \
|
||||
TARGET=${EMBEDDED_TARGET} \
|
||||
TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
|
||||
fi
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld -DNO_CLEAN
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel -DNO_CLEAN
|
||||
|
||||
return 0
|
||||
} # chroot_build_target
|
||||
|
||||
# chroot_build_release(): Invoke the 'make release' target.
|
||||
chroot_build_release() {
|
||||
load_target_env
|
||||
if [ ! -z "${WITH_VMIMAGES}" ]; then
|
||||
if [ -z "${VMFORMATS}" ]; then
|
||||
VMFORMATS="$(eval chroot ${CHROOTDIR} \
|
||||
make -C /usr/src/release -V VMFORMATS)"
|
||||
fi
|
||||
if [ -z "${VMSIZE}" ]; then
|
||||
VMSIZE="$(eval chroot ${CHROOTDIR} \
|
||||
make -C /usr/src/release -V VMSIZE)"
|
||||
fi
|
||||
RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} \
|
||||
VMFORMATS=\"${VMFORMATS}\" VMSIZE=${VMSIZE}"
|
||||
fi
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src/release \
|
||||
${RELEASE_RMAKEFLAGS} release
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src/release \
|
||||
${RELEASE_RMAKEFLAGS} install DESTDIR=/R \
|
||||
WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \
|
||||
WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES}
|
||||
|
||||
return 0
|
||||
} # chroot_build_release()
|
||||
|
||||
efi_boot_name()
|
||||
{
|
||||
case $1 in
|
||||
arm)
|
||||
echo "bootarm.efi"
|
||||
;;
|
||||
arm64)
|
||||
echo "bootaa64.efi"
|
||||
;;
|
||||
amd64)
|
||||
echo "bootx86.efi"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# chroot_arm_build_release(): Create arm SD card image.
|
||||
chroot_arm_build_release() {
|
||||
load_target_env
|
||||
case ${EMBEDDED_TARGET} in
|
||||
arm|arm64)
|
||||
if [ -e "${RELENGDIR}/tools/arm.subr" ]; then
|
||||
. "${RELENGDIR}/tools/arm.subr"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
[ ! -z "${RELEASECONF}" ] && . "${RELEASECONF}"
|
||||
export MAKE_FLAGS="${MAKE_FLAGS} TARGET=${EMBEDDED_TARGET}"
|
||||
export MAKE_FLAGS="${MAKE_FLAGS} TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
|
||||
eval chroot ${CHROOTDIR} env WITH_UNIFIED_OBJDIR=1 make ${MAKE_FLAGS} -C /usr/src/release obj
|
||||
export WORLDDIR="$(eval chroot ${CHROOTDIR} make ${MAKE_FLAGS} -C /usr/src/release -V WORLDDIR)"
|
||||
export OBJDIR="$(eval chroot ${CHROOTDIR} env WITH_UNIFIED_OBJDIR=1 make ${MAKE_FLAGS} -C /usr/src/release -V .OBJDIR)"
|
||||
export DESTDIR="${OBJDIR}/${KERNEL}"
|
||||
export IMGBASE="${CHROOTDIR}/${OBJDIR}/${BOARDNAME}.img"
|
||||
export OSRELEASE="$(eval chroot ${CHROOTDIR} make ${MAKE_FLAGS} -C /usr/src/release \
|
||||
TARGET=${EMBEDDED_TARGET} TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \
|
||||
-V OSRELEASE)"
|
||||
chroot ${CHROOTDIR} mkdir -p ${DESTDIR}
|
||||
chroot ${CHROOTDIR} truncate -s ${IMAGE_SIZE} ${IMGBASE##${CHROOTDIR}}
|
||||
export mddev=$(chroot ${CHROOTDIR} \
|
||||
mdconfig -f ${IMGBASE##${CHROOTDIR}} ${MD_ARGS})
|
||||
arm_create_disk
|
||||
arm_install_base
|
||||
arm_install_boot
|
||||
arm_install_uboot
|
||||
mdconfig -d -u ${mddev}
|
||||
chroot ${CHROOTDIR} rmdir ${DESTDIR}
|
||||
mv ${IMGBASE} ${CHROOTDIR}/${OBJDIR}/${OSRELEASE}-${BOARDNAME}.img
|
||||
chroot ${CHROOTDIR} mkdir -p /R
|
||||
chroot ${CHROOTDIR} cp -p ${OBJDIR}/${OSRELEASE}-${BOARDNAME}.img \
|
||||
/R/${OSRELEASE}-${BOARDNAME}.img
|
||||
chroot ${CHROOTDIR} xz -T ${XZ_THREADS} /R/${OSRELEASE}-${BOARDNAME}.img
|
||||
cd ${CHROOTDIR}/R && sha512 ${OSRELEASE}* \
|
||||
> CHECKSUM.SHA512
|
||||
cd ${CHROOTDIR}/R && sha256 ${OSRELEASE}* \
|
||||
> CHECKSUM.SHA256
|
||||
|
||||
return 0
|
||||
} # chroot_arm_build_release()
|
||||
|
||||
# main(): Start here.
|
||||
main() {
|
||||
set -e # Everything must succeed
|
||||
env_setup
|
||||
while getopts c: opt; do
|
||||
case ${opt} in
|
||||
c)
|
||||
RELEASECONF="$(realpath ${OPTARG})"
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ ! -z "${RELEASECONF}" ]; then
|
||||
if [ -e "${RELEASECONF}" ]; then
|
||||
. ${RELEASECONF}
|
||||
else
|
||||
echo "Nonexistent configuration file: ${RELEASECONF}"
|
||||
echo "Using default build environment."
|
||||
fi
|
||||
fi
|
||||
set -o xtrace
|
||||
env_check
|
||||
trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
|
||||
#chroot_setup
|
||||
extra_chroot_setup
|
||||
echo "chroot_build_target"
|
||||
chroot_build_target
|
||||
${chroot_build_release_cmd}
|
||||
|
||||
return 0
|
||||
} # main()
|
||||
|
||||
main "${@}"
|
||||
127
release.conf
Normal file
127
release.conf
Normal file
@@ -0,0 +1,127 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD: stable/12/release/release.conf.sample 339435 2018-10-19 00:24:23Z gjb $
|
||||
#
|
||||
|
||||
## Redefine environment variables here to override prototypes
|
||||
## defined in release.sh.
|
||||
#load_chroot_env() { }
|
||||
#load_target_env() { }
|
||||
#buildenv_setup() { }
|
||||
|
||||
## Set the directory within which the release will be built.
|
||||
CHROOTDIR="/scratch"
|
||||
|
||||
## Set the svn host.
|
||||
SVNROOT="svn://svn.FreeBSD.org/"
|
||||
|
||||
## Set the src/, ports/, and doc/ branches or tags.
|
||||
SRCBRANCH="base/stable/12@rHEAD"
|
||||
DOCBRANCH="doc/head@rHEAD"
|
||||
PORTBRANCH="ports/head@rHEAD"
|
||||
|
||||
## Run svn co --force for src checkout.
|
||||
#SRC_FORCE_CHECKOUT=yes
|
||||
|
||||
## Sample configuration for using git instead of svn.
|
||||
#VCSCMD="/usr/local/bin/git clone --branch master"
|
||||
#SVNROOT=""
|
||||
#SRCBRANCH="https://github.com/freebsd/freebsd"
|
||||
#DOCBRANCH="https://github.com/freebsd/freebsd-doc"
|
||||
#PORTBRANCH="https://github.com/freebsd/freebsd-ports"
|
||||
|
||||
## Set to override the default target architecture.
|
||||
TARGET="amd64"
|
||||
TARGET_ARCH="amd64"
|
||||
KERNEL="CBSD"
|
||||
## Multiple kernels may be set.
|
||||
#KERNEL="GENERIC XENHVM"
|
||||
|
||||
## Set to specify a custom make.conf and/or src.conf
|
||||
#MAKE_CONF="/etc/local/make.conf"
|
||||
#SRC_CONF="/etc/local/src.conf"
|
||||
|
||||
## Set to use make(1) flags.
|
||||
#MAKE_FLAGS="-s"
|
||||
|
||||
## Set to use world- and kernel-specific make(1) flags.
|
||||
WORLD_FLAGS="-j $(sysctl -n hw.ncpu)"
|
||||
KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))"
|
||||
|
||||
## Set miscellaneous 'make release' settings.
|
||||
NODOC=yes
|
||||
NOPORTS=no
|
||||
NOSRC=no
|
||||
#WITH_DVD=
|
||||
#WITH_COMPRESSED_IMAGES=
|
||||
|
||||
## Set to '1' to disable multi-threaded xz(1) compression.
|
||||
#XZ_THREADS=0
|
||||
|
||||
## Set when building embedded images.
|
||||
EMBEDDEDBUILD=yes
|
||||
|
||||
## Set to a list of ports required to build embedded system-on-chip
|
||||
## images, such as sysutils/u-boot-rpi.
|
||||
EMBEDDEDPORTS=
|
||||
|
||||
## Set to the hardware platform of the target userland. This value
|
||||
## is passed to make(1) to set the TARGET (value of uname -m) to cross
|
||||
## build.
|
||||
EMBEDDED_TARGET=amd64
|
||||
|
||||
## Set to the machine processor architecture of the target userland.
|
||||
## This value is passed to make(1) to set the TARGET_ARCH (value of uname -p)
|
||||
## to cross build.
|
||||
EMBEDDED_TARGET_ARCH=amd64
|
||||
|
||||
## Set to skip the chroot environment buildworld/installworld/distribution
|
||||
## step if it is expected the build environment will exist via alternate
|
||||
## means.
|
||||
CHROOTBUILD_SKIP=
|
||||
|
||||
## Set to a non-empty value skip checkout or update of /usr/src in
|
||||
## the chroot. This is intended for use when /usr/src already exists.
|
||||
SRC_UPDATE_SKIP=
|
||||
|
||||
## Set to a non-empty value skip checkout or update of /usr/doc in
|
||||
## the chroot. This is intended for use when /usr/doc already exists.
|
||||
DOC_UPDATE_SKIP=
|
||||
|
||||
## Set to a non-empty value skip checkout or update of /usr/ports in
|
||||
## the chroot. This is intended for use when /usr/ports already exists.
|
||||
PORTS_UPDATE_SKIP=
|
||||
|
||||
## Set to pass additional flags to make(1) for the build chroot setup, such
|
||||
## as TARGET/TARGET_ARCH.
|
||||
#CHROOT_MAKEENV=
|
||||
|
||||
## Set to a non-empty value to build virtual machine images as part of the
|
||||
## release build.
|
||||
WITH_VMIMAGES=
|
||||
|
||||
## Set to a non-empty value to compress virtual machine images with xz(1)
|
||||
## as part of the release build.
|
||||
#WITH_COMPRESSED_VMIMAGES=
|
||||
|
||||
## If WITH_VMIMAGES is set to a non-empty value, this is the name of the
|
||||
## file to use for the installed userland/kernel.
|
||||
#VMBASE="vm"
|
||||
|
||||
## If WITH_VMIMAGES is set to a non-empty value, this is the size of the
|
||||
## virtual machine disk filesystem. Valid size values are described in
|
||||
## the truncate(1) manual page.
|
||||
#VMSIZE="20G"
|
||||
|
||||
## If WITH_VMIMAGES is set to a non-empty value, this is a list of disk
|
||||
## image formats to create. Valid values are listed in the mkimg(1)
|
||||
## manual page, as well as 'mkimg --formats' output.
|
||||
#VMFORMATS="vhdf vmdk qcow2 raw"
|
||||
|
||||
## Set to a non-empty value to build virtual machine images for various
|
||||
## cloud providers as part of the release build.
|
||||
#WITH_CLOUDWARE=
|
||||
|
||||
## If WITH_CLOUDWARE is set to a non-empty value, this is a list of providers
|
||||
## to create disk images.
|
||||
#CLOUDWARE="EC2 GCE VAGRANT-VIRTUALBOX VAGRANT-VMWARE"
|
||||
127
release.conf-second
Normal file
127
release.conf-second
Normal file
@@ -0,0 +1,127 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD: stable/12/release/release.conf.sample 339435 2018-10-19 00:24:23Z gjb $
|
||||
#
|
||||
|
||||
## Redefine environment variables here to override prototypes
|
||||
## defined in release.sh.
|
||||
#load_chroot_env() { }
|
||||
#load_target_env() { }
|
||||
#buildenv_setup() { }
|
||||
|
||||
## Set the directory within which the release will be built.
|
||||
CHROOTDIR="/scratch"
|
||||
|
||||
## Set the svn host.
|
||||
SVNROOT="svn://svn.FreeBSD.org/"
|
||||
|
||||
## Set the src/, ports/, and doc/ branches or tags.
|
||||
SRCBRANCH="base/stable/12@rHEAD"
|
||||
DOCBRANCH="doc/head@rHEAD"
|
||||
PORTBRANCH="ports/head@rHEAD"
|
||||
|
||||
## Run svn co --force for src checkout.
|
||||
#SRC_FORCE_CHECKOUT=yes
|
||||
|
||||
## Sample configuration for using git instead of svn.
|
||||
#VCSCMD="/usr/local/bin/git clone --branch master"
|
||||
#SVNROOT=""
|
||||
#SRCBRANCH="https://github.com/freebsd/freebsd"
|
||||
#DOCBRANCH="https://github.com/freebsd/freebsd-doc"
|
||||
#PORTBRANCH="https://github.com/freebsd/freebsd-ports"
|
||||
|
||||
## Set to override the default target architecture.
|
||||
TARGET="amd64"
|
||||
TARGET_ARCH="amd64"
|
||||
KERNEL="CBSD"
|
||||
## Multiple kernels may be set.
|
||||
#KERNEL="GENERIC XENHVM"
|
||||
|
||||
## Set to specify a custom make.conf and/or src.conf
|
||||
#MAKE_CONF="/etc/local/make.conf"
|
||||
#SRC_CONF="/etc/local/src.conf"
|
||||
|
||||
## Set to use make(1) flags.
|
||||
#MAKE_FLAGS="-s"
|
||||
|
||||
## Set to use world- and kernel-specific make(1) flags.
|
||||
WORLD_FLAGS="-j $(sysctl -n hw.ncpu)"
|
||||
KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))"
|
||||
|
||||
## Set miscellaneous 'make release' settings.
|
||||
NODOC=yes
|
||||
NOPORTS=yes
|
||||
NOSRC=no
|
||||
#WITH_DVD=
|
||||
#WITH_COMPRESSED_IMAGES=
|
||||
|
||||
## Set to '1' to disable multi-threaded xz(1) compression.
|
||||
#XZ_THREADS=0
|
||||
|
||||
## Set when building embedded images.
|
||||
EMBEDDEDBUILD=yes
|
||||
|
||||
## Set to a list of ports required to build embedded system-on-chip
|
||||
## images, such as sysutils/u-boot-rpi.
|
||||
EMBEDDEDPORTS=
|
||||
|
||||
## Set to the hardware platform of the target userland. This value
|
||||
## is passed to make(1) to set the TARGET (value of uname -m) to cross
|
||||
## build.
|
||||
EMBEDDED_TARGET=amd64
|
||||
|
||||
## Set to the machine processor architecture of the target userland.
|
||||
## This value is passed to make(1) to set the TARGET_ARCH (value of uname -p)
|
||||
## to cross build.
|
||||
EMBEDDED_TARGET_ARCH=amd64
|
||||
|
||||
## Set to skip the chroot environment buildworld/installworld/distribution
|
||||
## step if it is expected the build environment will exist via alternate
|
||||
## means.
|
||||
CHROOTBUILD_SKIP=yes
|
||||
|
||||
## Set to a non-empty value skip checkout or update of /usr/src in
|
||||
## the chroot. This is intended for use when /usr/src already exists.
|
||||
SRC_UPDATE_SKIP=yes
|
||||
|
||||
## Set to a non-empty value skip checkout or update of /usr/doc in
|
||||
## the chroot. This is intended for use when /usr/doc already exists.
|
||||
DOC_UPDATE_SKIP=yes
|
||||
|
||||
## Set to a non-empty value skip checkout or update of /usr/ports in
|
||||
## the chroot. This is intended for use when /usr/ports already exists.
|
||||
PORTS_UPDATE_SKIP=yes
|
||||
|
||||
## Set to pass additional flags to make(1) for the build chroot setup, such
|
||||
## as TARGET/TARGET_ARCH.
|
||||
#CHROOT_MAKEENV=
|
||||
|
||||
## Set to a non-empty value to build virtual machine images as part of the
|
||||
## release build.
|
||||
WITH_VMIMAGES=
|
||||
|
||||
## Set to a non-empty value to compress virtual machine images with xz(1)
|
||||
## as part of the release build.
|
||||
#WITH_COMPRESSED_VMIMAGES=
|
||||
|
||||
## If WITH_VMIMAGES is set to a non-empty value, this is the name of the
|
||||
## file to use for the installed userland/kernel.
|
||||
#VMBASE="vm"
|
||||
|
||||
## If WITH_VMIMAGES is set to a non-empty value, this is the size of the
|
||||
## virtual machine disk filesystem. Valid size values are described in
|
||||
## the truncate(1) manual page.
|
||||
#VMSIZE="20G"
|
||||
|
||||
## If WITH_VMIMAGES is set to a non-empty value, this is a list of disk
|
||||
## image formats to create. Valid values are listed in the mkimg(1)
|
||||
## manual page, as well as 'mkimg --formats' output.
|
||||
#VMFORMATS="vhdf vmdk qcow2 raw"
|
||||
|
||||
## Set to a non-empty value to build virtual machine images for various
|
||||
## cloud providers as part of the release build.
|
||||
#WITH_CLOUDWARE=
|
||||
|
||||
## If WITH_CLOUDWARE is set to a non-empty value, this is a list of providers
|
||||
## to create disk images.
|
||||
#CLOUDWARE="EC2 GCE VAGRANT-VIRTUALBOX VAGRANT-VMWARE"
|
||||
456
release.sh
Executable file
456
release.sh
Executable file
@@ -0,0 +1,456 @@
|
||||
#!/bin/sh
|
||||
#-
|
||||
# Copyright (c) 2013-2018 The FreeBSD Foundation
|
||||
# Copyright (c) 2013 Glen Barber
|
||||
# Copyright (c) 2011 Nathan Whitehorn
|
||||
# All rights reserved.
|
||||
#
|
||||
# Portions of this software were developed by Glen Barber
|
||||
# under sponsorship from the FreeBSD Foundation.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# release.sh: check out source trees, and build release components with
|
||||
# totally clean, fresh trees.
|
||||
# Based on release/generate-release.sh written by Nathan Whitehorn
|
||||
#
|
||||
# $FreeBSD: stable/12/release/release.sh 339980 2018-10-31 23:54:36Z gjb $
|
||||
#
|
||||
|
||||
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
|
||||
|
||||
VERSION=2
|
||||
|
||||
# Prototypes that can be redefined per-chroot or per-target.
|
||||
load_chroot_env() { }
|
||||
load_target_env() { }
|
||||
buildenv_setup() { }
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [-c release.conf]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# env_setup(): Set up the default build environment variables, such as the
|
||||
# CHROOTDIR, VCSCMD, SVNROOT, etc. This is called before the release.conf
|
||||
# file is sourced, if '-c <release.conf>' is specified.
|
||||
env_setup() {
|
||||
# The directory within which the release will be built.
|
||||
CHROOTDIR="/scratch"
|
||||
RELENGDIR="$(dirname $(realpath ${0}))"
|
||||
|
||||
# The default version control system command to obtain the sources.
|
||||
for _dir in /usr/bin /usr/local/bin; do
|
||||
for _svn in svn svnlite; do
|
||||
[ -x "${_dir}/${_svn}" ] && VCSCMD="${_dir}/${_svn}"
|
||||
[ ! -z "${VCSCMD}" ] && break 2
|
||||
done
|
||||
done
|
||||
VCSCMD="${VCSCMD} checkout"
|
||||
|
||||
# The default svn checkout server, and svn branches for src/, doc/,
|
||||
# and ports/.
|
||||
SVNROOT="svn://svn.FreeBSD.org/"
|
||||
SRCBRANCH="base/head@rHEAD"
|
||||
DOCBRANCH="doc/head@rHEAD"
|
||||
PORTBRANCH="ports/head@rHEAD"
|
||||
|
||||
# Set for embedded device builds.
|
||||
EMBEDDEDBUILD=
|
||||
|
||||
# Sometimes one needs to checkout src with --force svn option.
|
||||
# If custom kernel configs copied to src tree before checkout, e.g.
|
||||
SRC_FORCE_CHECKOUT=
|
||||
|
||||
# The default make.conf and src.conf to use. Set to /dev/null
|
||||
# by default to avoid polluting the chroot(8) environment with
|
||||
# non-default settings.
|
||||
MAKE_CONF="/dev/null"
|
||||
SRC_CONF="/dev/null"
|
||||
|
||||
# The number of make(1) jobs, defaults to the number of CPUs available
|
||||
# for buildworld, and half of number of CPUs available for buildkernel.
|
||||
WORLD_FLAGS="-j$(sysctl -n hw.ncpu)"
|
||||
KERNEL_FLAGS="-j$(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2))"
|
||||
|
||||
MAKE_FLAGS="-s"
|
||||
|
||||
# The name of the kernel to build, defaults to GENERIC.
|
||||
KERNEL="GENERIC"
|
||||
|
||||
# Set to non-empty value to disable checkout of doc/ and/or ports/.
|
||||
# Disabling ports/ checkout also forces NODOC to be set.
|
||||
NODOC=
|
||||
NOPORTS=
|
||||
|
||||
# Set to non-empty value to disable distributing source tree.
|
||||
NOSRC=
|
||||
|
||||
# Set to non-empty value to build dvd1.iso as part of the release.
|
||||
WITH_DVD=
|
||||
WITH_COMPRESSED_IMAGES=
|
||||
|
||||
# Set to non-empty value to build virtual machine images as part of
|
||||
# the release.
|
||||
WITH_VMIMAGES=
|
||||
WITH_COMPRESSED_VMIMAGES=
|
||||
XZ_THREADS=0
|
||||
|
||||
# Set to non-empty value to build virtual machine images for various
|
||||
# cloud providers as part of the release.
|
||||
WITH_CLOUDWARE=
|
||||
|
||||
return 0
|
||||
} # env_setup()
|
||||
|
||||
# env_check(): Perform sanity tests on the build environment, such as ensuring
|
||||
# files/directories exist, as well as adding backwards-compatibility hacks if
|
||||
# necessary. This is called unconditionally, and overrides the defaults set
|
||||
# in env_setup() if '-c <release.conf>' is specified.
|
||||
env_check() {
|
||||
chroot_build_release_cmd="chroot_build_release"
|
||||
# Fix for backwards-compatibility with release.conf that does not have
|
||||
# the trailing '/'.
|
||||
case ${SVNROOT} in
|
||||
*svn*)
|
||||
SVNROOT="${SVNROOT}/"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Prefix the branches with the SVNROOT for the full checkout URL.
|
||||
SRCBRANCH="${SVNROOT}${SRCBRANCH}"
|
||||
DOCBRANCH="${SVNROOT}${DOCBRANCH}"
|
||||
PORTBRANCH="${SVNROOT}${PORTBRANCH}"
|
||||
|
||||
if [ -n "${EMBEDDEDBUILD}" ]; then
|
||||
WITH_DVD=
|
||||
WITH_COMPRESSED_IMAGES=
|
||||
NODOC=yes
|
||||
case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in
|
||||
arm:arm*|arm64:aarch64)
|
||||
chroot_build_release_cmd="chroot_arm_build_release"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# If PORTS is set and NODOC is unset, force NODOC=yes because the ports
|
||||
# tree is required to build the documentation set.
|
||||
if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
|
||||
echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
|
||||
echo " and NOPORTS is set."
|
||||
NODOC=yes
|
||||
fi
|
||||
|
||||
# If NOSRC, NOPORTS and/or NODOC are unset, they must not pass to make
|
||||
# as variables. The release makefile verifies definedness of the
|
||||
# NOPORTS/NODOC variables instead of their values.
|
||||
SRCDOCPORTS=
|
||||
if [ -n "${NOPORTS}" ]; then
|
||||
SRCDOCPORTS="NOPORTS=yes"
|
||||
fi
|
||||
if [ -n "${NODOC}" ]; then
|
||||
SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NODOC=yes"
|
||||
fi
|
||||
if [ -n "${NOSRC}" ]; then
|
||||
SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NOSRC=yes"
|
||||
fi
|
||||
|
||||
# The aggregated build-time flags based upon variables defined within
|
||||
# this file, unless overridden by release.conf. In most cases, these
|
||||
# will not need to be changed.
|
||||
CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
|
||||
if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
|
||||
ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
|
||||
else
|
||||
ARCH_FLAGS=
|
||||
fi
|
||||
# Force src checkout if configured
|
||||
FORCE_SRC_KEY=
|
||||
if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
|
||||
FORCE_SRC_KEY="--force"
|
||||
fi
|
||||
|
||||
if [ -z "${CHROOTDIR}" ]; then
|
||||
echo "Please set CHROOTDIR."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
echo "Needs to be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Unset CHROOTBUILD_SKIP if the chroot(8) does not appear to exist.
|
||||
if [ ! -z "${CHROOTBUILD_SKIP}" -a ! -e ${CHROOTDIR}/bin/sh ]; then
|
||||
CHROOTBUILD_SKIP=
|
||||
fi
|
||||
|
||||
CHROOT_MAKEENV="${CHROOT_MAKEENV} \
|
||||
MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
|
||||
CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
|
||||
CHROOT_IMAKEFLAGS="${WORLD_FLAGS} ${CONF_FILES}"
|
||||
CHROOT_DMAKEFLAGS="${WORLD_FLAGS} ${CONF_FILES}"
|
||||
RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} \
|
||||
${CONF_FILES}"
|
||||
RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \
|
||||
KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
|
||||
RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \
|
||||
KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${SRCDOCPORTS} \
|
||||
WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
|
||||
WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}"
|
||||
|
||||
return 0
|
||||
} # env_check()
|
||||
|
||||
# chroot_setup(): Prepare the build chroot environment for the release build.
|
||||
chroot_setup() {
|
||||
load_chroot_env
|
||||
mkdir -p ${CHROOTDIR}/usr
|
||||
|
||||
if [ -z "${SRC_UPDATE_SKIP}" ]; then
|
||||
${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
|
||||
fi
|
||||
if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then
|
||||
${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
|
||||
fi
|
||||
if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then
|
||||
${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
|
||||
fi
|
||||
|
||||
if [ -z "${CHROOTBUILD_SKIP}" ]; then
|
||||
cd ${CHROOTDIR}/usr/src
|
||||
env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld -DNO_CLEAN
|
||||
env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
|
||||
DESTDIR=${CHROOTDIR}
|
||||
env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
|
||||
DESTDIR=${CHROOTDIR}
|
||||
fi
|
||||
|
||||
return 0
|
||||
} # chroot_setup()
|
||||
|
||||
# extra_chroot_setup(): Prepare anything additional within the build
|
||||
# necessary for the release build.
|
||||
extra_chroot_setup() {
|
||||
mkdir -p ${CHROOTDIR}/dev
|
||||
mount -t devfs devfs ${CHROOTDIR}/dev
|
||||
[ -e /etc/resolv.conf -a ! -e ${CHROOTDIR}/etc/resolv.conf ] && \
|
||||
cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
|
||||
# Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
|
||||
# is created. This is needed by ports-mgmt/pkg.
|
||||
eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
|
||||
|
||||
# If MAKE_CONF and/or SRC_CONF are set and not character devices
|
||||
# (/dev/null), copy them to the chroot.
|
||||
if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
|
||||
mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
|
||||
cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
|
||||
fi
|
||||
if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
|
||||
mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
|
||||
cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
|
||||
fi
|
||||
|
||||
if [ -d ${CHROOTDIR}/usr/ports ]; then
|
||||
# Trick the ports 'run-autotools-fixup' target to do the right
|
||||
# thing.
|
||||
_OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
|
||||
REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
|
||||
BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
|
||||
UNAME_r=${REVISION}-${BRANCH}
|
||||
if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
|
||||
PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} WRKDIRPREFIX=/tmp/ports"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} DISTDIR=/tmp/distfiles"
|
||||
chroot ${CHROOTDIR} env ${PBUILD_FLAGS} \
|
||||
OPTIONS_UNSET="AVAHI FOP IGOR" make -C \
|
||||
/usr/ports/textproc/docproj \
|
||||
FORCE_PKG_REGISTER=1 \
|
||||
install clean distclean
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${EMBEDDEDPORTS}" ]; then
|
||||
_OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
|
||||
REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
|
||||
BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
|
||||
PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} WRKDIRPREFIX=/tmp/ports"
|
||||
PBUILD_FLAGS="${PBUILD_FLAGS} DISTDIR=/tmp/distfiles"
|
||||
for _PORT in ${EMBEDDEDPORTS}; do
|
||||
eval chroot ${CHROOTDIR} env ${PBUILD_FLAGS} make -C \
|
||||
/usr/ports/${_PORT} \
|
||||
FORCE_PKG_REGISTER=1 deinstall install clean distclean
|
||||
done
|
||||
fi
|
||||
|
||||
buildenv_setup
|
||||
|
||||
return 0
|
||||
} # extra_chroot_setup()
|
||||
|
||||
# chroot_build_target(): Build the userland and kernel for the build target.
|
||||
chroot_build_target() {
|
||||
load_target_env
|
||||
if [ ! -z "${EMBEDDEDBUILD}" ]; then
|
||||
RELEASE_WMAKEFLAGS="${RELEASE_WMAKEFLAGS} \
|
||||
TARGET=${EMBEDDED_TARGET} \
|
||||
TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
|
||||
RELEASE_KMAKEFLAGS="${RELEASE_KMAKEFLAGS} \
|
||||
TARGET=${EMBEDDED_TARGET} \
|
||||
TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
|
||||
fi
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld -DNO_CLEAN
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel -DNO_CLEAN
|
||||
|
||||
return 0
|
||||
} # chroot_build_target
|
||||
|
||||
# chroot_build_release(): Invoke the 'make release' target.
|
||||
chroot_build_release() {
|
||||
load_target_env
|
||||
if [ ! -z "${WITH_VMIMAGES}" ]; then
|
||||
if [ -z "${VMFORMATS}" ]; then
|
||||
VMFORMATS="$(eval chroot ${CHROOTDIR} \
|
||||
make -C /usr/src/release -V VMFORMATS)"
|
||||
fi
|
||||
if [ -z "${VMSIZE}" ]; then
|
||||
VMSIZE="$(eval chroot ${CHROOTDIR} \
|
||||
make -C /usr/src/release -V VMSIZE)"
|
||||
fi
|
||||
RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} \
|
||||
VMFORMATS=\"${VMFORMATS}\" VMSIZE=${VMSIZE}"
|
||||
fi
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src/release \
|
||||
${RELEASE_RMAKEFLAGS} release
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src/release \
|
||||
${RELEASE_RMAKEFLAGS} install DESTDIR=/R \
|
||||
WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \
|
||||
WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES}
|
||||
|
||||
return 0
|
||||
} # chroot_build_release()
|
||||
|
||||
efi_boot_name()
|
||||
{
|
||||
case $1 in
|
||||
arm)
|
||||
echo "bootarm.efi"
|
||||
;;
|
||||
arm64)
|
||||
echo "bootaa64.efi"
|
||||
;;
|
||||
amd64)
|
||||
echo "bootx86.efi"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# chroot_arm_build_release(): Create arm SD card image.
|
||||
chroot_arm_build_release() {
|
||||
load_target_env
|
||||
case ${EMBEDDED_TARGET} in
|
||||
arm|arm64)
|
||||
if [ -e "${RELENGDIR}/tools/arm.subr" ]; then
|
||||
. "${RELENGDIR}/tools/arm.subr"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
[ ! -z "${RELEASECONF}" ] && . "${RELEASECONF}"
|
||||
export MAKE_FLAGS="${MAKE_FLAGS} TARGET=${EMBEDDED_TARGET}"
|
||||
export MAKE_FLAGS="${MAKE_FLAGS} TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
|
||||
eval chroot ${CHROOTDIR} env WITH_UNIFIED_OBJDIR=1 make ${MAKE_FLAGS} -C /usr/src/release obj
|
||||
export WORLDDIR="$(eval chroot ${CHROOTDIR} make ${MAKE_FLAGS} -C /usr/src/release -V WORLDDIR)"
|
||||
export OBJDIR="$(eval chroot ${CHROOTDIR} env WITH_UNIFIED_OBJDIR=1 make ${MAKE_FLAGS} -C /usr/src/release -V .OBJDIR)"
|
||||
export DESTDIR="${OBJDIR}/${KERNEL}"
|
||||
export IMGBASE="${CHROOTDIR}/${OBJDIR}/${BOARDNAME}.img"
|
||||
export OSRELEASE="$(eval chroot ${CHROOTDIR} make ${MAKE_FLAGS} -C /usr/src/release \
|
||||
TARGET=${EMBEDDED_TARGET} TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \
|
||||
-V OSRELEASE)"
|
||||
chroot ${CHROOTDIR} mkdir -p ${DESTDIR}
|
||||
chroot ${CHROOTDIR} truncate -s ${IMAGE_SIZE} ${IMGBASE##${CHROOTDIR}}
|
||||
export mddev=$(chroot ${CHROOTDIR} \
|
||||
mdconfig -f ${IMGBASE##${CHROOTDIR}} ${MD_ARGS})
|
||||
arm_create_disk
|
||||
arm_install_base
|
||||
arm_install_boot
|
||||
arm_install_uboot
|
||||
mdconfig -d -u ${mddev}
|
||||
chroot ${CHROOTDIR} rmdir ${DESTDIR}
|
||||
mv ${IMGBASE} ${CHROOTDIR}/${OBJDIR}/${OSRELEASE}-${BOARDNAME}.img
|
||||
chroot ${CHROOTDIR} mkdir -p /R
|
||||
chroot ${CHROOTDIR} cp -p ${OBJDIR}/${OSRELEASE}-${BOARDNAME}.img \
|
||||
/R/${OSRELEASE}-${BOARDNAME}.img
|
||||
chroot ${CHROOTDIR} xz -T ${XZ_THREADS} /R/${OSRELEASE}-${BOARDNAME}.img
|
||||
cd ${CHROOTDIR}/R && sha512 ${OSRELEASE}* \
|
||||
> CHECKSUM.SHA512
|
||||
cd ${CHROOTDIR}/R && sha256 ${OSRELEASE}* \
|
||||
> CHECKSUM.SHA256
|
||||
|
||||
return 0
|
||||
} # chroot_arm_build_release()
|
||||
|
||||
# main(): Start here.
|
||||
main() {
|
||||
set -e # Everything must succeed
|
||||
env_setup
|
||||
while getopts c: opt; do
|
||||
case ${opt} in
|
||||
c)
|
||||
RELEASECONF="$(realpath ${OPTARG})"
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ ! -z "${RELEASECONF}" ]; then
|
||||
if [ -e "${RELEASECONF}" ]; then
|
||||
. ${RELEASECONF}
|
||||
else
|
||||
echo "Nonexistent configuration file: ${RELEASECONF}"
|
||||
echo "Using default build environment."
|
||||
fi
|
||||
fi
|
||||
set -o xtrace
|
||||
env_check
|
||||
trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
|
||||
chroot_setup
|
||||
extra_chroot_setup
|
||||
chroot_build_target
|
||||
${chroot_build_release_cmd}
|
||||
|
||||
return 0
|
||||
} # main()
|
||||
|
||||
main "${@}"
|
||||
4
run
Executable file
4
run
Executable file
@@ -0,0 +1,4 @@
|
||||
cd /rel
|
||||
tar cf clonos.tar clonos ; xz -9 clonos.tar ; mv clonos.tar.xz clonos.txz
|
||||
echo "MAKE"
|
||||
/rel/make.sh
|
||||
80
scripts/make-manifest.sh
Executable file
80
scripts/make-manifest.sh
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
|
||||
# make-manifest.sh: create checksums and package descriptions for the installer
|
||||
#
|
||||
# Usage: make-manifest.sh foo1.txz foo2.txz ...
|
||||
#
|
||||
# The output file looks like this (tab-delimited):
|
||||
# foo1.txz SHA256-checksum Number-of-files foo1 Description Install-by-default
|
||||
#
|
||||
# $FreeBSD: head/release/scripts/make-manifest.sh 328593 2018-01-30 16:34:56Z swills $
|
||||
|
||||
base="Base system"
|
||||
doc="Additional Documentation"
|
||||
kernel="Kernel"
|
||||
ports="Ports tree"
|
||||
src="System source tree"
|
||||
lib32="32-bit compatibility libraries"
|
||||
tests="Test suite"
|
||||
clonos="ClonOS components"
|
||||
|
||||
desc_base="${base} (MANDATORY)"
|
||||
desc_base_dbg="${base} (Debugging)"
|
||||
desc_doc="${doc}"
|
||||
desc_kernel="${kernel} (MANDATORY)"
|
||||
desc_kernel_dbg="${kernel} (Debugging)"
|
||||
desc_kernel_alt="Alternate ${kernel}"
|
||||
desc_kernel_alt_dbg="Alternate ${kernel} (Debugging)"
|
||||
desc_lib32="${lib32}"
|
||||
desc_lib32_dbg="${lib32} (Debugging)"
|
||||
desc_ports="${ports}"
|
||||
desc_src="${src}"
|
||||
desc_tests="${tests}"
|
||||
desc_clonos="ClonOS components"
|
||||
|
||||
default_doc=off
|
||||
default_src=off
|
||||
default_ports=off
|
||||
default_tests=off
|
||||
default_base_dbg=off
|
||||
default_lib32_dbg=off
|
||||
default_kernel_alt=off
|
||||
default_kernel_dbg=on
|
||||
default_kernel_alt_dbg=off
|
||||
default_clonos=on
|
||||
|
||||
for i in ${*}; do
|
||||
dist="${i}"
|
||||
distname="${i%%.txz}"
|
||||
distname="$(echo ${distname} | tr '-' '_')"
|
||||
distname="$(echo ${distname} | tr 'kernel.' 'kernel_')"
|
||||
hash="$(sha256 -q ${i})"
|
||||
nfiles="$(tar tvf ${i} | wc -l | tr -d ' ')"
|
||||
default="$(eval echo \${default_${distname}:-on})"
|
||||
desc="$(eval echo \"\${desc_${distname}}\")"
|
||||
|
||||
case ${i} in
|
||||
kernel-dbg.txz)
|
||||
desc="${desc_kernel_dbg}"
|
||||
;;
|
||||
kernel.*-dbg.txz)
|
||||
desc="$(eval echo \"${desc_kernel_alt_dbg}\")"
|
||||
desc="${desc}: $(eval echo ${i%%-dbg.txz} | cut -f 2 -d '.')"
|
||||
default="$(eval echo \"${default_kernel_alt_dbg}\")"
|
||||
;;
|
||||
kernel.*.txz)
|
||||
desc="$(eval echo \"${desc_kernel_alt}\")"
|
||||
desc="${desc}: $(eval echo ${i%%.txz} | cut -f 2 -d '.')"
|
||||
default="$(eval echo \"${default_kernel_alt}\")"
|
||||
;;
|
||||
clonos*.txz)
|
||||
desc="${desc_clonos}"
|
||||
default="$(eval echo \"${default_clonos}\")"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "${dist}\t${hash}\t${nfiles}\t${distname}\t\"${desc}\"\t${default}\n"
|
||||
done
|
||||
|
||||
36
sysctl.conf
Normal file
36
sysctl.conf
Normal file
@@ -0,0 +1,36 @@
|
||||
net.inet.ip.forwarding = 1
|
||||
net.inet.icmp.icmplim = 0
|
||||
security.bsd.see_other_gids = 0
|
||||
net.inet.tcp.fast_finwait2_recycle = 1
|
||||
net.inet.tcp.recvspace = 262144
|
||||
net.inet.tcp.sendspace = 262144
|
||||
security.bsd.see_other_uids = 0
|
||||
kern.ipc.shm_use_phys = 1
|
||||
kern.ipc.shmall = 262144
|
||||
kern.ipc.shmmax = 1073741824
|
||||
kern.ipc.somaxconn = 4096
|
||||
kern.maxfiles = 2048000
|
||||
kern.maxfilesperproc = 200000
|
||||
net.inet.ip.fw.dyn_max = 8192
|
||||
net.inet.ip.intr_queue_maxlen = 2048
|
||||
net.inet.ip.portrange.first = 1024
|
||||
net.inet.ip.portrange.last = 65535
|
||||
net.inet.ip.portrange.randomized = 0
|
||||
net.inet.tcp.cc.algorithm = htcp
|
||||
net.inet.tcp.maxtcptw = 40960
|
||||
net.inet.tcp.msl = 10000
|
||||
net.inet.tcp.nolocaltimewait = 1
|
||||
net.inet.tcp.syncookies = 1
|
||||
net.inet.udp.maxdgram = 18432
|
||||
net.local.stream.recvspace = 262144
|
||||
net.local.stream.sendspace = 262144
|
||||
security.jail.allow_raw_sockets = 1
|
||||
security.jail.chflags_allowed = 1
|
||||
security.jail.enforce_statfs = 2
|
||||
security.jail.mount_allowed = 1
|
||||
security.jail.set_hostname_allowed = 1
|
||||
security.jail.sysvipc_allowed = 1
|
||||
vfs.zfs.prefetch_disable = 1
|
||||
kern.corefile = /var/coredumps/%N.core
|
||||
kern.sugid_coredump = 1
|
||||
net.ipv4.ip_forward = 1
|
||||
Reference in New Issue
Block a user