about summary refs log tree commit diff
path: root/mkimage.sh.in
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-10-09 15:24:32 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-10-09 15:43:55 +0200
commit44722b79e2f31c0c51bd2fc8c8d43c0009d79529 (patch)
tree5fc9fce8937199de06e2c22ad781e59fa654dfd2 /mkimage.sh.in
parenta25ced5c198fff963ba7b7e9b613059e756374c0 (diff)
parentcb2510b3791091fb54681cee451eb7ec24e0b266 (diff)
downloadhrmpf-44722b79e2f31c0c51bd2fc8c8d43c0009d79529.tar.gz
hrmpf-44722b79e2f31c0c51bd2fc8c8d43c0009d79529.tar.xz
hrmpf-44722b79e2f31c0c51bd2fc8c8d43c0009d79529.zip
Merge remote-tracking branch 'origin/master'
* origin/master: (136 commits)
  dracut/services: don't autostart dmeventd, lvmetad and mdadm.
  mklive: fix guessing linux kernel pkgname.
  fix set_keymap rc.conf
  installer.sh: fix static IP settings in menu_install
  build-arm-images: PLATFORM can be overrided now.
  build-rootfs: build musl rootfs too; PLATFORMS can be overrided now.
  build-x86-images: added lxqt image.
  dracut/dm-autologin: autostart lxqt if available.
  mkrootfs: add dockstar support
  mklive: install GRUB EFI loader as EFI/BOOT/BOOTX64.EFI.
  build-x86-images: add gnome-keyring to cinnamon/mate/xfce images.
  build-x86-images: add firefox now it's available for musl.
  build-arm-images: respect musl targets.
  mkimage: consistently redirect std{err,out} to /dev/null with dd(1).
  build-arm-images: disable cubietruck for now; does not boot.
  build-arm-images: build all ARM images for glibc and musl.
  mkrootfs: get rid of pixz; fix rpi target arch.
  mkrootfs: set cachedir to $PWD/xbps-cachedir-<arch>; misc tweaks for musl.
  mkrootfs: update for musl support.
  build-x86-images: do not build the kde image; does not work yet.
  ...
Diffstat (limited to 'mkimage.sh.in')
-rw-r--r--mkimage.sh.in95
1 files changed, 58 insertions, 37 deletions
diff --git a/mkimage.sh.in b/mkimage.sh.in
index 493f359..13e9301 100644
--- a/mkimage.sh.in
+++ b/mkimage.sh.in
@@ -1,6 +1,6 @@
 #!/bin/sh
 #-
-# Copyright (c) 2013 Juan Romero Pardines.
+# Copyright (c) 2013-2015 Juan Romero Pardines.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@ cleanup() {
 }
 
 info_msg() {
-    printf "\033[1m$@\n\033[m"
+    printf "\033[1m[${PLATFORM}] $@\n\033[m"
 }
 
 die() {
@@ -102,13 +102,7 @@ if [ "$(id -u)" -ne 0 ]; then
     die "need root perms to continue, exiting."
 fi
 
-IMGSIZE="$2"
-if [ -z "$IMGSIZE" ]; then
-    IMGSIZE="2G"
-else
-    IMGSIZE="${2}G"
-fi
-
+: ${IMGSIZE:=2G}
 : ${BOOT_FSTYPE:=vfat}
 : ${BOOT_FSSIZE:=64M}
 : ${ROOT_FSTYPE:=ext4}
@@ -119,7 +113,7 @@ fi
 
 # double check PLATFORM is supported...
 case "$PLATFORM" in
-    cubieboard2|odroid-u2|rpi);;
+    bananapi|beaglebone|cubieboard2|cubietruck|odroid-u2|rpi|rpi2|usbarmory|*-musl);;
     *) die "The $PLATFORM is not supported, exiting..."
 esac
 
@@ -139,54 +133,81 @@ esac
 info_msg "Creating disk image ($IMGSIZE) ..."
 dd if=/dev/zero of=$FILENAME bs=$IMGSIZE count=1 ${DD_SPARSE} >/dev/null 2>&1
 
+ROOTFSDIR=$(mktemp -d)
+
 info_msg "Creating disk image partitions/filesystems ..."
 parted $FILENAME mktable msdos
 if [ "$BOOT_FSTYPE" = "vfat" ]; then
     _btype="fat32"
-    _args="-I"
+    _args="-I -F16"
 fi
