#!/bin/bash

set -eu

# the Debian release to use as a basis for the live-cd
nd_basedist="squeeze"
nd_version="6.0.3"
nd_arch=i386

deb_mirror="http://debproxy:9999"

# Prepare splash screen
if [ ! -e neurodebian-splash.png ]; then
    # For Grub2 it should be .tga;
	# NOTE: RLE compression is not supported by imagemagick for write
	convert -layers merge ../artwork/wallpaper_hotbrain.xcf neurodebian-splash-big.png
	convert neurodebian-splash-big.png -crop 1400x1050+280 -geometry 640x480 \
		neurodebian-splash.png
fi

# enable recommends for now since we care about 'typical' use patterns atm
lb config noauto \
  --apt apt \
  --apt-recommends true \
  --architecture ${nd_arch} \
  --archive-areas "main contrib non-free" \
  --binary-images iso-hybrid \
  --binary-indices none \
  --bootstrap-flavour standard \
  --debian-installer netinst \
  --distribution ${nd_basedist} \
  --hostname neurodebian \
  --iso-application "NeuroDebian Live" \
  --iso-preparer "NeuroDebian ${nd_version}; http://neuro.debian.net" \
  --iso-publisher "NeuroDebian project; http://neuro.debian.net" \
  --iso-volume "NeuroDebian Live ${nd_version} $nd_arch" \
  --keyring-packages "debian-archive-keyring neurodebian-archive-keyring" \
  --memtest memtest86+ \
  --mirror-bootstrap "${deb_mirror}/debian/" \
  --mirror-chroot "${deb_mirror}/debian/" \
  --mirror-chroot-security "${deb_mirror}/security/" \
  --packages-lists "nd-core nd-neuroimaging nd-neuroimaging-doc nd-electrphysiology nd-electrphysiology-doc" \
  --repositories neuro.debian.net \
  --security true \
  --syslinux-splash neurodebian-splash.png \
  --syslinux-timeout 4 \
  --username brain \
  --win32-loader enabled \
  ${@}

  # Leads to a stall... may be incorrect format
  # seems to be KVM issue...

  # --mirror-bootstrap "http://debian.lcs.mit.edu/debian/" \
  # --packages-lists xfce \

# May be
# Deploy 1:1 copy of the running Live system
# --debian-installer live

# Would be nice to have it utterly useful, but rescue is too bloated, may be
# at least forensics
# --packages-lists

# Do we need any of the additional tools from live.debian.net?
#  --repositories live.debian.net \

# Should we enable backports repo? then add
#  debian-backports-keyring
