2025-01-06 00:45:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Set default destination if FLATPAK_DEST is not set
|
|
|
|
if [ -z "$FLATPAK_DEST" ]; then
|
|
|
|
FLATPAK_DEST="/app"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if source directory is provided
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Usage: $0 <source_directory>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Define target directory
|
|
|
|
target_dir="${FLATPAK_DEST}/retrodeck/lib"
|
|
|
|
|
|
|
|
# Ensure the target directory exists
|
|
|
|
mkdir -p "$target_dir"
|
|
|
|
|
|
|
|
# Find and copy files
|
|
|
|
find "$1" -type f -exec sh -c '
|
2025-01-06 02:47:41 +00:00
|
|
|
target_dir="$1"
|
|
|
|
shift
|
|
|
|
for file in "$@"; do
|
|
|
|
dest_file="$target_dir/$(basename "$file")"
|
|
|
|
if [ ! -e "$dest_file" ]; then
|
2025-01-06 05:02:54 +00:00
|
|
|
if ! cp "$file" "$dest_file" 2>/dev/null; then
|
|
|
|
echo "Warning: Failed to copy $file. Skipping."
|
2025-01-06 00:45:59 +00:00
|
|
|
else
|
2025-01-06 05:02:54 +00:00
|
|
|
echo "Copied $file to $dest_file"
|
2025-01-06 00:45:59 +00:00
|
|
|
fi
|
2025-01-06 02:47:41 +00:00
|
|
|
else
|
2025-01-06 00:45:59 +00:00
|
|
|
echo "Skipped $file as $dest_file already exists"
|
2025-01-06 02:47:41 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
' sh "$target_dir" {} +
|