-parted $FILENAME mkpart primary ${_btype} 4096s ${BOOT_FSSIZE}
-parted $FILENAME mkpart primary ext2 ${BOOT_FSSIZE} 100%
-parted $FILENAME toggle 1 boot
-LOOPDEV=$(losetup --show --find $FILENAME)
-partx -a $LOOPDEV
-mkfs.${BOOT_FSTYPE} $_args ${LOOPDEV}p1 >/dev/null
-mkfs.${ROOT_FSTYPE} ${LOOPDEV}p2 >/dev/null 2>&1
+case "$PLATFORM" in
+cubieboard2|cubietruck)
+    parted $FILENAME mkpart primary ext2 2048s ${ROOT_FSSIZE} 100%
+    parted $FILENAME toggle 1 boot
+    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
+    LOOPDEV=$(losetup --show --find --partscan $FILENAME)
+    mkfs.${BOOT_FSTYPE} $_args ${LOOPDEV}p1 >/dev/null
+    case "$ROOT_FSTYPE" in
+        ext[34]) disable_journal="-O ^has_journal";;
+    esac
+    mkfs.${ROOT_FSTYPE} $disable_journal ${LOOPDEV}p2 >/dev/null 2>&1
+    mount ${LOOPDEV}p2 $ROOTFSDIR
+    mkdir -p ${ROOTFSDIR}/boot
+    mount ${LOOPDEV}p1 ${ROOTFSDIR}/boot
+    BOOT_UUID=$(blkid -o value -s UUID ${LOOPDEV}p1)
+    ROOT_UUID=$(blkid -o value -s UUID ${LOOPDEV}p2)
+    ;;
+esac
 
 info_msg "Unpacking rootfs tarball ..."
-ROOTFSDIR=$(mktemp -d)
-mount ${LOOPDEV}p2 $ROOTFSDIR
-mkdir -p ${ROOTFSDIR}/boot
-mount ${LOOPDEV}p1 ${ROOTFSDIR}/boot
-
+if [ "$PLATFORM" = "beaglebone" ]; then
+    fstab_args=",noauto"
+    tar xfp $ROOTFS_TARBALL -C $ROOTFSDIR ./boot/MLO
+    tar xfp $ROOTFS_TARBALL -C $ROOTFSDIR ./boot/u-boot.img
+    touch $ROOTFSDIR/boot/uEnv.txt
+    umount $ROOTFSDIR/boot
+fi
 tar xfp $ROOTFS_TARBALL -C $ROOTFSDIR
 
-BOOT_UUID=$(blkid -o value -s UUID ${LOOPDEV}p1)
-ROOT_UUID=$(blkid -o value -s UUID ${LOOPDEV}p2)
-echo "UUID=$BOOT_UUID /boot $BOOT_FSTYPE defaults 0 0" >> ${ROOTFSDIR}/etc/fstab
-echo "UUID=$ROOT_UUID / $ROOT_FSTYPE defaults 0 1" >> ${ROOTFSDIR}/etc/fstab
-
-if [ -s ${ROOTFSDIR}/boot/cmdline.txt ]; then
-   sed -e "s,rootfstype=ext4,rootfstype=${ROOT_FSTYPE}," -i ${ROOTFSDIR}/boot/cmdline.txt
+fspassno="1"
+if [ "$ROOT_FSTYPE" = "f2fs" ]; then
+    fspassno="0"
+fi
+echo "UUID=$ROOT_UUID / $ROOT_FSTYPE defaults 0 ${fspassno}" >> ${ROOTFSDIR}/etc/fstab
+if [ -n "$BOOT_UUID" ]; then
+    echo "UUID=$BOOT_UUID /boot $BOOT_FSTYPE defaults${fstab_args} 0 2" >> ${ROOTFSDIR}/etc/fstab
 fi
 
-# For cubieboard we need to flash u-boot to the image.
-if [ "$PLATFORM" = "cubieboard2" ]; then
+case "$PLATFORM" in
+bananapi|cubieboard2|cubietruck)
     dd if=${ROOTFSDIR}/boot/u-boot-sunxi-with-spl.bin of=${LOOPDEV} bs=1024 seek=8 >/dev/null 2>&1
-elif [ "$PLATFORM" = "odroid-u2" ]; then
+    ;;
+odroid-u2)
     dd if=${ROOTFSDIR}/boot/E4412_S.bl1.HardKernel.bin of=${LOOPDEV} seek=1 >/dev/null 2>&1
     dd if=${ROOTFSDIR}/boot/bl2.signed.bin of=${LOOPDEV} seek=31 >/dev/null 2>&1
     dd if=${ROOTFSDIR}/boot/u-boot.bin of=${LOOPDEV} seek=63 >/dev/null 2>&1
     dd if=${ROOTFSDIR}/boot/E4412_S.tzsw.signed.bin of=${LOOPDEV} seek=2111 >/dev/null 2>&1
-fi
+    ;;
+usbarmory)
+    dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1
+    ;;
+esac
 
-umount ${ROOTFSDIR}/boot
+mountpoint -q ${ROOTFSDIR}/boot && umount ${ROOTFSDIR}/boot
 umount $ROOTFSDIR
-partx -d $LOOPDEV
 losetup -d $LOOPDEV
 rmdir $ROOTFSDIR
 
 chmod 644 $FILENAME
-info_msg "Successfully created $FILENAME ($PLATFORM) image."
+info_msg "Successfully created $FILENAME image."
 
 # vim: set ts=4 sw=4 et: