Split main func (no os/proj dependency)
This commit is contained in:
44
src/func/filesystem_extract
Normal file
44
src/func/filesystem_extract
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
#remaster lib
|
||||
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
|
||||
[ -d "$LIBDR"] || { echo "LIBDR 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"
|
||||
}
|
Reference in New Issue
Block a user