diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2018-02-16 23:09:31 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2018-02-16 23:09:31 +0100 |
commit | 14c27de10398bfb91c127bd31a991d685619b195 (patch) | |
tree | 468655c9f02692e70e88823a916214cb10d17512 /build_rootfs.sh |
Initial commit
Diffstat (limited to 'build_rootfs.sh')
-rwxr-xr-x | build_rootfs.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/build_rootfs.sh b/build_rootfs.sh new file mode 100755 index 0000000..ec61ef9 --- /dev/null +++ b/build_rootfs.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +set -e + +if [ $# -ne 2 ]; then + echo "Usage: $0 <src tar> <dst file>" + exit 1 +fi + +src_tar=$1 +dst_file=$2 +base=`basename $src_tar` +dir=/tmp/build.$$ +export IPKG_INSTROOT=$dir + +unpack() { + mkdir $dir + cat $src_tar | (cd $dir && tar -xz) +} + +pack() { + echo Pack rootfs + (cd $dir && tar -cz *) > $dst_file +} + +pack_squashfs() { + echo Pack rootfs squashfs + mksquashfs $dir $dst_file +} + +add_files() { + for f in $(cd files && find); do + src=files/$f + dst=$dir/$f + if test -d $src; then + test -d $dst || mkdir $dst + elif test -f $src; then + cp $src $dst + foo=$(dirname $f) + if [ "$foo" = "./etc/init.d" ]; then + echo Enabling $f + set +e + sh $dir/etc/rc.common $src enable + set -e + fi + fi + done +} + +unpack +add_files +#pack +pack_squashfs |