#!/bin/sh

set -e

# Install partman hooks, script taken from partman-base.

# PACKAGE is exported from debian/rules
partman=debian/${PACKAGE}/lib/partman

install -d $partman/$1

cp -r $1/* $partman/$1/

# Remove any SVN dirs that were copied along
rm -rf `find $partman/$1/ -name .svn`

if [ -f $partman/$1/_numbers ]; then
    numbers=$(cat $partman/$1/_numbers)
    rm $partman/$1/_numbers
    echo "$numbers" |
    while read number name link; do
	set -e
	if [ "$link" ]; then
		# Create a symlink to a different entry with the same name
		# (e.g. to have two dividers in the same dialog)
		ln -s ${link}${name} $partman/$1/${number}${name}
	else
		mv $partman/$1/$name $partman/$1/${number}${name}
	fi
    done
fi

