summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh10
-rwxr-xr-xbuild_rootfs.sh64
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 <<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