-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathps3-squash.sh
More file actions
45 lines (36 loc) · 1.08 KB
/
ps3-squash.sh
File metadata and controls
45 lines (36 loc) · 1.08 KB
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
37
38
39
40
41
42
43
44
45
#!/bin/bash
#
# Repackage PS3 .iso images as xz-compressed .squashfs archives.
# For each .iso in the current directory: loop-mount it, copy the
# contents out, mksquashfs the result, and clean up. Mount point is
# unmounted on exit even if something fails mid-loop.
#
# Requires: mksquashfs (squashfs-tools), mount privileges (run as root
# or with the appropriate capabilities).
set -euo pipefail
MNT="tmpmnt"
cleanup() {
if mountpoint -q "${MNT}" 2>/dev/null; then
umount "${MNT}" || true
fi
rm -rf "${MNT}"
}
trap cleanup EXIT
for file in *.iso; do
[[ -f "$file" ]] || continue
name="$(basename "$file")"
out_dir="${name/.iso/.ps3}"
out_squash="${name/.iso/.ps3.squashfs}"
mkdir -p "${MNT}"
mount -o loop "${name}" "${MNT}"
mkdir -p "${out_dir}"
echo "Copying data for ${name%.iso}"
cp -rv "${MNT}/." "${out_dir}/"
echo "Unmounting..."
umount "${MNT}"
echo "Squashing ${out_dir}..."
mksquashfs "${out_dir}" "${out_squash}" -comp xz
echo "Cleaning up..."
rm -rf "${out_dir}"
echo "Done: ${out_squash}"
done