diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2018-02-16 23:52:09 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2018-02-16 23:52:09 +0100 |
commit | 0db029286e62bef881642cad8ae84aba636dec3e (patch) | |
tree | db864ef58e86debe2eeb241b26b46485bdce3aa9 | |
parent | 14c27de10398bfb91c127bd31a991d685619b195 (diff) |
Build unified tarball
-rwxr-xr-x | build.sh | 10 | ||||
-rwxr-xr-x | build_rootfs.sh | 64 |
2 files changed, 45 insertions, 29 deletions
@@ -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 <<EOF + cat > $metadata <<EOF architecture: "$arch" creation_date: $(date +%s) properties: @@ -32,13 +33,12 @@ EOF } build_image() { - tar czf metadata.tar.gz metadata.yaml lxc image import metadata.tar.gz $lxc_rootfs --alias $image } -build_rootfs build_metadata -build_image +build_rootfs +#build_image echo \# start echo lxc launch --config "raw.lxc=lxc.aa_profile=lxc-container-default-without-dev-mounting" --profile openwrt $image $name diff --git a/build_rootfs.sh b/build_rootfs.sh index ec61ef9..4497605 100755 --- a/build_rootfs.sh +++ b/build_rootfs.sh @@ -2,20 +2,23 @@ set -e -if [ $# -ne 2 ]; then - echo "Usage: $0 <src tar> <dst file>" +if [ $# -ne 3 ]; then + echo "Usage: $0 <src tar> <metadata.yaml> <dst file>" 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 |