diff options
Diffstat (limited to '')
-rwxr-xr-x | src/pmdk/utils/copy-source.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/pmdk/utils/copy-source.sh b/src/pmdk/utils/copy-source.sh new file mode 100755 index 000000000..5bb2d589d --- /dev/null +++ b/src/pmdk/utils/copy-source.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2018, Intel Corporation + +# +# utils/copy-source.sh -- copy source files (from HEAD) to 'path_to_dir/pmdk' +# directory whether in git repository or not. +# +# usage: ./copy-source.sh [path_to_dir] [srcversion] + +set -e + +DESTDIR="$1" +SRCVERSION=$2 + +if [ -d .git ]; then + if [ -n "$(git status --porcelain)" ]; then + echo "Error: Working directory is dirty: $(git status --porcelain)" + exit 1 + fi +else + echo "Warning: You are not in git repository, working directory might be dirty." +fi + +mkdir -p "$DESTDIR"/pmdk +echo -n $SRCVERSION > "$DESTDIR"/pmdk/.version + +if [ -d .git ]; then + git archive HEAD | tar -x -C "$DESTDIR"/pmdk +else + find . \ + -maxdepth 1 \ + -not -name $(basename "$DESTDIR") \ + -not -name . \ + -exec cp -r "{}" "$DESTDIR"/pmdk \; +fi |