diff --git a/.cirrus.yml b/.cirrus.yml index 20565af4..b4c27152 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,11 +1,12 @@ task: freebsd_instance: - cpu: 2 - memory: 8G + cpu: 8 + memory: 16G matrix: - # image: freebsd-12-1-release-amd64 # EOL + - image: freebsd-13-0-release-amd64 - image: freebsd-12-2-release-amd64 - # image: freebsd-13-0-release-amd64 # ISO way too large, HIDPI broken, BIOS boot broken, boot installed system broken? + # image: freebsd-14-0-current-amd64-v20211111 + # image: freebsd-12-1-release-amd64 # EOL env: CIRRUS_CLONE_DEPTH: 1 @@ -33,8 +34,9 @@ task: - kldload nullfs.ko || true - kldload geom_uzip.ko || true - pkg install -y pkg git-lite zsync wget sha bash zip devel/py-xdg librsvg2 ca_root_nss # qemu-devel uefi-edk2-qemu-x86_64 - - mkdir -p /usr/local/furybsd - # mount -t tmpfs tmpfs /usr/local/furybsd + - mkdir -p /usr/local/furybsd/uzip /usr/local/furybsd/cdroot/ + - mount -t tmpfs tmpfs /usr/local/furybsd/uzip + - mount -t tmpfs tmpfs /usr/local/furybsd/cdroot/ Build_script: - export VER=$(uname -r | cut -d "-" -f 1) @@ -45,14 +47,10 @@ task: - export BUILDNUMBER=$(RELEASE_ID_FOR_STORAGE=33980128 ./buildnumbers) - /bin/sh -x ./build.sh "${DESKTOP}" || true # FIXME: Why does this return an error even though the ISO succeeded? - df -h - - ls -lh "${CIRRUS_WORKING_DIR}"/artifacts/*.iso || false # Error out if ISO was not produced to mitigate the above - # ( cd "${CIRRUS_WORKING_DIR}"/artifacts ; zsyncmake *.iso ) + - ls -lh /usr/local/furybsd/iso/*.iso || false # Error out if ISO was not produced to mitigate the above + # ( cd /usr/local/furybsd/ ; zsyncmake *.iso ) Upload_script: - export VER=$(uname -r | cut -d "-" -f 1) # No way to pass on from Build_script to Upload_script? - - ls -lh "${CIRRUS_WORKING_DIR}"/artifacts/ - - case "$CIRRUS_BRANCH" in *pull/*) echo skipping since PR ;; * ) wget -c -q https://github.com/tcnksm/ghr/files/5247714/ghr.zip ; unzip ghr.zip ; ./ghr -prerelease -delete -t "${GITHUB_TOKEN}" -u "${CIRRUS_REPO_OWNER}" -r "${CIRRUS_REPO_NAME}" -b "This is an experimental __UNTESTED__ build for developers, it may not even boot." -c "${CIRRUS_CHANGE_IN_REPO}" "${CIRRUS_BRANCH}"-"${VER}" "${CIRRUS_WORKING_DIR}"/artifacts ; esac - - FreeNode_script: - - echo "TODO: Fix IRC bot script" - # case "$CIRRUS_BRANCH" in *pull/*) echo skipping since PR ;; * ) echo -e 'USER helloSystemBot guest tolmoon tolsun\nNICK helloSystemBot\nJOIN #helloSystem\nPRIVMSG #helloSystem :A new build is now available in the Create Live Media tool, happy testing!\nQUIT\n' | nc irc.freenode.net 6667 >/dev/null ; esac + - ls -lh /usr/local/furybsd/iso/ + - case "$CIRRUS_BRANCH" in *pull/*) echo skipping since PR ;; * ) wget -c -q https://github.com/tcnksm/ghr/files/5247714/ghr.zip ; unzip ghr.zip ; ./ghr -prerelease -delete -t "${GITHUB_TOKEN}" -u "${CIRRUS_REPO_OWNER}" -r "${CIRRUS_REPO_NAME}" -b "This is an experimental __UNTESTED__ build for developers, it may not even boot." -c "${CIRRUS_CHANGE_IN_REPO}" "${CIRRUS_BRANCH}"-"${VER}" /usr/local/furybsd/iso/ ; esac diff --git a/build.sh b/build.sh index 23e6eee7..12bc8273 100755 --- a/build.sh +++ b/build.sh @@ -28,8 +28,6 @@ if [ "${VERSIONSUFFIX#RC}"x != "${VERSIONSUFFIX}x" ] ; then FTPDIRECTORY="releases" fi -echo "${FTPDIRECTORY}" - # pkgset="branches/2020Q1" # TODO: Use it desktop=$1 tag=$2 @@ -43,15 +41,8 @@ cache="${livecd}/${arch}/cache" base="${cache}/${version}/base" export packages="${cache}/packages" iso="${livecd}/iso" - if [ -n "$CIRRUS_CI" ] ; then - # On Cirrus CI ${livecd} is in tmpfs for speed reasons - # and tends to run out of space. Writing the final ISO - # to non-tmpfs should be an acceptable compromise - iso="${CIRRUS_WORKING_DIR}/artifacts" - fi export uzip="${livecd}/uzip" export cdroot="${livecd}/cdroot" -ramdisk_root="${cdroot}/data/ramdisk" vol="furybsd" label="LIVE" export DISTRIBUTIONS="kernel.txz base.txz" @@ -111,8 +102,7 @@ if [ "${desktop}" = "hello" ] ; then # based on environment variable set e.g., by Cirrus CI if [ ! -z $BUILDNUMBER ] ; then echo "Injecting $BUILDNUMBER" into manifest - sed -i -e 's|\(^version: .*_\).*$|\1'$BUILDNUMBER'|g' "${cwd}/overlays/uzip/hello/manifest" - rm "${cwd}/overlays/uzip/hello/manifest-e" + sed -i '' -e 's|\(^version: .*_\).*$|\1'$BUILDNUMBER'|g' "${cwd}/overlays/uzip/hello/manifest" cat "${cwd}/overlays/uzip/hello/manifest" isopath="${iso}/${desktop}-${HELLO_VERSION}_${BUILDNUMBER}-FreeBSD-${VER}-${arch}.iso" else @@ -129,8 +119,10 @@ cleanup() else umount ${uzip}/var/cache/pkg >/dev/null 2>/dev/null || true umount ${uzip}/dev >/dev/null 2>/dev/null || true - zpool destroy -f furybsd >/dev/null 2>/dev/null || true - mdconfig -d -u 0 >/dev/null 2>/dev/null || true + if [ -d "${livecd}" ] ;then + chflags -R noschg ${uzip} ${cdroot} >/dev/null 2>/dev/null || true + rm -rf ${uzip} ${cdroot} >/dev/null 2>/dev/null || true + fi rm ${livecd}/pool.img >/dev/null 2>/dev/null || true rm -rf ${cdroot} >/dev/null 2>/dev/null || true fi @@ -138,24 +130,17 @@ cleanup() workspace() { - mkdir -p "${livecd}" "${base}" "${iso}" "${packages}" "${uzip}" "${ramdisk_root}/dev" "${ramdisk_root}/etc" >/dev/null 2>/dev/null - truncate -s 3g "${livecd}/pool.img" - mdconfig -f "${livecd}/pool.img" -u 0 - gpart create -s GPT md0 - gpart add -t freebsd-zfs md0 - sync ### Needed? - zpool create furybsd /dev/md0p1 + + # Mount a temporary filesystem image at "${uzip}" so that we can clean up afterwards more easily + # dd if=/dev/zero of=test.img bs=1M count=512 + # mdconfig -a -t vnode -f test.img -u 9 + # newfs /dev/md9 + # mount /dev/md9 "${uzip}" + + mkdir -p "${livecd}" "${base}" "${iso}" "${packages}" "${uzip}" "${cdroot}" >/dev/null 2>/dev/null + #truncate -s 3g "${livecd}/pool.img" + #mdconfig -f "${livecd}/pool.img" -u 0 sync ### Needed? - zfs set mountpoint="${uzip}" furybsd - # From FreeBSD 13 on, zstd can be used with zfs in base - MAJOR=$(uname -r | cut -d "." -f 1) - if [ $MAJOR -lt 14 ] ; then - zfs set compression=gzip-6 furybsd - else - # zstd conflicts uzip for good compression ratio? - zfs set recordsize=1M furybsd # This may influence the compression ratio - zfs set compression=zstd-15 furybsd # Since we do not write to it, 15 may be ok (but may need more RAM?) - fi } base() @@ -199,8 +184,7 @@ packages() # NOTE: Also adjust the Nvidia drivers accordingly below. TODO: Use one set of variables if [ $MAJOR -eq 12 ] ; then # echo "Major version 12, hence using release_2 packages since quarterly can be missing packages from one day to the next" - # sed -i -e 's|quarterly|release_2|g' "${uzip}/etc/pkg/FreeBSD.conf" - # rm -f "${uzip}/etc/pkg/FreeBSD.conf-e" + # sed -i '' -e 's|quarterly|release_2|g' "${uzip}/etc/pkg/FreeBSD.conf" echo "Major version 12, using quarterly packages" elif [ $MAJOR -eq 13 ] ; then echo "Major version 13, using quarterly packages" @@ -239,10 +223,8 @@ packages() /usr/local/sbin/pkg-static -r ${uzip} add "${packages}/transient/${p}" # pkg-static add has no -y done <"${packages}/transient/transient-packages-list" - # /usr/local/sbin/pkg-static -c ${uzip} info > "${cdroot}/data/system.uzip.manifest" # Manifest of installed packages ordered by size in bytes - /usr/local/sbin/pkg-static -c ${uzip} query "%sb\t%n\t%v\t%c" | sort -r -s -n -k 1,1 > "${cdroot}/data/system.uzip.manifest" - cp "${cdroot}/data/system.uzip.manifest" "${isopath}.manifest" + /usr/local/sbin/pkg-static -c ${uzip} query "%sb\t%n\t%v\t%c" | sort -r -s -n -k 1,1 > "${isopath}.manifest" # zip local.sqlite and put in output directory next to the ISO zip pkg.zip ${uzip}/var/db/pkg/local.sqlite mv pkg.zip "${isopath}.pkg.zip" @@ -275,18 +257,8 @@ repos() user() { - mkdir -p ${uzip}/usr/home/liveuser/Desktop - # chroot ${uzip} echo furybsd | chroot ${uzip} pw mod user root -h 0 - chroot ${uzip} pw useradd liveuser -u 1000 \ - -c "Live User" -d "/home/liveuser" \ - -g wheel -G operator -m -s /usr/local/bin/zsh -k /usr/share/skel -w none - chroot ${uzip} pw groupadd liveuser -g 1000 - # chroot ${uzip} echo furybsd | chroot ${uzip} pw mod user liveuser -h 0 - chroot ${uzip} chown -R 1000:1000 /usr/home/liveuser - chroot ${uzip} pw groupmod wheel -m liveuser - chroot ${uzip} pw groupmod video -m liveuser - chroot ${uzip} pw groupmod webcamd -m liveuser - chroot ${uzip} pw groupmod cups -m liveuser + # This is now done ad-hoc at boot time because we would + # need to constuct $HOME from skel anyway } dm() @@ -328,7 +300,6 @@ pkg() initgfx() { if [ "${arch}" != "i386" ] ; then - MAJOR=$(uname -r | cut -d "." -f 1) if [ $MAJOR -lt 14 ] ; then PKGS="quarterly" # PKGS="latest" # This must match what we specify in packages() @@ -337,8 +308,8 @@ initgfx() fi # 390 needed for Nvidia Quadro 2000, https://github.com/helloSystem/hello/discussions/241#discussioncomment-1599131 - for ver in '390'; do # Only use NVIDIA version 440 and 390 for now to reduce ISO image size - # for ver in '' 390 340 304; do + # 340 needed for Nvidia 320M + for ver in '' 390 340 304; do pkgfile=$(/usr/local/sbin/pkg-static -c ${uzip} rquery %n-%v.txz nvidia-driver${ver:+-$ver}) fetch -o "${cache}/" "https://pkg.freebsd.org/FreeBSD:${MAJOR}:amd64/${PKGS}/All/${pkgfile}" mkdir -p "${uzip}/usr/local/nvidia/${ver:-440}/" @@ -367,29 +338,28 @@ script() uzip() { + ( cd "${uzip}" ; ln -s . ./sysroot ) # Workaround for low-level tools trying to load things from /sysroot; https://github.com/helloSystem/ISO/issues/4#issuecomment-787062758 install -o root -g wheel -m 755 -d "${cdroot}" - sync ### Needed? - cd ${cwd} && zpool export furybsd && while zpool status furybsd >/dev/null; do :; done 2>/dev/null - sync ### Needed? - mkuzip -S -d -o "${cdroot}/data/system.uzip" "${livecd}/pool.img" -} + makefs "${cdroot}/rootfs.ufs" "${uzip}" + mkdir -p "${cdroot}/boot/" + if [ $MAJOR -lt 13 ] ; then + mkuzip -o "${cdroot}/boot/rootfs.uzip" "${cdroot}/rootfs.ufs" + else + # Use zstd when possible, which is available in FreeBSD beginning with 13 + mkuzip -A zstd -C 15 -o "${cdroot}/boot/rootfs.uzip" "${cdroot}/rootfs.ufs" + fi -ramdisk() -{ - cp -R "${cwd}/overlays/ramdisk/" "${ramdisk_root}" - sync ### Needed? - cd ${cwd} && zpool import furybsd && zfs set mountpoint=/usr/local/furybsd/uzip furybsd - sync ### Needed? - cd "${uzip}" && tar -cf - rescue | tar -xf - -C "${ramdisk_root}" - touch "${ramdisk_root}/etc/fstab" - cp ${uzip}/etc/login.conf ${ramdisk_root}/etc/login.conf - makefs -b '10%' "${cdroot}/data/ramdisk.ufs" "${ramdisk_root}" - gzip -f "${cdroot}/data/ramdisk.ufs" - rm -rf "${ramdisk_root}" + rm -f "${cdroot}/rootfs.ufs" + } boot() { + + # /bin/freebsd-version is used by Ventoy to detect FreeBSD ISOs + mkdir -p "${cdroot}"/bin/ ; cp "${uzip}"/bin/freebsd-version "${cdroot}"/bin/ + # /COPYRIGHT is used by Ventoy to inject code + cp "${uzip}"/COPYRIGHT "${cdroot}"/ cp -R "${cwd}/overlays/boot/" "${cdroot}" cd "${uzip}" && tar -cf - boot | tar -xf - -C "${cdroot}" # Remove all modules from the ISO that is not required before the root filesystem is mounted @@ -400,40 +370,24 @@ boot() -not -name 'cryptodev.ko' \ -not -name 'firewire.ko' \ -not -name 'geom_uzip.ko' \ - -not -name 'opensolaris.ko' \ -not -name 'tmpfs.ko' \ -not -name 'xz.ko' \ - -not -name 'zfs.ko' \ -delete # Compress the kernel - gzip "${cdroot}"/boot/kernel/kernel + gzip -f "${cdroot}"/boot/kernel/kernel || true + rm "${cdroot}"/boot/kernel/kernel || true # Compress the remaining modules - find "${cdroot}"/boot/kernel -type f -name '*.ko' -exec gzip {} \; - sync ### Needed? - cd ${cwd} && zpool export furybsd && mdconfig -d -u 0 - sync ### Needed? - # The name of a dependency for zfs.ko changed, violating POLA - # If we are loading both modules, then at least 13 cannot boot, hence only load one based on the FreeBSD major version - MAJOR=$(uname -r | cut -d "." -f 1) - if [ $MAJOR -lt 13 ] ; then - echo "Major version < 13, hence using opensolaris.ko" - sed -i -e 's|opensolaris_load=".*"|opensolaris_load="YES"|g' "${cdroot}"/boot/loader.conf - rm -f "${cdroot}"/boot/loader.conf-e - sed -i -e 's|cryptodev_load=".*"|cryptodev_load="NO"|g' "${cdroot}"/boot/loader.conf - rm -f "${cdroot}"/boot/loader.conf-e - sed -i -e 's|tmpfs_load=".*"|tmpfs_load="YES"|g' "${cdroot}"/boot/loader.conf - rm -f "${cdroot}"/boot/loader.conf-e - else - echo "Major version >= 13, hence using cryptodev.ko" - sed -i -e 's|cryptodev_load=".*"|cryptodev_load="YES"|g' "${cdroot}"/boot/loader.conf - rm -f "${cdroot}"/boot/loader.conf-e - sed -i -e 's|opensolaris_load=".*"|opensolaris_load="NO"|g' "${cdroot}"/boot/loader.conf - rm -f "${cdroot}"/boot/loader.conf-e - sed -i -e 's|tmpfs_load=".*"|tmpfs_load="NO"|g' "${cdroot}"/boot/loader.conf - rm -f "${cdroot}"/boot/loader.conf-e + find "${cdroot}"/boot/kernel -type f -name '*.ko' -exec gzip -f {} \; + find "${cdroot}"/boot/kernel -type f -name '*.ko' -delete + mkdir -p "${cdroot}"/dev "${cdroot}"/etc # TODO: Create all the others here as well instead of keeping them in overlays/boot + cp "${uzip}"/etc/login.conf "${cdroot}"/etc/ # Workaround for: init: login_getclass: unknown class 'daemon' + cd "${uzip}" && tar -cf - rescue | tar -xf - -C "${cdroot}" # /rescue is full of hardlinks + if [ $MAJOR -gt 12 ] ; then + # Must not try to load tmpfs module in FreeBSD 13 and later, + # because it will prevent the one in the kernel from working + sed -i '' -e 's|^tmpfs_load|# load_tmpfs_load|g' "${cdroot}"/boot/loader.conf + rm "${cdroot}"/boot/kernel/tmpfs.ko* fi - echo 'exec="mode 0"' >> "${cdroot}"/boot/loader.conf # Prevent the FreeBSD 13 bootloader from changing the screen resolution, https://github.com/helloSystem/ISO/issues/198#issuecomment-901919172 - sync ### Needed? } tag() @@ -445,14 +399,15 @@ tag() echo "${URL}" > "${cdroot}/.url" echo "${URL}" > "${uzip}/.url" echo "Setting extended attributes 'url' and 'sha' on '/.url'" - setextattr user sha "${SHA}" "${uzip}/.url" - setextattr user url "${URL}" "${uzip}/.url" - setextattr user build "${BUILDNUMBER}" "${uzip}/.url" + # setextattr user sha "${SHA}" "${uzip}/.url" # Does not work on tmpfs + # setextattr user url "${URL}" "${uzip}/.url" + # setextattr user build "${BUILDNUMBER}" "${uzip}/.url" fi } image() { + # For Ventoy, does it make a difference? TODO: Remove next line sh "${cwd}/scripts/mkisoimages-${arch}.sh" -b "${label}" "${isopath}" "${cdroot}" sync ### Needed? md5 "${isopath}" > "${isopath}.md5" @@ -487,7 +442,6 @@ dm script tag uzip -ramdisk boot image diff --git a/overlays/boot/etc/fstab b/overlays/boot/Applications/.gitkeep similarity index 100% rename from overlays/boot/etc/fstab rename to overlays/boot/Applications/.gitkeep diff --git a/overlays/boot/System/.gitkeep b/overlays/boot/System/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/bin/.gitkeep b/overlays/boot/bin/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/boot/init_script b/overlays/boot/boot/init_script new file mode 100644 index 00000000..14cae96f --- /dev/null +++ b/overlays/boot/boot/init_script @@ -0,0 +1,167 @@ +if [ "`ps -o command 1 | tail -n 1 | ( read c o; echo ${o} )`" = "-s" ]; then + echo "==> Running in single-user mode" + SINGLE_USER="true" + kenv boot_mute="NO" + sh +fi + +# /var/log/console.log will contain a log of this +# Silence messages if boot_mute="YES" is set +if [ "$(kenv boot_mute 2>/dev/null)" = "YES" ] ; then + exec 1>>/dev/null 2>&1 +fi + +set -x + +# kldload /boot/kernel/tmpfs.ko # TODO: must not be gzipped so that this works here? +mount -t tmpfs tmpfs /tmp +chmod 1777 /tmp # TODO: Check if really needed by FreeBSD 13 + +mdconfig -a -t vnode -o readonly -f /boot/rootfs.uzip + +mount -t tmpfs tmpfs /media +chmod 1777 /media # TODO: Check if really needed by FreeBSD 13 + +mkdir -p /media/uzip + +# kldload /boot/kernel/geom_uzip.ko # TODO: must not be gzipped so that this works here? +mount -t ufs -o ro /dev/md0.uzip /media/uzip + +kldload /media/uzip/boot/kernel/nullfs.ko +mount -t nullfs /media/uzip/System /System +mount -t nullfs /media/uzip/Applications /Applications +mount -t nullfs /media/uzip/bin /bin +mount -t nullfs /media/uzip/lib /lib +mount -t nullfs /media/uzip/libexec /libexec +mount -t tmpfs tmpfs /nvidia # Must be writable for initgfx +mount -t nullfs /media/uzip/sbin /sbin +mount -t nullfs /media/uzip/usr /usr +# mount -t nullfs /media/uzip/etc /etc +mount -t nullfs /media/uzip/boot /boot + +kldload /media/uzip/boot/kernel/unionfs.ko + +mount -t tmpfs tmpfs /root # does slim need this? + +mount -t tmpfs tmpfs /var +cp -R /media/uzip/var/ /var +mkdir -p /var/run # Needed for slim? +# mount -t unionfs -o below /media/uzip/var /var # TODO: Check: Crashes later on when slim starts? + +# The following does not instantly crash but since I get a crash later on, +# I suspect this causes it? +# mount -t unionfs -o below /media/uzip/var /var +# mkdir -p /var/run || echo "XXXXXXXXXXXXXXXX FAIL YYYYYYYYYYYYY" + +mount -t tmpfs tmpfs /usr/local +mount -t unionfs -o below /media/uzip/usr/local /usr/local + +# /etc, needed for networking +cp -R /media/uzip/etc /tmp +mount -t tmpfs tmpfs /etc +mount -t nullfs /tmp/etc /etc +# cp -R /tmp/etc /etc +# mv /tmp/etc/* /etc/ +# rm -r /tmp/etc # TODO later + +# FIXME: The following also gives instant reboot. Why? +# mkdir -p /tmp/unionfs/etc +# mount -o noatime -t unionfs /tmp/unionfs/etc /etc + +# Add liveuser, this also creates a writable $HOME from skel +mount -t tmpfs tmpfs /home +mkdir -p /home/liveuser/Desktop +pw useradd liveuser -u 1000 \ +-c "Live User" -d "/home/liveuser" \ +-g wheel -G operator -m -s /usr/local/bin/zsh -k /usr/share/skel -w none +chown -R liveuser /home/liveuser +pw groupmod wheel -m liveuser +pw groupmod video -m liveuser +pw groupmod webcamd -m liveuser +pw groupmod cups -m liveuser + +###################################################################### +# From here on optional, helloSystem specific optimizations +###################################################################### + +# Do not launch Welcome in Live mode +mkdir -p /home/liveuser/.config/hello/ +touch /home/liveuser/.config/hello/.helloSetupDone +chown -R liveuser /home/liveuser/.config + +# TODO: Check whether boot_mute is set and if it is not, then do this? +# Log the WHOLE verbose output of the helloDesktop session to a logfile +# Only use this selectively during development +sed -i '' -e 's|# This script is intended to be invoked by a desktop file|exec 1>>/tmp/start-hello.log 2>\&1\nset -x|g' /usr/local/bin/start-hello + +# Prevent /tmp and /var from being overwritten later in the boot process +# FIXME: Disabling these fails because 'service ... disable' does not find them. Side effect of chrooting? +# Outright deleting them messes up rcorder, +# So we are replacing them with dummy files that do nothing +# but offer the PROVIDEs that other rc scripts are using +cat > /etc/rc.d/tmp << \EOF +#!/bin/sh +# PROVIDE: tmp +# REQUIRE: mountcritremote +EOF +cat > /etc/rc.d/cleartmp << \EOF +#!/bin/sh +# PROVIDE: cleartmp +# REQUIRE: mountcritremote tmp +# BEFORE: DAEMON +EOF +cat > /etc/rc.d/cleanvar << \EOF +# PROVIDE: cleanvar +# REQUIRE: var +EOF +cat > /etc/rc.d/var << \EOF +# PROVIDE: var +# REQUIRE: mountcritlocal +EOF + +# Set hostname other than the default based on SMBIOS information +hostname $(kenv -q "smbios.system.product" | xargs | sed -e 's| |-|g') +# Prevent hostname from being overwritten later in the boot process +cat > /etc/rc.d/hostname << \EOF +# PROVIDE: hostname +# REQUIRE: FILESYSTEMS +# BEFORE: netif +EOF + +# TODO: Consider moving this to the ISO generation stage +# This writes entries to /etc/rc.conf +/usr/sbin/sysrc -f /etc/rc.conf sendmail_enable="NO" >/dev/null 2>/dev/null +/usr/sbin/sysrc -f /etc/rc.conf sendmail_submit_enable="NO" >/dev/null 2>/dev/null +/usr/sbin/sysrc -f /etc/rc.conf sendmail_outbound_enable="NO" >/dev/null 2>/dev/null +/usr/sbin/sysrc -f /etc/rc.conf sendmail_msp_queue_enable="NO" >/dev/null 2>/dev/null +/usr/sbin/sysrc -f /etc/rc.conf linux_enable="YES" >/dev/null 2>/dev/null +/usr/sbin/sysrc -f /etc/rc.conf dbus_enable="YES" >/dev/null 2>/dev/null +/usr/sbin/sysrc -f /etc/rc.conf kld_list+="cuse ig4 iicbus iichid utouch asmc" >/dev/null 2>/dev/null +/usr/sbin/sysrc -f /etc/rc.conf allscreens_kbdflags="-b quiet.off" >/dev/null 2>/dev/null + +# Change rcorder so that the desktop gets loaded as fast as possible +# The intended order is: +# live -> ldconfig -> dbus -> initgfx -> localize -> slim -> everything else + +# Allow ldconfig to run immediately after live +sed -i '' -e 's|# REQUIRE: .*|# REQUIRE: live|g' /etc/rc.d/ldconfig + +# Allow dbus to run immediately after ldconfig +sed -i '' -e 's|# REQUIRE: .*|# REQUIRE: ldconfig|g' /usr/local/etc/rc.d/dbus + +# Allow initgfx to run immediately after dbus +sed -i '' -e 's|# REQUIRE: .*|# REQUIRE: dbus|g' /etc/rc.d/initgfx + +# Allow localize to run immediately after initgfx +sed -i '' -e 's|# REQUIRE: .*|# REQUIRE: initgfx|g' /usr/local/etc/rc.d/localize + +# Allow slim to run immediately after initgfx +sed -i '' -e 's|# REQUIRE: .*|# REQUIRE: initgfx|g' /usr/local/etc/rc.d/slim + +# Force slim to run before var # TODO: See if it can work even earlier than that +sed -i '' -e 's|# REQUIRE: .*|# BEFORE: var|g' /usr/local/etc/rc.d/slim + +# For debugging: After applying the above patches, show resulting rcorder with +# rcorder /etc/rc.d/* /usr/local/etc/rc.d/* + +exit 0 diff --git a/overlays/boot/boot/loader.conf b/overlays/boot/boot/loader.conf index b9ed5655..a5d0ce7f 100644 --- a/overlays/boot/boot/loader.conf +++ b/overlays/boot/boot/loader.conf @@ -1,55 +1,47 @@ -# Load modules needed for compressed uzip +# TODO: Put those (and ONLY those) unzipped on the ISO so that we can load them with kldload +tmpfs_load="YES" # Must not do this on FreeBSD 13 geom_uzip_load="YES" -# Load modules needed for reroot -# Before 13, this is a kernel module. -# We want this file to work with both 12 and 13, so can we get away with trying to load it? -tmpfs_load="YES" +#init_path="/rescue/init" +#init_shell="/rescue/sh" +init_script="/boot/init_script" +#init_chroot="/chroot" -# Load ramdisk image -mfsroot_load="YES" -mfsroot_type="md_image" -mfsroot_name="/data/ramdisk.ufs" -vfs.root.mountfrom="ufs:/dev/md0" - -# Setup init for ramdisk -init_path="/rescue/init" -init_shell="/rescue/sh" -init_script="/init.sh" -init_chroot="/" +# Messages about which partition the kernel can see +kern.geom.label.debug="1" +# Not exactly sure why these were there in the first place +# but the helloSystem ISOs used to be recognized by the kernel +# when booted through Ventoy, so putting them in again. Will it help? kern.geom.label.disk_ident.enable=0 kern.geom.label.gptid.enable=0 kern.geom.label.ufsid.enable=0 -# Wait for all device probe to complete before mounting root, even if the -# root device is already available. This allows to avoid USB probe messages -# printed over the installer menu. This is needed only in installer with -# its UFS, since ZFS root of installed system implies it automatically. -vfs.root_mount_always_wait="1" +# FreeBSD 13: +# The colors are defined in /usr/src/sys/teken/teken.h +# and seem to correspond to standard ANSI colors +# teken.fg_color="7" +# teken.bg_color="4" + +# FreeBSD 13: +# Make font a known size and the same as on FreeBSD 12 +screen.font="8x16" # The following delay during mounting of root file # system is needed because mounting of an IPMI CD-ROM # sometimes slow. vfs.mountroot.timeout="180" -# Disable entropy cache -entropy_cache_load="NO" +# How can the official FreeBSD ISO do without this? +vfs.root.mountfrom="cd9660:/dev/iso9660/LIVE" +geom_ventoy_load="YES" -# Load modules for OpenZFS -# Before 13, zfs.ko has opensolaris.ko as a dependency, from 13 on cryptodev.ko instead. -# We want this file to work with both 12 and 13, so can we get away with trying to load both? -# No. When both are loaded, 13 cannot boot in Live mode. Hence we are changing these values -# in script.hello before things get written to the ISO -opensolaris_load="YES" -cryptodev_load="YES" -zfs_load="YES" +# Disable entropy cache +# entropy_cache_load="NO" # Tune arc for lower memory usage during LiveCD session vm.kmem_size="330M" vm.kmem_size_max="330M" -vfs.zfs.arc_max="40M" -vfs.zfs.vdev.cache.size="5M" # Enable tapping on touchpads # https://www.freebsd.org/cgi/man.cgi?psm(4) @@ -59,11 +51,37 @@ hw.psm.synaptics_support="1" hw.psm.tap_enabled="1" # Boot splash -boot_mute="YES" +# boot_mute="YES" beastie_disable="YES" -autoboot_delay="3" +autoboot_delay="1" + +# Enable equalizer for sound cards +# https://forums.ghostbsd.org/viewtopic.php?t=792 +# https://github.com/nomadbsd/NomadBSD/blob/master/config/boot/loader.conf +hint.pcm.0.eq="1" +hint.pcm.1.eq="1" +hint.pcm.2.eq="1" +hint.pcm.3.eq="1" +hint.pcm.4.eq="1" +hint.pcm.5.eq="1" +hint.pcm.6.eq="1" +hint.pcm.7.eq="1" +hint.pcm.8.eq="1" +hint.pcm.9.eq="1" + +# Do not beep on the command line +hw.syscons.bell=0 + +# Potential fix for poweroff not shuting down the system +# https://redmine.ixsystems.com/issues/6878#note-10 +hw.usb.no_shutdown_wait=1 + # console="spinconsole" # Affects bootloader messages, makes it impossible to hit Esc in the right moment # IEEE1394 High-performance Serial Bus FireWire chipset device driver # Does this allow Macs to be booted via FireWire? firewire_load="YES" + +# Performance tuning. TODO: Measure impact +# Async I/O system calls +aio_load="YES" diff --git a/overlays/boot/boot/loader.conf.local b/overlays/boot/boot/loader.conf.local new file mode 100644 index 00000000..b50b4ebd --- /dev/null +++ b/overlays/boot/boot/loader.conf.local @@ -0,0 +1,23 @@ +# Grey background with grey text +# TODO: Set text to same color as background for complete mute +# Unmute boot messages if user so desires by setting terminal to other color in userland +# https://www.freebsd.org/cgi/man.cgi?vt +kern.vt.color.0.rgb="100,100,100" +kern.vt.color.1.rgb="0,0,0" +kern.vt.color.2.rgb="0,0,0" +kern.vt.color.3.rgb="0,0,0" +kern.vt.color.4.rgb="0,0,0" +kern.vt.color.5.rgb="0,0,0" +kern.vt.color.6.rgb="0,0,0" +kern.vt.color.7.rgb="0,0,0" +kern.vt.color.8.rgb="0,0,0" +kern.vt.color.9.rgb="0,0,0" +kern.vt.color.10.rgb="0,0,0" +kern.vt.color.11.rgb="0,0,0" +kern.vt.color.12.rgb="0,0,0" +kern.vt.color.13.rgb="0,0,0" +kern.vt.color.14.rgb="0,0,0" +kern.vt.color.15.rgb="0,0,0" + +# TODO: Use smallest font +screen.font="8x16" diff --git a/overlays/boot/compat/.gitkeep b/overlays/boot/compat/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/dev/.gitkeep b/overlays/boot/dev/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/etc/.gitkeep b/overlays/boot/etc/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/etc/rc.deleteme b/overlays/boot/etc/rc.deleteme new file mode 100755 index 00000000..73c49c14 --- /dev/null +++ b/overlays/boot/etc/rc.deleteme @@ -0,0 +1,32 @@ +#!/rescue/sh + +# https://wiki.freebsd.org/AndriyGapon/AvgLiveCD + +mdconfig -a -t vnode -f /boot/rootfs.uzip -o readonly -u 0 +mount -r /dev/md0.uzip /chroot + +# mdconfig and mount need to be on the ISO9660, +# everything else we can use from inside the compressed filesystem image +PATH=/chroot/rescue + +# Silence messages if boot_mute="YES" is set +if [ "$(kenv boot_mute 2>/dev/null)" = "YES" ] ; then + exec 1>>/dev/null 2>&1 +else + set -x +fi + +mount -t devfs devfs /chroot/dev +kenv init_shell="/bin/sh" # set in loader.conf + +# After this script has exited, the outside of the chroot +# cannot be accessed anymore. Hence we run our preboot script +# already before we chroot the system +kldload -v /chroot/boot/kernel/tmpfs.ko +kldload -v /chroot/boot/kernel/nullfs.ko +mount_nullfs /boot /chroot/tmp/ +chroot /chroot /bin/sh /tmp/bootscript +umount /chroot/tmp/ +echo "--> chroot into uzip" + +exit 0 diff --git a/overlays/boot/home/.gitkeep b/overlays/boot/home/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/lib/.gitkeep b/overlays/boot/lib/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/libexec/.gitkeep b/overlays/boot/libexec/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/media/.gitkeep b/overlays/boot/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/mnt/.gitkeep b/overlays/boot/mnt/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/net/.gitkeep b/overlays/boot/net/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/nvidia/.gitkeep b/overlays/boot/nvidia/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/opt/.gitkeep b/overlays/boot/opt/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/proc/.gitkeep b/overlays/boot/proc/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/rescue/.gitkeep b/overlays/boot/rescue/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/root/.gitkeep b/overlays/boot/root/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/sbin/.gitkeep b/overlays/boot/sbin/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/sys/.gitkeep b/overlays/boot/sys/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/tmp/.gitkeep b/overlays/boot/tmp/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/usr/.gitkeep b/overlays/boot/usr/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/uzip/.gitkeep b/overlays/boot/uzip/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/boot/var/.gitkeep b/overlays/boot/var/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/overlays/ramdisk/etc/rc b/overlays/ramdisk/etc/rc deleted file mode 100644 index e3a78a92..00000000 --- a/overlays/ramdisk/etc/rc +++ /dev/null @@ -1,43 +0,0 @@ -#!/rescue/sh - -# Silence messages if boot_mute="YES" is set -if [ "$(kenv boot_mute)" = "YES" ] ; then - exec 1>>/dev/null 2>&1 -fi - -if [ "$SINGLE_USER" = "true" ]; then - echo "Starting interactive shell in /etc/rc of the ramdisk..." - exit 0 -fi - -set -x - -if [ "$(kenv use_unionfs)" = "YES" ] ; then - echo "==> Ramdisk /etc/rc running" - echo "==> Unmounting /cdrom and exiting rc" - # umount -f /cdrom - kenv init_chroot # Hopefully the system will continue booting from that location after this script exits with 0 - kenv -u init_path - kenv -u init_script - kenv -u init_shell - exit 0 -else - if [ ! -e /dev/md2 ] ; then - halt -p - fi - echo "==> Ramdisk /etc/rc running" - echo "==> Unset rescue init kernel environment variables" - kenv -u init_chroot - kenv -u init_path - kenv -u init_script - kenv -u init_shell - echo "==> Unmount filesystems for cloning" - umount -f /livecd/dev - zpool export livecd - zpool export furybsd || true - umount -f /cdrom - echo "==> Set /dev/md2 device for reroot" - kenv vfs.root.mountfrom=zfs:livecd - echo "==> Rerooting into memdisk" - reboot -r -fi diff --git a/overlays/ramdisk/init.sh b/overlays/ramdisk/init.sh deleted file mode 100644 index f84ca557..00000000 --- a/overlays/ramdisk/init.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/rescue/sh - -PATH="/rescue" - -if [ "`ps -o command 1 | tail -n 1 | ( read c o; echo ${o} )`" = "-s" ]; then - echo "==> Running in single-user mode" - SINGLE_USER="true" - kenv boot_mute="NO" -fi - -if [ "`ps -o command 1 | tail -n 1 | ( read c o; echo ${o} )`" = "-v" ]; then - echo "==> Running in verbose mode" - kenv boot_mute="NO" -fi - -# Silence messages if boot_mute="YES" is set -if [ "$(kenv boot_mute)" = "YES" ] ; then - exec 1>>/dev/null 2>&1 -fi - -set -x - -echo "==> Ramdisk /init.sh running" - -echo "==> Remount rootfs as read-write" -mount -u -w / - -echo "==> Make mountpoints" -mkdir -p /cdrom /memdisk /sysroot - -echo "Waiting for Live media to appear" -while : ; do - [ -e "/dev/iso9660/LIVE" ] && echo "found /dev/iso9660/LIVE" && break - sleep 1 -done - -echo "==> Mount cdrom" -mount_cd9660 -o ro /dev/iso9660/LIVE /cdrom -mdconfig -o readonly -f /cdrom/data/system.uzip -u 1 -zpool import furybsd -o readonly=on # Without readonly=on zfs refuses to mount this with: "one or more devices is read only" -zpool list # furybsd -mount # /usr/local/furybsd/uzip - -if [ "$SINGLE_USER" = "true" ]; then - echo "Starting interactive shell in temporary rootfs ..." - exit 0 -fi - -# Optionally use unionfs if requested. FIXME: This does not boot yet -if [ "$(kenv use_unionfs)" = "YES" ] ; then - echo "==> Trying unionfs" - - ## Could we snapshot /usr/local/furybsd/uzip here? - ## zfs snapshot furybsd@now - ## results in: - ## cannot create snapshots : pool is read-only - - ## FIXME: The following does NOT seem to work - ## mkdir /tmp - ## mount -t tmpfs tmpfs /tmp - ## It is said that tmpfs and unionfs should be avoided, hence using a swap based md(4) devices; FIXME - #mkdir /md - #mdmfs -s 64m md /md - #kldload /usr/local/furybsd/uzip/boot/kernel/unionfs.ko # Fixes next line: mount_unionfs: /usr/local/furybsd/uzip: Operation not supported by device - #mount -t unionfs /md /usr/local/furybsd/uzip - ## Result: Stalls later on after /etc/rc in the ramdisk exits. Why? FIXME - ## Same result of one applies the unionfs only selectively, e.g., to /usr/local. - ## https://wiki.freebsd.org/AndriyGapon/AvgLiveCD#Further_enhancements - ## https://forums.freebsd.org/threads/combining-tmpfs-and-unionfs-on-root-filesystem.16279/ - - ## TODO: https://github.com/lantw44/freebsd-gnome-livecd/blob/master/init.sh.in - ## shows how to make /cdrom available to the booted system - - mount -t devfs devfs /usr/local/furybsd/uzip/dev - mount -t tmpfs tmpfs /usr/local/furybsd/uzip/tmp - - # Since unionfs does not work, let's use a workaround - mkdir /null - mount -t tmpfs tmpfs /null - cp -r /usr/local/furybsd/uzip/etc /null/etc - cp -r /usr/local/furybsd/uzip/usr/local/etc /null/usr-local-etc - cp -r /usr/local/furybsd/uzip/root /null/root - cp -r /usr/local/furybsd/uzip/usr/local/var /null/usr-local-var - cp -r /usr/local/furybsd/uzip/home /null/home - ### cp -r /usr/local/furybsd/uzip/var /null/var ### With this it did boot but D-Bus complains and start-hello needs to be executed manually - kldload /usr/local/furybsd/uzip/boot/kernel/nullfs.ko # Fixes next line: mount_nullfs: /usr/local/furybsd/uzip: Operation not supported by device - mount -t nullfs /null/etc /usr/local/furybsd/uzip/etc - mount -t nullfs /null/usr-local-etc /usr/local/furybsd/uzip/usr/local/etc - mount -t nullfs /null/root /usr/local/furybsd/uzip/root - mount -t nullfs /null/usr-local-var /usr/local/furybsd/uzip/usr/local/var - mount -t nullfs /null/home /usr/local/furybsd/uzip/home - ### mount -t nullfs /null/var /usr/local/furybsd/uzip/var ### With this it did boot but D-Bus complains and start-hello needs to be executed manually - mount -t tmpfs tmpfs /usr/local/furybsd/uzip/var - - # chroot /usr/local/furybsd/uzip /usr/local/bin/furybsd-init-helper # Should we run it? Only makes sense if we can become r/w until here - - kenv use_unionfs=YES # So that /etc/rc in the ramdisk knows what to do - kenv init_chroot=/usr/local/furybsd/uzip # TODO: Can we possibly reroot instead of chroot? - kenv init_shell="/rescue/sh" - exit 0 # etc/rc in he ramdisk gets executed next -fi - -# Ensure the system has more than enough memory for memdisk - x=3163787264 - y=$(sysctl -n hw.physmem) - echo "Required memory ${x} for memdisk" - echo "Detected memory ${y} for memdisk" - if [ $x -gt $y ] ; then - # Will >/dev/tty make the message show even when boot_mute is used? - # https://github.com/helloSystem/ISO/issues/130#issuecomment-781486502 - echo "Live system requires 4GB of memory for memdisk, and operation!" >/dev/tty - echo "Type exit, and press enter after entering the rescue shell to power off." >/dev/tty - exit 1 - fi - -echo "==> Mount swap-based memdisk" -mdconfig -a -t swap -s 3g -u 2 >/dev/null 2>/dev/null -gpart create -s GPT md2 >/dev/null 2>/dev/null -gpart add -t freebsd-zfs md2 >/dev/null 2>/dev/null -zpool create livecd /dev/md2p1 >/dev/null 2>/dev/null - -# From FreeBSD 13 on, zstd can be used with zfs in base -MAJOR=$(printf '%-.2s' $(sysctl -n kern.osrelease)) # First two characters of kern.osrelease -if [ $MAJOR -lt 13 ] ; then - zfs set compression=gzip-6 livecd -else - zfs set compression=zstd-6 livecd -fi - -zfs set primarycache=none livecd - -echo "==> Replicate system image to swap-based memdisk." -echo " TODO: Remove the need for this." -echo " Can we get unionfs or OpenZFS to make the r/o system image r/w instantly" -echo " without the need for this time consuming operation? Please let us know." -echo " https://github.com/helloSystem/ISO/issues/4" -zfs send -c -e furybsd | dd status=progress bs=1M | zfs recv -F livecd - -mount -t devfs devfs /livecd/dev -chroot /livecd /usr/local/bin/furybsd-init-helper - -kenv init_shell="/rescue/sh" -exit 0 diff --git a/overlays/uzip/furybsd-live-settings/files/usr/local/bin/furybsd-install b/overlays/uzip/furybsd-live-settings/files/usr/local/bin/furybsd-install index f09324bc..db36d59d 100755 --- a/overlays/uzip/furybsd-live-settings/files/usr/local/bin/furybsd-install +++ b/overlays/uzip/furybsd-live-settings/files/usr/local/bin/furybsd-install @@ -8,7 +8,12 @@ set +e # Export our variables -LIVEFS="/" +if [ -e /media/uzip/libexec ] ; then + # We are running on a 0.7.0+ style Live system + LIVEFS="/media/uzip" +else + LIVEFS="/" +fi FSMNT="/mnt" DESTPOOL=$(zpool list -H | grep /mnt | awk -F '\t' '{print $1;}') @@ -18,10 +23,14 @@ DESTPOOL=$(zpool list -H | grep /mnt | awk -F '\t' '{print $1;}') # then immediately exit # if INSTALLER_PRINT_MIB_NEEDED is set. This is needed for the graphical installer frontend if [ -n "${INSTALLER_PRINT_MIB_NEEDED}" ] ; then - # echo INSTALLER_MIB_NEEDED=$(df -m / | awk '{print $2}' | tail -n 1) - bytes=$(zpool get -Hpo value allocated livecd) - mib=$(echo "${bytes}/1024/1024" | bc) # Convert bytes to MiB - echo "INSTALLER_MIB_NEEDED=${mib}" + if [ -e /media/uzip/libexec ] ; then + # We are running on a 0.7.0+ style Live system + echo INSTALLER_MIB_NEEDED=$(df -m /dev/md0.uzip | awk '{print $2}' | tail -n 1) + else + bytes=$(zpool get -Hpo value allocated livecd) + mib=$(echo "${bytes}/1024/1024" | bc) # Convert bytes to MiB + echo "INSTALLER_MIB_NEEDED=${mib}" + fi sudo dmidecode --type 0,1,2,3 > /tmp/dmi.txt exit 0 fi @@ -34,12 +43,15 @@ if [ "$(id -u)" != "0" ]; then exit 1 fi -# Cleanup memory devices created before reroot if they exist -if [ -e "/dev/md0" ] ; then - /sbin/mdconfig -du md0 -fi -if [ -e "/dev/md1" ] ; then - /sbin/mdconfig -du md1 +if [ "${LIVEFS}" == "/" ] ; then + # On Live systems before 0.7.0: + # Cleanup memory devices created before reroot if they exist + if [ -e "/dev/md0" ] ; then + /sbin/mdconfig -du md0 + fi + if [ -e "/dev/md1" ] ; then + /sbin/mdconfig -du md1 + fi fi # Clean up any previous runs @@ -239,9 +251,15 @@ EOF # A leftover initgfx_config.id file can result in the installed system failing to start Xorg sudo rm "${FSMNT}/var/initgfx_config.id" || true +# Fix unbootable FreeBSD 13 +# https://github.com/helloSystem/hello/issues/242#issuecomment-965617810 +if [ -n "${INSTALLER_DEVICE}" ] ; then + mount -t msdosfs /dev/"${INSTALLER_DEVICE}p1" "${FSMNT}"/boot/efi + bsdinstall -D /tmp/bootconfig.log bootconfig + umount "${FSMNT}"/boot/efi +fi + # Cleanup -# umount -f "${FSMNT}/dev" >/dev/null 2>/dev/null || true # Is this needed? TODO: Re-enable if yes -# zpool export -f "${DESTPOOL}" >/dev/null 2>/dev/null || true # Is this needed? TODO: Re-enable if yes echo "Installation finished!" # Reboot diff --git a/overlays/uzip/furybsd-settings/files/etc/fstab b/overlays/uzip/furybsd-settings/files/etc/fstab deleted file mode 100644 index da82f095..00000000 --- a/overlays/uzip/furybsd-settings/files/etc/fstab +++ /dev/null @@ -1 +0,0 @@ -/dev/md2 / ufs rw 0 0 diff --git a/overlays/uzip/hello/files/etc/rc.d/live b/overlays/uzip/hello/files/etc/rc.d/live new file mode 100755 index 00000000..5717d34d --- /dev/null +++ b/overlays/uzip/hello/files/etc/rc.d/live @@ -0,0 +1,25 @@ +#!/bin/sh + +# PROVIDE: live +# REQUIRE: sysctl +# BEFORE: hostid + +. /etc/rc.subr + +name="live" +desc="Prepare read-only filesystem for live boot" +stop_cmd=":" +start_cmd="live_start" + +live_start() +{ + # If we are going to use vfs.root.mountfrom="ufs:/dev/ufs/live" + # without chroot/reroot, then we may want to put code here that + # makes the relevant parts of the filesystem writeable; + # e.g., by invoking the code that currently is in /boot/bootscript + # on the ISO + # See https://github.com/helloSystem/ISO/issues/4#issuecomment-962623208 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/overlays/uzip/hello/files/usr/local/bin/screencast b/overlays/uzip/hello/files/usr/local/bin/screencast index 00b1bd24..147a56d9 100755 --- a/overlays/uzip/hello/files/usr/local/bin/screencast +++ b/overlays/uzip/hello/files/usr/local/bin/screencast @@ -12,7 +12,7 @@ echo $DSP if [ -e /tmp/screencast.mp4 ] ; then pkill -f ffmpeg pkill -f screenkey - notify-send "Stopped because /tmp/screencast.mp4 exists" + notify-send "Playing /tmp/screencast.mp4" sleep 1 xdg-open /tmp/screencast.mp4 else diff --git a/overlays/uzip/hello/files/usr/share/skel/dot.config/featherpad/fp.conf b/overlays/uzip/hello/files/usr/share/skel/dot.config/featherpad/fp.conf index 3c267a3c..b3bd43a6 100644 --- a/overlays/uzip/hello/files/usr/share/skel/dot.config/featherpad/fp.conf +++ b/overlays/uzip/hello/files/usr/share/skel/dot.config/featherpad/fp.conf @@ -1,5 +1,5 @@ [text] -font="Source Code Pro,11,-1,5,50,0,0,0,0,0" +font="Source Code Pro Medium,10,-1,5,50,0,0,0,0,0" [shortcuts] actionClose=Ctrl+W diff --git a/overlays/uzip/initgfx/files/etc/rc.d/initgfx b/overlays/uzip/initgfx/files/etc/rc.d/initgfx index d0e01921..9d576740 100755 --- a/overlays/uzip/initgfx/files/etc/rc.d/initgfx +++ b/overlays/uzip/initgfx/files/etc/rc.d/initgfx @@ -41,7 +41,7 @@ load_rc_config ${name} path_config_id="/var/initgfx_config.id" path_xorg_cfg_dir="/usr/local/etc/X11/xorg.conf.d" -path_xorg_cfg="${path_xorg_cfg_dir}/10-video-${name}.conf" +path_xorg_cfg="${path_xorg_cfg_dir}/00-video-${name}.conf" path_drm_legacy="/boot/drm_legacy" path_nvidia="/usr/local/nvidia" @@ -75,6 +75,24 @@ del_stale_files() rm -f "${path_config_id}" > /dev/null 2>&1 } +restore_symlinks() +{ + local extpath=/usr/local/lib/xorg/modules/extensions + + if [ -L "${extpath}/libglx.so" ]; then + rm -f "${extpath}/libglx.so" + fi + if [ ! -e "${extpath}/libglx.so" ]; then + ln -s "${extpath}/.xorg/libglx.so" ${extpath}/ + fi +} + +__reset() +{ + del_stale_files + restore_symlinks +} + calc_config_id() { sysctl dev.vgapci | sort | md5 @@ -131,37 +149,82 @@ test_x() "${path_cfg_test_dir}" } -get_device_info() -{ - unit=$(sysctl -n hw.pci.default_vgapci_unit) - [ -z "$unit" -o "$unit" = "-1" ] && unit=0 - local info=$(pciconf -lv | grep "^vgapci${unit}" | awk -F'[ \t]+' ' { - for (i = 1; i <= NF; i++) { - if ($i ~ /^vgapci[0-9]/) { - if (split($i, a, ":") < 4) - exit(1); - busID = sprintf("%d:%d:%d", a[2], a[3], a[4]) - } else if ($i ~ /^chip=/) { - device = substr($i, 8, 4); - vendor = substr($i, 12, 4); - } else if ($i ~ /^vendor=/) { - split($i, a, /=0x/); - vendor = a[2]; - } else if ($i ~ /^device=/) { - split($i, a, /=0x/); - device = a[2]; + +get_vgapci_devices() { + __devindex=1 + default_unit=$(sysctl -n hw.pci.default_vgapci_unit) + [ -z "${default_unit}" -o "${default_unit}" = "-1" ] && default_unit=0 + __device_list=$(pciconf -lv | awk -v default_unit=${default_unit} '{ + if (/^vgapci/) { + in_vgapci_entry = 1; + n = split($0, a, "[ \t]+"); + split(a[1], b, "^vgapci|[@:]+"); + unit = b[2]; + bus = sprintf("%d:%d:%d", b[4], b[5], b[6]); + for (i = 2; i <= n; i++) { + if (match(a[i], "^chip=0x")) { + device = substr(a[i], 8, 4); + vendor = substr(a[i], 12, 4); + break; + } else if (match(a[i], "^vendor=0x")) { + vendor = substr(a[i], 10, 4) + } else if (match(a[i], "^device=0x")) { + device = substr(a[i], 10, 4) + } + } + } else if (/^[^ \t]/) { + if (in_vgapci_entry) { + recs[++nrecs] = sprintf("%s\t%s\t%s\t%s\t%s", + unit, bus, vendor, device, descr); } + in_vgapci_entry = 0; + } else if (in_vgapci_entry && /^[ \t]+device[ \t]+=/) { + n = split($0, a, "^[ \t]+device[ \t]+=[ \t]+"); + descr = ""; + if (n >= 2) + descr = a[2]; } } END { - printf("%s %s %s", busID, vendor, device); + if (in_vgapci_entry) { + recs[++nrecs] = sprintf("%s\t%s\t%s\t%s\t%s", + unit, bus, vendor, device, descr); + } + # Make record matching the default unit the first one + rx = sprintf("^%d[\t]+", default_unit); + for (i = 1; i <= nrecs; i++) + if (recs[i] ~ rx) { + print(recs[i]); + break + } + for (i = 1; i <= nrecs; i++) + if (recs[i] !~ rx) + print(recs[i]); }') - set -- $info - device=$3; vendor=$2; busID=$1 - if [ -z "${vendor}" -o -z "${device}" -o -z "${busID}" ]; then - echo "${name}: Error parsing 'pciconf' output" - exit 1 - fi +} + +next_device() +{ + local rec ret IFS + + [ -z "${__device_list}" ] && return 1 + rec=$(printf "${__device_list}" | awk -v idx=${__devindex} '{ + if (++n == idx) { + printf("%s\n", $0); exit(0) + } + } + END { + if (n != idx) + exit(1) + }') + ret=$? + __devindex=$((${__devindex} + 1)) + [ ${ret} -ne 0 ] && return 1 + IFS=" " + set -- ${rec} + unit=$1; busID=$2; vendor=$3; device=$4; descr=$5 + + return 0 } rc_conf_d_ldconfig() @@ -222,16 +285,15 @@ setup_ati_amd() setup_nvidia() { - local d dir driver device srcdir + local d dir driver srcdir device_descr [ "${vendor}" != "10de" ] && return 1 - device=$(pciconf -lv | grep -A3 ^vgapci${unit} | grep device | \ - cut -d"'" -f 2) + device_descr=$(echo "${descr}" | cut -d"'" -f 2) driver="" - for d in 440 390 340 304; do - nvidia_${d}_ids | awk -v device="$device" ' - match(tolower(device), tolower($0)) > 0 { - printf("%s ~ %s\n", device, $0); + for d in latest 390 340 304; do + nvidia_${d}_ids | awk -v descr="${device_descr}" ' + match(tolower(descr), tolower($0)) > 0 { + printf("%s ~ %s\n", descr, $0); exit(100) } ' @@ -279,7 +341,7 @@ setup_nvidia() tar -C "${srcdir}${dir}" \ --exclude '.nvidia' -cf - . | tar -C "/nvidia/${dir}" -xf - - if [ ${driver} -ge 390 ]; then + if [ ${driver} = "latest" ] || [ ${driver} -ge 390 ]; then kmods="${srcdir}/boot/modules/nvidia.ko" kmods="${kmods} ${srcdir}/boot/modules/nvidia-modeset.ko" else @@ -292,6 +354,28 @@ setup_nvidia() return 0 } +setup_nv() +{ + local driver device + + [ "${vendor}" != "10de" ] && return 1 + nv_xorg_cfg > "${path_xorg_cfg}" + return 0 +} + +setup_via() +{ + [ "${vendor}" != "1106" ] && return 1 + via_ids | awk -v device="0x${device}" ' + $1 == device { + exit(100); + } + ' + [ $? -ne 100 ] && return 1 + nv_xorg_cfg > "${path_xorg_cfg}" + return 0 +} + is_vm() { pciconf -lv | grep -B3 display | grep -E -q -i 'virtualbox|VMware' @@ -311,22 +395,53 @@ write_fallback_cfg() (printf "Section \"Device\"\n"; \ printf "\tIdentifier \"Card0\"\n"; \ printf "\tDriver \"${fallback_driver}\"\n"; \ - printf "\tBusID \"PCI:$busID\"\n"; \ +# printf "\tBusID \"PCI:$busID\"\n"; printf "EndSection\n") > "${path_xorg_cfg}" } +probe_and_setup() +{ + local i + + for i in nvidia nv ati_amd intel via; do + if setup_${i}; then + initgfx_debug "Testing Xorg configuration ..." + if test_x; then + # FIXME: Without the delay the result is a + # reboot when using a Nvidia GPU. + [ $i = "nvidia" ] && __wait 3 + save_config_id + cp -a "${path_tmp_rc_conf}" /etc/rc.conf + return 0 + else + __reset + if [ $i = "nvidia" ]; then + initgfx_warn "Failed to use $i driver. Trying nv ...">&2 + else + return 1 + fi + fi + fi + done + + return 1 +} + do_initgfx() { unalias echo + + get_vgapci_devices + get_fallback_driver + if [ "$(kenv -q initgfx.detect.disable)" = "1" ]; then - del_stale_files - get_device_info + __reset if ! is_vm; then - get_fallback_driver write_fallback_cfg fi return fi + if check_configured; then initgfx_debug "Using previous configuration ..." for m in ${initgfx_kmods}; do @@ -335,38 +450,24 @@ do_initgfx() done return fi - initgfx_debug "Creating new configuration ..." - del_stale_files - cp -a /etc/rc.conf "${path_tmp_rc_conf}" - + __reset # In VirtualBox and VMware we are done here if is_vm; then save_config_id return fi - get_fallback_driver + + initgfx_debug "Creating new configuration ..." + cp -a /etc/rc.conf "${path_tmp_rc_conf}" + initgfx_debug "Auto-detecting graphics driver ..." - get_device_info - # Prepare for a crash. - for i in nvidia ati_amd intel; do - if setup_${i}; then - initgfx_debug "Testing Xorg configuration ..." - if test_x; then - # FIXME: Without the delay the result is a - # reboot when using a Nvidia GPU. - __wait 3 - save_config_id - cp -a "${path_tmp_rc_conf}" /etc/rc.conf - return - else - initgfx_warn "Failed to use $i driver. " \ - "Using ${fallback_driver} instead ..." >&2 - del_stale_files - fi - break - fi + while next_device; do + probe_and_setup && return done + + initgfx_warn "No suitable graphics driver found. " \ + "Using ${fallback_driver} instead ..." >&2 write_fallback_cfg cp -a "${path_tmp_rc_conf}" /etc/rc.conf sysrc -x initgfx_kmods diff --git a/overlays/uzip/initgfx/files/etc/rc.d/initgfx_message b/overlays/uzip/initgfx/files/etc/rc.d/initgfx_message index a50f5dd3..4ccc34e8 100755 --- a/overlays/uzip/initgfx/files/etc/rc.d/initgfx_message +++ b/overlays/uzip/initgfx/files/etc/rc.d/initgfx_message @@ -3,8 +3,7 @@ # Copyright (c) 2021, Simon Peter # # PROVIDE: initgfx_message -# REQUIRE: LOGIN -# BEFORE: initgfx +# REQUIRE: initgfx . /etc/rc.subr @@ -29,9 +28,6 @@ initgfx_debug() do_initgfx_message() { -# Wait for one minute after running initfgx -sleep 60 - # Exit if Xorg is running pgrep -f Xorg && exit 0 @@ -54,13 +50,10 @@ de cet appareil ne soit pas encore pris en charge. Veuillez nous le faire savoir. EOF -# echo "" -# echo "FreeBSD kernel version: $(freebsd-version -k)" - -echo "" -sysctl dev.vgapci | grep pnpinfo -echo "" -echo "https://git.io/JXs1V" +echo "" > /dev/console +sysctl dev.vgapci | grep pnpinfo > /dev/console +echo "" > /dev/console +echo "https://git.io/JXs1V" > /dev/console # TODO: Output QR code for https://bsd-hardware.info/?id=pci:1002-67df-1682-c570 # qrencode -m 2 -t utf8 <<< "https://superuser.com/questions/1492624/how-do-you-output-a-qr-code-to-the-linux-cli-terminal-for-scanning/1492625" diff --git a/overlays/uzip/localize/files/usr/local/sbin/localize b/overlays/uzip/localize/files/usr/local/sbin/localize index 987494f3..529fb962 100755 --- a/overlays/uzip/localize/files/usr/local/sbin/localize +++ b/overlays/uzip/localize/files/usr/local/sbin/localize @@ -1,6 +1,4 @@ #!/usr/local/bin/python3 -# Unfortunately #!/usr/bin/env python3.7 does not seem to work for rc.d -# maybe because /usr/local/bin is not in the $PATH at that point yet? # localize # Use different signals to automatically determine country, language, and timezone diff --git a/scripts/install-boot.sh b/scripts/install-boot.sh new file mode 100644 index 00000000..ce6e363a --- /dev/null +++ b/scripts/install-boot.sh @@ -0,0 +1,443 @@ +#!/bin/sh + +# $FreeBSD$ + +# +# Installs/updates the necessary boot blocks for the desired boot environment +# +# Lightly tested.. Intended to be installed, but until it matures, it will just +# be a boot tool for regression testing. + +# insert code here to guess what you have -- yikes! + +# Minimum size of FAT filesystems, in KB. +fat32min=33292 +fat16min=2100 + +die() { + echo $* + exit 1 +} + +doit() { + echo $* + eval $* +} + +find-part() { + dev=$1 + part=$2 + + gpart show $dev | tail +2 | awk '$4 == "'$part'" { print $3; }' +} + +get_uefi_bootname() { + + case ${TARGET:-$(uname -m)} in + amd64) echo bootx64 ;; + arm64) echo bootaa64 ;; + i386) echo bootia32 ;; + arm) echo bootarm ;; + riscv) echo bootriscv64 ;; + *) die "machine type $(uname -m) doesn't support UEFI" ;; + esac +} + +make_esp_file() { + local file sizekb loader device stagedir fatbits efibootname + + file=$1 + sizekb=$2 + loader=$3 + + if [ "$sizekb" -ge "$fat32min" ]; then + fatbits=32 + elif [ "$sizekb" -ge "$fat16min" ]; then + fatbits=16 + else + fatbits=12 + fi + + stagedir=$(mktemp -d /tmp/stand-test.XXXXXX) + mkdir -p "${stagedir}/EFI/BOOT" + efibootname=$(get_uefi_bootname) + cp "${loader}" "${stagedir}/EFI/BOOT/${efibootname}.efi" + makefs -t msdos \ + -o fat_type=${fatbits} \ + -o sectors_per_cluster=1 \ + -o volume_label=EFISYS \ + -s ${sizekb}k \ + "${file}" "${stagedir}" + rm -rf "${stagedir}" +} + +make_esp_device() { + local dev file mntpt fstype efibootname kbfree loadersize efibootfile + local isboot1 existingbootentryloaderfile bootorder bootentry + + # ESP device node + dev=$1 + file=$2 + + mntpt=$(mktemp -d /tmp/stand-test.XXXXXX) + + # See if we're using an existing (formatted) ESP + fstype=$(fstyp "${dev}") + + if [ "${fstype}" != "msdosfs" ]; then + newfs_msdos -F 32 -c 1 -L EFISYS "${dev}" > /dev/null 2>&1 + fi + + mount -t msdosfs "${dev}" "${mntpt}" + if [ $? -ne 0 ]; then + die "Failed to mount ${dev} as an msdosfs filesystem" + fi + + echo "Mounted ESP ${dev} on ${mntpt}" + + efibootname=$(get_uefi_bootname) + kbfree=$(df -k "${mntpt}" | tail -1 | cut -w -f 4) + loadersize=$(stat -f %z "${file}") + loadersize=$((loadersize / 1024)) + + # Check if /EFI/BOOT/BOOTxx.EFI is the FreeBSD boot1.efi + # If it is, remove it to avoid leaving stale files around + efibootfile="${mntpt}/EFI/BOOT/${efibootname}.efi" + if [ -f "${efibootfile}" ]; then + isboot1=$(strings "${efibootfile}" | grep "FreeBSD EFI boot block") + + if [ -n "${isboot1}" ] && [ "$kbfree" -lt "${loadersize}" ]; then + echo "Only ${kbfree}KB space remaining: removing old FreeBSD boot1.efi file /EFI/BOOT/${efibootname}.efi" + rm "${efibootfile}" + rmdir "${mntpt}/EFI/BOOT" + else + echo "${kbfree}KB space remaining on ESP: renaming old boot1.efi file /EFI/BOOT/${efibootname}.efi /EFI/BOOT/${efibootname}-old.efi" + mv "${efibootfile}" "${mntpt}/EFI/BOOT/${efibootname}-old.efi" + fi + fi + + if [ ! -f "${mntpt}/EFI/freebsd/loader.efi" ] && [ "$kbfree" -lt "$loadersize" ]; then + umount "${mntpt}" + rmdir "${mntpt}" + echo "Failed to update the EFI System Partition ${dev}" + echo "Insufficient space remaining for ${file}" + echo "Run e.g \"mount -t msdosfs ${dev} /mnt\" to inspect it for files that can be removed." + die + fi + + mkdir -p "${mntpt}/EFI/freebsd" + + # Keep a copy of the existing loader.efi in case there's a problem with the new one + if [ -f "${mntpt}/EFI/freebsd/loader.efi" ] && [ "$kbfree" -gt "$((loadersize * 2))" ]; then + cp "${mntpt}/EFI/freebsd/loader.efi" "${mntpt}/EFI/freebsd/loader-old.efi" + fi + + echo "Copying loader to /EFI/freebsd on ESP" + cp "${file}" "${mntpt}/EFI/freebsd/loader.efi" + + if [ -n "${updatesystem}" ]; then + existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}//EFI/freebsd/loader.efi") + + if [ -z "$existingbootentryloaderfile" ]; then + # Try again without the double forward-slash in the path + existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}/EFI/freebsd/loader.efi") + fi + + if [ -z "$existingbootentryloaderfile" ]; then + echo "Creating UEFI boot entry for FreeBSD" + efibootmgr --create --label FreeBSD --loader "${mntpt}/EFI/freebsd/loader.efi" > /dev/null + if [ $? -ne 0 ]; then + die "Failed to create new boot entry" + fi + + # When creating new entries, efibootmgr doesn't mark them active, so we need to + # do so. It doesn't make it easy to find which entry it just added, so rely on + # the fact that it places the new entry first in BootOrder. + bootorder=$(efivar --name 8be4df61-93ca-11d2-aa0d-00e098032b8c-BootOrder --print --no-name --hex | head -1) + bootentry=$(echo "${bootorder}" | cut -w -f 3)$(echo "${bootorder}" | cut -w -f 2) + echo "Marking UEFI boot entry ${bootentry} active" + efibootmgr --activate "${bootentry}" > /dev/null + else + echo "Existing UEFI FreeBSD boot entry found: not creating a new one" + fi + else + # Configure for booting from removable media + if [ ! -d "${mntpt}/EFI/BOOT" ]; then + mkdir -p "${mntpt}/EFI/BOOT" + fi + cp "${file}" "${mntpt}/EFI/BOOT/${efibootname}.efi" + fi + + umount "${mntpt}" + rmdir "${mntpt}" + echo "Finished updating ESP" +} + +make_esp() { + local file loaderfile + + file=$1 + loaderfile=$2 + + if [ -f "$file" ]; then + make_esp_file ${file} ${fat32min} ${loaderfile} + else + make_esp_device ${file} ${loaderfile} + fi +} + +make_esp_mbr() { + dev=$1 + dst=$2 + + s=$(find-part $dev "!239") + if [ -z "$s" ] ; then + s=$(find-part $dev "efi") + if [ -z "$s" ] ; then + die "No ESP slice found" + fi + fi + make_esp /dev/${dev}s${s} ${dst}/boot/loader.efi +} + +make_esp_gpt() { + dev=$1 + dst=$2 + + idx=$(find-part $dev "efi") + if [ -z "$idx" ] ; then + die "No ESP partition found" + fi + make_esp /dev/${dev}p${idx} ${dst}/boot/loader.efi +} + +boot_nogeli_gpt_ufs_legacy() { + dev=$1 + dst=$2 + + idx=$(find-part $dev "freebsd-boot") + if [ -z "$idx" ] ; then + die "No freebsd-boot partition found" + fi + doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev +} + +boot_nogeli_gpt_ufs_uefi() { + make_esp_gpt $1 $2 +} + +boot_nogeli_gpt_ufs_both() { + boot_nogeli_gpt_ufs_legacy $1 $2 $3 + boot_nogeli_gpt_ufs_uefi $1 $2 $3 +} + +boot_nogeli_gpt_zfs_legacy() { + dev=$1 + dst=$2 + + idx=$(find-part $dev "freebsd-boot") + if [ -z "$idx" ] ; then + die "No freebsd-boot partition found" + fi + doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev +} + +boot_nogeli_gpt_zfs_uefi() { + make_esp_gpt $1 $2 +} + +boot_nogeli_gpt_zfs_both() { + boot_nogeli_gpt_zfs_legacy $1 $2 $3 + boot_nogeli_gpt_zfs_uefi $1 $2 $3 +} + +boot_nogeli_mbr_ufs_legacy() { + dev=$1 + dst=$2 + + doit gpart bootcode -b ${mbr0} ${dev} + s=$(find-part $dev "freebsd") + if [ -z "$s" ] ; then + die "No freebsd slice found" + fi + doit gpart bootcode -p ${mbr2} ${dev}s${s} +} + +boot_nogeli_mbr_ufs_uefi() { + make_esp_mbr $1 $2 +} + +boot_nogeli_mbr_ufs_both() { + boot_nogeli_mbr_ufs_legacy $1 $2 $3 + boot_nogeli_mbr_ufs_uefi $1 $2 $3 +} + +boot_nogeli_mbr_zfs_legacy() { + dev=$1 + dst=$2 + + # search to find the BSD slice + s=$(find-part $dev "freebsd") + if [ -z "$s" ] ; then + die "No BSD slice found" + fi + idx=$(find-part ${dev}s${s} "freebsd-zfs") + if [ -z "$idx" ] ; then + die "No freebsd-zfs slice found" + fi + # search to find the freebsd-zfs partition within the slice + # Or just assume it is 'a' because it has to be since it fails otherwise + doit gpart bootcode -b ${dst}/boot/mbr ${dev} + dd if=${dst}/boot/zfsboot of=/tmp/zfsboot1 count=1 + doit gpart bootcode -b /tmp/zfsboot1 ${dev}s${s} # Put boot1 into the start of part + sysctl kern.geom.debugflags=0x10 # Put boot2 into ZFS boot slot + doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s}a skip=1 seek=1024 + sysctl kern.geom.debugflags=0x0 +} + +boot_nogeli_mbr_zfs_uefi() { + make_esp_mbr $1 $2 +} + +boot_nogeli_mbr_zfs_both() { + boot_nogeli_mbr_zfs_legacy $1 $2 $3 + boot_nogeli_mbr_zfs_uefi $1 $2 $3 +} + +boot_geli_gpt_ufs_legacy() { + boot_nogeli_gpt_ufs_legacy $1 $2 $3 +} + +boot_geli_gpt_ufs_uefi() { + boot_nogeli_gpt_ufs_uefi $1 $2 $3 +} + +boot_geli_gpt_ufs_both() { + boot_nogeli_gpt_ufs_both $1 $2 $3 +} + +boot_geli_gpt_zfs_legacy() { + boot_nogeli_gpt_zfs_legacy $1 $2 $3 +} + +boot_geli_gpt_zfs_uefi() { + boot_nogeli_gpt_zfs_uefi $1 $2 $3 +} + +boot_geli_gpt_zfs_both() { + boot_nogeli_gpt_zfs_both $1 $2 $3 +} + +# GELI+MBR is not a valid configuration +boot_geli_mbr_ufs_legacy() { + exit 1 +} + +boot_geli_mbr_ufs_uefi() { + exit 1 +} + +boot_geli_mbr_ufs_both() { + exit 1 +} + +boot_geli_mbr_zfs_legacy() { + exit 1 +} + +boot_geli_mbr_zfs_uefi() { + exit 1 +} + +boot_geli_mbr_zfs_both() { + exit 1 +} + +boot_nogeli_vtoc8_ufs_ofw() { + dev=$1 + dst=$2 + + # For non-native builds, ensure that geom_part(4) supports VTOC8. + kldload geom_part_vtoc8.ko + doit gpart bootcode -p ${vtoc8} ${dev} +} + +usage() { + printf 'Usage: %s -b bios [-d destdir] -f fs [-g geli] [-h] [-o optargs] -s scheme \n' "$0" + printf 'Options:\n' + printf ' bootdev device to install the boot code on\n' + printf ' -b bios bios type: legacy, uefi or both\n' + printf ' -d destdir destination filesystem root\n' + printf ' -f fs filesystem type: ufs or zfs\n' + printf ' -g geli yes or no\n' + printf ' -h this help/usage text\n' + printf ' -u Run commands such as efibootmgr to update the\n' + printf ' currently running system\n' + printf ' -o optargs optional arguments\n' + printf ' -s scheme mbr or gpt\n' + exit 0 +} + +srcroot=/ + +# Note: we really don't support geli boot in this script yet. +geli=nogeli + +while getopts "b:d:f:g:ho:s:u" opt; do + case "$opt" in + b) + bios=${OPTARG} + ;; + d) + srcroot=${OPTARG} + ;; + f) + fs=${OPTARG} + ;; + g) + case ${OPTARG} in + [Yy][Ee][Ss]|geli) geli=geli ;; + *) geli=nogeli ;; + esac + ;; + u) + updatesystem=1 + ;; + o) + opts=${OPTARG} + ;; + s) + scheme=${OPTARG} + ;; + + ?|h) + usage + ;; + esac +done + +if [ -n "${scheme}" ] && [ -n "${fs}" ] && [ -n "${bios}" ]; then + shift $((OPTIND-1)) + dev=$1 +fi + +# For gpt, we need to install pmbr as the primary boot loader +# it knows about +gpt0=${srcroot}/boot/pmbr +gpt2=${srcroot}/boot/gptboot +gptzfs2=${srcroot}/boot/gptzfsboot + +# For MBR, we have lots of choices, but select mbr, boot0 has issues with UEFI +mbr0=${srcroot}/boot/mbr +mbr2=${srcroot}/boot/boot + +# VTOC8 +vtoc8=${srcroot}/boot/boot1 + +# sanity check here + +# Check if we've been given arguments. If not, this script is probably being +# sourced, so we shouldn't run anything. +if [ -n "${dev}" ]; then + eval boot_${geli}_${scheme}_${fs}_${bios} $dev $srcroot $opts || echo "Unsupported boot env: ${geli}-${scheme}-${fs}-${bios}" +fi diff --git a/scripts/mkisoimages-amd64.sh b/scripts/mkisoimages-amd64.sh index 2ab8f548..c2c91f90 100644 --- a/scripts/mkisoimages-amd64.sh +++ b/scripts/mkisoimages-amd64.sh @@ -23,6 +23,11 @@ # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. +set -e + +HERE="$(dirname "$(readlink -f "${0}")")" +. ${HERE}/install-boot.sh + if [ -z $ETDUMP ]; then ETDUMP=etdump fi @@ -40,22 +45,12 @@ if [ "$1" = "-b" ]; then # This is highly x86-centric and will be used directly below. bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot" - # Make EFI system partition (should be done with makefs in the future) - dd if=/dev/zero of=efiboot.img bs=1k count=2048 - device=`mdconfig -a -t vnode -f efiboot.img` - newfs_msdos -F 12 -m 0xf8 -L ESP /dev/$device - mkdir efi - mount -t msdosfs /dev/$device efi - mkdir -p efi/efi/boot - if [ "${arch}" = "i386" ] ; then - cp -p "$BASEBITSDIR/boot/loader.efi" efi/efi/boot/bootia32.efi - else - cp -p "$BASEBITSDIR/boot/loader.efi" efi/efi/boot/bootx64.efi - fi - umount efi - rmdir efi - mdconfig -d -u $device - bootable="$bootable -o bootimage=i386;efiboot.img -o no-emul-boot -o platformid=efi" + # Make EFI system partition. + espfilename=$(mktemp /tmp/efiboot.XXXXXX) + # ESP file size in KB. + espsize="2048" + make_esp_file ${espfilename} ${espsize} ${BASEBITSDIR}/boot/loader.efi + bootable="$bootable -o bootimage=i386;${espfilename} -o no-emul-boot -o platformid=efi" shift else @@ -71,11 +66,11 @@ fi LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift NAME="$1"; shift -publisher="FuryBSD" -echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" -$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" $OVERLAY_DIR +publisher="NOT YET VENTOY COMPATIBLE" +### echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" +$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" rm -f "$BASEBITSDIR/etc/fstab" -rm -f efiboot.img +rm -f ${espfilename} if [ "$bootable" != "" ]; then # Look for the EFI System Partition image we dropped in the ISO image. @@ -94,8 +89,8 @@ if [ "$bootable" != "" ]; then $MKIMG -s gpt \ --capacity $imgsize \ -b "$BASEBITSDIR/boot/pmbr" \ - $espparam \ -p freebsd-boot:="$BASEBITSDIR/boot/isoboot" \ + $espparam \ -o hybrid.img # Drop the PMBR, GPT, and boot code into the System Area of the ISO. diff --git a/scripts/mkisoimages-i386.sh b/scripts/mkisoimages-i386.sh index b9eb893e..ab6082fe 100644 --- a/scripts/mkisoimages-i386.sh +++ b/scripts/mkisoimages-i386.sh @@ -42,6 +42,6 @@ LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift NAME="$1"; shift publisher="The FreeBSD Project. https://www.FreeBSD.org/" -echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" +### echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" rm -f "$1/etc/fstab" diff --git a/settings/packages.common-14 b/settings/packages.common-14 new file mode 100644 index 00000000..5b95ce17 --- /dev/null +++ b/settings/packages.common-14 @@ -0,0 +1,66 @@ +pkg +sudo +nano +tmux +xorg-server +xf86-input-evdev +xf86-input-keyboard +xf86-input-libinput +xf86-input-mouse +xf86-input-vmmouse +xf86-video-ati +xf86-video-cirrus +xf86-video-intel +xf86-video-scfb +xf86-video-vesa +xf86-video-vmware +xf86-video-qxl # !i386 +drm-kmod +# drm-legacy-kmod # Does not exist in 13. FIXME: What happens to the devices that need it? +libva-intel-driver +drm-kmod +# nvidia-driver # !i386 # Is now handled in build.sh initgfx() +mesa-libs +mesa-dri +gpu-firmware-kmod +open-vm-tools +virtualbox-ose-additions +xauth +xinit +setxkbmap +xdg-user-dirs +xdg-utils +git-lite +zsh +usbids +wpa_supplicant_gui +webcamd +# webcamoid # Draws in jackit, which draws in db5, which is huge +utouch-kmod +pv +cpdup +# iichid # iichid is not available in 13 because it is in base there; adding it here breaks the 13 build +avahi-app +nss_mdns +openntpd +x11-toolkits/py-qt5-widgets +freedesktop-sound-theme +# Library to access the Xorg/XFree86 Synaptics TouchPad Driver +libsynaptics +# Hardware detecting, device driver loading daemon +dsbdriverd +# Needed by pkg-static to verify certificates? +ca_root_nss +# Needed for SynPS/2 Synaptics TouchPad? +libinput +# Needed to interact with Apple System Management Controller, e.g., for keyboard backlight +asmctl +# Needed for Broadcom WLAN work (e.g., for MacBooks) +b43-fwcutter +# bwn-firmware-kmod # Exists only in ports, not in packages; need a workaround +# daemon that loads suitable drivers for PCI and USB hardware based on a txt db of USB and PCI IDs +dsbdriverd +# Control screen brightness on some Intel-based machines including MacBook Pro +intel-backlight +# Realtek card readers +# rtsx-kmod # No packages available to install matching 'rtsx-kmod' have been found in the repositories diff --git a/settings/rc.conf.common b/settings/rc.conf.common index 8445fe17..42c1f602 100644 --- a/settings/rc.conf.common +++ b/settings/rc.conf.common @@ -1,3 +1,4 @@ +root_rw_mount="NO" hostname="FreeBSD" sendmail_enable="NONE" sendmail_submit_enable="NO"