Live-Build

Attachment '0001-live-build-binary_hdd-enablement-for-ppc64el.patch'

Download

   1 From 3bf05be0483d43246890b11dbde74db1e4ad94cb Mon Sep 17 00:00:00 2001
   2 From: Deb McLemore <debmc@linux.vnet.ibm.com>
   3 Date: Thu, 15 Dec 2016 17:48:32 -0600
   4 Subject: [PATCH 1/2] live-build binary_hdd enablement for ppc64el
   5 
   6 This patch enables the building of an HDD live image with persistence.
   7 
   8 OVERVIEW
   9 ----------------------------------------------------------------------
  10 
  11 If the LB_PERSIST variable is set to "auto" (config/binary) then a
  12 secondary partition will be automatically created and configured
  13 as a persistent storage device (you still need to add "persistence"
  14 on LB_BOOTAPPEND_LIVE).
  15 
  16 Using LB_PERSIST set to "auto" with LB_HDD_SIZE set to "auto"
  17 (LB_HDD_SIZE is the primary partition size) then the same minimum
  18 size will be used as both the primary partition size and the
  19 persistent storage size partition (so two partitions are created
  20 with the same minimum size each).
  21 
  22 If a specific size is desired for LB_HDD_SIZE (the primary partition),
  23 then setting LB_HDD_SIZE to the desired size will then be replicated
  24 for the auto sizing of the LB_PERSIST persistent storage size.
  25 
  26 If differing sizes are desired then use the LB_HDD_SIZE for defining
  27 the first partition size and LB_PERSIST to define the persistent
  28 storage size of the second partition, e.g. LB_HDD_SIZE=2048 and
  29 LB_PERSIST=4096 (sizes in MB).
  30 
  31 If no persistent storage is desired set LB_PERSIST to a non-numeric
  32 string not equal to "auto", e.g. "noauto".
  33 
  34 See the build log for output on values picked up during building:
  35 
  36 	sudo lb build 2>&1 | tee /home/myuid/build.log
  37 	grep "Image" /home/myuid/build.log
  38 
  39 Another handy grep in the build log is:
  40 
  41 	grep "binary_hdd" /home/myuid/build.log
  42 
  43 Example usage (these tweaks expect that you already have
  44 live-build installed and building properly with this patch):
  45 
  46 config/build:
  47 Type: hdd
  48 
  49 config/binary:
  50 LB_BOOTAPPEND_LIVE="boot=live persistence"
  51 	Note: these are just adds for this feature
  52 
  53 LB_BOOTLOADERS="grub-efi"
  54 
  55 LB_HDD_SIZE="auto"
  56 
  57 LB_PERSIST="auto"
  58 
  59 LB_BOOTLOADER_PARTITION_SIZE="auto"
  60 
  61 LB_HDD_PARTITION_TABLE_TYPE="auto"
  62 
  63 LB_BOOTLOADER_PARTITION_TYPE="auto"
  64 
  65 BUILDING
  66 ----------------------------------------------------------------------
  67 
  68 IMPORTANT:
  69 1 - You must build the ppc64el HDD image on a ppc64el host.
  70 2 - You need to have grub2-common 2.02 or later.
  71 
  72 TESTING
  73 
  74 ----------------------------------------------------------------------
  75 Burn to a USB (be sure to replace sdX with your USB device name):
  76 
  77 ppc64el platform ->
  78 sudo dd if=/home/myid/live-image-ppc64el.img of=/dev/sdX && sync
  79 
  80 amd64 platform ->
  81 sudo dd if=/home/myid/live-image-amd64.img of=/dev/sdX && sync
  82 
  83 ----------------------------------------------------------------------
  84 
  85 TEST ppc64el image (from ppc64el KVM Host):
  86 
  87 sudo kvm -m 2G -hda live-image-ppc64el.img -nographic
  88 -nodefaults -serial stdio
  89 
  90 TEST ppc64el image (from x86_64 KVM Host or ppc64el KVM Host):
  91 
  92 sudo apt-get install qemu-system-ppc
  93 
  94 sudo qemu-system-ppc64 -m 2G -hda live-image-ppc64el.img -nographic
  95 -nodefaults -serial stdio
  96 
  97 ----------------------------------------------------------------------
  98 
  99 TEST amd64 ESP image (from x86_64 KVM Host):
 100 
 101 sudo apt-get install qemu-system-x86
 102 sudo apt-get install ovmf
 103 
 104 sudo cp /usr/share/OVMF/OVMF_VARS.fd ~/live_OVMF_VARS.fd
 105 
 106 sudo qemu-system-x86_64 -m 2G -enable-kvm
 107 -vga qxl
 108 -hda live-image-amd64.img
 109 -drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd
 110 -drive if=pflash,format=raw,file=live_OVMF_VARS.fd
 111 
 112 ----------------------------------------------------------------------
 113 
 114 TEST amd64 bios_grub image (from x86_64 KVM Host):
 115 
 116 sudo qemu-system-x86_64 -m 2G -hda live-image-amd64.img
 117 
 118 ----------------------------------------------------------------------
 119 
 120 Signed-off-by: Deb McLemore <debmc@linux.vnet.ibm.com>
 121 ---
 122  functions/architectures.sh               |  10 +-
 123  functions/defaults.sh                    |  39 +-
 124  functions/losetup.sh                     |   6 +-
 125  functions/packages.sh                    |  15 +-
 126  scripts/build/binary_grub-efi            | 214 +++++++----
 127  scripts/build/binary_grub-pc             |  11 +-
 128  scripts/build/binary_hdd                 | 609 ++++++++++++++++++++++++-------
 129  scripts/build/binary_iso                 | 113 +++---
 130  scripts/build/binary_linux-image         |   3 +-
 131  scripts/build/binary_loopback_cfg        |  80 +++-
 132  scripts/build/binary_netboot             |   5 +
 133  scripts/build/binary_rootfs              |   3 +-
 134  scripts/build/binary_syslinux            |  31 +-
 135  scripts/build/config                     |  75 +++-
 136  scripts/build/efi-image                  | 129 ++++---
 137  scripts/build/grub-cpmodules             |  27 +-
 138  scripts/build/installer_debian-installer |   6 +-
 139  17 files changed, 1028 insertions(+), 348 deletions(-)
 140 
 141 diff --git a/functions/architectures.sh b/functions/architectures.sh
 142 index 7c6c48c..452e99e 100755
 143 --- a/functions/architectures.sh
 144 +++ b/functions/architectures.sh
 145 @@ -2,6 +2,7 @@
 146  
 147  ## live-build(7) - System Build Scripts
 148  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
 149 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 150  ##
 151  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 152  ## This is free software, and you are welcome to redistribute it
 153 @@ -42,7 +43,7 @@ Check_architectures ()
 154  
 155  	if [ "${VALID}" = "false" ]
 156  	then
 157 -		Echo_warning "skipping %s, foreign architecture(s)." "${0}"
 158 +		Echo_warning "skipping %s, foreign architecture(s) - ${LB_ARCHITECTURES}." "${0}"
 159  		exit 0
 160  	fi
 161  }
 162 @@ -65,11 +66,16 @@ Check_crossarchitectures ()
 163  			CROSS="powerpc ppc64"
 164  			;;
 165  
 166 +		ppc64el)
 167 +			CROSS="ppc64el"
 168 +			;;
 169 +
 170  		*)
 171  			CROSS="${HOST}"
 172  			;;
 173  	esac
 174  
 175 +
 176  	if [ "${LB_ARCHITECTURES}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" ]
 177  	then
 178  
 179 @@ -112,7 +118,7 @@ Check_multiarchitectures ()
 180  						DESTDIR_INSTALL="${DESTDIR_INSTALL}.386"
 181  						;;
 182  
 183 -					powerpc)
 184 +					powerpc|ppc64el)
 185  						DESTDIR="${DESTDIR}.ppc"
 186  						DESTDIR_LIVE="${DESTDIR_LIVE}.ppc"
 187  						DESTDIR_INSTALL="${DESTDIR_INSTALL}.ppc"
 188 diff --git a/functions/defaults.sh b/functions/defaults.sh
 189 index 78ca358..9ed4567 100755
 190 --- a/functions/defaults.sh
 191 +++ b/functions/defaults.sh
 192 @@ -2,6 +2,7 @@
 193  
 194  ## live-build(7) - System Build Scripts
 195  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
 196 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 197  ##
 198  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 199  ## This is free software, and you are welcome to redistribute it
 200 @@ -443,7 +444,7 @@ Set_defaults ()
 201  			esac
 202  			;;
 203  
 204 -		powerpc)
 205 +		powerpc|powerpc64)
 206  			case "${LB_MODE}" in
 207  				progress-linux)
 208  					Echo_error "Architecture ${LB_ARCHITECTURES} not supported in the ${LB_MODE} mode."
 209 @@ -456,6 +457,19 @@ Set_defaults ()
 210  			esac
 211  			;;
 212  
 213 +		ppc64el)
 214 +			case "${LB_MODE}" in
 215 +				progress-linux)
 216 +					Echo_error "Architecture ${LB_ARCHITECTURES} not supported in the ${LB_MODE} mode."
 217 +					exit 1
 218 +					;;
 219 +
 220 +				*)
 221 +					LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-generic}"
 222 +					;;
 223 +			esac
 224 +			;;
 225 +
 226  		s390x)
 227  			case "${LB_MODE}" in
 228  				progress-linux)
 229 @@ -532,7 +546,10 @@ Set_defaults ()
 230  	then
 231  		case "${LB_ARCHITECTURES}" in
 232  			amd64|i386)
 233 -				LB_BOOTLOADERS="syslinux,grub-efi"
 234 +				LB_BOOTLOADERS="syslinux"
 235 +				;;
 236 +			ppc64el)
 237 +				LB_BOOTLOADERS="grub-efi"
 238  				;;
 239  		esac
 240  	fi
 241 @@ -678,6 +695,24 @@ Set_defaults ()
 242  	# Setting hdd size
 243  	LB_HDD_SIZE="${LB_HDD_SIZE:-auto}"
 244  
 245 +	# Setting hdd partition start
 246 +	LB_HDD_PARTITION_START="${LB_HDD_PARTITION_START:-auto}"
 247 +
 248 +	# Setting persistence storage
 249 +	LB_PERSIST="${LB_PERSIST:-auto}"
 250 +
 251 +	# Setting bootloader partition size
 252 +	LB_BOOTLOADER_PARTITION_SIZE="${LB_BOOTLOADER_PARTITION_SIZE:-auto}"
 253 +
 254 +	# Setting hdd partition table type
 255 +	LB_HDD_PARTITION_TABLE_TYPE="${LB_HDD_PARTITION_TABLE_TYPE:-auto}"
 256 +
 257 +	# Set the type of the bootloader partition
 258 +	LB_BOOTLOADER_PARTITION_TYPE="${LB_BOOTLOADER_PARTITION_TYPE:-auto}"
 259 +
 260 +	# Set the sleep interval for timing between read/write, mount operations
 261 +	LB_SLEEP_INTERVAL="${LB_SLEEP_INTERVAL:-1}"
 262 +
 263  	# Setting iso volume
 264  	case "${LB_MODE}" in
 265  		debian)
 266 diff --git a/functions/losetup.sh b/functions/losetup.sh
 267 index 9d9b46e..61f375f 100755
 268 --- a/functions/losetup.sh
 269 +++ b/functions/losetup.sh
 270 @@ -2,6 +2,7 @@
 271  
 272  ## live-build(7) - System Build Scripts
 273  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
 274 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 275  ##
 276  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 277  ## This is free software, and you are welcome to redistribute it
 278 @@ -85,12 +86,13 @@ Calculate_partition_size_without_journal ()
 279  	WITHOUT_JOURNAL_ORIGINAL_SIZE="${1}"
 280  	WITHOUT_JOURNAL_FILESYSTEM="${2}"
 281  
 282 +	# Making PERCENT minimum 15 percent since random hits at lower values caused bad i/o
 283  	case "${WITHOUT_JOURNAL_FILESYSTEM}" in
 284  		ext2|ext3|ext4)
 285 -			PERCENT="6"
 286 +			PERCENT="15"
 287  			;;
 288  		*)
 289 -			PERCENT="3"
 290 +			PERCENT="15"
 291  			;;
 292  	esac
 293  
 294 diff --git a/functions/packages.sh b/functions/packages.sh
 295 index 7c3592d..8a51c4c 100755
 296 --- a/functions/packages.sh
 297 +++ b/functions/packages.sh
 298 @@ -2,6 +2,7 @@
 299  
 300  ## live-build(7) - System Build Scripts
 301  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
 302 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 303  ##
 304  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 305  ## This is free software, and you are welcome to redistribute it
 306 @@ -41,6 +42,16 @@ Install_package ()
 307  				Chroot chroot "aptitude install --without-recommends ${APTITUDE_OPTIONS} ${_LB_PACKAGES}"
 308  				;;
 309  		esac
 310 +	else
 311 +		case "${LB_APT}" in
 312 +			apt|apt-get)
 313 +				apt-get install -o APT::Install-Recommends=false ${APT_OPTIONS} ${_LB_PACKAGES}
 314 +				;;
 315 +
 316 +			aptitude)
 317 +				aptitude install --without-recommends ${APTITUDE_OPTIONS} ${_LB_PACKAGES}
 318 +				;;
 319 +		esac
 320  	fi
 321  }
 322  
 323 @@ -82,11 +93,11 @@ Check_installed ()
 324  	else
 325  		if which dpkg-query > /dev/null 2>&1
 326  		then
 327 -			if dpkg-query -s "${PACKAGE}" 2> /dev/null | grep -qs "Status: install"
 328 +			if dpkg-query -s ${PACKAGE} | grep -qs "Status: install"
 329  			then
 330  				INSTALL_STATUS=0
 331  			else
 332 -				INSTALL_STATUS=1
 333 +				INSTALL_STATUS=2
 334  			fi
 335  		else
 336  			if [ ! -e "${FILE}" ]
 337 diff --git a/scripts/build/binary_grub-efi b/scripts/build/binary_grub-efi
 338 index d24532d..7301a48 100755
 339 --- a/scripts/build/binary_grub-efi
 340 +++ b/scripts/build/binary_grub-efi
 341 @@ -2,6 +2,7 @@
 342  
 343  ## live-build(7) - System Build Scripts
 344  ## Copyright (C) 2016 Adrian Gibanel Lopez <adrian15sgd@gmail.com>
 345 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 346  ##
 347  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 348  ## This is free software, and you are welcome to redistribute it
 349 @@ -26,7 +27,7 @@ Set_defaults
 350  
 351  Check_Any_Bootloader_Role "grub-efi"
 352  
 353 -Echo_message "Begin preparing Grub based EFI support..."
 354 +Echo_message "Begin preparing Grub Images for BIOS, UEFI or PReP ..."
 355  
 356  # Requiring stage file
 357  Require_stagefile .build/config .build/bootstrap
 358 @@ -41,22 +42,82 @@ Check_lockfile .lock
 359  Create_lockfile .lock
 360  
 361  # Check architecture
 362 -Check_architectures amd64 i386
 363 +Check_architectures amd64 i386 ppc64el
 364  Check_crossarchitectures
 365  
 366  # Checking depends
 367 -Check_package chroot /usr/lib/grub/x86_64-efi/configfile.mod grub-efi-amd64-bin
 368 -Check_package chroot /usr/lib/grub/i386-efi/configfile.mod grub-efi-ia32-bin
 369 -Check_package chroot /usr/bin/grub-mkimage grub-common
 370 -Check_package chroot /usr/bin/mcopy mtools
 371 -Check_package chroot /sbin/mkfs.msdos dosfstools
 372 +case "${LB_BUILD_WITH_CHROOT}" in
 373 +	true)
 374 +		_CHROOT_DIR=""
 375 +
 376 +		case "${LB_ARCHITECTURES}" in
 377 +			amd64|i386)
 378 +				case "${LB_BOOTLOADER_PARTITION_TYPE}" in
 379 +					esp)
 380 +						Check_package chroot /usr/lib/grub/x86_64-efi/configfile.mod grub-efi-amd64-bin
 381 +						Check_package chroot /usr/lib/grub/i386-efi/configfile.mod grub-efi-ia32-bin
 382 +						_TARGET_FORMAT="esp"
 383 +						;;
 384 +					bios_grub)
 385 +						Check_package chroot /usr/lib/grub/i386-pc/configfile.mod grub-pc-bin
 386 +						Check_package host /usr/sbin/grub-bios-setup grub-pc
 387 +						_TARGET_FORMAT="i386-pc"
 388 +						;;
 389 +					*)
 390 +						if [ -d /sys/firmware/efi ]
 391 +						then
 392 +							Check_package chroot /usr/lib/grub/x86_64-efi/configfile.mod grub-efi-amd64-bin
 393 +							Check_package chroot /usr/lib/grub/i386-efi/configfile.mod grub-efi-ia32-bin
 394 +							_TARGET_FORMAT="esp"
 395 +						else
 396 +							Check_package chroot /usr/lib/grub/i386-pc/configfile.mod grub-pc-bin
 397 +							Check_package host /usr/sbin/grub-bios-setup grub-pc
 398 +							_TARGET_FORMAT="i386-pc"
 399 +						fi
 400 +						;;
 401 +				esac
 402 +				;;
 403 +			ppc64el)
 404 +				Check_package chroot /usr/lib/grub/powerpc-ieee1275/configfile.mod grub-ieee1275
 405 +				_TARGET_FORMAT="powerpc-ieee1275"
 406 +				;;
 407 +			*)
 408 +				Echo_error "Architecture of ${LB_ARCHITECTURES} not supported for binary_grub-efi."
 409 +				exit 1
 410 +				;;
 411 +		esac
 412 +
 413 +		Check_package chroot /usr/bin/grub-mkimage grub-common
 414 +		Check_package chroot /usr/bin/mcopy mtools
 415 +		Check_package chroot /sbin/mkfs.msdos dosfstools
 416 +
 417 +		;;
 418 +
 419 +	*)
 420 +		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported in binary_grub-efi without building \
 421 +			with LB_BUILD_WITH_CHROOT set to \"true\"."
 422 +		exit 1
 423 +esac
 424  
 425  # Setting destination directory
 426  case "${LIVE_IMAGE_TYPE}" in
 427 +        iso*)
 428 +                case "${LB_INITRAMFS}" in
 429 +                        live-boot)
 430 +                                DESTDIR_LIVE="binary/live"
 431 +                                ;;
 432 +
 433 +                        *) # this case as placeholder to work on non-live-boot path
 434 +                                DESTDIR_LIVE="binary/live"
 435 +                                ;;
 436 +                esac
 437 +
 438 +                DESTDIR_INSTALL="binary/install"
 439 +                ;;
 440 +
 441  	hdd*|netboot)
 442 -		Echo_warning "Bootloader in this image type not yet supported by live-build."
 443 -		Echo_warning "This would produce a not bootable image, aborting (FIXME)."
 444 -		exit 1
 445 +		DESTDIR_LIVE="binary/live"
 446 +		Echo_message "LB_BOOTLOADERS of ${LB_BOOTLOADERS} in binary_grub-efi of LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE} on architecture of ${LB_ARCHITECTURES} is in alpha-test for binary_grub-efi (Architecture of ppc64el being actively tested Jan 2017)."
 447  	;;
 448  esac
 449  
 450 @@ -66,26 +127,36 @@ Restore_cache cache/packages.binary
 451  # Installing depends
 452  Install_package
 453  
 454 -# Cleanup files that we generate
 455 -rm -rf binary/boot/efi.img binary/boot/grub/i386-efi/ binary/boot/grub/x86_64-efi
 456 +# Cleanup files that we generate to restore fresh state
 457 +case "${LB_ARCHITECTURES}" in
 458 +	ppc64el)
 459 +		rm -rf binary/boot/grub/powerpc-ieee1275-efi
 460 +		;;
 461 +	amd64|i386)
 462 +		rm -rf binary/boot/grub/x86_64-efi/
 463 +		rm -rf binary/boot/grub/i386-efi/
 464 +		rm -rf binary/boot/grub/i386-pc/
 465 +		;;
 466 +esac
 467  
 468  # This is workaround till both efi-image and grub-cpmodules are put into a binary package
 469  case "${LB_BUILD_WITH_CHROOT}" in
 470 -        true)
 471 +	true)
 472  		if [ ! -e "${LIVE_BUILD}" ] ; then
 473  			LIVE_BUILD_PATH="/usr/lib/live/build"
 474  		else
 475  			LIVE_BUILD_PATH="${LIVE_BUILD}/scripts/build"
 476  		fi
 477  		mkdir -p chroot/${LIVE_BUILD_PATH}
 478 +		case "${LB_ARCHITECTURES}" in
 479 +			ppc64el)
 480 +				mkdir -p binary/boot/grub
 481 +				mkdir -p binary/ppc/chrp
 482 +				;;
 483 +		esac
 484  		cp "${LIVE_BUILD_PATH}/efi-image" "chroot/${LIVE_BUILD_PATH}"
 485  		cp "${LIVE_BUILD_PATH}/grub-cpmodules" "chroot/${LIVE_BUILD_PATH}"
 486 -
 487 -		_CHROOT_DIR=""
 488 -	;;
 489 -	false)
 490 -		_CHROOT_DIR="chroot"
 491 -        ;;
 492 +		;;
 493  esac
 494  #####
 495  cat >binary.sh <<END
 496 @@ -93,48 +164,40 @@ cat >binary.sh <<END
 497  
 498  set -e
 499  
 500 -PRE_EFI_IMAGE_PATH="${PATH}"
 501  if [ ! -e "${LIVE_BUILD}" ] ; then
 502 -	LIVE_BUILD_PATH="/usr/lib/live/build"
 503 +        LIVE_BUILD_PATH="/usr/lib/live/build"
 504  else
 505 -	LIVE_BUILD_PATH="${LIVE_BUILD}/scripts/build"
 506 +        LIVE_BUILD_PATH="${LIVE_BUILD}/scripts/build"
 507  fi
 508  
 509 -PATH="${PATH}:\${LIVE_BUILD_PATH}" # Make sure grub-cpmodules is used as if it was installed in the system
 510 -
 511 -"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/" "x86_64-efi" "x64" "debian-live/amd64"
 512 -mkdir -p ${_CHROOT_DIR}/grub-efi-temp/efi/boot
 513 -mcopy -n -i ${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/efi.img '::efi/boot/boot*.efi' ${_CHROOT_DIR}/grub-efi-temp/efi/boot
 514 -cp -r "${_CHROOT_DIR}"/grub-efi-temp-x86_64-efi/* "${_CHROOT_DIR}/grub-efi-temp/"
 515 -
 516 -"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-i386-efi/" "i386-efi" "ia32" "debian-live/i386"
 517 -PATH="\${PRE_EFI_IMAGE_PATH}"
 518 -mkdir -p ${_CHROOT_DIR}/grub-efi-temp/efi/boot
 519 -mcopy -n -i ${_CHROOT_DIR}/grub-efi-temp-i386-efi/efi.img '::efi/boot/boot*.efi' ${_CHROOT_DIR}/grub-efi-temp/efi/boot
 520 -cp -r "${_CHROOT_DIR}"/grub-efi-temp-i386-efi/* "${_CHROOT_DIR}/grub-efi-temp/"
 521 -
 522 -# The code below is adapted from tools/boot/jessie/boot-x86
 523 -# in debian-cd
 524 -
 525 -# Stuff the EFI boot files into a FAT filesystem, making it as
 526 -# small as possible.  24KiB headroom seems to be enough;
 527 -# (x+31)/32*32 rounds up to multiple of 32.
 528 -# This is the same as in efi-image, but we need to redo it here in
 529 -# the case of a multi-arch amd64/i386 image
 530 -
 531 -size=0
 532 -for file in ${_CHROOT_DIR}/grub-efi-temp/efi/boot/boot*.efi; do
 533 -	size=\$((\$size + \$(stat -c %s "\$file")))
 534 -done
 535 -
 536 -blocks=\$(((\$size / 1024 + 55) / 32 * 32 ))
 537 -
 538 -rm -f ${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img
 539 -mkfs.msdos -C "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" \$blocks >/dev/null
 540 -mmd -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ::efi
 541 -mmd -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ::efi/boot
 542 -mcopy -o -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ${_CHROOT_DIR}/grub-efi-temp/efi/boot/boot*.efi \
 543 -	"::efi/boot"
 544 +case "${LB_ARCHITECTURES}" in
 545 +        amd64|i386)
 546 +		case "${_TARGET_FORMAT}" in
 547 +			i386-pc)
 548 +				"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-i386-pc/boot/grub" "i386-pc" "i386-pc" "core.img"
 549 +				"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-i386-pc/boot/grub" "i386-pc"
 550 +				;;
 551 +			esp)
 552 +				"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/boot/grub" "x86_64-efi" "x64" "x86_64-efi.efi"
 553 +				"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/boot/grub" "x86_64-efi"
 554 +
 555 +				"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-i386-efi/boot/grub" "i386-efi" "ia32" "i386-efi.efi"
 556 +				"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-i386-efi/boot/grub" "i386-efi"
 557 +				;;
 558 +		esac
 559 +		;;
 560 +
 561 +	ppc64el)
 562 +		"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-powerpc-ieee1275-efi/boot/grub" "powerpc-ieee1275" "powerpc" "debian-live/ppc64el"
 563 +		"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-powerpc-ieee1275-efi/boot/grub" "powerpc-ieee1275"
 564 +		;;
 565 +
 566 +	*)
 567 +		echo "ERROR: can't provide EFI boot support to architecture ${LB_ARCHITECTURES}" >&2
 568 +		exit 1
 569 +		;;
 570 +esac
 571 +
 572  END
 573  
 574  case "${LB_BUILD_WITH_CHROOT}" in
 575 @@ -156,15 +219,36 @@ case "${LB_BUILD_WITH_CHROOT}" in
 576  		;;
 577  esac
 578  
 579 -# Remove unnecessary files
 580 -rm -f chroot/grub-efi-temp/bootnetia32.efi
 581 -rm -f chroot/grub-efi-temp/bootnetx64.efi
 582 +case "${LB_ARCHITECTURES}" in
 583 +	ppc64el)
 584 +		# binary/ppc/bootinfo.txt is placed for a PReP boot
 585 +		cp chroot/usr/lib/grub/powerpc-ieee1275/bootinfo.txt binary/ppc
 586 +		cp chroot/usr/share/grub/unicode.pf2 binary/boot/grub
 587 +		cp -r chroot/grub-efi-temp-powerpc-ieee1275-efi/* binary
 588 +		;;
 589 +	amd64|i386)
 590 +		cp chroot/usr/share/grub/unicode.pf2 binary/boot/grub
 591 +		case "${_TARGET_FORMAT}" in
 592 +			esp)
 593 +				cp -r chroot/grub-efi-temp-x86_64-efi/* binary
 594 +				cp -r chroot/grub-efi-temp-i386-efi/*   binary
 595 +				;;
 596 +			*)
 597 +				cp -r chroot/grub-efi-temp-i386-pc/* binary
 598 +				;;
 599 +		esac
 600 +esac
 601  
 602 -mkdir -p binary
 603 -cp -r chroot/grub-efi-temp/* binary/
 604 -rm -rf chroot/grub-efi-temp-x86_64-efi
 605 -rm -rf chroot/grub-efi-temp-i386-efi
 606 -rm -rf chroot/grub-efi-temp
 607 +case "${LB_ARCHITECTURES}" in
 608 +	ppc64el)
 609 +		rm -rf chroot/grub-efi-temp-powerpc-ieee1275-efi
 610 +		;;
 611 +	amd64|i386)
 612 +		rm -rf chroot/grub-efi-temp-i386-pc
 613 +		rm -rf chroot/grub-efi-temp-x86_64-efi
 614 +		rm -rf chroot/grub-efi-temp-i386-efi
 615 +		;;
 616 +esac
 617  
 618  # We rely on: binary_loopback_cfg to generate grub.cfg and other configuration files
 619  
 620 diff --git a/scripts/build/binary_grub-pc b/scripts/build/binary_grub-pc
 621 index 6d111a7..d949e3b 100755
 622 --- a/scripts/build/binary_grub-pc
 623 +++ b/scripts/build/binary_grub-pc
 624 @@ -2,6 +2,7 @@
 625  
 626  ## live-build(7) - System Build Scripts
 627  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
 628 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 629  ##
 630  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 631  ## This is free software, and you are welcome to redistribute it
 632 @@ -41,9 +42,17 @@ Check_lockfile .lock
 633  Create_lockfile .lock
 634  
 635  # Check architecture
 636 -Check_architectures amd64 i386
 637 +# Need to include ppc64el in checks to stop processing if defined
 638 +Check_architectures amd64 i386 ppc64el
 639  Check_crossarchitectures
 640  
 641 +case "${LB_ARCHITECTURES}" in
 642 +	ppc*)
 643 +		Echo_error "Architecture ${LB_ARCHITECTURES} is not supported in binary_grub-pc (try LB_BOOTLOADERS of \"grub-efi\" in config/binary)."
 644 +		exit 1
 645 +		;;
 646 +esac
 647 +
 648  # Checking depends
 649  Check_package chroot /usr/bin/grub-mkimage grub-pc
 650  
 651 diff --git a/scripts/build/binary_hdd b/scripts/build/binary_hdd
 652 index c6b842e..bb7f307 100755
 653 --- a/scripts/build/binary_hdd
 654 +++ b/scripts/build/binary_hdd
 655 @@ -2,6 +2,7 @@
 656  
 657  ## live-build(7) - System Build Scripts
 658  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
 659 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 660  ##
 661  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 662  ## This is free software, and you are welcome to redistribute it
 663 @@ -14,7 +15,7 @@ set -e
 664  [ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
 665  
 666  # Setting static variables
 667 -DESCRIPTION="$(Echo 'build binary image')"
 668 +DESCRIPTION="$(Echo 'build binary Image')"
 669  HELP=""
 670  USAGE="${PROGRAM} [--force]"
 671  
 672 @@ -29,7 +30,7 @@ then
 673  	exit 0
 674  fi
 675  
 676 -Echo_message "Begin building binary hdd image..."
 677 +Echo_message "Begin building binary hdd Image..."
 678  
 679  # Requiring stage file
 680  Require_stagefile .build/config .build/bootstrap .build/chroot_proc
 681 @@ -56,20 +57,19 @@ esac
 682  
 683  Check_package chroot /usr/share/doc/mtools mtools
 684  Check_package chroot /sbin/parted parted
 685 +Check_package host /sbin/kpartx kpartx
 686 +Check_package host /sbin/sgdisk gdisk
 687  
 688 -echo "${LB_BOOTLOADERS}" | \
 689 -while IFS="," read -r BOOTLOADER
 690 -do
 691 -	case "${BOOTLOADER}" in
 692 -		grub)
 693 -			Check_package chroot /usr/sbin/grub grub
 694 +case "${LB_FIRST_BOOTLOADER}" in
 695 +		syslinux)
 696 +			Check_package host /usr/bin/syslinux syslinux
 697 +			Check_package host /usr/bin/extlinux extlinux
 698  			;;
 699 -	esac
 700 -done
 701 +esac
 702  
 703 -case ${LB_FIRST_BOOTLOADER} in
 704 +case "${LB_FIRST_BOOTLOADER}" in
 705  		syslinux)
 706 -			case ${LB_BINARY_FILESYSTEM} in
 707 +			case "${LB_BINARY_FILESYSTEM}" in
 708  				fat*|ntfs)
 709  					_BOOTLOADER=syslinux
 710  					;;
 711 @@ -77,11 +77,41 @@ case ${LB_FIRST_BOOTLOADER} in
 712  					_BOOTLOADER=extlinux
 713  					;;
 714  				*)
 715 -					Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}"
 716 +					Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in binary_hdd."
 717 +					exit 1
 718 +					;;
 719 +			esac
 720 +			case "${LB_ARCHITECTURES}" in
 721 +				amd64|i386)
 722 +					Check_package chroot /usr/bin/${_BOOTLOADER} ${_BOOTLOADER}
 723 +					;;
 724 +				ppc64el)
 725 +					Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in binary_hdd (try LB_BOOTLOADERS of \"grub-efi\" in config/binary)."
 726 +					exit 1
 727 +					;;
 728 +				*)
 729 +					Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in binary_hdd."
 730 +					exit 1
 731 +					;;
 732 +			esac
 733 +			;;
 734 +		grub-efi)
 735 +			case "${LB_ARCHITECTURES}" in
 736 +				ppc64el)
 737 +					Echo_warning "Architecture of ${LB_ARCHITECTURES} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} is in alpha-test for binary_hdd  (Architecture of ppc64el being actively tested Jan 2017)."
 738 +					;;
 739 +				amd64|i386)
 740 +					Echo_warning "Architecture of ${LB_ARCHITECTURES} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} is in alpha-test for binary_hdd  (Architecture of i386-pc being actively tested Jan 2017)."
 741 +					;;
 742 +				*)
 743 +					Echo_error "Architecture of ${LB_ARCHITECTURES} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in LB_BOOTLOADERS of ${LB_BOOTLOADERS} is not supported for LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE} in binary_hdd, try LB_BOOTLOADERS of \"syslinux\" (config/binary)."
 744  					exit 1
 745  					;;
 746  			esac
 747 -			Check_package chroot /usr/bin/${_BOOTLOADER} ${_BOOTLOADER}
 748 +			;;
 749 +		*)
 750 +			Echo_error "LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in LB_BOOTLOADERS of ${LB_BOOTLOADERS} is not supported for LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE} in binary_hdd."
 751 +			exit 1
 752  			;;
 753  esac
 754  
 755 @@ -137,29 +167,217 @@ then
 756  	export LB_BINARY_FILESYSTEM
 757  fi
 758  
 759 -# Everything which comes here needs to be cleaned up,
 760 -if [ "$LB_HDD_SIZE" = "auto" ];
 761 +DU_DIM="$(du ${DU_OPTIONS} -ms binary | cut -f1)"
 762 +REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LB_BINARY_FILESYSTEM})"
 763 +ORIG_REAL_DIM=$REAL_DIM
 764 +# really just placeholder to account for space needed by MBR in overall size calculations MB
 765 +MBR_SPACE=1
 766 +# HDD buffer is extra space needed to help account for alignment and available space for partition table overhead
 767 +HDD_BUFFER=2
 768 +
 769 +# sizes in MB
 770 +PREP_DEFAULT_SIZE=8
 771 +
 772 +# ESP's recommend
 773 +ESP_DEFAULT_SIZE=550
 774 +
 775 +# BIOS_GRUB recommends
 776 +BIOS_GRUB_DEFAULT_SIZE=2
 777 +
 778 +# For now lets limit the number of partitions to 4, need to re-visit code to support more than 4
 779 +_MAX_PART_NUMS=4
 780 +
 781 +case "${LB_HDD_PARTITION_TABLE_TYPE}" in
 782 +	auto|gpt)
 783 +		if [ "${LB_FIRST_BOOTLOADER}" != "syslinux" ]
 784 +		then
 785 +			_GPT="true"
 786 +		else
 787 +			_GPT="false"
 788 +			Echo_message "binary_hdd is going to use LB_HDD_PARTITION_TABLE_TYPE of \"msdos\" since the LB_FIRST_BOOTLOADER of \"${LB_FIRST_BOOTLOADER}\" was specified (since syslinux installs its bootloader into the MBR sector).  If some other layout is desired, please specify LB_BOOTLOADERS in config/binary with \"grub-efi\" to allow for GPT as the LB_HDD_PARTITION_TABLE_TYPE and to allow the installation of the grub bootloader."
 789 +		fi
 790 +		;;
 791 +	*) # msdos falls in this branch
 792 +		_GPT="false"
 793 +		;;
 794 +esac
 795 +
 796 +# first test to make sure an integer
 797 +if [ "$LB_SLEEP_INTERVAL" -eq "$LB_SLEEP_INTERVAL" > /dev/null 2>&1 ]
 798  then
 799 -	DU_DIM="$(du ${DU_OPTIONS} -ms binary | cut -f1)"
 800 -	REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LB_BINARY_FILESYSTEM})"
 801 +	LB_SLEEP_INTERVAL=$(($LB_SLEEP_INTERVAL))
 802  else
 803 -	REAL_DIM=$LB_HDD_SIZE
 804 +	LB_SLEEP_INTERVAL=1
 805  fi
 806  
 807 -dd if=/dev/zero of=chroot/binary.img bs=1024k count=0 seek=${REAL_DIM}
 808 -FREELO="$(${LB_LOSETUP} -f)"
 809 -if [ ! -b chroot/${FREELO} ]
 810 +case "${LB_BOOTLOADER_PARTITION_TYPE}" in
 811 +	esp)
 812 +		_TARGET_FORMAT="esp"
 813 +		;;
 814 +	bios_grub)
 815 +		_TARGET_FORMAT="bios_grub"
 816 +		;;
 817 +	*)
 818 +		if [ -d /sys/firmware/efi ]
 819 +		then
 820 +			_TARGET_FORMAT="esp"
 821 +		else
 822 +			_TARGET_FORMAT="bios_grub"
 823 +		fi
 824 +		;;
 825 +esac
 826 +
 827 +case "${LB_BOOTLOADER_PARTITION_SIZE}" in
 828 +	auto)
 829 +		case "${LB_ARCHITECTURES}" in
 830 +			ppc64el)
 831 +				_BOOTLOADER_PART_SIZE=$PREP_DEFAULT_SIZE
 832 +				;;
 833 +			*)
 834 +				if [ "${_TARGET_FORMAT}" = "esp" ]
 835 +				then
 836 +					_BOOTLOADER_PART_SIZE=$ESP_DEFAULT_SIZE
 837 +				else
 838 +					_BOOTLOADER_PART_SIZE=$BIOS_GRUB_DEFAULT_SIZE
 839 +				fi
 840 +				;;
 841 +		esac
 842 +		;;
 843 +	*)
 844 +		# first test to make sure an integer
 845 +		if [ "$LB_BOOTLOADER_PARTITION_SIZE" -eq "$LB_BOOTLOADER_PARTITION_SIZE" > /dev/null 2>&1 ]
 846 +		then
 847 +			if [ "$LB_BOOTLOADER_PARTITION_SIZE" -gt "0" > /dev/null 2>&1 ]
 848 +			then
 849 +				_BOOTLOADER_PART_SIZE=$(($LB_BOOTLOADER_PARTITION_SIZE))
 850 +			else
 851 +				_BOOTLOADER_PART_SIZE=$PREP_DEFAULT_SIZE
 852 +				# if a non-numeric value was given set to a valid value cross platform
 853 +				# PReP default size used as a fail-safe value since anything greater is a problem on ppc64el
 854 +				Echo_warning "binary_hdd the value given for LB_BOOTLOADER_PARTITION_SIZE \"${LB_BOOTLOADER_PARTITION_SIZE}\" was not \"auto\" or a valid numeric integer value, so ignoring and using the \"auto\" calculations.  If this is not desired, please update LB_BOOTLOADER_PARTITION_SIZE."
 855 +			fi
 856 +		else
 857 +			_BOOTLOADER_PART_SIZE=$PREP_DEFAULT_SIZE
 858 +			# if a non-numeric value was given set to a valid value cross platform
 859 +			# PReP default size used as a fail-safe value since anything greater is a problem on ppc64el
 860 +			Echo_warning "binary_hdd the value given for LB_BOOTLOADER_PARTITION_SIZE \"${LB_BOOTLOADER_PARTITION_SIZE}\" was not \"auto\" or a valid numeric integer value, so ignoring and using the \"auto\" calculations.  If this is not desired, please update LB_BOOTLOADER_PARTITION_SIZE."
 861 +		fi
 862 +		;;
 863 +esac
 864 +
 865 +Echo_message "Image sizes and partition starts are input parameters used for creating partition layouts, however optimal settings are used which may alter these actual values to allow better alignments.  Using tools such as parted or gdisk will identify the actual physical layout."
 866 +
 867 +
 868 +# first test to make sure an integer
 869 +if [ "$LB_HDD_SIZE" -eq "$LB_HDD_SIZE" > /dev/null 2>&1 ]
 870  then
 871 -	MAKEDEV="true"
 872 +	if [ "$LB_HDD_SIZE" -ge $(($REAL_DIM+$MBR_SPACE)) ]
 873 +	then
 874 +		REAL_DIM=$LB_HDD_SIZE
 875 +		Echo_message "LB_HDD_SIZE of ${LB_HDD_SIZE} MB will be used for input on creating the partition holding the base Image."
 876 +	else
 877 +		Echo_warning "LB_HDD_SIZE of ${LB_HDD_SIZE} MB is not large enough to hold the base Image plus the boot sector, so the minimum real size of ${ORIG_REAL_DIM} MB plus boot sector of ${MBR_SPACE} MB will be used to create the partition for the base Image."
 878 +	fi
 879 +fi
 880 +
 881 +PRIMARY_SIZE=$REAL_DIM
 882 +PRIMARY_START=$MBR_SPACE
 883 +BOOTLOADER_START=$MBR_SPACE
 884 +REAL_START=$MBR_SPACE
 885  
 886 -	mv chroot/dev chroot/dev.tmp
 887 -	find /dev | cpio -dmpu chroot
 888 +
 889 +# first test to make sure an integer
 890 +if [ "$LB_HDD_PARTITION_START" -eq "$LB_HDD_PARTITION_START" > /dev/null 2>&1 ]
 891 +then
 892 +	if [ "$LB_HDD_PARTITION_START" -ge "$MBR_SPACE" ]
 893 +	# We use PRIMARY_END to build the Image so no need to check this offset to make sure it will fit
 894 +	then
 895 +		PRIMARY_START=$LB_HDD_PARTITION_START
 896 +		BOOTLOADER_START=$LB_HDD_PARTITION_START
 897 +		REAL_START=$LB_HDD_PARTITION_START
 898 +		Echo_message "LB_HDD_PARTITION_START of ${LB_HDD_PARTITION_START} MB will be used for the desired start of the partition holding the base Image."
 899 +	else
 900 +		Echo_warning "LB_HDD_PARTITION_START of ${LB_HDD_PARTITION_START} MB is not able to be used (the MBR plus some space (e.g. alignment) is ${MBR_SPACE} MB). The Image has a base partition with a size of ${PRIMARY_SIZE} MB, so ignoring the LB_HDD_PARTITION_START value of ${LB_HDD_PARTITION_START} MB."
 901 +	fi
 902  fi
 903  
 904 -echo "!!! The following error/warning messages can be ignored !!!"
 905 -Losetup $FREELO chroot/binary.img 0
 906 +PRIMARY_END=$(($PRIMARY_START+$PRIMARY_SIZE))
 907 +IMAGE_SIZE=$(($PRIMARY_SIZE))
 908 +
 909 +# megabytes
 910 +MAKE_PERSIST="false"
 911 +case "${LB_PERSIST}" in
 912 +	auto)
 913 +		PERSIST_START=$(($PRIMARY_END+1))
 914 +		IMAGE_SIZE=$(($PRIMARY_SIZE*2))
 915 +		PERSIST_SIZE=$(($PRIMARY_SIZE))
 916 +		MAKE_PERSIST="true"
 917 +		Echo_message "LB_PERSIST will be automatically creating an additional persistent storage partition of size ${PRIMARY_SIZE} MB in the Image, which is determined by the LB_HDD_SIZE, the LB_PERSIST size or the actual size of ${ORIG_REAL_DIM} MB."
 918 +	;;
 919 +	*)
 920 +		# first test to make sure an integer
 921 +		if [ "$LB_PERSIST" -eq "$LB_PERSIST" > /dev/null 2>&1 ]
 922 +		then
 923 +			if [ "$LB_PERSIST" -gt "0" ]
 924 +			then
 925 +				PERSIST_START=$(($PRIMARY_END+1))
 926 +				PERSIST_SIZE=$(($LB_PERSIST))
 927 +				IMAGE_SIZE=$(($PRIMARY_SIZE+$LB_PERSIST))
 928 +				MAKE_PERSIST="true"
 929 +				Echo_message "LB_PERSIST will be automatically creating an additional persistent storage partition in the Image of size ${LB_PERSIST} MB."
 930 +			fi
 931 +		fi
 932 +	;;
 933 +esac
 934 +
 935 +if [ "$MAKE_PERSIST" = "false" ]
 936 +then
 937 +	Echo_message "LB_PERSIST was not defined as either auto or a size specified in MB, so not adding a persistent storage partition.  The Image will not save changes across boot cycles."
 938 +fi
 939  
 940 -PARTITION_TABLE_TYPE="msdos"
 941 +PREP_PARTNUM=1
 942 +# Set the initial partnums, but they may get bumped if persist is used
 943 +BOOTLOADER_DEVICE_PARTNUM=1
 944 +PRIMARY_PARTNUM=1
 945 +PERSIST_PARTNUM=2
 946 +
 947 +# Keeping architectures unique cases for now, these may be collapsed in the future
 948 +case "${LB_ARCHITECTURES}" in
 949 +	ppc64el)
 950 +		# Need to add PReP partition
 951 +		HDD_EXTRA_SIZE=$(($_BOOTLOADER_PART_SIZE))
 952 +		# bump the partnum to account for additional PReP partition
 953 +		PRIMARY_START=$(($PRIMARY_START+$_BOOTLOADER_PART_SIZE))
 954 +		PRIMARY_END=$(($PRIMARY_END+$_BOOTLOADER_PART_SIZE))
 955 +		PERSIST_START=$(($PERSIST_START+$_BOOTLOADER_PART_SIZE))
 956 +		PRIMARY_PARTNUM=2
 957 +		PERSIST_PARTNUM=3
 958 +		;;
 959 +	amd64|i386)
 960 +		# Need to add BIOS boot partition or ESP
 961 +		HDD_EXTRA_SIZE=$(($_BOOTLOADER_PART_SIZE))
 962 +		# bump the partnum to account for additional BIOS boot partition
 963 +		PRIMARY_START=$(($PRIMARY_START+$_BOOTLOADER_PART_SIZE))
 964 +		PRIMARY_END=$(($PRIMARY_END+$_BOOTLOADER_PART_SIZE))
 965 +		PERSIST_START=$(($PERSIST_START+$_BOOTLOADER_PART_SIZE))
 966 +		PRIMARY_PARTNUM=2
 967 +		PERSIST_PARTNUM=3
 968 +		;;
 969 +	*)
 970 +		HDD_EXTRA_SIZE=0
 971 +		;;
 972 +esac
 973 +
 974 +# align the sizes
 975 +
 976 +# an additional 2M is appended to the HDD size to compensate for overhead
 977 +REAL_HDD_SIZE=$(($IMAGE_SIZE+$REAL_START+$HDD_EXTRA_SIZE+$HDD_BUFFER))
 978 +Echo_message "The Image size being built is ${REAL_HDD_SIZE} MB, which is determined by LB_HDD_SIZE (or default minimum of ${ORIG_REAL_DIM} MB), the MBR plus some alignment space of ${MBR_SPACE} MB and any automatic persistent storage and any additional extra size of ${HDD_EXTRA_SIZE} MB (which is the architecture specific bootloader space) and a small additional little buffer of ${HDD_BUFFER} MB for other overhead."
 979 +
 980 +dd if=/dev/zero of=chroot/binary.img bs=1024k count=0 seek=${REAL_HDD_SIZE}
 981 +FREELO="$(${LB_LOSETUP} -f)"
 982 +
 983 +losetup ${FREELO} chroot/binary.img
 984  
 985  case "${LB_BINARY_FILESYSTEM}" in
 986  	ext2|ext3|ext4)
 987 @@ -175,74 +393,140 @@ case "${LB_BINARY_FILESYSTEM}" in
 988  		;;
 989  
 990  	*)
 991 -		Echo_error "Unsupported binary filesystem %s" "${LB_BINARY_FILESYSTEM}"
 992 +		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} in binary_hdd."
 993  		exit 1
 994  		;;
 995  esac
 996  
 997 -case "${LB_BUILD_WITH_CHROOT}" in
 998 -	true)
 999 -		Chroot chroot "parted -s ${FREELO} mklabel ${PARTITION_TABLE_TYPE}" || true
1000 -		if [ "x${LB_HDD_PARTITION_START}" = "x" ];
1001 -		then
1002 -			Chroot chroot "parted -a optimal -s ${FREELO} mkpart primary\
1003 -				${PARTITION_TYPE} 0% 100%" || true
1004 -		else
1005 -			Echo_message "using partition start at ${LB_HDD_PARTITION_START}"
1006 -			Chroot chroot "parted -s ${FREELO} mkpart primary ${PARTITION_TYPE}\
1007 -				${LB_HDD_PARTITION_START} 100%" || true
1008 -		fi
1009 -		Chroot chroot "parted -s ${FREELO} set 1 boot on" || true
1010 -		Chroot chroot "parted -s ${FREELO} set 1 lba off" || true
1011 +sgdisk -Z ${FREELO}
1012 +sgdisk -o ${FREELO}
1013  
1014 -		if [ "${LB_FIRST_BOOTLOADER}" = "syslinux" ]
1015 -		then
1016 -			dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
1017 -		fi
1018 -		;;
1019 -
1020 -	false)
1021 -		parted -s ${FREELO} mklabel ${PARTITION_TABLE_TYPE} || true
1022 -		if [ "x${LB_HDD_PARTITION_START}" = "x" ];
1023 -		then
1024 -			parted -a optimal -s ${FREELO} mkpart primary ${PARTITION_TYPE}\
1025 -				0% 100% || true
1026 -		else
1027 -			Echo_message "using partition start at ${LB_HDD_PARTITION_START}"
1028 -			parted -s ${FREELO} mkpart primary ${PARTITION_TYPE}\
1029 -				${LB_HDD_PARTITION_START} 100% || true
1030 -		fi
1031 -		parted -s "${FREELO}" set 1 boot on || true
1032 -		parted -s "${FREELO}" set 1 lba off || true
1033 +# Prime the conversion partnums, we build the string
1034 +CONVERT_PARTNUMS="1"
1035  
1036 -		if [ "${LB_FIRST_BOOTLOADER}" = "syslinux" ]
1037 -		then
1038 -			dd if=/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
1039 -		fi
1040 +case "${LB_ARCHITECTURES}" in
1041 +	ppc64el)
1042 +		# First partition for PReP install
1043 +		sgdisk  -n ${PREP_PARTNUM}:${BOOTLOADER_START}M:+${_BOOTLOADER_PART_SIZE}M \
1044 +			-t ${PREP_PARTNUM}:4100 -c ${PREP_PARTNUM}:"PowerPC PReP boot" ${FREELO}
1045 +		CONVERT_PARTNUMS="1:2"
1046 +		;;
1047 +	amd64|i386)
1048 +		case "${_TARGET_FORMAT}" in
1049 +			esp)
1050 +		# First partition for bootloader install
1051 +		# This is for future use to help to allow customization post-build, this could be changed to ESP and extra HDD size added to manually customize
1052 +		sgdisk -n ${BOOTLOADER_DEVICE_PARTNUM}:${BOOTLOADER_START}M:+${_BOOTLOADER_PART_SIZE}M -t ${BOOTLOADER_DEVICE_PARTNUM}:EF00 -c ${BOOTLOADER_DEVICE_PARTNUM}:"ESP  boot partition" ${FREELO}
1053 +		CONVERT_PARTNUMS="1:2"
1054 +
1055 +				;;
1056 +			*)
1057 +		# First partition for bootloader install
1058 +		# This is for future use to help to allow customization post-build, this could be changed to ESP and extra HDD size added to manually customize
1059 +		sgdisk -n ${BOOTLOADER_DEVICE_PARTNUM}:${BOOTLOADER_START}M:+${_BOOTLOADER_PART_SIZE}M -t ${BOOTLOADER_DEVICE_PARTNUM}:EF02 -c ${BOOTLOADER_DEVICE_PARTNUM}:"BIOS boot partition" ${FREELO}
1060 +		CONVERT_PARTNUMS="1:2"
1061 +				;;
1062 +		esac
1063 +		;;
1064 +	*)
1065 +		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported in binary_hdd.  Check your setup for a supported type."
1066 +		exit 1
1067  		;;
1068  esac
1069  
1070 -Lodetach ${FREELO}
1071 +sgdisk -n ${PRIMARY_PARTNUM}:${PRIMARY_START}M:+${PRIMARY_SIZE}M -t ${PRIMARY_PARTNUM}:8300 -c ${PRIMARY_PARTNUM}:"Linux filesystem" ${FREELO}
1072 +
1073 +if [ "$MAKE_PERSIST" = "true" ]
1074 +then
1075 +	# Keeping architectures unique cases for now, may collapse in future
1076 +	case "${LB_ARCHITECTURES}" in
1077 +		amd64|i386)
1078 +			CONVERT_PARTNUMS="1:2:3"
1079 +			;;
1080 +		ppc64el)
1081 +			CONVERT_PARTNUMS="1:2:3"
1082 +			;;
1083 +	esac
1084 +	sgdisk  -n ${PERSIST_PARTNUM}:${PERSIST_START}M:+${PERSIST_SIZE}M \
1085 +		-t ${PERSIST_PARTNUM}:8300 \
1086 +		-c ${PERSIST_PARTNUM}:"Linux filesystem" ${FREELO}
1087 +	_PART_NUMS=3
1088 +else
1089 +	_PART_NUMS=2
1090 +fi
1091 +
1092 +if [ "$_GPT" = "false" ]
1093 +then
1094 +			if [ "$_PART_NUMS" -le "$_MAX_PART_NUMS" ]
1095 +			then
1096 +				sgdisk -m ${CONVERT_PARTNUMS} ${FREELO}
1097 +				case "${LB_ARCHITECTURES}" in
1098 +					ppc64el)
1099 +						MBR_PART_NUM_BOOT_FLAG=1
1100 +						;;
1101 +					*)
1102 +						MBR_PART_NUM_BOOT_FLAG=$PRIMARY_PARTNUM
1103 +						;;
1104 +				esac
1105 +				parted -s ${FREELO} set ${MBR_PART_NUM_BOOT_FLAG} boot on
1106 +				Echo_message "binary_hdd setting MBR boot flag for partition number ${MBR_PART_NUM_BOOT_FLAG} (any EF00 or EF02 type partitions will be reflected as EF type in \"msdos\" partition layout."
1107 +			else
1108 +				Echo_error "Architecture of ${LB_ARCHITECTURES} with LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} and LB_HDD_PARTITION_TABLE_TYPE of ${LB_HDD_PARTITION_TABLE_TYPE} has reached its maximum number of partitions.  You can check LB_HDD_PARTITION_TABLE_TYPE and set it to \"auto\" or \"gpt\" or try setting LB_PERSIST to \"noauto\" in config/binary to remove a partition (however you will lose the persistence feature if LB_PERSIST is set to \"noauto\")."
1109 +				exit 1
1110 +			fi
1111 +else # _GPT = "true"
1112 +	case "${LB_BINARY_FILESYSTEM}" in
1113 +		ext2|ext3|ext4)
1114 +			case "${LB_ARCHITECTURES}" in
1115 +				amd64|i386)
1116 +					sgdisk --attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}
1117 +					# set bit 2 attribute (legacy BIOS bootable)
1118 +					Echo_message "binary_hdd setting PRIMARY_PARTNUM to active (--attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}"
1119 +					;;
1120 +			esac
1121 +			;;
1122 +		*)
1123 +			Echo_warning "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} with use of GPT Partition Table Type (LB_HDD_PARTITION_TABLE_TYPE of \"${LB_HDD_PARTITION_TABLE_TYPE}\" from config/binary in binary_hdd, we will use LB_BINARY_FILESYSTEM of \"ext2\"."
1124 +			OLD_BINARY_FILESYSTEM=$LB_BINARY_FILESYSTEM
1125 +			LB_BINARY_FILESYSTEM="ext2"
1126 +                        Echo_warning "LB_BINARY_FILESYSTEM is being updated to ${LB_BINARY_FILESYSTEM} (from ${OLD_BINARY_FILESYSTEM}) since the LB_HDD_PARTITION_TABLE_TYPE is being automatically determined (LB_HDD_PARTITION_TABLE_TYPE is \"${LB_HDD_PARTITION_TABLE_TYPE}\").  If this is not desired, please update LB_HDD_PARTITION_TABLE_TYPE to the desired value."
1127 +			case "${LB_ARCHITECTURES}" in
1128 +				amd64|i386)
1129 +					sgdisk --attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}
1130 +					# set bit 2 attribute (legacy BIOS bootable)
1131 +					Echo_message "binary_hdd setting PRIMARY_PARTNUM to active (--attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}"
1132 +					;;
1133 +			esac
1134 +			;;
1135 +	esac
1136 +	Echo_message "binary_hdd using GPT for creation of LB_HDD_PARTITION_TABLE_TYPE of \"${LB_HDD_PARTITION_TABLE_TYPE}\"."
1137 +fi
1138 +
1139 +losetup -d ${FREELO}
1140 +Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1141 +sleep $LB_SLEEP_INTERVAL
1142  
1143  FREELO="$(${LB_LOSETUP} -f)"
1144 -Losetup $FREELO chroot/binary.img 1
1145 +losetup -P ${FREELO} chroot/binary.img
1146 +Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1147 +sleep $LB_SLEEP_INTERVAL
1148  
1149  case "${LB_BINARY_FILESYSTEM}" in
1150  	ext2|ext3|ext4)
1151  		MKFS="${LB_BINARY_FILESYSTEM}"
1152 -		MKFS_OPTIONS="-L ${LB_HDD_LABEL} -m 0 -O ^64bit"
1153 +		MKFS_OPTIONS="-b 4096 -L ${LB_HDD_LABEL}"
1154  		MOUNT_OPTIONS=""
1155  		;;
1156  
1157  	fat16)
1158  		MKFS="vfat"
1159 -		MKFS_OPTIONS="-F 16 -n ${LB_HDD_LABEL}"
1160 +		MKFS_OPTIONS="-F 16 -I -n ${LB_HDD_LABEL}"
1161  		MOUNT_OPTIONS=""
1162  		;;
1163  
1164  	fat32)
1165  		MKFS="vfat"
1166 -		MKFS_OPTIONS="-F 32 -n ${LB_HDD_LABEL}"
1167 +		MKFS_OPTIONS="-F 32 -I -n ${LB_HDD_LABEL}"
1168  		MOUNT_OPTIONS=""
1169  		;;
1170  
1171 @@ -253,15 +537,18 @@ case "${LB_BINARY_FILESYSTEM}" in
1172  		;;
1173  esac
1174  
1175 -case "${LB_BUILD_WITH_CHROOT}" in
1176 -	true)
1177 -		Chroot chroot "mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}"
1178 -		;;
1179 +mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}p${PRIMARY_PARTNUM}
1180 +Echo_message "binary_hdd mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}p${PRIMARY_PARTNUM}"
1181  
1182 -	false)
1183 -		mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}
1184 -		;;
1185 -esac
1186 +Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1187 +sleep $LB_SLEEP_INTERVAL
1188 +Echo_message "Copying binary contents into Image..."
1189 +
1190 +mkdir -p chroot/binary.tmp
1191 +mount ${MOUNT_OPTIONS} ${FREELO}p${PRIMARY_PARTNUM} chroot/binary.tmp
1192 +
1193 +Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1194 +sleep $LB_SLEEP_INTERVAL
1195  
1196  case "${LB_BINARY_FILESYSTEM}" in
1197  	fat*)
1198 @@ -273,78 +560,136 @@ case "${LB_BINARY_FILESYSTEM}" in
1199  		;;
1200  esac
1201  
1202 -Echo_message "Copying binary contents into image..."
1203 -
1204 -mkdir -p chroot/binary.tmp
1205 -mount ${MOUNT_OPTIONS} ${FREELO} chroot/binary.tmp
1206  cp -T ${CP_OPTIONS} binary/ chroot/binary.tmp
1207  
1208 -FIXME()
1209 -{
1210 -if [ "${LB_FIRST_BOOTLOADER}" = "grub" ]
1211 -then
1212 -
1213 -cat > chroot/grub.sh << EOF
1214 -cd binary.tmp
1215 -grub --batch << EOM
1216 -find /live/vmlinuz
1217 -EOM
1218 -EOF
1219 -
1220 -	rootpartition="$(Chroot chroot 'sh grub.sh' 2>/dev/null | grep -A 1 'find /live/vmlinuz' | grep -v 'find /live/vmlinuz')"
1221 -	hdddev="$(echo $rootpartition | sed -e 's|,[[:digit:]]||')"
1222 -	echo "Root partition is $rootpartition, device is: $hdddev"
1223 -
1224 -	echo "WAITING..." && read WAIT
1225 -
1226 -#cat > chroot/grub.sh << EOF
1227 -#grub --batch << EOM
1228 -#root $rootpartition
1229 -#setup $hdddev
1230 -#EOM
1231 -#EOF
1232 -
1233 -#Chroot chroot "sh grub.sh"
1234 -
1235 -	rm -f chroot/grub.sh
1236 -fi
1237 -}
1238 +Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1239 +sleep $LB_SLEEP_INTERVAL
1240  
1241  case "${_BOOTLOADER}" in
1242  	syslinux)
1243 -		_SYSLINUX_INSTALLER="syslinux ${FREELO}"
1244 +		_SYSLINUX_INSTALLER="syslinux ${FREELO}p${PRIMARY_PARTNUM}"
1245  		;;
1246  	extlinux)
1247 -		_SYSLINUX_INSTALLER="extlinux --install /binary.tmp/boot/extlinux"
1248 +		_SYSLINUX_INSTALLER="extlinux --install chroot/binary.tmp/boot/extlinux"
1249  		;;
1250  	*)
1251  		_SYSLINUX_INSTALLER=""
1252  		;;
1253  esac
1254  
1255 -if [ -n "${_SYSLINUX_INSTALLER}" ]
1256 -then
1257 -	case "${LB_BUILD_WITH_CHROOT}" in
1258 -		true)
1259 -			Chroot chroot "${_SYSLINUX_INSTALLER}"
1260 -			;;
1261 -		false)
1262 -			${_SYSLINUX_INSTALLER}
1263 -			;;
1264 -	esac
1265 -fi
1266 +case "${LB_ARCHITECTURES}" in
1267 +	ppc64el)
1268 +		grub-install --no-nvram --no-floppy --boot-directory=chroot/binary.tmp/boot ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM}
1269 +		Echo_message "binary_hdd is using the default LB_BOOTLOADER_PARTITION_TYPE of \"PReP\" for architecture of \"${LB_ARCHITECTURES}\" (the value specified in LB_BOOTLOADER_PARTITION_TYPE is \"${LB_BOOTLOADER_PARTITION_TYPE}\" in config/binary)."
1270 +		;;
1271 +	amd64|i386)
1272 +		case "${LB_FIRST_BOOTLOADER}" in
1273 +			syslinux)
1274 +				if [ "${_GPT}" = "false" ]
1275 +				then
1276 +					dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
1277 +				else
1278 +					dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/gptmbr.bin of=${FREELO} conv=notrunc bs=440 count=1
1279 +				fi
1280 +
1281 +				if [ -n "${_SYSLINUX_INSTALLER}" ]
1282 +				then
1283 +					${_SYSLINUX_INSTALLER}
1284 +					Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1285 +					sleep $LB_SLEEP_INTERVAL
1286 +				fi
1287 +				Echo_message "binary_hdd is using the default LB_HDD_PARTITION_TABLE_TYPE of \"msdos\".  If this is not the desired layout, changing the LB_BOOTLOADERS to \"grub-efi\" will allow flexibility on LB_BOOTLOADER_PARTITION_TYPE (currently specified as \"${LB_BOOTLOADER_PARTITION_TYPE}\" in config/binary)."
1288 +				;;
1289 +			grub-efi)
1290 +				case "${_TARGET_FORMAT}" in
1291 +					esp)
1292 +						if [ -n "${LB_HDD_LABEL}" ]
1293 +						then
1294 +							_ESP_LABEL=$LB_HDD_LABEL
1295 +						else
1296 +							_ESP_LABEL="LB-ESP"
1297 +						fi
1298 +						mkdir -p chroot/binary.esp
1299 +						mkfs.vfat -F 32 -I -n ${_ESP_LABEL} ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM}
1300 +						Echo_message "binary_hdd mkfs.vfat -F 32 -I -n ${_ESP_LABEL} ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM}"
1301 +						mount ${MOUNT_OPTIONS} ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM} chroot/binary.esp
1302 +						mkdir -p chroot/binary.esp/EFI/BOOT
1303 +						mkdir -p chroot/binary.esp/EFI/${_ESP_LABEL}
1304 +						# first copy the default efi's, these get picked up by EFI to boot if nothing found, so a failsafe
1305 +						cp chroot/binary.tmp/boot/grub/x86_64-efi/x86_64-efi.efi chroot/binary.esp/EFI/BOOT/BOOTX64.EFI
1306 +						cp chroot/binary.tmp/boot/grub/i386-efi/i386-efi.efi chroot/binary.esp/EFI/BOOT/BOOTIA32.EFI
1307 +						# next copy the distribution specific efi's (similar content, see efi-image for prefix differences)
1308 +						cp chroot/binary.tmp/boot/grub/x86_64-efi/x86_64-efi.efi-grub chroot/binary.esp/EFI/${_ESP_LABEL}/grubx64.efi
1309 +						cp chroot/binary.tmp/boot/grub/i386-efi/i386-efi.efi-grub chroot/binary.esp/EFI/${_ESP_LABEL}/grubia32.efi
1310 +						# No need to do a grub-install on ESP, and this can be destructive if run from a UEFI Host
1311 +						# grub-install with efi-directory still runs efibootmgr which is executing on the build Host, not in the chroot
1312 +						# efibootmgr will then delete and create a registry entry on EFI which will update the WRONG target
1313 +						# grub-install on efi should allow a by-pass to NOT update the EFI registry
1314 +						#grub-install --no-floppy --efi-directory=chroot/binary.esp/boot/efi
1315 +						#--directory=chroot/binary.tmp/boot/grub/x86_64-efi --boot-directory=chroot/binary.tmp/boot ${FREELO} -v
1316 +						#grub-install --no-floppy --directory=chroot/binary.tmp/boot/grub/i386-efi --boot-directory=chroot/binary.tmp/boot ${FREELO} -v
1317 +						umount chroot/binary.esp
1318 +						rmdir chroot/binary.esp
1319 +						;;
1320 +					*)
1321 +						# --debug-image=all
1322 +						#grub-install --no-floppy --target=i386pc --directory=chroot/usr/lib/grub/i386-pc --boot-directory=chroot/binary.tmp/boot ${FREELO} -v
1323 +						grub-bios-setup --verbose --directory=chroot/binary.tmp/boot/grub/i386-pc ${FREELO} -v
1324 +						;;
1325 +				esac
1326 +				;;
1327 +		esac
1328  
1329 +		;;
1330 +esac
1331 +
1332 +Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1333 +sleep $LB_SLEEP_INTERVAL
1334  umount chroot/binary.tmp
1335  rmdir chroot/binary.tmp
1336  
1337 -Lodetach ${FREELO}
1338 -
1339 -echo "!!! The above error/warning messages can be ignored !!!"
1340 +losetup -d ${FREELO}
1341  
1342 -if [ -n "${MAKEDEV}" ]
1343 +if [ "$MAKE_PERSIST" = "true" ]
1344  then
1345 -	rm -rf chroot/dev
1346 -	mv chroot/dev.tmp chroot/dev
1347 +# these steps are done without chroot since devmapper is needed
1348 +		FREELO_PERSIST="$(${LB_LOSETUP} -f)"
1349 +		# expect kpartx to pick up next free loop device
1350 +		kpartx -a -v chroot/binary.img
1351 +		# take the /dev/loopX and strip off the loopX to use in the devmapper
1352 +		LOOP_STRING="$(echo "${FREELO_PERSIST}" | rev | cut -d"/" -f1 | rev)"
1353 +		# sleep to wait for dev mapper to finish
1354 +		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1355 +		sleep ${LB_SLEEP_INTERVAL}
1356 +
1357 +		mkfs.ext4 -b 4096 -L persistence /dev/mapper/${LOOP_STRING}p${PERSIST_PARTNUM}
1358 +		Echo_message "binary_hdd mkfs.ext4 -b 4096 -L persistence /dev/mapper/${LOOP_STRING}p${PERSIST_PARTNUM}"
1359 +		# We need to make this ext4 to use -L and not sure what type came in
1360 +
1361 +		# sleep to wait for mkfs to finish
1362 +		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1363 +		sleep ${LB_SLEEP_INTERVAL}
1364 +
1365 +		mkdir -p chroot/binary_persist.tmp
1366 +		# expect to use partition 2 for persistence
1367 +		mount /dev/mapper/${LOOP_STRING}p${PERSIST_PARTNUM} chroot/binary_persist.tmp
1368 +		# sleep to wait for mounts
1369 +		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1370 +		sleep ${LB_SLEEP_INTERVAL}
1371 +
1372 +		echo "/ union" > chroot/binary_persist.tmp/persistence.conf
1373 +		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1374 +		sleep ${LB_SLEEP_INTERVAL}
1375 +
1376 +		umount chroot/binary_persist.tmp
1377 +		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1378 +		sleep ${LB_SLEEP_INTERVAL}
1379 +
1380 +		kpartx -d -v chroot/binary.img
1381 +		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
1382 +		sleep ${LB_SLEEP_INTERVAL}
1383 +
1384 +		rmdir chroot/binary_persist.tmp
1385  fi
1386  
1387  mv chroot/binary.img ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.img
1388 diff --git a/scripts/build/binary_iso b/scripts/build/binary_iso
1389 index 6ddb9dd..25b6244 100755
1390 --- a/scripts/build/binary_iso
1391 +++ b/scripts/build/binary_iso
1392 @@ -2,6 +2,7 @@
1393  
1394  ## live-build(7) - System Build Scripts
1395  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
1396 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
1397  ##
1398  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
1399  ## This is free software, and you are welcome to redistribute it
1400 @@ -30,7 +31,17 @@ case "${LIVE_IMAGE_TYPE}" in
1401  		;;
1402  
1403  	iso-hybrid)
1404 -		IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.hybrid.iso"
1405 +		case "${LB_ARCHITECTURES}" in
1406 +			ppc64el)
1407 +				Echo_warning "Architecture of ${LB_ARCHITECTURES} is not supported for LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE}, using type of iso."
1408 +				LIVE_IMAGE_TYPE=iso
1409 +				IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.iso"
1410 +				;;
1411 +			*)
1412 +				IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.hybrid.iso"
1413 +				;;
1414 +		esac
1415 +
1416  		;;
1417  
1418  	*)
1419 @@ -120,65 +131,77 @@ do
1420  
1421  	# If the bootloader number is greater or equal than 2 it means
1422  	# we are not the first bootloader and thus we need to tell
1423 -	# mkisosfs to add an additional eltorito entry
1424 -	if [ ${BOOTLOADER_NUMBER} -ge 2 ]
1425 -	then
1426 -		XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot "
1427 -	fi
1428 -	case "${BOOTLOADER}" in
1429 -		grub)
1430 -			XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
1431 -			XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
1432 -			XORRISO_EXCLUDE="boot/grub/stage2_eltorito"
1433 -			;;
1434 +	# mkisosfs to add an additional eltorito entry for some platforms
1435  
1436 -		grub-pc)
1437 -			XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
1438 -			XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito -J"
1439 -			XORRISO_EXCLUDE="boot/grub/grub_eltorito"
1440 -			;;
1441 -
1442 -		syslinux)
1443 -			case "${LB_MODE}" in
1444 -				progress-linux)
1445 -					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/boot.bin -c boot/boot.cat"
1446 -					XORRISO_EXCLUDE="boot/boot.bin"
1447 +	case "${LB_ARCHITECTURES}" in
1448 +		ppc64el)
1449 +			case "${BOOTLOADER}" in
1450 +				grub-efi)
1451 +					XORRISO_OPTIONS="${XORRISO_OPTIONS} -chrp-boot-part"
1452  					;;
1453 -
1454  				*)
1455 -					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat"
1456 -					XORRISO_EXCLUDE="isolinux/isolinux.bin"
1457 +					Echo_error "Architecture of ${LB_ARCHITECTURES} does not support BOOTLOADER of ${BOOTLOADER} in LB_BOOTLOADERS of binary_iso."
1458 +					exit 1
1459  					;;
1460  			esac
1461  
1462 -			XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
1463  			;;
1464 -
1465 -		grub-efi)
1466 -			if [ -e binary/boot/grub/efi.img ]
1467 +		*)
1468 +			if [ ${BOOTLOADER_NUMBER} -ge 2 ]
1469  			then
1470 -				XORRISO_OPTIONS="${XORRISO_OPTIONS} -e boot/grub/efi.img -no-emul-boot"
1471 -				XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-gpt-basdat -isohybrid-apm-hfsplus"
1472 -			else
1473 -				Echo "No EFI boot code to include in the ISO"
1474 +				XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot "
1475  			fi
1476 -			;;
1477 +			case "${BOOTLOADER}" in
1478 +				grub)
1479 +					XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
1480 +					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
1481 +					XORRISO_EXCLUDE="boot/grub/stage2_eltorito"
1482 +					;;
1483  
1484 -		*)
1485 -			Echo_warning "Bootloader on your architecture not yet supported by live-build."
1486 -			Echo_warning "This will produce a most likely not bootable image (Continuing in 5 seconds)."
1487 -			sleep 5
1488 +				grub-pc)
1489 +					XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
1490 +					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito -J"
1491 +					XORRISO_EXCLUDE="boot/grub/grub_eltorito"
1492 +					;;
1493 +
1494 +				syslinux)
1495 +					case "${LB_MODE}" in
1496 +						progress-linux)
1497 +							XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/boot.bin -c boot/boot.cat"
1498 +							XORRISO_EXCLUDE="boot/boot.bin"
1499 +							;;
1500 +
1501 +						*)
1502 +							XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat"
1503 +							XORRISO_EXCLUDE="isolinux/isolinux.bin"
1504 +							;;
1505 +					esac
1506 +
1507 +					XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
1508 +					;;
1509 +
1510 +				grub-efi)
1511 +					if [ -e binary/boot/grub/efi.img ]
1512 +					then
1513 +						XORRISO_OPTIONS="${XORRISO_OPTIONS} -e boot/grub/efi.img -no-emul-boot"
1514 +						XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-gpt-basdat -isohybrid-apm-hfsplus"
1515 +					else
1516 +						Echo_warning "No EFI boot code to include in the ISO"
1517 +					fi
1518 +					;;
1519 +
1520 +				*)
1521 +					Echo_error "Architecture of ${LB_ARCHITECTURES} does not support BOOTLOADER of ${BOOTLOADER} in LB_BOOTLOADERS."
1522 +					Echo_error "Try a minimum for LB_BOOTLOADERS of syslinux (use a comma separated list if needed)."
1523 +					exit 1
1524 +					;;
1525 +			esac
1526  			;;
1527  	esac
1528  
1529  done
1530  IFS="$OLDIFS"
1531  
1532 -#if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
1533 -#then
1534 -#	XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
1535 -#fi
1536 -
1537  if [ "${LB_FIRST_BOOTLOADER}" = "grub-pc" ]
1538  then
1539  
1540 @@ -218,6 +241,8 @@ echo "xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary" > binary/.disk/
1541  xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary
1542  EOF
1543  
1544 +Echo_message "XORRISO_OPTIONS being used are ${XORRISO_OPTIONS} for LB_BOOTLOADERS of ${LB_BOOTLOADERS} in binary_iso."
1545 +
1546  case "${LB_BUILD_WITH_CHROOT}" in
1547  	true)
1548  		# Moving image
1549 diff --git a/scripts/build/binary_linux-image b/scripts/build/binary_linux-image
1550 index 6227a24..f13cc52 100755
1551 --- a/scripts/build/binary_linux-image
1552 +++ b/scripts/build/binary_linux-image
1553 @@ -2,6 +2,7 @@
1554  
1555  ## live-build(7) - System Build Scripts
1556  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
1557 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
1558  ##
1559  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
1560  ## This is free software, and you are welcome to redistribute it
1561 @@ -54,7 +55,7 @@ case "${LB_INITRAMFS}" in
1562  esac
1563  
1564  case "${LB_ARCHITECTURES}" in
1565 -	powerpc)
1566 +	powerpc|ppc64el)
1567  		LINUX="vmlinux"
1568  		;;
1569  
1570 diff --git a/scripts/build/binary_loopback_cfg b/scripts/build/binary_loopback_cfg
1571 index 00f537c..07bf122 100755
1572 --- a/scripts/build/binary_loopback_cfg
1573 +++ b/scripts/build/binary_loopback_cfg
1574 @@ -2,6 +2,7 @@
1575  
1576  ## live-build(7) - System Build Scripts
1577  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
1578 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
1579  ##
1580  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
1581  ## This is free software, and you are welcome to redistribute it
1582 @@ -43,9 +44,22 @@ Check_lockfile .lock
1583  Create_lockfile .lock
1584  
1585  # Check architecture
1586 -Check_architectures amd64 i386
1587 +Check_architectures amd64 i386 ppc64el
1588  Check_crossarchitectures
1589  
1590 +# Checking depends
1591 +case "${LB_ARCHITECTURES}" in
1592 +	ppc64el)
1593 +		Check_package host /usr/share/live/build/templates/grub2/grub.cfg live-build
1594 +		;;
1595 +	amd64|i386)
1596 +		Check_package host /usr/share/live/build/templates/grub2/grub.cfg live-build
1597 +		;;
1598 +	*)
1599 +		Echo_warning "Architecture of ${LB_ARCHITECTURES} may need Host packages installed to support LB_BOOTLOADERS of ${LB_BOOTLOADERS}."
1600 +		;;
1601 +esac
1602 +
1603  # Variable used to embed newlines
1604  NL="
1605  "
1606 @@ -130,17 +144,32 @@ menuentry "$LB_MEMTEST" {
1607  END
1608  }
1609  
1610 -if [ -e "config/bootloaders/grub-pc" ]
1611 +case  "${LB_FIRST_BOOTLOADER}" in
1612 +	grub-pc)
1613 +		# binary_syslinux sets other custom bootloaders
1614 +		_BOOTLOADER=grub-pc
1615 +		# _PATH must be on the Host build machine, not in the chroot
1616 +		_PATH=/usr/share/live/build/bootloaders/
1617 +		;;
1618 +	*)
1619 +		# binary_syslinux sets other custom bootloaders
1620 +		# but we need to have some grub.cfg's to allow sed to work later
1621 +		_BOOTLOADER=grub2
1622 +		# _PATH must be on the Host build machine, not in the chroot
1623 +		_PATH=/usr/share/live/build/templates/
1624 +		;;
1625 +esac
1626 +
1627 +if [ -e "config/bootloaders/${_BOOTLOADER}" ]
1628  then
1629 -	# Internal local copy
1630 -	_SOURCE="config/bootloaders/grub-pc"
1631 +	# Use customizations provided
1632 +	_SOURCE="config/bootloaders/${_BOOTLOADER}"
1633  else
1634 -	# Internal system copy
1635  	if [ -n "${LIVE_BUILD}" ]
1636  	then
1637 -		_SOURCE="${LIVE_BUILD}/share/bootloaders/grub-pc"
1638 +		_SOURCE="${LIVE_BUILD}${_PATH}${_BOOTLOADER}"
1639  	else
1640 -		_SOURCE="/usr/share/live/build/bootloaders/grub-pc"
1641 +		_SOURCE="${_PATH}${_BOOTLOADER}"
1642  	fi
1643  fi
1644  
1645 @@ -154,6 +183,19 @@ case "${LB_INITRAMFS}" in
1646  		;;
1647  esac
1648  
1649 +case "${LB_ARCHITECTURES}" in
1650 +	amd64|i386)
1651 +		LINUX="vmlinuz"
1652 +		;;
1653 +	ppc64el)
1654 +		LINUX="vmlinux"
1655 +		;;
1656 +	*)
1657 +		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported in binary_loopback_cfg"
1658 +		exit 1
1659 +		;;
1660 +esac
1661 +
1662  Check_multiarchitectures
1663  
1664  # Setting boot parameters
1665 @@ -170,8 +212,8 @@ fi
1666  
1667  # Default entries
1668  DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
1669 -DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
1670 -DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
1671 +DEFAULT_KERNEL="$(basename chroot/boot/${LINUX}-*${DEFAULT_FLAVOUR})"
1672 +DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e "s|${LINUX}-||")"
1673  
1674  KERNEL_LIVE="/${INITFS}/${DEFAULT_KERNEL}"
1675  INITRD_LIVE="/${INITFS}/${DEFAULT_INITRD}"
1676 @@ -189,10 +231,10 @@ done
1677  
1678  if [ "${_AMD64_486_NUMBER}" -ge 2 ] ; then
1679  	# Default entries
1680 -	AMD64_KERNEL="$(basename chroot/boot/vmlinuz-*amd64)"
1681 -	AMD64_INITRD="initrd.img-$(echo ${AMD64_KERNEL} | sed -e 's|vmlinuz-||')"
1682 -	_486_KERNEL="$(basename chroot/boot/vmlinuz-*486)"
1683 -	_486_INITRD="initrd.img-$(echo ${_486_KERNEL} | sed -e 's|vmlinuz-||')"
1684 +	AMD64_KERNEL="$(basename chroot/boot/${LINUX}-*amd64)"
1685 +	AMD64_INITRD="initrd.img-$(echo ${AMD64_KERNEL} | sed -e "s|${LINUX}-||")"
1686 +	_486_KERNEL="$(basename chroot/boot/${LINUX}-*486)"
1687 +	_486_INITRD="initrd.img-$(echo ${_486_KERNEL} | sed -e "s|${LINUX}-||")"
1688  
1689  	Grub_live_autodetect_entry "Live system (autodetect)" \
1690  		"/${INITFS}/${AMD64_KERNEL}" \
1691 @@ -210,14 +252,14 @@ then
1692  fi
1693  
1694  _COUNT=0
1695 -for KERNEL in chroot/boot/vmlinuz-*; do
1696 +for KERNEL in chroot/boot/${LINUX}-*; do
1697  	_COUNT=$(( $COUNT + 1 ))
1698  done
1699  
1700  if [ $_COUNT -gt 1 ]; then
1701 -	for KERNEL in chroot/boot/vmlinuz-*
1702 +	for KERNEL in chroot/boot/${LINUX}-*
1703  	do
1704 -		VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')"
1705 +		VERSION="$(basename ${KERNEL} | sed -e "s|${LINUX}-||")"
1706  
1707  		Grub_live_entry "Live system, kernel ${VERSION}" "/${INITFS}/$(basename ${KERNEL})" "/${INITFS}/initrd.img-${VERSION}" "${APPEND_LIVE}"
1708  
1709 @@ -230,11 +272,11 @@ fi
1710  # Assembling debian-installer configuration
1711  if [ "${LB_DEBIAN_INSTALLER}" != "false" ]
1712  then
1713 -	KERNEL_DI="/install/vmlinuz"
1714 +	KERNEL_DI="/install/${LINUX}"
1715  	INITRD_DI="/install/initrd.gz"
1716  	APPEND_DI="vga=normal quiet ${LB_BOOTAPPEND_INSTALL}"
1717  
1718 -	KERNEL_GI="/install/gtk/vmlinuz"
1719 +	KERNEL_GI="/install/gtk/${LINUX}"
1720  	INITRD_GI="/install/gtk/initrd.gz"
1721  	APPEND_GI="video=vesa:ywrap,mtrr vga=788 quiet ${LB_BOOTAPPEND_INSTALL}"
1722  
1723 @@ -258,7 +300,7 @@ fi
1724  
1725  # Copying templates
1726  mkdir -p binary/boot/grub
1727 -cp -a "${_SOURCE}"/* binary/boot/grub/
1728 +cp -aL "${_SOURCE}"/* binary/boot/grub/
1729  
1730  escape_for_sed() {
1731      echo -n "$1" | perl -npe 's/\n/\\n/gm'
1732 diff --git a/scripts/build/binary_netboot b/scripts/build/binary_netboot
1733 index 7a94b4f..e244e22 100755
1734 --- a/scripts/build/binary_netboot
1735 +++ b/scripts/build/binary_netboot
1736 @@ -2,6 +2,7 @@
1737  
1738  ## live-build(7) - System Build Scripts
1739  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
1740 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
1741  ##
1742  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
1743  ## This is free software, and you are welcome to redistribute it
1744 @@ -48,6 +49,10 @@ Check_lockfile .lock
1745  # Creating lock file
1746  Create_lockfile .lock
1747  
1748 +# Check architectures
1749 +Check_architectures amd64 i386
1750 +Check_crossarchitectures
1751 +
1752  # Remove old binary
1753  rm -f ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.gz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.bz2 ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.xz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.xz
1754  
1755 diff --git a/scripts/build/binary_rootfs b/scripts/build/binary_rootfs
1756 index 6c797ac..a46c260 100755
1757 --- a/scripts/build/binary_rootfs
1758 +++ b/scripts/build/binary_rootfs
1759 @@ -2,6 +2,7 @@
1760  
1761  ## live-build(7) - System Build Scripts
1762  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
1763 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
1764  ##
1765  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
1766  ## This is free software, and you are welcome to redistribute it
1767 @@ -43,7 +44,7 @@ case "${LB_ARCHITECTURES}" in
1768  		LINUX="vmlinuz"
1769  		;;
1770  
1771 -	powerpc)
1772 +	powerpc|ppc64el)
1773  		LINUX="vmlinux"
1774  		;;
1775  esac
1776 diff --git a/scripts/build/binary_syslinux b/scripts/build/binary_syslinux
1777 index bb66588..1c50dae 100755
1778 --- a/scripts/build/binary_syslinux
1779 +++ b/scripts/build/binary_syslinux
1780 @@ -2,6 +2,7 @@
1781  
1782  ## live-build(7) - System Build Scripts
1783  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
1784 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
1785  ##
1786  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
1787  ## This is free software, and you are welcome to redistribute it
1788 @@ -41,9 +42,20 @@ Check_lockfile .lock
1789  Create_lockfile .lock
1790  
1791  # Check architecture
1792 -Check_architectures amd64 i386
1793 +# Need to include ppc64el in checks to stop processing if defined
1794 +Check_architectures amd64 i386 ppc64el
1795  Check_crossarchitectures
1796  
1797 +case "${LB_ARCHITECTURES}" in
1798 +	amd64|i386)
1799 +		LINUX="vmlinuz"
1800 +		;;
1801 +	*)
1802 +		Echo_error "Architecture ${LB_ARCHITECTURES} not supported in binary_syslinux (try LB_BOOTLOADERS of \"grub-efi\" in config/binary)."
1803 +		exit 1
1804 +		;;
1805 +esac
1806 +
1807  case "${LB_INITRAMFS}" in
1808  	*)
1809  		_INITRAMFS="live"
1810 @@ -99,6 +111,9 @@ case "${LIVE_IMAGE_TYPE}" in
1811  		;;
1812  esac
1813  
1814 +Check_package host /usr/lib/ISOLINUX/isolinux.bin  isolinux
1815 +
1816 +# Internal system copy
1817  if [ -e "config/bootloaders/${_BOOTLOADER}" ]
1818  then
1819  	# Internal local copy
1820 @@ -134,9 +149,9 @@ case "${LB_BUILD_WITH_CHROOT}" in
1821  		mkdir -p ${_TARGET}
1822  
1823  		# Copy in two steps since the theme can have absolute symlinks and would therefore not be dereferenced correctly
1824 -		cp -a ${_SOURCE} chroot/root
1825 +		cp -aL ${_SOURCE} chroot/root
1826  		Chroot chroot cp -aL /root/$(basename ${_SOURCE}) /root/$(basename ${_SOURCE}).tmp > /dev/null 2>&1 || true
1827 -		cp -a chroot/root/$(basename ${_SOURCE}).tmp/* ${_TARGET}
1828 +		cp -aL chroot/root/$(basename ${_SOURCE}).tmp/* ${_TARGET}
1829  		rm -rf chroot/root/$(basename ${_SOURCE}) chroot/root/$(basename ${_SOURCE}).tmp
1830  		;;
1831  
1832 @@ -157,11 +172,11 @@ then
1833  		1)
1834  			# If multiple initrd images are being generated (by DKMS packages, etc),
1835  			# we likely only want the latest version.
1836 -			ln $(ls -r1 --sort=version binary/${_INITRAMFS}/vmlinuz-* | head -n 1) binary/${_INITRAMFS}/vmlinuz
1837 +			ln $(ls -r1 --sort=version binary/${_INITRAMFS}/${LINUX}-* | head -n 1) binary/${_INITRAMFS}/${LINUX}
1838  			ln $(ls -r1 --sort=version binary/${_INITRAMFS}/initrd.img-* | head -n 1) binary/${_INITRAMFS}/initrd.img
1839  
1840  			sed -e "s|@FLAVOUR@|${LB_LINUX_FLAVOURS}|g" \
1841 -			    -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz|g" \
1842 +			    -e "s|@LINUX@|/${_INITRAMFS}/${LINUX}|g" \
1843  			    -e "s|@INITRD@|/${_INITRAMFS}/initrd.img|g" \
1844  			"${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
1845  
1846 @@ -175,7 +190,7 @@ then
1847  			do
1848  				_NUMBER="$((${_NUMBER} + 1))"
1849  
1850 -				ln binary/${_INITRAMFS}/vmlinuz-*-${_FLAVOUR} binary/${_INITRAMFS}/vmlinuz${_NUMBER}
1851 +				ln binary/${_INITRAMFS}/${LINUX}-*-${_FLAVOUR} binary/${_INITRAMFS}/${LINUX}${_NUMBER}
1852  				ln binary/${_INITRAMFS}/initrd.img-*-${_FLAVOUR} binary/${_INITRAMFS}/initrd${_NUMBER}.img
1853  
1854  				if [ "${_NUMBER}" -gt 1 ]
1855 @@ -187,7 +202,7 @@ then
1856  				fi
1857  
1858  				sed -i -e "s|@FLAVOUR@|${_FLAVOUR}|g" \
1859 -				       -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz${_NUMBER}|g" \
1860 +				       -e "s|@LINUX@|/${_INITRAMFS}/${LINUX}${_NUMBER}|g" \
1861  				       -e "s|@INITRD@|/${_INITRAMFS}/initrd${_NUMBER}.img|g" \
1862  				"${_TARGET}/live.cfg"
1863  			done
1864 @@ -215,7 +230,7 @@ _HOUR="$(date +%H)"
1865  _MINUTE="$(date +%M)"
1866  _SECOND="$(date +%S)"
1867  
1868 -_LINUX_VERSIONS="$(for _LINUX in chroot/boot/vmlinuz-* ; do chroot chroot apt-cache policy $(basename ${_LINUX} | sed -e 's|vmlinuz-|linux-image-|') | awk '/Installed: / { print $2 }' ; done | sort -Vru | tr "\n" " ")"
1869 +_LINUX_VERSIONS="$(for _LINUX in chroot/boot/${LINUX}-* ; do chroot chroot apt-cache policy $(basename ${_LINUX} | sed -e 's|${LINUX}-|linux-image-|') | awk '/Installed: / { print $2 }' ; done | sort -Vru | tr "\n" " ")"
1870  
1871  _LIVE_BUILD_VERSION="$(lb --version)"
1872  _LIVE_BOOT_VERSION="$(chroot chroot apt-cache policy live-boot | awk '/Installed: / { print $2 }')"
1873 diff --git a/scripts/build/config b/scripts/build/config
1874 index c692a92..83b9e9c 100755
1875 --- a/scripts/build/config
1876 +++ b/scripts/build/config
1877 @@ -2,6 +2,7 @@
1878  
1879  ## live-build(7) - System Build Scripts
1880  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
1881 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
1882  ##
1883  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
1884  ## This is free software, and you are welcome to redistribute it
1885 @@ -123,7 +124,12 @@ USAGE="${PROGRAM}   [--apt apt|aptitude]\n\
1886  \t    [--win32-loader true|false]\n\
1887  \t    [--bootstrap-qemu-exclude PACKAGES]\n\
1888  \t    [--bootstrap-qemu-static PATH]\n\
1889 -\t    [--bootstrap-qemu-arch ARCH]"
1890 +\t    [--bootstrap-qemu-arch ARCH]\n\
1891 +\t    [--persist auto|noauto|MB]\n\
1892 +\t    [--bootloader-part-size auto|noauto|MB]\n\
1893 +\t    [--hdd-part-type auto|msdos|gpt]\n\
1894 +\t    [--bootloader-part-type auto|bios_grub|esp|PReP]\n\
1895 +\t    [--lb-sleep-interval 1|seconds]"
1896  
1897  
1898  Local_arguments ()
1899 @@ -148,7 +154,7 @@ Local_arguments ()
1900  		net-cow-server:,net-tarball:,firmware-binary:,firmware-chroot:,swap-file-path:,swap-file-size:,
1901  		loadlin:,win32-loader:,source:,source-images:,breakpoints,conffile:,debug,force,
1902  		help,ignore-system-defaults,quiet,usage,verbose,version,bootstrap-qemu-static:,bootstrap-qemu-arch:,
1903 -		bootstrap-qemu-exclude:"
1904 +		bootstrap-qemu-exclude:,persist:,bootloader-part-size:,hdd-part-type:,bootloader-part-type:,lb-sleep-interval:"
1905  	# Remove spaces added by indentation
1906  	LONG_OPTIONS="$(echo ${LONG_OPTIONS} | tr -d ' ')"
1907  	ARGUMENTS="$(getopt --longoptions ${LONG_OPTIONS} --name="${PROGRAM}" --options a:f:d:m:l:k:p:b:e:s:c:huv --shell sh -- "${@}")"
1908 @@ -699,6 +705,31 @@ Local_arguments ()
1909  				shift 2
1910  				;;
1911  
1912 +			--persist)
1913 +				LB_PERSIST="${2}"
1914 +				shift 2
1915 +				;;
1916 +
1917 +			--bootloader-part-size)
1918 +				LB_BOOTLOADER_PARTITION_SIZE="${2}"
1919 +				shift 2
1920 +				;;
1921 +
1922 +			--hdd-part-type)
1923 +				LB_HDD_PARTITION_TABLE_TYPE="${2}"
1924 +				shift 2
1925 +				;;
1926 +
1927 +			--bootloader-part-type)
1928 +				LB_BOOTLOADER_PARTITION_TYPE="${2}"
1929 +				shift 2
1930 +				;;
1931 +
1932 +			--lb-sleep-interval)
1933 +				LB_SLEEP_INTERVAL="${2}"
1934 +				shift 2
1935 +				;;
1936 +
1937  			# config/source
1938  			--source)
1939  				LB_SOURCE="${2}"
1940 @@ -1145,6 +1176,9 @@ cat > config/binary << EOF
1941  
1942  # \$LB_BINARY_FILESYSTEM: set image filesystem
1943  # (Default: ${LB_BINARY_FILESYSTEM})
1944 +# If building an HDD image, consider the LB_HDD_PARTITION_TABLE_TYPE
1945 +# with this value.  If using auto on LB_HDD_PARTITION_TABLE_TYPE
1946 +# (which will use GPT) then this value needs to be ext2/ext3/ext4
1947  LB_BINARY_FILESYSTEM="${LB_BINARY_FILESYSTEM}"
1948  
1949  # \$LB_APT_INDICES: set apt/aptitude generic indices
1950 @@ -1160,11 +1194,17 @@ LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE}"
1951  LB_BOOTAPPEND_INSTALL="${LB_BOOTAPPEND_INSTALL}"
1952  
1953  # \$LB_BOOTAPPEND_LIVE_FAILSAFE: set boot parameters
1954 -# (Default: empty)
1955 +# Specify a value of "none" to not have this appear
1956 +# as an option on the boot screens
1957  LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE}"
1958  
1959  # \$LB_BOOTLOADERS: set bootloaders
1960  # (Default: ${LB_BOOTLOADERS})
1961 +# For x platforms most typical usage is syslinux.
1962 +# For ppc platforms most typical usage is grub-efi.
1963 +# x platforms can specify grub-efi which gives a grub2 configuration
1964 +# The build type of HDD needs to be defined in config/build to leverage
1965 +# the LB_BOOTLOADER_PARTITION_SIZE and LB_HDD_PARTITION_TABLE_TYPE
1966  LB_BOOTLOADERS="${LB_BOOTLOADERS}"
1967  
1968  # \$LB_CHECKSUMS: set checksums
1969 @@ -1210,12 +1250,39 @@ LB_HDD_LABEL="${LB_HDD_LABEL}"
1970  
1971  # \$LB_HDD_SIZE: set hdd filesystem size
1972  # (Default: ${LB_HDD_SIZE})
1973 +# Sizes defined in MB
1974  LB_HDD_SIZE="${LB_HDD_SIZE}"
1975  
1976 -# \$LB_HDD_PARTITION_START: set start of partition for the hdd target for BIOSes that expect a specific boot partition start (e.g. "63s"). If empty, use optimal layout.
1977 +# \$LB_HDD_PARTITION_START: set start of partition for the hdd image
1978 +# These values are defined in MB offsets, values are not absolute,
1979 +# alignments will be done, this is to allow the boot sector
1980 +# to be enlarged for example before any primary partitions
1981 +# are created on the hdd image
1982  # (Default: ${LB_HDD_PARTITION_START})
1983  LB_HDD_PARTITION_START="${LB_HDD_PARTITION_START}"
1984  
1985 +# \$LB_PERSIST: set persistence for hdd
1986 +# (Default: ${LB_PERSIST})
1987 +LB_PERSIST="${LB_PERSIST}"
1988 +
1989 +# \$LB_BOOTLOADER_PARTITION_SIZE: set the size for the bios_grub, esp, or PReP partition size
1990 +# These are usually small values in MB
1991 +# (Default: ${LB_BOOTLOADER_PARTITION_SIZE})
1992 +LB_BOOTLOADER_PARTITION_SIZE="${LB_BOOTLOADER_PARTITION_SIZE}"
1993 +
1994 +# \$LB_HDD_PARTITION_TABLE_TYPE: set the type of partition table schema: msdos or gpt
1995 +# (Default: ${LB_HDD_PARTITION_TABLE_TYPE})
1996 +LB_HDD_PARTITION_TABLE_TYPE="${LB_HDD_PARTITION_TABLE_TYPE}"
1997 +
1998 +# \$LB_BOOTLOADER_PARTITION_TYPE: set the type of the bootloader partition: bios_grub, esp or PReP
1999 +# (Default: ${LB_BOOTLOADER_PARTITION_TYPE})
2000 +LB_BOOTLOADER_PARTITION_TYPE="${LB_BOOTLOADER_PARTITION_TYPE}"
2001 +
2002 +# \$LB_SLEEP_INTERVAL: set the interval value used to sleep between internal operations
2003 +# This interval is for compensation for slower machines between read/write, mount operations
2004 +# (Default: ${LB_SLEEP_INTERVAL})
2005 +LB_SLEEP_INTERVAL="${LB_SLEEP_INTERVAL}"
2006 +
2007  # \$LB_ISO_APPLICATION: set iso author
2008  # (Default: ${LB_ISO_APPLICATION})
2009  LB_ISO_APPLICATION="${LB_ISO_APPLICATION}"
2010 diff --git a/scripts/build/efi-image b/scripts/build/efi-image
2011 index c372327..5bdb1ee 100755
2012 --- a/scripts/build/efi-image
2013 +++ b/scripts/build/efi-image
2014 @@ -3,6 +3,7 @@ set -e
2015  
2016  # Copyright (C) 2010, 2011 Canonical Ltd.
2017  # Author: Colin Watson <cjwatson@ubuntu.com>
2018 +# Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
2019  #
2020  # This program is free software; you can redistribute it and/or modify it
2021  # under the terms of the GNU General Public License as published by the Free
2022 @@ -28,59 +29,103 @@ fi
2023  outdir="$1"
2024  platform="$2"
2025  efi_name="$3"
2026 -netboot_prefix="$4"
2027 -
2028 -memdisk_img=
2029 -workdir=
2030 -
2031 -cleanup () {
2032 -	[ -z "$memdisk_img" ] || rm -f "$memdisk_img"
2033 -	[ -z "$workdir" ] || rm -rf "$workdir"
2034 -}
2035 -trap cleanup EXIT HUP INT QUIT TERM
2036 +image_name="$4"
2037  
2038  rm -rf "$outdir"
2039 -mkdir -p "$outdir"
2040 +mkdir -p "${outdir}/${platform}"
2041  
2042 -memdisk_img="$(mktemp efi-image.XXXXXX)"
2043 -workdir="$(mktemp -d efi-image.XXXXXX)"
2044 +case "${platform}" in
2045 +	power*)
2046  
2047 -# Skeleton configuration file which finds the real boot disk.
2048 -mkdir -p "$workdir/boot/grub"
2049 -cat >"$workdir/boot/grub/grub.cfg" <<EOF
2050 +cat >"${outdir}/${platform}/load.cfg" <<EOF
2051  search --file --set=root /.disk/info
2052  set prefix=(\$root)/boot/grub
2053 -source \$prefix/$platform/grub.cfg
2054  EOF
2055 +		grub-mkimage -O "${platform}" -p '()/boot/grub' \
2056 +			--verbose --config="$outdir/$platform/load.cfg" \
2057 +			-o "${outdir}/$efi_name.elf" normal iso9660 \
2058 +			search_fs_file search_fs_uuid search_label search \
2059 +			configfile normal memdisk tar tftp net iso9660 \
2060 +			part_msdos part_gpt msdospart fat ext2 \
2061 +			png jpeg tga all_video gfxterm gettext \
2062 +			video video_colors video_fb videoinfo videotest \
2063 +			gzio xzio probe loadenv \
2064 +			gfxmenu gfxterm_background gfxterm_menu \
2065 +			elf cat disk diskfilter ls cpio echo gfxterm_background
2066 +		;;
2067 +
2068 +	x86_64-efi|i386-efi|i386-pc)
2069  
2070 -mkdir -p "$outdir/boot/grub/$platform"
2071 -(for i in /usr/lib/grub/$platform/part_*.mod; do
2072 -    i=`echo $i | sed 's?^.*/??g;s?\.mod$??g;'`
2073 -	echo "insmod $i"
2074 - done; \
2075 - echo "source /boot/grub/grub.cfg") >"$outdir/boot/grub/$platform/grub.cfg"
2076 +cat >"${outdir}/${platform}/load.cfg" <<EOF
2077 +search --file --set=root /.disk/info
2078 +set prefix=(\$root)/boot/grub
2079 +EOF
2080 +		# This is running in the chroot, so copy it over to the outdir
2081  
2082 -# Build the core image.
2083 -(cd "$workdir"; tar -cf - boot) >"$memdisk_img"
2084 -grub-mkimage -O "$platform" -m "$memdisk_img" \
2085 -	-o "$workdir/boot$efi_name.efi" -p '(memdisk)/boot/grub' \
2086 -	search iso9660 configfile normal memdisk tar part_msdos part_gpt fat
2087 +		case "${platform}" in
2088 +			i386-pc)
2089 +				cp /usr/lib/grub/${platform}/boot.img ${outdir}/${platform}
2090 +				# load.cfg is built above to be embedded in the core.img
2091 +				# we use the chroot's /usr/lib/grub path since grub-install needs to use the images and modules from there
2092 +				grub-mkimage --verbose --config="$outdir/$platform/load.cfg" \
2093 +					--format="$platform" \
2094 +					--output="$outdir/$platform/$image_name" \
2095 +					--prefix=/boot/grub \
2096 +					--compression=auto \
2097 +					--directory="/usr/lib/grub/$platform" \
2098 +					search search_fs_file search_fs_uuid search_label \
2099 +					configfile normal memdisk tar tftp net iso9660 \
2100 +					biosdisk part_msdos part_gpt msdospart fat ext2 \
2101 +					pxe png jpeg tga all_video gfxterm gettext play \
2102 +					vbe vga vga_text video video_bochs \
2103 +					video_cirrus video_colors video_fb videoinfo \
2104 +					videotest gzio xzio usb terminfo probe loadenv \
2105 +					gdb gfxmenu gfxterm_background gfxterm_menu \
2106 +					elf cat ls boot cpio echo gfxterm_background
2107 +					;;
2108 +			x86_64-efi|i386-efi)
2109 +				# using this image with p='' for BOOTX64.EFI and BOOTIA32.EFI"
2110 +				grub-mkimage --verbose --config="$outdir/$platform/load.cfg" \
2111 +					--format="$platform" \
2112 +					--output="$outdir/$platform/$image_name" \
2113 +					--prefix='' \
2114 +					--compression=auto \
2115 +					--directory="/usr/lib/grub/$platform" \
2116 +					search search_fs_file search_fs_uuid search_label \
2117 +					configfile normal memdisk tar tftp net iso9660 \
2118 +					part_msdos part_gpt msdospart fat ext2 \
2119 +					png jpeg tga all_video gfxterm gettext play \
2120 +					video video_bochs \
2121 +					video_cirrus video_colors video_fb videoinfo \
2122 +					videotest gzio xzio usb terminfo probe loadenv \
2123 +					gfxmenu gfxterm_background gfxterm_menu \
2124 +					elf cat ls boot cpio echo gfxterm_background
2125  
2126 -grub-mkimage -O "$platform" \
2127 -	-o "$outdir/bootnet$efi_name.efi" -p "$netboot_prefix/grub" \
2128 -	search configfile normal efinet tftp net
2129 +				# using this image with p=/boot/grub for EFI/ubuntu"
2130 +				grub-mkimage --verbose --config="$outdir/$platform/load.cfg" \
2131 +					--format="$platform" \
2132 +					--output="$outdir/$platform/$image_name-grub" \
2133 +					--prefix="/boot/grub" \
2134 +					--compression=auto \
2135 +					--directory="/usr/lib/grub/$platform" \
2136 +					search search_fs_file search_fs_uuid search_label \
2137 +					configfile normal memdisk tar tftp net iso9660 \
2138 +					part_msdos part_gpt msdospart fat ext2 \
2139 +					png jpeg tga all_video gfxterm gettext play \
2140 +					video video_bochs \
2141 +					video_cirrus video_colors video_fb videoinfo \
2142 +					videotest gzio xzio usb terminfo probe loadenv \
2143 +					gfxmenu gfxterm_background gfxterm_menu \
2144 +					elf cat ls boot cpio echo gfxterm_background
2145  
2146 -# Stuff it into a FAT filesystem, making it as small as possible.  24KiB
2147 -# headroom seems to be enough; (x+31)/32*32 rounds up to multiple of 32.
2148 -mkfs.msdos -C "$outdir/efi.img" \
2149 -	$(( ($(stat -c %s "$workdir/boot$efi_name.efi") / 1024 + 55) \
2150 -	    / 32 * 32 ))
2151 -mmd -i "$outdir/efi.img" ::efi
2152 -mmd -i "$outdir/efi.img" ::efi/boot
2153 -mcopy -i "$outdir/efi.img" "$workdir/boot$efi_name.efi" \
2154 -	"::efi/boot/boot$efi_name.efi"
2155 +					;;
2156 +		esac
2157 +		;;
2158  
2159 -grub-cpmodules "$outdir" "$platform"
2160 -cp /usr/share/grub/unicode.pf2 "$outdir/boot/grub/"
2161 +	*)
2162 +		echo "Platform of ${platform} is not supported in efi-image."
2163 +		exit 1
2164 +		;;
2165 +esac
2166  
2167  exit 0
2168 diff --git a/scripts/build/grub-cpmodules b/scripts/build/grub-cpmodules
2169 index 437ebdf..df9c7d3 100755
2170 --- a/scripts/build/grub-cpmodules
2171 +++ b/scripts/build/grub-cpmodules
2172 @@ -3,6 +3,7 @@ set -e
2173  
2174  # Copyright (C) 2010, 2011 Canonical Ltd.
2175  # Author: Colin Watson <cjwatson@ubuntu.com>
2176 +# Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
2177  #
2178  # This program is free software; you can redistribute it and/or modify it
2179  # under the terms of the GNU General Public License as published by the Free
2180 @@ -30,26 +31,10 @@ fi
2181  outdir="$1"
2182  platform="$2"
2183  
2184 -# Copy over GRUB modules, except for those already built in.
2185 -cp -a "/usr/lib/grub/$platform"/*.lst "$outdir/boot/grub/$platform/"
2186 -for x in "/usr/lib/grub/$platform"/*.mod; do
2187 -	# TODO: Some of these exclusions are based on knowledge of module
2188 -	# dependencies.  It would be nice to have a way to read the module
2189 -	# list directly out of the image.
2190 -	case $(basename "$x" .mod) in
2191 -	    configfile|fshelp|iso9660|memdisk|search|search_fs_file|search_fs_uuid|search_label|tar)
2192 -		# included in boot image
2193 -		;;
2194 -	    affs|afs|afs_be|befs|befs_be|minix|nilfs2|sfs|zfs|zfsinfo)
2195 -		# unnecessary filesystem modules
2196 -		;;
2197 -	    example_functional_test|functional_test|hello)
2198 -		# other cruft
2199 -		;;
2200 -	    *)
2201 -		cp -a "$x" "$outdir/boot/grub/$platform/"
2202 -		;;
2203 -	esac
2204 -done
2205 +# Copy over GRUB modules since grub-mkimages vary in contents
2206 +# we want to have all modules available to be loaded post-build
2207 +#
2208 +# Need to use $outdir/$platform to allow customizations
2209 +cp -a "/usr/lib/grub/$platform"/* "${outdir}/${platform}"
2210  
2211  exit 0
2212 diff --git a/scripts/build/installer_debian-installer b/scripts/build/installer_debian-installer
2213 index ec931fa..2c1927b 100755
2214 --- a/scripts/build/installer_debian-installer
2215 +++ b/scripts/build/installer_debian-installer
2216 @@ -2,6 +2,7 @@
2217  
2218  ## live-build(7) - System Build Scripts
2219  ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
2220 +## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
2221  ##
2222  ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
2223  ## This is free software, and you are welcome to redistribute it
2224 @@ -124,7 +125,7 @@ case "${LB_ARCHITECTURES}" in
2225  		DI_REMOTE_BASE_GTK="${DI_REMOTE_BASE}/gtk"
2226  		;;
2227  
2228 -	powerpc)
2229 +	powerpc|ppc64el)
2230  		case "${DI_IMAGE_TYPE}" in
2231  			cdrom)
2232  				DI_REMOTE_BASE="${LB_ARCHITECTURES}/cdrom"
2233 @@ -289,7 +290,7 @@ then
2234  			DOWNLOAD_GTK_INSTALLER=1
2235  			;;
2236  
2237 -		powerpc)
2238 +		powerpc|ppc64el)
2239  			if [ "${LB_DEBIAN_INSTALLER}" = "netboot" ]
2240  			then
2241  				DOWNLOAD_GTK_INSTALLER=1
2242 @@ -329,6 +330,7 @@ then
2243  			DI_REQ_PACKAGES="yaboot"
2244  			DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-powerpc linux-image-powerpc64 linux-image-powerpc-smp"
2245  			;;
2246 +
2247  	esac
2248  
2249  	DI_PACKAGES="${DI_PACKAGES} busybox cryptsetup mdadm lvm2 xfsprogs jfsutils"
2250 -- 
2251 2.7.4

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2017-10-04 01:27:14, 79.7 KB) [[attachment:0001-live-build-binary_hdd-enablement-for-ppc64el.patch]]
  • [get | view] (2017-10-04 01:27:37, 19.8 KB) [[attachment:0002-live-build-installer-enablement-for-ppc64el.patch]]
  • [get | view] (2017-10-04 01:28:03, 746.9 KB) [[attachment:latest-fwts-live-v5-ppc64el.tar.gz]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.