Fix rootfs issue

This commit is contained in:
2025-04-29 00:01:36 -07:00
parent fcab0c9c55
commit cac89696cc
2 changed files with 139 additions and 213 deletions

246
build.sh
View File

@@ -1,206 +1,135 @@
#!/bin/bash -e #!/bin/bash -e
# shellcheck disable=SC2119 # shellcheck disable=SC2119
run_sub_stage() run_sub_stage() {
{
log "Begin ${SUB_STAGE_DIR}" log "Begin ${SUB_STAGE_DIR}"
pushd "${SUB_STAGE_DIR}" >/dev/null pushd "${SUB_STAGE_DIR}" >/dev/null
for i in {00..99}; do for i in {00..99}; do
if [ -f "${i}-debconf-${ARCH}" ]; then for DEBCONF_FILE in "${i}-debconf-${ARCH}" "${i}-debconf-arm-only" "${i}-debconf"; do
log "Begin ${SUB_STAGE_DIR}/${i}-debconf-${ARCH}" if [ -f "${SUB_STAGE_DIR}/${DEBCONF_FILE}" ]; then
on_chroot << EOF # Skip arm-only if not arm
debconf-set-selections <<SELEOF if [[ "${DEBCONF_FILE}" == *"-debconf-arm-only" ]] && [[ "${ARCH}" != "armhf" && "${ARCH}" != "arm64" ]]; then
$(cat "${i}-debconf-${ARCH}") continue
SELEOF
EOF
log "End ${SUB_STAGE_DIR}/${i}-debconf-${ARCH}"
elif [ -f "${i}-debconf-arm-only" ] && [[ "${ARCH}" == "arm64" || "${ARCH}" == "armhf" ]]; then
log "Begin ${SUB_STAGE_DIR}/${i}-debconf-arm-only"
on_chroot << EOF
debconf-set-selections <<SELEOF
$(cat "${i}-debconf-arm-only")
SELEOF
EOF
log "End ${SUB_STAGE_DIR}/${i}-debconf-arm-only"
elif [ -f "${i}-debconf" ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-debconf"
on_chroot << EOF
debconf-set-selections <<SELEOF
$(cat "${i}-debconf")
SELEOF
EOF
log "End ${SUB_STAGE_DIR}/${i}-debconf"
fi fi
if [ -f "${i}-packages-nr-${ARCH}" ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-packages-nr-${ARCH}" log "Begin ${SUB_STAGE_DIR}/${DEBCONF_FILE}"
PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${i}-packages-nr-${ARCH}")"
on_chroot <<EOF
debconf-set-selections <<SELEOF
$(cat "${SUB_STAGE_DIR}/${DEBCONF_FILE}")
SELEOF
EOF
log "End ${SUB_STAGE_DIR}/${DEBCONF_FILE}"
fi
done
for PACKAGE_LIST in "${i}-packages-nr-${ARCH}" "${i}-packages-nr-arm-only" "${i}-packages-nr"; do
if [ -f "${SUB_STAGE_DIR}/${PACKAGE_LIST}" ]; then
# Skip arm-only packages if not arm architecture
if [[ "${PACKAGE_LIST}" == *"-nr-arm-only" ]] && [[ "${ARCH}" != "armhf" && "${ARCH}" != "arm64" ]]; then
continue
fi
log "Begin ${SUB_STAGE_DIR}/${PACKAGE_LIST}"
PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" <"${SUB_STAGE_DIR}/${PACKAGE_LIST}")"
if [ -n "$PACKAGES" ]; then if [ -n "$PACKAGES" ]; then
on_chroot <<EOF on_chroot <<EOF
apt-get -o Acquire::Retries=3 install --no-install-recommends -y $PACKAGES apt-get -o Acquire::Retries=3 install --no-install-recommends -y $PACKAGES
EOF EOF
fi fi
log "End ${SUB_STAGE_DIR}/${i}-packages-nr-${ARCH}"
elif [ -f "${i}-packages-nr-arm-only" ] && [[ "${ARCH}" == "arm64" || "${ARCH}" == "armhf" ]]; then log "End ${SUB_STAGE_DIR}/${PACKAGE_LIST}"
log "Begin ${SUB_STAGE_DIR}/${i}-packages-nr-arm-only"
PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${i}-packages-nr-arm-only")"
if [ -n "$PACKAGES" ]; then
on_chroot << EOF
apt-get -o Acquire::Retries=3 install --no-install-recommends -y $PACKAGES
EOF
fi fi
log "End ${SUB_STAGE_DIR}/${i}-packages-nr-arm-only" done
elif [ -f "${i}-packages-nr" ]; then for PACKAGE_LIST in "${i}-packages-${ARCH}" "${i}-packages-arm-only" "${i}-packages"; do
log "Begin ${SUB_STAGE_DIR}/${i}-packages-nr" if [ -f "${SUB_STAGE_DIR}/${PACKAGE_LIST}" ]; then
PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${i}-packages-nr")" # Skip arm-only packages if not arm architecture
if [ -n "$PACKAGES" ]; then if [[ "${PACKAGE_LIST}" == *"-packages-arm-only" ]] && [[ "${ARCH}" != "armhf" && "${ARCH}" != "arm64" ]]; then
on_chroot << EOF continue
apt-get -o Acquire::Retries=3 install --no-install-recommends -y $PACKAGES
EOF
fi fi
log "End ${SUB_STAGE_DIR}/${i}-packages-nr"
fi log "Begin ${SUB_STAGE_DIR}/${PACKAGE_LIST}"
if [ -f "${i}-packages-${ARCH}" ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-packages-${ARCH}" PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" <"${SUB_STAGE_DIR}/${PACKAGE_LIST}")"
PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${i}-packages-${ARCH}")"
if [ -n "$PACKAGES" ]; then if [ -n "$PACKAGES" ]; then
on_chroot <<EOF on_chroot <<EOF
apt-get -o Acquire::Retries=3 install -y $PACKAGES apt-get -o Acquire::Retries=3 install -y $PACKAGES
EOF EOF
fi fi
log "End ${SUB_STAGE_DIR}/${i}-packages-${ARCH}"
elif [ -f "${i}-packages-arm-only" ] && [[ "${ARCH}" == "arm64" || "${ARCH}" == "armhf" ]]; then log "End ${SUB_STAGE_DIR}/${PACKAGE_LIST}"
log "Begin ${SUB_STAGE_DIR}/${i}-packages-arm-only"
PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${i}-packages-arm-only")"
if [ -n "$PACKAGES" ]; then
on_chroot << EOF
apt-get -o Acquire::Retries=3 install -y $PACKAGES
EOF
fi fi
log "End ${SUB_STAGE_DIR}/${i}-packages-arm-only" done
elif [ -f "${i}-packages" ]; then for PATCH_DIR in "${i}-patches-${ARCH}" "${i}-patches-arm-only" "${i}-patches"; do
log "Begin ${SUB_STAGE_DIR}/${i}-packages" if [ -d "${SUB_STAGE_DIR}/${PATCH_DIR}" ]; then
PACKAGES="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${i}-packages")" # Check arm-only patches should only apply for armhf/arm64
if [ -n "$PACKAGES" ]; then if [[ "${PATCH_DIR}" == *"-patches-arm-only" ]] && [[ "${ARCH}" != "armhf" && "${ARCH}" != "arm64" ]]; then
on_chroot << EOF continue
apt-get -o Acquire::Retries=3 install -y $PACKAGES
EOF
fi fi
log "End ${SUB_STAGE_DIR}/${i}-packages"
fi log "Begin ${SUB_STAGE_DIR}/${PATCH_DIR}"
if [ -d "${i}-patches-${ARCH}" ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-patches-${ARCH}"
pushd "${STAGE_WORK_DIR}" >/dev/null pushd "${STAGE_WORK_DIR}" >/dev/null
if [ "${CLEAN}" = "1" ]; then if [ "${CLEAN}" = "1" ]; then
rm -rf .pc rm -rf .pc
rm -rf ./*-pc rm -rf ./*-pc
fi fi
QUILT_PATCHES="${SUB_STAGE_DIR}/${i}-patches-${ARCH}"
QUILT_PATCHES="${SUB_STAGE_DIR}/${PATCH_DIR}"
SUB_STAGE_QUILT_PATCH_DIR="$(basename "$SUB_STAGE_DIR")-pc" SUB_STAGE_QUILT_PATCH_DIR="$(basename "$SUB_STAGE_DIR")-pc"
mkdir -p "$SUB_STAGE_QUILT_PATCH_DIR" mkdir -p "$SUB_STAGE_QUILT_PATCH_DIR"
ln -snf "$SUB_STAGE_QUILT_PATCH_DIR" .pc ln -snf "$SUB_STAGE_QUILT_PATCH_DIR" .pc
quilt upgrade quilt upgrade
if [ -e "${SUB_STAGE_DIR}/${i}-patches-${ARCH}/EDIT" ]; then
if [ -e "${SUB_STAGE_DIR}/${PATCH_DIR}/EDIT" ]; then
echo "Dropping into bash to edit patches..." echo "Dropping into bash to edit patches..."
bash bash
fi fi
RC=0 RC=0
quilt push -a || RC=$? quilt push -a || RC=$?
case "$RC" in case "$RC" in
0|2) 0 | 2) ;; # 0 = success, 2 = "already applied"
;; *) false ;;
*)
false
;;
esac esac
popd >/dev/null popd >/dev/null
log "End ${SUB_STAGE_DIR}/${i}-patches-${ARCH}" log "End ${SUB_STAGE_DIR}/${PATCH_DIR}"
elif [ -d "${i}-patches-arm-only" ] && [[ "${ARCH}" == "arm64" || "${ARCH}" == "armhf" ]]; then
log "Begin ${SUB_STAGE_DIR}/${i}-patches-arm-only"
pushd "${STAGE_WORK_DIR}" > /dev/null
if [ "${CLEAN}" = "1" ]; then
rm -rf .pc
rm -rf ./*-pc
fi fi
QUILT_PATCHES="${SUB_STAGE_DIR}/${i}-patches-arm-only" done
SUB_STAGE_QUILT_PATCH_DIR="$(basename "$SUB_STAGE_DIR")-pc" for RUN_SCRIPT in "${i}-run-${ARCH}.sh" "${i}-run-arm-only.sh" "${i}-run.sh"; do
mkdir -p "$SUB_STAGE_QUILT_PATCH_DIR" if [ -x "${SUB_STAGE_DIR}/${RUN_SCRIPT}" ]; then
ln -snf "$SUB_STAGE_QUILT_PATCH_DIR" .pc # Skip arm-only if not arm
quilt upgrade if [[ "${RUN_SCRIPT}" == *"-arm-only.sh" ]] && [[ "${ARCH}" != "armhf" && "${ARCH}" != "arm64" ]]; then
if [ -e "${SUB_STAGE_DIR}/${i}-patches-arm-only/EDIT" ]; then continue
echo "Dropping into bash to edit patches..."
bash
fi fi
RC=0
quilt push -a || RC=$? log "Begin ${SUB_STAGE_DIR}/${RUN_SCRIPT}"
case "$RC" in "./${RUN_SCRIPT}"
0|2) log "End ${SUB_STAGE_DIR}/${RUN_SCRIPT}"
;;
*)
false
;;
esac
popd > /dev/null
log "End ${SUB_STAGE_DIR}/${i}-patches-arm-only"
elif [ -d "${i}-patches" ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-patches"
pushd "${STAGE_WORK_DIR}" > /dev/null
if [ "${CLEAN}" = "1" ]; then
rm -rf .pc
rm -rf ./*-pc
fi fi
QUILT_PATCHES="${SUB_STAGE_DIR}/${i}-patches" done
SUB_STAGE_QUILT_PATCH_DIR="$(basename "$SUB_STAGE_DIR")-pc" for CHROOT_SCRIPT in "${i}-run-chroot-${ARCH}.sh" "${i}-run-chroot-arm-only.sh" "${i}-run-chroot.sh"; do
mkdir -p "$SUB_STAGE_QUILT_PATCH_DIR" if [ -f "${SUB_STAGE_DIR}/${CHROOT_SCRIPT}" ]; then
ln -snf "$SUB_STAGE_QUILT_PATCH_DIR" .pc # Skip arm-only if not arm
quilt upgrade if [[ "${CHROOT_SCRIPT}" == *"-arm-only.sh" ]] && [[ "${ARCH}" != "armhf" && "${ARCH}" != "arm64" ]]; then
if [ -e "${SUB_STAGE_DIR}/${i}-patches/EDIT" ]; then continue
echo "Dropping into bash to edit patches..."
bash
fi fi
RC=0
quilt push -a || RC=$? log "Begin ${SUB_STAGE_DIR}/${CHROOT_SCRIPT}"
case "$RC" in on_chroot <"${SUB_STAGE_DIR}/${CHROOT_SCRIPT}"
0|2) log "End ${SUB_STAGE_DIR}/${CHROOT_SCRIPT}"
;;
*)
false
;;
esac
popd > /dev/null
log "End ${SUB_STAGE_DIR}/${i}-patches"
fi
if [ -x ${i}-run-${ARCH}.sh ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-run-${ARCH}.sh"
./${i}-run-${ARCH}.sh
log "End ${SUB_STAGE_DIR}/${i}-run-${ARCH}.sh"
elif [ -x "${i}-run-arm-only.sh" ] && [[ "${ARCH}" == "arm64" || "${ARCH}" == "armhf" ]]; then
log "Begin ${SUB_STAGE_DIR}/${i}-run-arm-only.sh"
./${i}-run-arm-only.sh
log "End ${SUB_STAGE_DIR}/${i}-run-arm-only.sh"
elif [ -x ${i}-run.sh ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-run.sh"
./${i}-run.sh
log "End ${SUB_STAGE_DIR}/${i}-run.sh"
fi
if [ -f ${i}-run-chroot-${ARCH}.sh ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot-${ARCH}.sh"
on_chroot < ${i}-run-chroot-${ARCH}.sh
log "End ${SUB_STAGE_DIR}/${i}-run-chroot-${ARCH}.sh"
elif [ -f "${i}-run-chroot-arm-only.sh" ] && [[ "${ARCH}" == "arm64" || "${ARCH}" == "armhf" ]]; then
log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot-arm-only.sh"
on_chroot < ${i}-run-chroot-arm-only.sh
log "End ${SUB_STAGE_DIR}/${i}-run-chroot-arm-only.sh"
elif [ -f ${i}-run-chroot.sh ]; then
log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot.sh"
on_chroot < ${i}-run-chroot.sh
log "End ${SUB_STAGE_DIR}/${i}-run-chroot.sh"
fi fi
done done
done
popd >/dev/null popd >/dev/null
log "End ${SUB_STAGE_DIR}" log "End ${SUB_STAGE_DIR}"
} }
run_stage() { run_stage() {
log "Begin ${STAGE_DIR}" log "Begin ${STAGE_DIR}"
STAGE="$(basename "${STAGE_DIR}")" STAGE="$(basename "${STAGE_DIR}")"
@@ -281,16 +210,14 @@ if [ -f config ]; then
source config source config
fi fi
while getopts "c:" flag while getopts "c:" flag; do
do
case "$flag" in case "$flag" in
c) c)
EXTRA_CONFIG="$OPTARG" EXTRA_CONFIG="$OPTARG"
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "$EXTRA_CONFIG" source "$EXTRA_CONFIG"
;; ;;
*) *) ;;
;;
esac esac
done done
@@ -368,7 +295,6 @@ trap term EXIT INT TERM
dependencies_check "${BASE_DIR}/depends" dependencies_check "${BASE_DIR}/depends"
PAGESIZE=$(getconf PAGESIZE) PAGESIZE=$(getconf PAGESIZE)
if [ "$ARCH" == "armhf" ] && [ "$PAGESIZE" != "4096" ]; then if [ "$ARCH" == "armhf" ] && [ "$PAGESIZE" != "4096" ]; then
echo echo

View File

@@ -70,14 +70,14 @@ else
fi fi
mkdosfs -n bootfs -F "$FAT_SIZE" -s 4 -v "$BOOT_DEV" > /dev/null mkdosfs -n bootfs -F "$FAT_SIZE" -s 4 -v "$BOOT_DEV" > /dev/null
mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null
mkfs.ext4 -L recovery -O "$ROOT_FEATURES" "$RECOVERY_DEV" > /dev/null mkfs.ext4 -L recovery -O "$ROOT_FEATURES" "$RECOVERY_DEV" > /dev/null
mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null
mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4 mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4
mkdir -p "${ROOTFS_DIR}/boot/firmware" mkdir -p "${ROOTFS_DIR}/boot/firmware"
mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot/firmware" -t vfat mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot/firmware" -t vfat
mkdir -p "${ROOTFS_DIR}/recovery" #mkdir -p "${ROOTFS_DIR}/recovery"
mount -v "$RECOVERY_DEV" "${ROOTFS_DIR}/recovery" -t ext4 #mount -v "$RECOVERY_DEV" "${ROOTFS_DIR}/recovery" -t ext4
rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot/firmware "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/" rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot/firmware "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/"
rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/firmware/" "${ROOTFS_DIR}/boot/firmware/" rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/firmware/" "${ROOTFS_DIR}/boot/firmware/"