mkimage: get rid of parted; use sfdisk(8).

This commit is contained in:
Juan RP 2016-04-26 15:00:55 +02:00
parent be2251492f
commit 6372530837
2 changed files with 13 additions and 12 deletions

View File

@ -11,7 +11,6 @@ This repository contains utilities for Void Linux:
#### Dependencies
* xbps>=0.45
* parted (for mkimage)
* qemu-user-static binaries (for mkrootfs)
#### Usage

View File

@ -1,6 +1,6 @@
#!/bin/sh
#-
# Copyright (c) 2013-2015 Juan Romero Pardines.
# Copyright (c) 2013-2016 Juan Romero Pardines.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -56,11 +56,11 @@ Usage: $PROGNAME [options] <rootfs-tarball>
The <rootfs-tarball> argument expects a tarball generated by void-mkrootfs.
The platform is guessed automatically by its name.
Accepted sizes suffixes: K, M, G, T, E.
Accepted sizes suffixes: KiB, MiB, GiB, TiB, EiB.
OPTIONS
-b <fstype> Set /boot filesystem type (defaults to FAT)
-B <bsize> Set /boot filesystem size (defaults to 64MB)
-B <bsize> Set /boot filesystem size (defaults to 64MiB)
-r <fstype> Set / filesystem type (defaults to EXT4)
-s <totalsize> Set total image size (defaults to 2GB)
-o <output> Set image filename (guessed automatically)
@ -104,7 +104,7 @@ fi
: ${IMGSIZE:=2G}
: ${BOOT_FSTYPE:=vfat}
: ${BOOT_FSSIZE:=64M}
: ${BOOT_FSSIZE:=64MiB}
: ${ROOT_FSTYPE:=ext4}
if [ -z "$FILENAME" ]; then
@ -117,7 +117,7 @@ case "$PLATFORM" in
*) die "The $PLATFORM is not supported, exiting..."
esac
for f in parted partx losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do
for f in sfdisk partx losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do
if ! which ${f} >/dev/null; then
die "Cannot find ${f}, exiting."
fi
@ -143,17 +143,19 @@ if [ "$BOOT_FSTYPE" = "vfat" ]; then
fi
case "$PLATFORM" in
cubieboard2|cubietruck|ci20*)
parted $FILENAME mkpart primary ext2 2048s ${ROOT_FSSIZE} 100%
parted $FILENAME toggle 1 boot
sfdisk ${FILENAME} <<_EOF
2048,,L
_EOF
LOOPDEV=$(losetup --show --find --partscan $FILENAME)
mkfs.${ROOT_FSTYPE} $disable_journal ${LOOPDEV}p1 >/dev/null 2>&1
mount ${LOOPDEV}p1 $ROOTFSDIR
ROOT_UUID=$(blkid -o value -s UUID ${LOOPDEV}p1)
;;
*)
parted $FILENAME mkpart primary ${_btype} 2048s ${BOOT_FSSIZE}
parted $FILENAME mkpart primary ext2 ${BOOT_FSSIZE} 100%
parted $FILENAME toggle 1 boot
sfdisk ${FILENAME} <<_EOF
2048,${BOOT_FSSIZE},b
${BOOT_SIZE},+,L,*
_EOF
LOOPDEV=$(losetup --show --find --partscan $FILENAME)
mkfs.${BOOT_FSTYPE} $_args ${LOOPDEV}p1 >/dev/null
case "$ROOT_FSTYPE" in
@ -201,7 +203,7 @@ usbarmory)
dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1
;;
ci20)
ln -sf /boot/uImage ${ROOTFSDIR}/vmlinux.img
cp -f ${ROOTFSDIR}/boot/uImage ${ROOTFSDIR}/boot/vmlinux.img
dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1
dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1
;;