From nobody Tue Jan 9 18:17:52 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T8fL92rFLz567qk; Tue, 9 Jan 2024 18:17:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T8fL92BvTz4Vwt; Tue, 9 Jan 2024 18:17:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704824273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IQy8e/1CHw5ex2aAnNS7VZ4rPSyfcpUBwARRhIioEFE=; b=WiUMJQnne1T0zRvVvLpHl9dyWpy4Urcl8gwoJ0lVWcymwJDLqgBhiqWVR+uxitFcg3+uO0 gkqBuIgZ1EjurKU5qAuHQOAXELLkAa5jOtnHzQvCL9gofDisejxLTTWhjn/tZhVd/KAAtn SY45EHCgpBkEVhTnkhnqAyud/jZmSJNckJiX9bhm3exyoK0ndokqhNRir9xhmfBNs12n5X GGpwFJPGGOVywiSH9Vg99v7lTMVLPf4+bB3Z4YpywXXGDeziKCdD5GKVXDfhZgEfFdgK74 O+iBNMcky0Ccwmagd7dFC8N/kGMal2eBTls1BA01ITPPEm+jBZtmz+9fBOBDIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704824273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IQy8e/1CHw5ex2aAnNS7VZ4rPSyfcpUBwARRhIioEFE=; b=hcaTUVM/jKi7VZKWZFfp3hwbhPl92lq44JLJq3lwfKBBJcHxl25G/hHyloOuwC6/FQSazN cWvCSldfHfkB5DO3JMjyjMQOxL9a6looNTVVjcv09ATlj4tJFVcIJtmShhumK5xBE070Pq aBEOure7mYeXNLjEE8MHJXqvMY3AKPZwUhtsLNFIr+ewxyaHbQks+BYAMAxp40bajAycfH l19c4Rw5GDwnumlCNuqjrtMS6i2p1Xaysc379t4/KcmfFcKR3nRLurwTUykH4fQcb1312N ybox9cvEPX5tTxDcjmCYUzT5n6LVY55OkGz8+TODWcy3Y1sNv9hvj3BaLGNAGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704824273; a=rsa-sha256; cv=none; b=e0n7eA5CrGIo0U6xfJZGU+V0XZ4KbeULCXfDK4EYXSqyS+hi4OV3oLm8B6PWDuubMBkq7g +m8F1dVdoanMyJ79jBp4aN3h3xjm2MmXlsleO7L2HqByMZ8I6F61gamN9eyzElrqhstCuV UwChzHctN8nyNDxPUp8Zkh4WoMioya9rbymE3zOmU990mrLqH/cXGdmcAFHkJAmMDaUx1c 9LNe4P5kW/bOMojVhm4/BJL6/8bZ0hfjGJZJGVs/pavoFKMwzrpVDiY1F+HpuEeWR2aSoX mDwNFQ3qcNaTNjr2ybUAfNivR0G2AmxbNP6lcvNeTxy8XOiZ9OfSVvkKibS2XA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T8fL90g76z11tk; Tue, 9 Jan 2024 18:17:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 409IHqua015123; Tue, 9 Jan 2024 18:17:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 409IHqik015121; Tue, 9 Jan 2024 18:17:52 GMT (envelope-from git) Date: Tue, 9 Jan 2024 18:17:52 GMT Message-Id: <202401091817.409IHqik015121@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Gmelin Subject: git: 731704f5ea2f - main - bsdinstall: Fix installation script splitting List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: grembo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 731704f5ea2f6f9d7e3c4b5ed2ad1a3cba703f42 Auto-Submitted: auto-generated The branch main has been updated by grembo: URL: https://cgit.FreeBSD.org/src/commit/?id=731704f5ea2f6f9d7e3c4b5ed2ad1a3cba703f42 commit 731704f5ea2f6f9d7e3c4b5ed2ad1a3cba703f42 Author: Michael Gmelin AuthorDate: 2024-01-06 16:55:31 +0000 Commit: Michael Gmelin CommitDate: 2024-01-09 18:14:17 +0000 bsdinstall: Fix installation script splitting This allows writing setup scripts that contain lines starting with "#!", e.g., a shebang when creating a shell script using cat: #!/bin/sh echo "Populate rc.local" cat >/etc/rc.local<pathb; else print}' \ + "$SCRIPT" $TMPDIR/bsdinstall-installscript-setup \ + >$TMPDIR/bsdinstall-installscript-preamble + + . $TMPDIR/bsdinstall-installscript-preamble fi test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR @@ -146,8 +151,9 @@ cp /etc/localtime $1/etc cp /var/db/zoneinfo $1/var/db # Run post-install script -if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then - cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript +if [ -f $TMPDIR/bsdinstall-installscript-setup ]; then + cp $TMPDIR/bsdinstall-installscript-setup \ + $BSDINSTALL_CHROOT/tmp/installscript chmod a+x $BSDINSTALL_CHROOT/tmp/installscript mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1 diff --git a/usr.sbin/bsdinstall/scripts/script b/usr.sbin/bsdinstall/scripts/script index ae1c6b3011fa..00ded5f8e24d 100755 --- a/usr.sbin/bsdinstall/scripts/script +++ b/usr.sbin/bsdinstall/scripts/script @@ -88,10 +88,15 @@ shift f_dprintf "Began Installation at %s" "$( date )" rm -rf $BSDINSTALL_TMPETC mkdir $BSDINSTALL_TMPETC +rm -f $TMPDIR/bsdinstall-installscript-setup -split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript- +# split script into preamble and setup script at first shebang +awk 'BEGIN {pathb=ARGV[2]; ARGV[2]=""} /^#!/{b=1} { + if (b) print >pathb; else print}' \ + "$SCRIPT" $TMPDIR/bsdinstall-installscript-setup \ + >$TMPDIR/bsdinstall-installscript-preamble -. $TMPDIR/bsdinstall-installscript-aa +. $TMPDIR/bsdinstall-installscript-preamble : ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS export BSDINSTALL_DISTDIR @@ -158,8 +163,9 @@ if [ ! -f $BSDINSTALL_CHROOT/etc/resolv.conf -a -f /etc/resolv.conf ]; then fi # Run post-install script -if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then - cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript +if [ -f $TMPDIR/bsdinstall-installscript-setup ]; then + cp $TMPDIR/bsdinstall-installscript-setup \ + $BSDINSTALL_CHROOT/tmp/installscript chmod a+x $BSDINSTALL_CHROOT/tmp/installscript chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1 rm $BSDINSTALL_CHROOT/tmp/installscript