#!/bin/bash
#set -e -u

device="frontier"
codename="unstable"
FSSIZEMB=${FSSIZEMB:-1024}

ARGS="$@"

tempcfg="mkos-${device}.mstrap"
cfgfile=/usr/share/mkos-${device}/$tempcfg
tempmnt="mkos-${device}.fs"

# Generate the multistrap config file.
mkos-mlo-config -i $cfgfile -o $tempcfg -t mkos-${device}.tar.gz -p device-${device}-base $ARGS

# Run the pre-multistrap hooks, then produce the filesystem directory.
#
# Additional hooks inside of multistrap will create the tgz, repo, manifest,
# ISO, and IMG files.
mkos-mlo-prehooks $tempmnt $@ &&
    FSSIZEMB=$FSSIZEMB fakeroot /usr/sbin/multistrap -f $tempcfg -d $tempmnt

