aboutsummaryrefslogtreecommitdiffstats
path: root/export-noobs/prerun.sh
blob: 9f9a39fa3a52f7045446b08802ff0ef354b11c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash -e

IMG_FILE="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.img"
NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}"
unmount_image ${IMG_FILE}

cp ${WORK_DIR}/export-image/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.img ${STAGE_WORK_DIR}/

rm -rf ${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}

LOOP_DEV=`kpartx -asv ${IMG_FILE} | grep -E -o -m1 'loop[[:digit:]]+' | head -n 1`
BOOT_DEV=/dev/mapper/${LOOP_DEV}p1
ROOT_DEV=/dev/mapper/${LOOP_DEV}p2

mkdir -p ${STAGE_WORK_DIR}/rootfs
mkdir -p ${STAGE_WORK_DIR}/bootfs
mkdir -p ${NOOBS_DIR}

mount $ROOT_DEV ${STAGE_WORK_DIR}/rootfs
mount $BOOT_DEV ${STAGE_WORK_DIR}/bootfs

tar -I pxz -C ${STAGE_WORK_DIR}/bootfs -cpf ${NOOBS_DIR}/boot.tar.xz .
tar -I pxz -C ${STAGE_WORK_DIR}/rootfs -cpf ${NOOBS_DIR}/root.tar.xz .

unmount_image ${IMG_FILE}