From 0db029286e62bef881642cad8ae84aba636dec3e Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 16 Feb 2018 23:52:09 +0100 Subject: Build unified tarball --- build.sh | 10 ++++----- build_rootfs.sh | 64 +++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/build.sh b/build.sh index 93ad201..a467c4d 100755 --- a/build.sh +++ b/build.sh @@ -10,16 +10,17 @@ name=openwrt generic_rootfs=lede-${ver}-${arch_dash}-generic-rootfs.tar.gz lxc_rootfs=lede-${ver}-${arch_dash}-lxc-rootfs.tar.gz +metadata=metadata.yaml build_rootfs() { - fakeroot ./build_rootfs.sh $generic_rootfs $lxc_rootfs + fakeroot ./build_rootfs.sh $generic_rootfs $metadata $lxc_rootfs } build_metadata() { stat=`stat -c %Y $lxc_rootfs` date=`date -R -d "@${stat}"` - cat > metadata.yaml < $metadata < " +if [ $# -ne 3 ]; then + echo "Usage: $0 " exit 1 fi src_tar=$1 -dst_file=$2 +metadata_dir=`dirname $2` +metadata=`basename $2` +dst_file=$3 base=`basename $src_tar` dir=/tmp/build.$$ -export IPKG_INSTROOT=$dir +files_dir=files/ +export IPKG_INSTROOT=$dir/rootfs unpack() { - mkdir $dir - cat $src_tar | (cd $dir && tar -xz) + mkdir -p $dir/rootfs + cat $src_tar | (cd $dir/rootfs && tar -xz) } pack() { @@ -28,26 +31,39 @@ pack_squashfs() { mksquashfs $dir $dst_file } +add_file() { + file=$1 + src_dir=$2 + dst_dir=$3 + + src=$src_dir/$file + dst=$dst_dir/$file + + if test -d $src; then + test -d $dst || mkdir $dst + elif test -f $src; then + cp $src $dst + foo=$(dirname $file) + if [ "$foo" = "./etc/init.d" ]; then + echo Enabling $file + set +e + sh $dir/rootfs/etc/rc.common $src enable + set -e + fi + fi +} + 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 + src_dir=$1 + dst_dir=$2 + + for f in $(cd $src_dir && find); do + add_file $f $src_dir $dst_dir done } unpack -add_files -#pack -pack_squashfs +add_files $files_dir $dir/rootfs/ +add_file $metadata $metadata_dir $dir +pack +#pack_squashfs -- cgit v1.2.3