Rootfs: Rewrite build script

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>