#!/bin/sh

. common.sh

cd ${ZIPSPEAK_BUILD_ROOT}
rm -rf spkconf
mkdir -p spkconf/usr/{bin,doc/speakupconfig}
mkdir -p spkconf/etc/rc.d
tar zxf ${ZIPSPEAK_SOURCE_DIR}/speakupconfig-${SPEAKUPCONFIG_VERSION}.tar.gz
cp speakupconfig/speakupconfig spkconf/usr/bin
cp speakupconfig/README spkconf/usr/doc/speakupconfig
cp ${ZIPSPEAK_ROOT}/rc.speakup spkconf/etc/rc.d
cd spkconf
chown -R root.root .
chown -R root.bin usr/bin
makepkg ${ZIPSPEAK_PACKAGE_DIR}/spkconf.tgz
cp ${ZIPSPEAK_PACKAGE_DIR}/spkconf.tgz ${ZIPSPEAK_STAGE_ROOT}/tmp
chroot ${ZIPSPEAK_STAGE_ROOT} installpkg /tmp/spkconf.tgz
rm ${ZIPSPEAK_STAGE_ROOT}/tmp/spkconf.tgz
cd ${ZIPSPEAK_STAGE_ROOT}/etc/rc.d
patch -s < ${ZIPSPEAK_ROOT}/rc.M.patch
