File: copy-source.sh

package info (click to toggle)
pmdk 1.13.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,944 kB
  • sloc: ansic: 126,815; sh: 21,543; cpp: 9,413; python: 5,893; makefile: 3,119; perl: 2,294; pascal: 1,442
file content (36 lines) | stat: -rwxr-xr-x 818 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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