#!/bin/zsh

# We're going to run this in the MacTeXDVD working directory...
WORK=`pwd`

echo "Removing old file tree at ${WORK}/root"
rm -rf ${WORK}/root

echo "Creating root"

mkdir -p ${WORK}/root/usr/local/share/ghostscript/9.55.0/lib
mkdir -p ${WORK}/root/usr/local/lib

# Copy libgs binaries and make libgs links

cp ${WORK}/Binaries/libgs.dylib.9.55 ${WORK}/root/usr/local/share/ghostscript/9.55.0/lib/libgs.dylib.9.55
cd ${WORK}/root/usr/local/lib
ln -s /usr/local/share/ghostscript/9.55.0/lib/libgs.dylib.9.55 libgs.dylib
ln -s /usr/local/share/ghostscript/9.55.0/lib/libgs.dylib.9.55 libgs.9.dylib
ln -s /usr/local/share/ghostscript/9.55.0/lib/libgs.dylib.9.55 libgs.9.55.dylib
cd ${WORK}

# chmod
echo "Changing permissions"
chmod -R a+r ${WORK}/root/usr
chown -R root  ${WORK}/root/usr
chgrp -R wheel  ${WORK}/root/usr
chmod 755 ${WORK}/root/usr


