diff options
author | nachoparker <nacho@ownyourbits.com> | 2018-05-29 00:19:13 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2018-05-29 19:57:24 +0300 |
commit | d578ef156842f32ea779376f9b03dd388ff0e52c (patch) | |
tree | 0a63c5fe2b538c8f3088ca6fbead84e3ef26f94b | |
parent | b45e68f1f0bd148d7c817932c974b33a7479855a (diff) |
general build improvements
-rwxr-xr-x | batch.sh | 12 | ||||
-rwxr-xr-x | build-SD-armbian.sh | 64 | ||||
-rwxr-xr-x | build-SD-bananapi.sh | 44 | ||||
-rwxr-xr-x | build-SD-odroidHC2.sh | 44 | ||||
-rwxr-xr-x | build-SD-rock64.sh | 46 | ||||
-rwxr-xr-x | build-SD-rpi.sh | 11 | ||||
-rw-r--r-- | buildlib.sh | 18 | ||||
-rw-r--r-- | config-bananapi.conf | 5 | ||||
-rw-r--r-- | config-odroidxu4.conf | 5 | ||||
-rw-r--r-- | config-rock64.conf | 6 |
10 files changed, 107 insertions, 148 deletions
@@ -15,13 +15,19 @@ IP=${1:-192.168.0.145} # For QEMU automated testing ## BUILDING source buildlib.sh # initializes $IMGNAME +[[ "$FTPPASS" == "" ]] && { + echo -e "\e[1mNo FTPPASS variable found, FTP won't work.\nYou can to cancel now\e[0m" + sleep 5 +} + # Raspbian ./build-SD-rpi.sh "$IP" +# TODO berryboot # Armbian -./build-SD-odroidHC2.sh -./build-SD-rock64.sh -./build-SD-bananapi.sh +./build-SD-armbian.sh odroidxu4 OdroidHC2 +./build-SD-armbian.sh rock64 +./build-SD-armbian.sh bananapi # Docker x86 docker pull debian:stretch-slim diff --git a/build-SD-armbian.sh b/build-SD-armbian.sh new file mode 100755 index 00000000..1edf6085 --- /dev/null +++ b/build-SD-armbian.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Batch creation of NextCloudPi Armbian based images +# +# Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> +# GPL licensed (see end of file) * Use at your own risk! +# +# Usage: ./build-SD-armbian.sh <board_code> [<board_name>] +# + +#CLEAN=1 # Pass this envvar to clean download cache +BOARD="$1" +BNAME="${2:-$1}" + +IMG="NextCloudPi_${BNAME}_$( date "+%m-%d-%y" ).img" +IMG=tmp/"$IMG" + +set -e +source buildlib.sh + +prepare_dirs # tmp cache output + +# get latest armbian +[[ -d armbian ]] || git clone https://github.com/armbian/build armbian +( cd armbian && git pull --ff-only --tags ) + +# get NCP modifications +mkdir -p armbian/userpatches +wget https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/armbian.sh \ + -O armbian/userpatches/customize-image.sh + +# GENERATE IMAGE + +# default parameters +cat > armbian/config-docker-guest.conf <<EOF +BOARD="$BOARD" +BRANCH=default +RELEASE=stretch +KERNEL_ONLY=no +KERNEL_CONFIGURE=no +BUILD_DESKTOP=no +CLEAN_LEVEL="" +USE_CCACHE=yes +EOF + +# board specific parameters +CONF="config-$BOARD".conf +[[ -f "$CONF" ]] && cat "$CONF" >> armbian/config-docker-guest.conf + +# build +armbian/compile.sh docker + +mv armbian/output/images/Armbian*.img "$IMG" + +# pack image +TAR=output/"$( basename "$IMG" .img ).tar.bz2" +pack_image "$IMG" "$TAR" + +# test +# TODO + +# upload +create_torrent "$TAR" +upload_ftp "$( basename "$TAR" .tar.bz2 )" diff --git a/build-SD-bananapi.sh b/build-SD-bananapi.sh deleted file mode 100755 index f57271e3..00000000 --- a/build-SD-bananapi.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# Batch creation of NextCloudPi image for the Banana Pi -# -# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> -# GPL licensed (see end of file) * Use at your own risk! -# -# Usage: ./build-SD-bananapi.sh <DHCP QEMU image IP> -# - -IMG="NextCloudPi_bananapi_$( date "+%m-%d-%y" ).img" - -set -e - -# get armbian -[[ -d armbian ]] || git clone https://github.com/armbian/build armbian - -# get NCP modifications -mkdir -p armbian/userpatches -wget https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/armbian.sh \ - -O armbian/userpatches/customize-image.sh - -# generate image -armbian/compile.sh docker \ - BOARD=bananapi\ - BRANCH=next\ - KERNEL_ONLY=no\ - KERNEL_CONFIGURE=no\ - RELEASE=stretch\ - BUILD_DESKTOP=no\ - CLEAN_LEVEL=""\ - USE_CCACHE=yes\ - NO_APT_CACHER=no - -# pack image -TAR=output/"$( basename "$IMG" .img ).tar.bz2" -pack_image "$IMG" "$TAR" - -# testing -# TODO - -# uploading -create_torrent "$TAR" -upload_ftp "$( basename "$TAR" .tar.bz2 )" diff --git a/build-SD-odroidHC2.sh b/build-SD-odroidHC2.sh deleted file mode 100755 index 27c42d3a..00000000 --- a/build-SD-odroidHC2.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# Batch creation of NextCloudPi image for the Odroid HC1 -# -# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> -# GPL licensed (see end of file) * Use at your own risk! -# -# Usage: ./build-SD-odroid.sh <DHCP QEMU image IP> -# - -IMG="NextCloudPi_OdroidHC2_$( date "+%m-%d-%y" ).img" - -set -e - -# get armbian -[[ -d armbian ]] || git clone https://github.com/armbian/build armbian - -# get NCP modifications -mkdir -p armbian/userpatches -wget https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/armbian.sh \ - -O armbian/userpatches/customize-image.sh - -# generate image -armbian/compile.sh docker \ - BOARD=odroidxu4\ - BRANCH=next\ - KERNEL_ONLY=no\ - KERNEL_CONFIGURE=no\ - RELEASE=stretch\ - BUILD_DESKTOP=no\ - CLEAN_LEVEL=""\ - USE_CCACHE=yes\ - NO_APT_CACHER=no - -# pack image -TAR=output/"$( basename "$IMG" .img ).tar.bz2" -pack_image "$IMG" "$TAR" - -# testing -# TODO - -# uploading -create_torrent "$TAR" -upload_ftp "$( basename "$TAR" .tar.bz2 )" diff --git a/build-SD-rock64.sh b/build-SD-rock64.sh deleted file mode 100755 index 67cbcc2e..00000000 --- a/build-SD-rock64.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -# Batch creation of NextCloudPi image for the Odroid HC1 -# -# Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> -# GPL licensed (see end of file) * Use at your own risk! -# -# Usage: ./build-SD-odroid.sh <DHCP QEMU image IP> -# - -IMG="NextCloudPi_Rock64_$( date "+%m-%d-%y" ).img" - -set -e - -# get armbian -[[ -d armbian ]] || git clone https://github.com/armbian/build armbian - -# get NCP modifications -mkdir -p armbian/userpatches -wget https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/armbian.sh \ - -O armbian/userpatches/customize-image.sh - -# generate image -armbian/compile.sh docker \ 2.62 L ✔ - BOARD=rock64\ - BRANCH=default\ - KERNEL_ONLY=no\ - KERNEL_CONFIGURE=no\ - RELEASE=stretch\ - BUILD_DESKTOP=no\ - EXPERT=yes \ - LIB_TAG="development"\ - USE_CCACHE=yes\ - CLEAN_LEVEL=""\ - NO_APT_CACHER=no - -# pack image -TAR=output/"$( basename "$IMG" .img ).tar.bz2" -pack_image "$IMG" "$TAR" - -# test -# TODO - -# upload -create_torrent "$TAR" -upload_ftp "$( basename "$TAR" .tar.bz2 )" diff --git a/build-SD-rpi.sh b/build-SD-rpi.sh index 09751f73..e3d46e34 100755 --- a/build-SD-rpi.sh +++ b/build-SD-rpi.sh @@ -20,21 +20,16 @@ IMG="NextCloudPi_RPi_$( date "+%m-%d-%y" ).img" ## preparations -[[ "$FTPPASS" == "" ]] && { - echo -e "\e[1mNo FTPPASS variable found, FTP won't work.\nYou can to cancel now\e[0m" - sleep 5 -} - -[[ "$CLEAN" != "" ]] && rm -rf cache -rm -rf tmp && mkdir tmp IMG=tmp/"$IMG" +prepare_dirs # tmp cache output download_raspbian "$IMG" resize_image "$IMG" "$SIZE" update_boot_uuid "$IMG" # PARTUUID has changed after resize ## BUILD NCP +echo -e "\e[1m\n[ Build NCP ]\e[0m" prepare_chroot_raspbian "$IMG" mkdir raspbian_root/tmp/ncp-build @@ -75,7 +70,6 @@ clean_chroot_raspbian ## pack -mkdir -p output TAR=output/"$( basename "$IMG" .img ).tar.bz2" pack_image "$IMG" "$TAR" @@ -83,7 +77,6 @@ pack_image "$IMG" "$TAR" set_static_IP "$IMG" "$IP" test_image "$IMG" "$IP" -rm -r tmp # upload create_torrent "$TAR" diff --git a/buildlib.sh b/buildlib.sh index 0d091607..6d410588 100644 --- a/buildlib.sh +++ b/buildlib.sh @@ -116,6 +116,13 @@ $CFG_STEP launch_installation "$IP" # uses $INSTALLATION_CODE } +function prepare_dirs() +{ + [[ "$CLEAN" != "" ]] && rm -rf cache + rm -rf tmp + mkdir -p tmp output cache +} + function mount_raspbian() { local IMG="$1" @@ -178,12 +185,13 @@ function resize_image() local IMG="$1" local SIZE="$2" local DEV + echo -e "\n\e[1m[ Resize Image ]\e[0m" fallocate -l$SIZE "$IMG" parted "$IMG" -- resizepart 2 -1s DEV="$( losetup -f )" mount_raspbian "$IMG" sudo resize2fs -f "$DEV" - echo "image resized" + echo "Image resized" umount_raspbian } @@ -192,6 +200,7 @@ function update_boot_uuid() local IMG="$1" local PTUUID="$( sudo blkid -o export "$IMG" | grep PTUUID | sed 's|.*=||' )" + echo -e "\n\e[1m[ Update Raspbian Boot UUIDS ]\e[0m" mount_raspbian "$IMG" || return 1 sudo bash -c "cat > raspbian_root/etc/fstab" <<EOF PARTUUID=${PTUUID}-01 /boot vfat defaults 0 2 @@ -257,6 +266,7 @@ function download_raspbian() local IMG_CACHE=cache/raspbian_lite.img local ZIP_CACHE=cache/raspbian_lite.zip + echo -e "\n\e[1m[ Download Raspbian ]\e[0m" mkdir -p cache test -f $IMG_CACHE && \ echo -e "INFO: $IMG_CACHE already exists. Skipping download ..." && \ @@ -280,6 +290,7 @@ function pack_image() local TAR="$2" local DIR="$( dirname "$IMG" )" local IMG="$( basename "$IMG" )" + echo -e "\n\e[1m[ Pack Image ]\e[0m" echo "packing $IMG → $TAR" tar -I pbzip2 -C "$DIR" -cvf "$TAR" "$IMG" && \ echo -e "$TAR packed successfully" @@ -288,13 +299,14 @@ function pack_image() function create_torrent() { local TAR="$1" + echo -e "\n\e[1m[ Create Torrent ]\e[0m" [[ -f "$TAR" ]] || { echo "image $TAR not found"; return 1; } local IMGNAME="$( basename "$TAR" .tar.bz2 )" local DIR="torrent/$IMGNAME" [[ -d "$DIR" ]] && { echo "dir $DIR already exists"; return 1; } mkdir -p torrent/"$IMGNAME" && cp -v --reflink=auto "$TAR" torrent/"$IMGNAME" md5sum "$DIR"/*.bz2 > "$DIR"/md5sum - createtorrent -a udp://tracker.opentrackr.org -p 1337 -c "NextCloudPi. Nextcloud for Raspberry Pi image" "$DIR" "$DIR".torrent + createtorrent -a udp://tracker.opentrackr.org -p 1337 -c "NextCloudPi. Nextcloud ready to use image" "$DIR" "$DIR".torrent } function generate_changelog() @@ -309,6 +321,7 @@ function generate_changelog() function upload_ftp() { local IMGNAME="$1" + echo -e "\n\e[1m[ Upload FTP ]\e[0m" [[ -f torrent/"$IMGNAME"/"$IMGNAME".tar.bz2 ]] || { echo "No image file found, abort"; return 1; } [[ "$FTPPASS" == "" ]] && { echo "No FTPPASS variable found, abort"; return 1; } @@ -340,6 +353,7 @@ function test_image() { local IMG="$1" local IP="$2" + echo -e "\e[1m\n[ QEMU Test ]\e[0m" [[ -f "$IMG" ]] || { echo "No image file found, abort"; return 1; } launch_qemu "$IMG" & sleep 10 diff --git a/config-bananapi.conf b/config-bananapi.conf new file mode 100644 index 00000000..8f7d3a22 --- /dev/null +++ b/config-bananapi.conf @@ -0,0 +1,5 @@ +# +# Place here configuration options that differ from standard NCP build options +# + +BRANCH=next diff --git a/config-odroidxu4.conf b/config-odroidxu4.conf new file mode 100644 index 00000000..8f7d3a22 --- /dev/null +++ b/config-odroidxu4.conf @@ -0,0 +1,5 @@ +# +# Place here configuration options that differ from standard NCP build options +# + +BRANCH=next diff --git a/config-rock64.conf b/config-rock64.conf new file mode 100644 index 00000000..4b5fd536 --- /dev/null +++ b/config-rock64.conf @@ -0,0 +1,6 @@ +# +# Place here configuration options that differ from standard NCP build options +# + +#EXPERT=yes +#LIB_TAG=development |