general build improvements

This commit is contained in:
nachoparker 2018-05-28 23:19:13 +02:00
parent b45e68f1f0
commit d578ef1568
10 changed files with 107 additions and 148 deletions

View File

@ -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

64
build-SD-armbian.sh Executable file
View File

@ -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 )"

View File

@ -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 )"

View File

@ -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 )"

View File

@ -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 )"

View File

@ -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"

View File

@ -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

5
config-bananapi.conf Normal file
View File

@ -0,0 +1,5 @@
#
# Place here configuration options that differ from standard NCP build options
#
BRANCH=next

5
config-odroidxu4.conf Normal file
View File

@ -0,0 +1,5 @@
#
# Place here configuration options that differ from standard NCP build options
#
BRANCH=next

6
config-rock64.conf Normal file
View File

@ -0,0 +1,6 @@
#
# Place here configuration options that differ from standard NCP build options
#
#EXPERT=yes
#LIB_TAG=development