diff --git a/ostree_prep_rootfs.sh b/ostree_prep_rootfs.sh index 40a2a20..8a97f64 100755 --- a/ostree_prep_rootfs.sh +++ b/ostree_prep_rootfs.sh @@ -3,6 +3,8 @@ # Modified from # https://salsa.debian.org/debian/ostree/-/blob/debian/master/debian/ostree-boot-examples/modified-deb-ostree-builder +OSTREE_OS=debian + cd /tmp IMG_XZ=/tmp/$(basename $1) @@ -28,6 +30,9 @@ mount /dev/mapper/${LOOP_NUM}p1 $BUILDDIR cd ${BUILDDIR} +UNAME_R=$(grep "uname_r=" boot/uEnv.txt) +KERNEL_VERSION=$(echo "${UNAME_R/uname_r=}") + mv bin/* usr/bin rm -r bin ln -s usr/bin bin @@ -59,6 +64,7 @@ mv var/lib/dpkg usr/share/dpkg/database ln -sr usr/share/dpkg/database var/lib/dpkg cat > usr/lib/tmpfiles.d/ostree.conf < ${BUILDDIR}/boot/initrd.img-$KERNEL_VERSION +# This is in here so ostree doesn't complain about the kernel +# when doing "ostree admin deploy" +# TODO - develop a specialized Beaglebone ostree bootloader deployment +cd ${BUILDDIR} +cp boot/vmlinuz-$KERNEL_VERSION usr/lib/modules/$KERNEL_VERSION/vmlinuz +cp boot/initrd.img-$KERNEL_VERSION usr/lib/modules/$KERNEL_VERSION/initramfs.img +CHECKSUM=$(cat boot/vmlinuz-$KERNEL_VERSION boot/initrd.img-$KERNEL_VERSION | sha256sum | head -c 64) + +# TODO - I'm using /ostree/boot here assuming this could be a symbolic link to the correct +# /ostree/boot.1 or /ostree/boot.0. I don't quite understand how this is supposed to be done. +# If this deploy path can be known here at build time, then /boot could simply be a symlink +# to the ostree repository's /boot +DEPLOY=/ostree/boot/${OSTREE_OS}/${CHECKSUM}/0 +REL_DEPLOY=ostree/boot/${OSTREE_OS}/${CHECKSUM}/0 + +#sed -i 's/^uname_r=.*$/uname_r=current/' boot/uEnv.txt +sed -i "/^cmdline=/ s,\$, ostree=$DEPLOY," boot/uEnv.txt + cd /tmp mkdir repo @@ -110,7 +138,6 @@ rm -r ${BUILDDIR}/* #OSTREE_SYSROOT=$(mktemp -d -p /var/tmp ostree-deploy.XXXXXXXXXX) # Make sure ostree_prep_rootfs.sh runs first so /mnt/ostree_rootfs is setup OSTREE_SYSROOT=${BUILDDIR} -OSTREE_OS=debian # TODO add a remote URL #OSTREE_URL=https://www.example.com OSTREE_BRANCH_DEPLOY=pocketnc/bbb/console @@ -132,44 +159,20 @@ uuid=$(uuid) kargs=(--karg=root=UUID=${uuid} --karg=rw --karg=splash --karg=plymouth.ignore-serial-consoles --karg=quiet) ostree admin --sysroot="${OSTREE_SYSROOT}" deploy --os=${OSTREE_OS} "${kargs[@]}" ${OSTREE_OS}:${OSTREE_BRANCH_DEPLOY} -# TODO - * is used below, but is assuming only one folder/file will match because the repo only has a single commit/deployment -# Eventually we won't be able to make that assumption, but taking a shortcut for now. How do we figure out what deployment -# is active? - -cd $BUILDDIR/boot -ln -s loader/uEnv.txt -ln -s loader/vmlinuz-$KERNEL_VERSION -ln -s loader/initrd.img-$KERNEL_VERSION -ln -s loader/dtbs -ln -s loader/System.map-$KERNEL_VERSION -ln -s loader/config-$KERNEL_VERSION -ln -s loader/SOC.sh -ln -s loader/uboot - -cd $BUILDDIR/boot/loader -cp ../../ostree/deploy/debian/deploy/*/boot/uEnv.txt . - -# Add ostree= argument to kernel cmdline arguments -DEPLOY=$(echo ../../ostree/deploy/debian/deploy/*/ | sed 's,/$,,') -ABS_DEPLOY=$(echo $DEPLOY | sed 's,../../,/,') -REL_DEPLOY=$(echo $DEPLOY | sed 's,../../,,') -sed -i "/^cmdline=/ s,\$, ostree=$ABS_DEPLOY," uEnv.txt - -ln -s $DEPLOY/boot/vmlinuz-$KERNEL_VERSION -ln -s $DEPLOY/boot/initrd.img-$KERNEL_VERSION -ln -s $DEPLOY/boot/dtbs -ln -s $DEPLOY/boot/System.map-$KERNEL_VERSION -ln -s $DEPLOY/boot/config-$KERNEL_VERSION -ln -s $DEPLOY/boot/SOC.sh -ln -s $DEPLOY/boot/uboot +cd $BUILDDIR + +# TODO - I believe this should eventually be done by ostree admin deploy +rm -r boot +ln -s ${REL_DEPLOY}/boot +ln -s boot.1 ostree/boot # So U-Boot can find firmware -cd ${BUILDDIR} -ln -s $REL_DEPLOY/lib -ln -s $REL_DEPLOY/usr +ln -s boot/lib cd /tmp +mv /tmp/home/* ${BUILDDIR}/home + #mkdir /tmp/ostree_rootfs #cp -r ${BUILDDIR}/* /tmp/ostree_rootfs