Commit 44a63491 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm repack common.sh: add move_file function

parent 67dd6567
......@@ -30,6 +30,25 @@ remove_file()
subst "s|.*$file.*||" $SPEC
}
is_dir_empty()
{
[ -z "$(ls -A "$1")" ]
}
# Move file to a new place
move_file()
{
local from="$1"
local to="$2"
[ -e "$BUILDROOT$from" ] || return
mkdir -p "$(dirname "$BUILDROOT$to")" || return
cp -av "$BUILDROOT$from" "$BUILDROOT$to" || return
remove_file "$from"
pack_file "$to"
# try remove dir if empty
is_dir_empty "$(dirname "$BUILDROOT$from")" && remove_dir "$(dirname" $from")"
}
# Remove dir (recursively) from the file system and from spec
remove_dir()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment