#!/bin/bash

# SAIR can decompress the installer image itself, but it's faster to work with uncompressed images when developing.
slk_rpiofficialimg=/mnt/prisroot/devel/armedslack-distrib/slackwarearm/platform/aarch64/bootware/installer-aio/slackwareaarch64-current/rpi_generic.img.xz
uncomp_slkimg=/tmp/rpi_generic.img
[ ! -f ${uncomp_slkimg} ] && {
  echo "Uncompressing RPi AiO image..."
  xzcat ${slk_rpiofficialimg} > ${uncomp_slkimg} ;}

rpiver=rpi4
#rpiver=rpi5

# Refresh the entire package set?
# You need a copy of the public Slackware tree in the env variable '$SLACKPUBTREEDIR'
# (which would be set by the 'slackkit' package's configuration)
export SAIR_REPLACEPKGSET=Yes
#export SAIR_REPLACEPKGSET=No

# Add a flag to pause the installer before launching the post installation
# configuration scripts?
#export SAIR_FLAGS_INSTPAUSE=Yes
export SAIR_FLAGS_INSTPAUSE=No

# To control the behaviour of the 'rpi_generic' SAIR config file, change the
# --hardware-model name. The config file will use this to adjust settings
# according to the RPi variant - e.g. "rpi5".
./sair \
  --src-aio-installer-image ${uncomp_slkimg} \
  --dst-aio-installer-image /tmp/${rpiver}-sair.img \
  --config rpi_generic \
  --hardware-model ${rpiver} \
  --asset-dir $PWD/sair.assets \

#  --debug \
#  --compress-dst \
