2018-04-30 18:57:01 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#remaster lib
|
2018-05-07 01:49:19 +02:00
|
|
|
[ -d "<LIBDIR>"] || { echo "LIBDIR not exist"; exit 1; }
|
2018-04-30 18:57:01 +02:00
|
|
|
|
|
|
|
#filesystem_extract [filesystem_img_source] [chroot_path]
|
|
|
|
function filesystem_extract() {
|
|
|
|
echo "extract filesystem ..."
|
|
|
|
|
|
|
|
#$1 = filesystem_img_source
|
|
|
|
#$2 = chroot_path
|
|
|
|
filesystem_img_source="$1"
|
|
|
|
chroot_path="$2"
|
|
|
|
filesystem_log="`mktemp`"
|
|
|
|
|
|
|
|
#Überfrüfen der Parameter
|
|
|
|
[ -f "$filesystem_img_source" ] || {
|
|
|
|
echo "### ERROR ### filesystem_extract: squashfs \"$filesystem_img_source\" not exist!"
|
|
|
|
return 11
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "`mkdir -p "$chroot_path"`" != "" ] && {
|
|
|
|
echo "### ERROR ### filesystem_extract: chroot_path \"$chroot_path\" can't create!"
|
|
|
|
return 13
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "`filesystem_get_type $chroot_path`" != "ext4" ] && [ "`filesystem_get_type $chroot_path`" != "btrfs" ] && {
|
|
|
|
echo "### ERROR ### filesystem_extract: wrong filesystem (`filesystem_get_type $chroot_path`)!"
|
|
|
|
return 22
|
|
|
|
}
|
|
|
|
|
|
|
|
rm -r "$chroot_path"
|
|
|
|
|
|
|
|
#eigendliches entpacken
|
|
|
|
unsquashfs -d "$chroot_path" "$filesystem_img_source" > "$filesystem_log" || {
|
|
|
|
echo "### ERROR ### filesystem_extract: unsquashfs failed!"
|
|
|
|
return 14
|
|
|
|
}
|
|
|
|
|
|
|
|
grep -v "\[" "$filesystem_log"
|
|
|
|
rm "$filesystem_log"
|
|
|
|
|
|
|
|
echo "done"
|
|
|
|
}
|