summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2018-02-25 23:41:23 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2018-02-25 23:41:23 +0100
commit0085573cf470dab1d7668c6ea44d395886b1e76f (patch)
tree9b52d104d798e40bfaf22f30c1410f8971212589
parent7892a82d9a2379fc1b7f185eaf736ba87816568f (diff)
Download rootfs
-rwxr-xr-xbuild.sh36
1 files changed, 30 insertions, 6 deletions
diff --git a/build.sh b/build.sh
index 43b9200..872d568 100755
--- a/build.sh
+++ b/build.sh
@@ -2,17 +2,39 @@
set -e
-arch=x86_64
-arch_dash=`echo $arch | tr _ -`
+arch=x86
+subarch=64
+arch_lxd=${arch}_${subarch}
+arch_dash=${arch}-${subarch}
ver=17.01.4
image=openwrt
name=openwrt
dist=lede
-generic_rootfs=${dist}-${ver}-${arch_dash}-generic-rootfs.tar.gz
+generic_rootfs_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}/${dist}-${ver}-${arch_dash}-generic-rootfs.tar.gz
+generic_rootfs_sum=43886c6b4a555719603286ceb1733ea2386d43b095ab0da9be35816cd2ad8959
+generic_rootfs=dl/$(basename $generic_rootfs_url)
+
lxc_tar=${dist}-${ver}-${arch_dash}-lxd.tar.gz
metadata=metadata.yaml
+download_rootfs() {
+ test -e dl || mkdir dl
+
+ if ! test -e "$generic_rootfs" ; then
+ echo Downloading $generic_rootfs_url
+ wget -O $generic_rootfs "$generic_rootfs_url"
+ fi
+}
+
+check_rootfs() {
+ sum=$(sha256sum $generic_rootfs| cut -d ' ' -f1)
+ if test $generic_rootfs_sum != $sum; then
+ echo Bad checksum $sum of $generic_rootfs
+ exit 1
+ fi
+}
+
build_tarball() {
fakeroot ./build_rootfs.sh $generic_rootfs $metadata $lxc_tar
}
@@ -22,11 +44,11 @@ build_metadata() {
date=`date -R -d "@${stat}"`
cat > $metadata <<EOF
-architecture: "$arch"
+architecture: "$arch_lxd"
creation_date: $(date +%s)
properties:
- architecture: "$arch"
- description: "OpenWrt $ver $arch ($date)"
+ architecture: "$arch_lxd"
+ description: "OpenWrt $ver $arch_lxd ($date)"
os: "OpenWrt"
release: "$ver"
templates:
@@ -45,6 +67,8 @@ build_image() {
lxc image import $lxc_tar --alias $image
}
+download_rootfs
+check_rootfs
build_metadata
build_tarball
build_image