#! /bin/sh

# gets ARCH, THEMES, DESTDIR, INSTSYS_PARTS, BOOT_PARTS, WITH_FLOPPY via env

set -e

# create directory layout
mkdir -p $DESTDIR/CD1/boot/$ARCH
for theme in $THEMES ; do
  mkdir -p $DESTDIR/branding/$theme/CD1/boot/$ARCH
done

# copy branding independent parts
for i in $INSTSYS_PARTS $BOOT_PARTS ; do
  [ -e images/$i ] && cp -r images/$i $DESTDIR/CD1/boot/$ARCH
done

# copy branding dependent parts
for theme in $THEMES ; do
  for i in $INSTSYS_PARTS $BOOT_PARTS ; do
    [ -e images/$theme/$i ] && cp -r images/$theme/$i $DESTDIR/branding/$theme/CD1/boot/$ARCH
  done

  ln -s efi $DESTDIR/branding/$theme/CD1/boot/$ARCH/image
done

mkdir -p $DESTDIR/usr/share
cp images/mini-iso-rmlist $DESTDIR/usr/share

