1
0
Fork 0

Fix code style

This commit is contained in:
Braiden Vasco 2017-07-02 18:24:32 +00:00
parent 11f349fc52
commit 8a37703ab4

View file

@ -1,19 +1,19 @@
#!/bin/bash -e #!/bin/bash -e
unmount_image ${IMG_FILE} unmount_image "$IMG_FILE"
rm -f ${IMG_FILE} rm -f "$IMG_FILE"
rm -rf ${ROOTFS_DIR} rm -rf "$ROOTFS_DIR"
mkdir -p ${ROOTFS_DIR} mkdir -p "$ROOTFS_DIR"
BOOT_SIZE=$(du --apparent-size -s ${ROOTFS_DIR}/boot --block-size=1 | cut -f 1) BOOT_SIZE=$(du --apparent-size -s "$ROOTFS_DIR/boot" --block-size=1 | cut -f 1)
TOTAL_SIZE=$(du --apparent-size -s ${ROOTFS_DIR} --exclude var/cache/apt/archives --block-size=1 | cut -f 1) TOTAL_SIZE=$(du --apparent-size -s "$ROOTFS_DIR" --exclude var/cache/apt/archives --block-size=1 | cut -f 1)
IMG_SIZE=$((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024))) IMG_SIZE=$((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024)))
truncate -s ${IMG_SIZE} ${IMG_FILE} truncate -s $IMG_SIZE "$IMG_FILE"
fdisk -H 255 -S 63 ${IMG_FILE} <<EOF fdisk -H 255 -S 63 "$IMG_FILE" <<EOF
o o
n n
@ -33,7 +33,7 @@ p
w w
EOF EOF
PARTED_OUT=$(parted -s ${IMG_FILE} unit b print) PARTED_OUT=$(parted -s "$IMG_FILE" unit b print)
BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \ BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
| cut -d" " -f 2 | tr -d B) | cut -d" " -f 2 | tr -d B)
BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \ BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
@ -44,14 +44,14 @@ ROOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \ ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
| cut -d" " -f 4 | tr -d B) | cut -d" " -f 4 | tr -d B)
BOOT_DEV=$(losetup --show -f -o ${BOOT_OFFSET} --sizelimit ${BOOT_LENGTH} ${IMG_FILE}) BOOT_DEV=$(losetup --show -f -o $BOOT_OFFSET --sizelimit $BOOT_LENGTH "$IMG_FILE")
ROOT_DEV=$(losetup --show -f -o ${ROOT_OFFSET} --sizelimit ${ROOT_LENGTH} ${IMG_FILE}) ROOT_DEV=$(losetup --show -f -o $ROOT_OFFSET --sizelimit $ROOT_LENGTH "$IMG_FILE")
echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH" echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH"
echo "/: offset $ROOT_OFFSET, length $ROOT_LENGTH" echo "/: offset $ROOT_OFFSET, length $ROOT_LENGTH"
mkdosfs -n boot -F 32 -v $BOOT_DEV > /dev/null mkdosfs -n boot -F 32 -v $BOOT_DEV > /dev/null
mkfs.ext4 -O ^huge_file $ROOT_DEV > /dev/null mkfs.ext4 -O ^huge_file $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 mkdir -p "$ROOTFS_DIR/boot"
mount -v $BOOT_DEV ${ROOTFS_DIR}/boot -t vfat mount -v $BOOT_DEV "$ROOTFS_DIR/boot" -t vfat