#!/bin/bash #remaster lib [ -d "" ] || { echo "LIBDIR not exist"; exit 1; } #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" } #this func is standalone executable [ -n "$1" ] && { filesystem_extract $@ }