summaryrefslogtreecommitdiff
path: root/build_rootfs.sh
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2018-02-16 23:52:09 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2018-02-16 23:52:09 +0100
commit0db029286e62bef881642cad8ae84aba636dec3e (patch)
treedb864ef58e86debe2eeb241b26b46485bdce3aa9 /build_rootfs.sh
parent14c27de10398bfb91c127bd31a991d685619b195 (diff)
Build unified tarball
Diffstat (limited to 'build_rootfs.sh')
-rwxr-xr-xbuild_rootfs.sh64
1 files changed, 40 insertions, 24 deletions
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