#!/bin/sh -e
#
# mki-get-topdir
#
# This file is part of mkimage
# Copyright (C) 2009  Alexey Gladkov <gladkov.alexey@gmail.com>
#
# This file is covered by the GNU General Public License,
# which should be included with mkimage as the file COPYING.
#

dir="$1"
topdir="$dir"

while [ -n "$topdir" -a ! -d "$topdir/.mki" ]; do
	topdir="${topdir%/*}"
done
printf '%s\n' "${topdir:-$dir}"
