LIBMAN: simplified script

This commit is contained in:
XargonWan 2025-01-06 15:26:15 +09:00
parent 5203448698
commit 90856f1dbe

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
echo "Starting LibMan"
# Set default destination if FLATPAK_DEST is not set # Set default destination if FLATPAK_DEST is not set
if [ -z "$FLATPAK_DEST" ]; then if [ -z "$FLATPAK_DEST" ]; then
FLATPAK_DEST="/app" FLATPAK_DEST="/app"
@ -15,22 +17,29 @@ fi
target_dir="${FLATPAK_DEST}/retrodeck/lib" target_dir="${FLATPAK_DEST}/retrodeck/lib"
# Ensure the target directory exists # Ensure the target directory exists
mkdir -p "$target_dir" if ! mkdir -p "$target_dir"; then
echo "Error: Failed to create target directory $target_dir"
exit 0
fi
# Find and copy files # Find and copy files
find "$1" -type f -exec sh -c ' find "$1" -type f | while IFS= read -r file; do
target_dir="$1" # Define destination file path
shift dest_file="$target_dir/$(basename "$file")"
for file in "$@"; do
dest_file="$target_dir/$(basename "$file")" # Skip if the destination file already exists
if [ ! -e "$dest_file" ]; then if [ -e "$dest_file" ]; then
if ! cp "$file" "$dest_file" 2>/dev/null; then echo "Skipped $file as $dest_file already exists"
echo "Warning: Failed to copy $file. Skipping." continue
else fi
echo "Copied $file to $dest_file"
fi # Attempt to copy the file
else if cp "$file" "$dest_file"; then
echo "Skipped $file as $dest_file already exists" echo "Copied $file to $dest_file"
fi else
done echo "Warning: Failed to copy $file. Skipping."
' sh "$target_dir" {} + fi
done
echo "Terminating LibMan"