Skip to content

Commit

Permalink
grml-live: stop manipulating CWD
Browse files Browse the repository at this point in the history
  • Loading branch information
zeha committed Nov 26, 2024
1 parent 5877318 commit ceba20a
Showing 1 changed file with 38 additions and 43 deletions.
81 changes: 38 additions & 43 deletions grml-live
Original file line number Diff line number Diff line change
Expand Up @@ -1635,51 +1635,46 @@ else
;;
esac

if pushd "$BUILD_OUTPUT" >/dev/null; then
log "Generating build information in conf/buildinfo.json"
einfo "Generating build information in conf/buildinfo.json"
mkdir -p conf/
generate_build_info > conf/buildinfo.json
eend $?

log "$MKISOFS -V '${GRML_NAME} ${VERSION}' -publisher 'grml-live | grml.org' -l -r -J $BOOT_ARGS $EFI_ARGS -no-pad -o ${ISO_OUTPUT}/${ISO_NAME} ."
einfo "Generating ISO file..."
# shellcheck disable=SC2086 # BOOT_ARGS and EFI_ARGS need splitting
$MKISOFS -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
-l -r -J $BOOT_ARGS $EFI_ARGS -no-pad \
-o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
eend $RC

# do not continue on errors, otherwise we might generate/overwrite the ISO with dd if=... stuff
if [ "$RC" != 0 ] ; then
log "Error: critical error while generating ISO [exit code ${RC}]. Exiting."
eerror "Error: critical error while generating ISO [exit code ${RC}]. Exiting." ; eend 1
bailout "$RC"
fi

# pad the output ISO to multiples of 256 KiB for partition table support
siz=$($getfilesize "${ISO_OUTPUT}/${ISO_NAME}")
cyls=$((siz / 512 / 32 / 16 + 1)) # C=$cyls H=16 S=32
siz=$((cyls * 16 * 32 * 512)) # size after padding
dd if=/dev/zero bs=1 count=1 seek=$((siz - 1)) \
of="${ISO_OUTPUT}/${ISO_NAME}" 2>/dev/null

# generate ISO checksums if we are using class 'RELEASE':
case $CLASSES in *RELEASE*)
[ "$RC" = 0 ] && \
(
if cd "$ISO_OUTPUT" ; then
sha256sum "${ISO_NAME}" > "${ISO_NAME}.sha256" && \
touch -r "${ISO_NAME}" "${ISO_NAME}.sha256"
fi
)
;;
esac

# shellcheck disable=SC2164 # If previous CWD disappears, what are we gonna do.
popd >/dev/null
log "Generating build information in conf/buildinfo.json"
einfo "Generating build information in conf/buildinfo.json"
mkdir -p "$BUILD_OUTPUT"/conf/
generate_build_info > "$BUILD_OUTPUT"/conf/buildinfo.json
eend $?

log "$MKISOFS -V '${GRML_NAME} ${VERSION}' -publisher 'grml-live | grml.org' -l -r -J $BOOT_ARGS $EFI_ARGS -no-pad -o ${ISO_OUTPUT}/${ISO_NAME} ."
einfo "Generating ISO file..."
# shellcheck disable=SC2086 # BOOT_ARGS and EFI_ARGS need splitting
$MKISOFS -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
-l -r -J $BOOT_ARGS $EFI_ARGS -no-pad \
-o "${ISO_OUTPUT}/${ISO_NAME}" "$BUILD_OUTPUT"/ ; RC=$?
eend $RC

# do not continue on errors, otherwise we might generate/overwrite the ISO with dd if=... stuff
if [ "$RC" != 0 ] ; then
log "Error: critical error while generating ISO [exit code ${RC}]. Exiting."
eerror "Error: critical error while generating ISO [exit code ${RC}]. Exiting." ; eend 1
bailout "$RC"
fi

# pad the output ISO to multiples of 256 KiB for partition table support
siz=$($getfilesize "${ISO_OUTPUT}/${ISO_NAME}")
cyls=$((siz / 512 / 32 / 16 + 1)) # C=$cyls H=16 S=32
siz=$((cyls * 16 * 32 * 512)) # size after padding
dd if=/dev/zero bs=1 count=1 seek=$((siz - 1)) \
of="${ISO_OUTPUT}/${ISO_NAME}" 2>/dev/null

# generate ISO checksums if we are using class 'RELEASE':
case $CLASSES in *RELEASE*)
[ "$RC" = 0 ] && \
(
if cd "$ISO_OUTPUT" ; then
sha256sum "${ISO_NAME}" > "${ISO_NAME}.sha256" && \
touch -r "${ISO_NAME}" "${ISO_NAME}.sha256"
fi
)
;;
esac

if [ "$RC" = 0 ] ; then
log "Finished execution of stage 'iso build' [$(date)]"
einfo "Finished execution of stage 'iso build'" ; eend 0
Expand Down

0 comments on commit ceba20a

Please sign in to comment.