From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 319F45A027C for ; Fri, 26 Apr 2024 04:01:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1714096870; bh=mc+40BsnUUZGBGSdOZ3nMR1V6hvGetHY4WHqVC2xPvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aUcUlTLzWkldVc/0kDU5zxLR0arDzEYs0lsQ7FhIHBMIuTNmGN0TXTm6xT7MxGQNO fUmlrim53WhBzoEHO3qno+B5/0FTaakE4aG09flaHqXrK7+9k1/iXGcky/e7tjoese 87ztgAXq1wvrRiBktjlvnod062NlECt7LKL96mDFfOtbd/NQ6GsX7UZDpEqMYau6wr aFRG2tHdzXLU52xIUzxUbRilS77P8sC7diVs7wGhSXbkm2YF5AxK/LlEYUs1TIEfr1 i+y5WI3+lXiHx8dMA8zbRQWGJcURR/sq4wxJUdhyQ+N1VoudILWv4HkschKYF1oMRN sKqO/xRIGWVSA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VQbYL6NY4z4x1Y; Fri, 26 Apr 2024 12:01:10 +1000 (AEST) From: David Gibson To: Stefano Brivio Subject: [PATCH v2 4/4] Remove unnecessary cpio_init function Date: Fri, 26 Apr 2024 12:01:08 +1000 Message-ID: <20240426020108.1522375-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240426020108.1522375-1-david@gibson.dropbear.id.au> References: <20240426020108.1522375-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: H7IWXGJMVLIZUGNMPFSKTHXPYJHIL2XH X-Message-ID-Hash: H7IWXGJMVLIZUGNMPFSKTHXPYJHIL2XH X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, lvivier@redhat.com, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The cpio_init function is now only every called with the "discard" option. But, moreover, what it does is create an initial mostly empty archive which will just get overwritten by the final archive. So, it's entirely unnecessary except for one subtlety. Our use of realpath when generating the final output requires that a file already exist in the output location. We can fix that by shuffling some things out of a subshell, removing the need for realpath. This removes functionality to modify an existing initramfs image. However that was already broken in a several ways. Just remove it, and update the help messages to match. Signed-off-by: David Gibson --- mbuto | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/mbuto b/mbuto index eb559fb..247b63d 100755 --- a/mbuto +++ b/mbuto @@ -544,28 +544,6 @@ subopts_get() { ### CPIO ####################################################################### -# cpio_init() - Source existing CPIO archive, or create if needed -# $1: Path to CPIO archive, might exist, might be discarded if existing -cpio_init() { - if [ -f "${OUT}" ] && [ "${1}" != "discard" ]; then - info "Sourcing CPIO archive from ${OUT}" - - if ! "${GZIP}" -dfc "${OUT}" | - "${CPIO}" --quiet -iD "${wd}"; then - err "Invalid CPIO archive ${OUT}" - fi - else - info "Creating new CPIO archive" - - if [ -z "${OUT}" ]; then - OUT="$("${MKTEMP}")" - notice "Creating image: ${OUT}" - else - OUT="$("${REALPATH}" "${OUT}")" - fi - fi -} - # compress_select() - Try compressors and pick the fastest to decompress image # $1: Existing CPIO archive compress_select() { @@ -987,7 +965,6 @@ pkg_add() { # build() - Build a new image, sourcing contents build() { - cpio_init discard kmod_init for __d in ${DIRS}; do @@ -1083,11 +1060,11 @@ cmds() { [ "${NOSTRIP}" != "y" ] && strip_all - ( __out="$("${REALPATH}" "${OUT}")" + ( "${CD}" "${wd}" - "${FIND}" . | "${CPIO}" --create -H newc --quiet > "${OUT}" - cpio_compress "${__out}" - ) + "${FIND}" . | "${CPIO}" --create -H newc --quiet + ) > "${OUT}" + cpio_compress "${OUT}" stats @@ -1139,9 +1116,9 @@ usage() { echo " -v: verbose" echo " -h: show this help" echo - echo "Build initramfs image unless an existing one is passed." - echo "Additional programs, kernel modules, device nodes, generic files" - echo "can be passed as a list of ADD_ON parameters." + echo "Build initramfs image. Additional programs, kernel modules," + echo "device nodes, generic files can be passed as a list of ADD_ON" + echo "parameters." echo echo "Distribution packages (deb and RPM currently supported) can be" echo "added too, but they will simply be extracted, not installed." @@ -1173,8 +1150,6 @@ usage() { echo " Build a base image as a temporary file" echo " ${0} grep" echo " Build a new image including grep and needed libraries" - echo " ${0} -f kata.img zsh_5.6.2-3_amd64.deb" - echo " Install zsh package to pre-existing kata.img" echo " ${0} -v -f kata.img -p kata_debug -c lz4" echo " Use lz4 compression, run a shell before proceeding" exit 1 -- 2.44.0