#!/bin/sh
# Copyright (C) 2010-2012 Eugene Prokopiev  <enp@altlinux.org>
# Copyright (C) 2011-2013      Michael Pozhidaev <msp@altlinux.org>

THIS=${0##*/}

DEST_DIR="${1%%/}"

[ -z "$DEST_DIR" ] && echo "$THIS:chroot directory is not mentioned" >&2 && exit 1

find /usr/libexec/homeros-install/chroot.d/ -type f |
while read l; do
    LOCAL="$DEST_DIR/bin/homeros-install-local"
    /bin/cp "$l" "$LOCAL"
    /bin/chmod 755 "$LOCAL"
    /sbin/chroot "$DEST_DIR" homeros-install-local
    /bin/rm -f "$LOCAL"
done
