42 lines
896 B
Bash
Executable File
42 lines
896 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
UPSTREAM_DIR="$ROOT_DIR/../linuxcnc"
|
|
VENDOR_DIR="$ROOT_DIR/vendor/linuxcnc"
|
|
MANIFEST_FILE="$ROOT_DIR/tools/source-manifest.txt"
|
|
|
|
copy_file() {
|
|
local src_rel="$1"
|
|
local src="$UPSTREAM_DIR/$src_rel"
|
|
local dst="$VENDOR_DIR/$src_rel"
|
|
|
|
if [[ ! -f "$src" ]]; then
|
|
echo "missing upstream file: $src" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$(dirname "$dst")"
|
|
if [[ -f "$dst" ]] && cmp -s "$src" "$dst"; then
|
|
touch -r "$src" "$dst"
|
|
echo "unchanged $src_rel"
|
|
return
|
|
fi
|
|
|
|
cp -p "$src" "$dst"
|
|
echo "copied $src_rel"
|
|
}
|
|
|
|
if [[ ! -f "$MANIFEST_FILE" ]]; then
|
|
echo "missing manifest: $MANIFEST_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
while IFS= read -r src_rel; do
|
|
[[ -z "$src_rel" ]] && continue
|
|
[[ "${src_rel:0:1}" == "#" ]] && continue
|
|
copy_file "$src_rel"
|
|
done < "$MANIFEST_FILE"
|
|
|
|
echo "extraction complete"
|