This commit is contained in:
Igor Pecovnik
2021-10-07 18:23:07 +02:00
commit aa28e4fdd7
89 changed files with 1079 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/*.conf

1
HASH Normal file
View File

@@ -0,0 +1 @@
593104add4263d54f2de7b1095ad561db0d42938

21
README.md Normal file
View File

@@ -0,0 +1,21 @@
- cacherebuild.sh is a script which can run at PUSH + once per day. It regenerates cache:
- all cache 4 days before end of the month (for next month) which is enough that cache is sync across our network
- changed cache where packages were changed
- gpg signing should be done elsewhere
- ubootrebuild.sh builds all u-boots.
- Can be ran manually - before starting testing new release.
- can run on public server
- betarepository.sh builds all kernels if changed
- only builds changed kernels
- always build BSP
- bump nighly version
- update repository
- selected-images.sh builds image for or more boards
# VERSION
- bug fix releases for selected images
- new stable images added after major release
- BSP will be recreated for all and pushed to stable repository
- build artefacts for selected builds will also be pushed to stable repository

1
VERSION Normal file
View File

@@ -0,0 +1 @@
21.08.3

87
betarepository.sh Executable file
View File

@@ -0,0 +1,87 @@
#!/bin/bash
#BLTPATH="/build/"
PULL_FROM="master"
# load config file to override default values
[[ -f betarepository.conf ]] && source betarepository.conf
# delete lock file after 6 hours
sudo find /run -name nightly-repo -type f -mmin +1440 -delete
# exit if kernel update is running
[[ -f /var/run/nightly-repo ]] && echo "Previous job didn't finished." && exit 0
[[ -f ${BLTPATH}output/debs-beta/.waiting ]] && echo "Repository update in progress. Job will restart automatically!" && exit 0
# remove lock file on exit
trap '{ sudo rm -f -- "/var/run/nightly-repo"; }' EXIT
sudo sh -c 'echo $$ > /var/run/nightly-repo'
# remove user configs
sudo rm ${BLTPATH}userpatches/targets.conf 2>/dev/null
cd ${BLTPATH}
# refresh
sudo git pull
sudo git clean -f
# pull changes from master and push to nightly
CURRENT=`sudo git branch | grep "*" | awk '{print $2}'`
# exit if not on nightly
[[ "$CURRENT" != "nightly" ]] && exit 1
# pull from desktop
sudo git checkout -f $PULL_FROM
sudo git reset --hard origin/$PULL_FROM
sudo git fetch
sudo git merge origin/$PULL_FROM
sudo git checkout ${CURRENT}
sudo git merge $PULL_FROM ${CURRENT} --no-ff --no-edit
# exit if push to nightly is not possible
[[ $(sudo git branch | grep "*" | awk '{print $2}') != nightly ]] && exit 1
echo "1"
[[ $? -eq 0 ]] && sudo git push || exit 1
# Build kernels if there is any change to patches, config or upstream
#
# Add patches with label: "beta" or "need testings"
#
#for h in $(sudo gh pr list --label "8.beta" --label "7.needs testing" -R "https://github.com/armbian/build" | cut -f1 | xargs); do
# KOMANDA="sudo wget -qO - https://github.com/armbian/build/pull/$h.patch | sudo git apply --whitespace=nowarn"
# eval $KOMANDA
#done
./compile.sh all-new-beta-kernels
if [[ $? -ne 0 ]]; then
# report error
exit 1
elif [[ "$(cat .tmp/n 2> /dev/null)" -eq 0 ]]; then
sudo rm -f /var/run/nightly-repo
exit 0
fi
# exit if not changes
if [[ -n $(cat output/debug/output.log| grep Error) ]]; then
echo "Error"
# report for error
exit 1
fi
# create BSP
./compile.sh all-new-beta-bsp
[[ $? -ne 0 ]] && exit 1
sleep 1m
touch output/debs-beta/.waiting
echo "Updating repository"
while :
do
sleep 15m
echo "."
[[ ! -f output/debs-beta/.waiting ]] && break
done
./compile.sh all-new-beta-kernels BUMP_VERSION="yes"

420
cacherebuild.sh Executable file
View File

@@ -0,0 +1,420 @@
#!/bin/bash
BLTPATH="$(pwd)/" # path of the build script
FORCE=yes # yes | force = remove cache and create new one
FORCED_MONTH_OFFSET=0 # cache is valid one month. This allows creation in advance
MAKEFORALLAPPS="no" # yes = make all app combinations. It might be too much. If not set, hardcoded values are choosen
PARALLEL_BUILDS="" # choose how many you want to run in parallel. Leave empty for auto
USE_SCREEN="no" # run commands in screen
FORCE_RELEASE="hirsute bullseye" # we only build supported releases caches. her you can add unsupported ones which you wish to experiment
FORCE_DESKTOP="cinnamon" # we only build supported desktop caches. here you can add unsupported ones which you wish to build anyway
PURGEDAYS="4" # delete files that are older then n days and are not used anymore
#
# Fancy status display
#
display_alert()
{
local tmp=""
[[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]"
case $3 in
err)
echo -e "[\e[0;31m error \x1B[0m] $1 $tmp"
;;
wrn)
echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp"
;;
ext)
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0m $tmp"
;;
info)
echo -e "[\e[0;32m o.k. \x1B[0m] $1 $tmp"
;;
*)
echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp"
;;
esac
}
#
# Cycle main build commands
#
function boards
{
# we only need to select one 32 and one 64bit board
local TARGETS=(lepotato bananapi)
for h in "${TARGETS[@]}"
do
PARAMETER=""
[[ $PARALLEL_BUILDS -gt 1 && $USE_SCREEN == yes ]] && PARAMETER="screen -dmSL ${h}$1 "
PARAMETER+="${BLTPATH}compile.sh BOARD=\"$h\" BRANCH=\"current\" RELEASE=\"$1\""
if [[ $2 == cli* ]]; then
PARAMETER+=" BUILD_MINIMAL=\"$4\" BUILD_DESKTOP=\"no\" DESKTOP_ENVIRONMENT=\"\""
else
PARAMETER+=" BUILD_MINIMAL=\"no\" BUILD_DESKTOP=\"yes\" DESKTOP_ENVIRONMENT=\"$2\""
fi
PARAMETER+=" DESKTOP_ENVIRONMENT_CONFIG_NAME=\"$4\" DESKTOP_APPGROUPS_SELECTED=\"$5\" ROOT_FS_CREATE_ONLY=\"${FORCE}\" KERNEL_ONLY=\"no\" "
PARAMETER+=" KERNEL_CONFIGURE=\"no\" OFFLINE_WORK=\"yes\" FORCED_MONTH_OFFSET=\"${FORCED_MONTH_OFFSET}\" IGNORE_UPDATES=\"yes\" SYNC_CLOCK=\"no\" "
PARAMETER+=" REPOSITORY_INSTALL=\"u-boot,kernel,bsp,armbian-config,armbian-firmware\" EXPERT=\"yes\" USE_TORRENT=\"no\" APT_PROXY_ADDR=\"10.0.10.10:3142\""
[[ $USE_SCREEN != yes ]] && PARAMETER+=" &"
r=$(( r + 1 ))
vari=$2
# support for older way. will be deprecated once merged
[[ ! -d config/desktop && $2 == cli_1 ]] && vari=cli
[[ ! -d config/desktop && $2 == cli_2 ]] && vari=minimal
[[ ! -d config/desktop && $2 == xfce ]] && vari=xfce-desktop
CURRENT_TIME=$(date +%s)
[[ $h == "lepotato" ]] && build_architec="arm64" || build_architec="armhf"
if [[ ${DISPLAY_STAT} == yes ]]; then
echo "Rebuilding cache: $(( CURRENT_TIME - START_TIME ))"
echo "[ ${r}. $1_${build_architec}_$2" "$3" "$4" "$5 ]"
echo ""
fi
echo "$PARAMETER" >> ../build-rootfs/filelist.txt
# store pids
PIDS=$PIDS" "$(echo $!)
while :
do
sleep 0.5
CURRENT_TIME=$(date +%s)
CONCURENT=$(df | grep /.tmp | wc -l)
FREE_MEM=$(free | grep Mem | awk '{print $4/$2 * 100}' | awk '{print int($1+0.5)}')
if [[ ${CONCURENT} -le ${PARALLEL_BUILDS} ]]; then
break
fi
done
done
}
#
# Cycle or scan for releases we use
#
function releases
{
local releases=($(grep -rw config/distributions/*/ -e 'supported' | cut -d"/" -f3))
[[ -n $FORCE_RELEASE ]] && local releases+=($FORCE_RELEASE)
for i in ${releases[@]}
do
variants "$i"
done
}
#
# Cycle build variants, cli, cli, minimal
#
function variants
{
local variants=(cli_1 cli_2)
local variants+=($(find -L config/desktop/$1/environments/ -name support -exec grep -l 'supported' {} \; | cut -d"/" -f5))
[[ -n $FORCE_DESKTOP ]] && local variants+=($FORCE_DESKTOP)
for j in ${variants[@]}
do
build_desktop="yes"
build_minimal="no"
[[ $j == cli_1 ]] && build_desktop="no" && build_minimal="no"
[[ $j == cli_2 ]] && build_desktop="no" && build_minimal="yes"
configs "$1" "$j" "$build_desktop" "$build_minimal"
done
}
#
# Cycle build configs - full / minimal / medium
#
function configs
{
if [[ -d config/desktop && $build_desktop != no ]]; then
local configs=($(find -L config/desktop/$1/environments/$2/config* -name packages 2>/dev/null | cut -d"/" -f6 | uniq))
else
local configs="$4"
fi
for k in ${configs[@]}
do
appgroup "$1" "$2" "$3" "$k"
done
}
#
# Cycle appgroup and make all combinations
#
function appgroup
{
# optionally set limi from head. Default = all
local limit=16
if [[ -d config/desktop && $3 == "yes" && $MAKEFORALLAPPS == "yes" ]]; then
string=$(find -L config/desktop/$1/appgroups/ -mindepth 1 -maxdepth 1 -type d 2> /dev/null | sort | cut -d"/" -f5 | head -${limit} | tr '\n' ' ' )
string=$(printf '%s\n' "$string" | tr -s '[:blank:]' ' ')
wordCount=$(printf '%s\n' "$string" | wc -w)
start=1
boards "$1" "$2" "$3" "$4" ""
while [ $start -le $wordCount ]; do
end=$start
while [ $end -le $wordCount ]; do
boards "$1" "$2" "$3" "$4" "$(printf '%s\n' "$string" | cut -d ' ' -f "$start-$end")"
end=$(( end + 1 ))
done
start=$(( start + 1 ))
done
elif [[ -d config/desktop && $3 == "yes" ]]; then
boards "$1" "$2" "$3" "$4" ""
boards "$1" "$2" "$3" "$4" "browsers"
boards "$1" "$2" "$3" "$4" "browsers chat desktop_tools editors email internet languages multimedia office programming remote_desktop"
if [[ -d "config/desktop/$1/appgroups/3dsupport" ]]; then
boards "$1" "$2" "$3" "$4" "3dsupport browsers"
boards "$1" "$2" "$3" "$4" "3dsupport browsers chat desktop_tools editors email internet languages multimedia office programming remote_desktop"
fi
else
boards "$1" "$2" "$3" "$4" ""
fi
}
#
# Main function
#
# load config file to override default values
[[ -f cacherebuild.conf ]] && source cacherebuild.conf
# hardcoded variables and calculations
DAYSBEFORE=4
START_TIME=$(date +%s)
MONTH=$(date -d "$M" '+%m' | sed 's/\<0//g')
DAYINMONTH=$(date -d "$D" '+%d' | sed 's/\<0//g')
REBUILDDAY=$(date -d "${MONTH}/1 + 1 month - ${DAYSBEFORE} day" "+%d")
MEM_INFO=$(($(LC_ALL=C free -w 2>/dev/null | grep "^Mem" | awk '{print $2}' || LC_ALL=C free | grep "^Mem"| awk '{print $2}')/1024))
r=0
# jump to build script folder
cd ${BLTPATH}
display_alert "Starting rootfs cache rebuilt" "$(date)" "info"
display_alert "Currently present cache files" "$(ls -l ${BLTPATH}cache/rootfs/*.lz4 2> /dev/null | wc -l)" "info"
git pull -q 2> /dev/null
if [[ $? -ne 0 ]]; then
display_alert "Updating build script" "git pull" "err"
exit 1
else
display_alert "Updating build script" "git pull" "info"
fi
display_alert "System memory" "$(($MEM_INFO/1024))Gb" "info"
if [[ -z ${PARALLEL_BUILDS} ]]; then
PARALLEL_BUILDS=$(awk '{printf("%d",$1/12000)}' <<<${MEM_INFO})
display_alert "Calculated parallel builds" "$PARALLEL_BUILDS" "info"
else
display_alert "Selected parallel builds" "$PARALLEL_BUILDS" "info"
fi
if [[ "${FORCE}" == "force" ]]; then
display_alert "Cache will be removed and rebuild" "${FORCE}" "info"
else
display_alert "Cache will be updated" "${FORCE}" "info"
fi
# when we should start building for next month
if [[ $DAYINMONTH -gt $REBUILDDAY ]]; then
display_alert "${DAYSBEFORE} days before next month" "building for next month FORCED_MONTH_OFFSET=1" "info"
FORCED_MONTH_OFFSET=1
fi
if [[ $DAYINMONTH -lt 7 ]]; then
display_alert "First seven (7) days we clean files of previous month" "cleaning files older then 14 days" "info"
find ${BLTPATH}cache/rootfs/ -type f -mtime +14 -exec sudo rm -f {} \;
fi
if [[ $UPLOAD != "yes" ]]; then
display_alert "Uploading to servers" "no" "info"
else
display_alert "Uploading to servers" "yes" "info"
fi
# don't start if previous run is still running
while :
do
sleep 3
CURRENT_TIME=$(date +%s)
display_alert "Waiting for cleanup" "yes" "info"
if [[ $(df | grep /.tmp | wc -l) -lt 1 ]]; then
break
fi
done
# removing previous cache if forced
[[ "${FORCE}" == "force" ]] && sudo rm -f ${BLTPATH}cache/rootfs/*
# removing previous tmp build directories
sudo rm -rf ${BLTPATH}.tmp
sudo rm ${BLTPATH}cache/rootfs/*.current 2>/dev/null
sleep 3
# run main rebuild function
releases
#
# wait until all build PIDS are done
#
while true
do
i=0
for pids in $PIDS
do
if ps -p $pids > /dev/null; then
i=$((i+1))
fi
done
[[ $i -eq 0 ]] && break
done
exit
#
# clean all build that are not labelled as .current and are older then 4 days
#
if [[ ${FORCED_MONTH_OFFSET} -eq 0 ]]; then
display_alert "Clean all build that are not labelled as current." "cleanup" "info"
# create a diff between marked as current and others
BRISI=($(diff <(find ${BLTPATH}cache/rootfs -name "*.lz4.current" | sed "s/.current//" | sort) <(find ${BLTPATH}cache/rootfs -name "*.lz4" | sort) | grep ">" | sed "s/> //"))
for brisi in "${BRISI[@]}"; do
if [[ $(find "$brisi" -mtime +${PURGEDAYS} -print) ]]; then
display_alert "File is older then ${PURGEDAYS} days. Deleting." "$(basename $brisi)" "info"
sudo rm $brisi
else
display_alert "File is not older then ${PURGEDAYS} days" "$(basename $brisi)" "info"
fi
done
# remove .current mark
sudo rm ${BLTPATH}cache/rootfs/*.current
fi
# calculate execution time
CURRENT_TIME=$(date +%s)
display_alert "Rebuilding cache time" "$(( CURRENT_TIME - START_TIME )) seconds" "info"
display_alert "Currently present cache files" "$(ls -l ${BLTPATH}cache/rootfs/*.lz4 | wc -l)" "info"
# files are collected by 3rd party script if this file exists
sudo touch ${BLTPATH}cache/rootfs/.waiting
# removing previous tmp build directories
sudo rm -rf ${BLTPATH}.tmp

View File

@@ -0,0 +1,16 @@
RC="yes"
KERNEL_ONLY="no"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
LIB_TAG="${INPUT_RC_LIB_TAG}"
USE_TORRENT="yes"
BUILD_KSRC="no"
IGNORE_UPDATES="yes"
REPOSITORY_INSTALL="u-boot,kernel,armbian-config,armbian-firmware"
IGNORE_HASH="yes"
MULTITHREAD="4"
EXPERT="yes"

View File

@@ -0,0 +1,22 @@
BETA="yes"
KERNEL_ONLY="no"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
LIB_TAG="nightly"
USE_TORRENT="yes"
BUILD_KSRC="no"
IGNORE_UPDATES="yes"
IGNORE_HASH="yes"
MULTITHREAD="16"
#BUMP_VERSION="yes"
ALLTARGETS="yes"
OFFLINE_WORK="yes"
BSP_BUILD="yes"
SYNC_CLOCK="no"
REPOSITORY_INSTALL="u-boot,kernel,armbian-zsh,armbian-config,armbian-firmware"
MAKE_ALL_BETA="yes"
EXPERT="yes"

View File

@@ -0,0 +1,16 @@
BETA="yes"
KERNEL_ONLY="no"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
LIB_TAG="nightly"
USE_TORRENT="yes"
BUILD_KSRC="no"
IGNORE_UPDATES="yes"
REPOSITORY_INSTALL="u-boot,kernel,armbian-config,armbian-firmware"
IGNORE_HASH="yes"
MULTITHREAD="4"
EXPERT="yes"

View File

@@ -0,0 +1,18 @@
BETA="yes"
MAKE_ALL_BETA="yes"
KERNEL_ONLY="yes"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
LIB_TAG="nightly"
USE_TORRENT="yes"
REPOSITORY_INSTALL="u-boot"
BUILD_KSRC="yes"
PRIVATE_CCACHE="yes"
#BUMP_VERSION="yes"
#MULTITHREAD="100"
#USE_OVERLAYFS="yes"
EXPERT="yes"

View File

@@ -0,0 +1,22 @@
BETA="no"
KERNEL_ONLY="no"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
LIB_TAG="nightly"
USE_TORRENT="yes"
BUILD_KSRC="no"
IGNORE_UPDATES="yes"
IGNORE_HASH="yes"
MULTITHREAD="16"
#BUMP_VERSION="yes"
ALLTARGETS="yes"
OFFLINE_WORK="yes"
BSP_BUILD="yes"
SYNC_CLOCK="no"
REPOSITORY_INSTALL="u-boot,kernel,armbian-config,armbian-firmware"
MAKE_ALL_BETA="yes"
EXPERT="yes"

View File

@@ -0,0 +1,17 @@
BETA="no"
KERNEL_ONLY="no"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
#LIB_TAG="v20.11"
USE_TORRENT="yes"
BUILD_KSRC="no"
IGNORE_UPDATES="yes"
#REPOSITORY_INSTALL="u-boot,kernel,armbian-config,armbian-firmware"
REPOSITORY_INSTALL="u-boot"
IGNORE_HASH="yes"
MULTITHREAD="30"
EXPERT="yes"

View File

@@ -0,0 +1,15 @@
BETA="no"
MAKE_ALL_BETA="yes"
KERNEL_ONLY="yes"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
LIB_TAG="master"
USE_TORRENT="yes"
REPOSITORY_INSTALL="u-boot"
BUILD_KSRC="yes"
PRIVATE_CCACHE="yes"
EXPERT="yes"

View File

@@ -0,0 +1,17 @@
BETA="no"
MAKE_ALL_BETA="yes"
KERNEL_ONLY="yes"
KERNEL_CONFIGURE="no"
CLEAN_LEVEL="make,oldcache"
DEST_LANG="en_US.UTF-8"
KERNEL_KEEP_CONFIG="no"
EXTERNAL_NEW="prebuilt"
BUILD_ALL="yes"
LIB_TAG="master"
USE_TORRENT="yes"
BUILD_KSRC="yes"
PRIVATE_CCACHE="yes"
REPOSITORY_INSTALL="kernel,armbian-config,armbian-firmware"
IGNORE_HASH="yes"
BSP_BUILD="yes"
SYNC_CLOCK="no"

View File

@@ -0,0 +1,24 @@
# Read build script documentation https://docs.armbian.com/Developer-Guide_Build-Options/
# for detailed explanation of these options and for additional options not listed here
KERNEL_ONLY="" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
KERNEL_CONFIGURE="" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
CLEAN_LEVEL="make,debs,oldcache" # comma-separated list of clean targets: "make" = make clean for selected kernel and u-boot,
# "debs" = delete packages in "./output/debs" for current branch and family,
# "alldebs" = delete all packages in "./output/debs", "images" = delete "./output/images",
# "cache" = delete "./output/cache", "sources" = delete "./sources"
# "oldcache" = remove old cached rootfs except for the newest 8 files
REPOSITORY_INSTALL="" # comma-separated list of core modules which will be installed from repository
# "u-boot", "kernel", "bsp", "armbian-config", "armbian-firmware"
# leave empty to build from sources or use local cache
DEST_LANG="en_US.UTF-8" # sl_SI.UTF-8, en_US.UTF-8
# advanced
EXTERNAL_NEW="prebuilt" # compile and install or install prebuilt additional packages
INSTALL_HEADERS="" # install kernel headers package
LIB_TAG="nightly" # change to "branchname" to use any branch currently available.
USE_TORRENT="yes" # use torrent network for faster toolchain and cache download
DOWNLOAD_MIRROR="" # set to "china" to use mirrors.tuna.tsinghua.edu.cn
CARD_DEVICE="" # device name /dev/sdx of your SD card to burn directly to the card when done

143
configs/config-docker.conf Normal file
View File

@@ -0,0 +1,143 @@
# DO NOT EDIT THIS FILE
#
# This is a Docker launcher file. To set up the configuration, use command line arguments to compile.sh
# or use pass a config file as a parameter ./compile docker [example] BUILD_KERNEL="yes" ...
[[ ! -c /dev/loop-control ]] && display_alert "/dev/loop-control does not exist, image building may not work" "" "wrn"
# second argument can be a build parameter or a config file
# create user accessible directories and set their owner group and permissions
# if they are created from Docker they will be owned by root and require root permissions to change/delete
mkdir -p $SRC/{output,userpatches}
grep -q '^docker:' /etc/group && chgrp --quiet docker $SRC/{output,userpatches}
chmod --quiet g+w,g+s $SRC/{output,userpatches}
VERSION=$(cat $SRC/VERSION)
if grep -q $VERSION <(grep armbian <(docker images)); then
display_alert "Using existed a armbian Docker container"
else
# build a new container based on provided Dockerfile
display_alert "Docker container not found or out of date"
display_alert "Building a Docker container"
if ! docker build -t armbian:$VERSION . ; then
STATUS=$?
# Adding a newline, so the alert won't be shown in the same line as the error
echo
display_alert "Docker container build exited with code: " "$STATUS" "err"
exit 1
fi
fi
DOCKER_FLAGS=()
# Running this container in privileged mode is a simple way to solve loop device access issues
# Required for USB FEL or when writing image directly to the block device, when CARD_DEVICE is defined
#DOCKER_FLAGS+=(--privileged)
# add only required capabilities instead (though MKNOD should be already present)
# CAP_SYS_PTRACE is required for systemd-detect-virt in some cases
DOCKER_FLAGS+=(--cap-add=SYS_ADMIN --cap-add=MKNOD --cap-add=SYS_PTRACE)
# mounting things inside the container on Ubuntu won't work without this
# https://github.com/moby/moby/issues/16429#issuecomment-217126586
DOCKER_FLAGS+=(--security-opt=apparmor:unconfined)
# remove resulting container after exit to minimize clutter
# bad side effect - named volumes are considered not attached to anything and are removed on "docker volume prune"
#DOCKER_FLAGS+=(--rm)
# pass through loop devices
for d in /dev/loop*; do
DOCKER_FLAGS+=(--device=$d)
done
# accessing dynamically created devices won't work by default
# and --device doesn't accept devices that don't exist at the time "docker run" is executed
# https://github.com/moby/moby/issues/27886
# --device-cgroup-rule requires new Docker version
# Test for --device-cgroup-rule support. If supported, appends it
# Otherwise, let it go and let user know that only kernel and u-boot for you
if docker run --help | grep device-cgroup-rule > /dev/null 2>&1; then
# allow loop devices (not required)
DOCKER_FLAGS+=(--device-cgroup-rule='b 7:* rmw')
# allow loop device partitions
DOCKER_FLAGS+=(--device-cgroup-rule='b 259:* rmw')
# this is an ugly hack, but it is required to get /dev/loopXpY minor number
# for mknod inside the container, and container itself still uses private /dev internally
DOCKER_FLAGS+=(-v /dev:/tmp/dev:ro)
else
display_alert "Your Docker version does not support device-cgroup-rule" "" "wrn"
display_alert "and will be able to create only Kernel and u-boot packages (KERNEL_ONLY=yes)" "" "wrn"
fi
# Expose ports for NFS server inside docker container, required for USB FEL
#DOCKER_FLAGS+=(-p 0.0.0.0:2049:2049 -p 0.0.0.0:2049:2049/udp -p 0.0.0.0:111:111 -p 0.0.0.0:111:111/udp -p 0.0.0.0:32765:32765 -p 0.0.0.0:32765:32765/udp -p 0.0.0.0:32767:32767 -p 0.0.0.0:32767:32767/udp)
# Export usb device for FEL, required for USB FEL
#DOCKER_FLAGS+=(-v /dev/bus/usb:/dev/bus/usb:ro)
# map source to Docker Working dir.
DOCKER_FLAGS+=(-v=$SRC/:/root/armbian/)
# mount 2 named volumes - for cacheable data and compiler cache
DOCKER_FLAGS+=(-v=armbian-cache:/root/armbian/cache -v=armbian-ccache:/root/.ccache)
DOCKER_FLAGS+=(-e COLUMNS="`tput cols`" -e LINES="`tput lines`")
# pass other command line arguments like KERNEL_ONLY=yes, KERNEL_CONFIGURE=yes, etc.
# pass "docker-guest" as an additional config name that will be sourced in the container if exists
if [[ $SHELL_ONLY == yes ]]; then
display_alert "Running the container in shell mode" "" "info"
cat <<\EOF
Welcome to the docker shell of Armbian.
To build the whole thing using default profile, run:
./compile.sh
To build the U-Boot only, run:
# Optional: prepare the environment first if you had not run `./compile.sh`
./compile.sh 'prepare_host && compile_sunxi_tools && install_rkbin_tools'
# build the U-Boot only
./compile.sh compile_uboot
If you prefer to use profile, for example, `userpatches/config-my.conf`, try:
./compile.sh my 'prepare_host && compile_sunxi_tools && install_rkbin_tools'
./compile.sh my compile_uboot
EOF
docker run "${DOCKER_FLAGS[@]}" -it --rm --entrypoint /usr/bin/env armbian:$VERSION "$@" /bin/bash
else
display_alert "Running the container" "" "info"
docker run "${DOCKER_FLAGS[@]}" -it --rm armbian:$VERSION "$@"
fi
# Docker error treatment
STATUS=$?
# Adding a newline, so the message won't be shown in the same line as the error
echo
case $STATUS in
0)
# No errors from either Docker or build script
echo
;;
125)
display_alert "Docker command failed, check syntax or version support. Error code: " "$STATUS" "err"
;;
126)
display_alert "Failure when running containerd command. Error code: " "$STATUS" "err"
;;
127)
display_alert "containerd command not found. Error code: " "$STATUS" "err"
;;
137)
display_alert "Container exit from docker stop. Error code: " "$STATUS" "info"
;;
*)
# Build script exited with error, but the error message should have been already printed
echo
;;
esac
# don't need to proceed further on the host
exit 0

View File

@@ -0,0 +1,24 @@
# Read build script documentation https://docs.armbian.com/Developer-Guide_Build-Options/
# for detailed explanation of these options and for additional options not listed here
KERNEL_ONLY="" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
KERNEL_CONFIGURE="" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
CLEAN_LEVEL="make,debs,oldcache" # comma-separated list of clean targets: "make" = make clean for selected kernel and u-boot,
# "debs" = delete packages in "./output/debs" for current branch and family,
# "alldebs" = delete all packages in "./output/debs", "images" = delete "./output/images",
# "cache" = delete "./output/cache", "sources" = delete "./sources"
# "oldcache" = remove old cached rootfs except for the newest 8 files
REPOSITORY_INSTALL="" # comma-separated list of core modules which will be installed from repository
# "u-boot", "kernel", "bsp", "armbian-config", "armbian-firmware"
# leave empty to build from sources or use local cache
DEST_LANG="en_US.UTF-8" # sl_SI.UTF-8, en_US.UTF-8
# advanced
EXTERNAL_NEW="prebuilt" # compile and install or install prebuilt additional packages
INSTALL_HEADERS="" # install kernel headers package
LIB_TAG="nightly" # change to "branchname" to use any branch currently available.
USE_TORRENT="yes" # use torrent network for faster toolchain and cache download
DOWNLOAD_MIRROR="" # set to "china" to use mirrors.tuna.tsinghua.edu.cn
CARD_DEVICE="" # device name /dev/sdx of your SD card to burn directly to the card when done

View File

@@ -0,0 +1,20 @@
KERNEL_ONLY="no" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
KERNEL_CONFIGURE="no" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
CLEAN_LEVEL="make,oldcache" # comma-separated list of clean targets: "make" = make clean for selected kernel and u-boot,
# "debs" = delete packages in "./output/debs" for current branch and family,
# "alldebs" = delete all packages in "./output/debs", "images" = delete "./output/images",
# "cache" = delete "./output/cache", "sources" = delete "./sources"
# "oldcache" = remove old cached rootfs except for the newest 6 files
DEST_LANG="en_US.UTF-8" # sl_SI.UTF-8, en_US.UTF-8
# advanced
KERNEL_KEEP_CONFIG="no" # do not overwrite kernel config before compilation
EXTERNAL_NEW="prebuilt" # compile and install or install prebuilt additional packages
BUILD_KSRC="no"
EXPERT="yes"
SYNC_CLOCK="no"
COMPRESS_OUTPUTIMAGE="no"
LIB_TAG="nightly"
#USE_MAINLINE_GOOGLE_MIRROR="yes"
USE_OVERLAYFS="yes"

6
configs/lib.config Normal file
View File

@@ -0,0 +1,6 @@
[[ $(curl -s http://ifconfig.me) == "93.103.15.56" ]] && APT_PROXY_ADDR="10.0.10.10:3142"
FORCE_USE_RAMDISK="yes"
COMPRESS_OUTPUTIMAGE="sha,gpg,xz"
PRIVATE_CCACHE="yes"
FAST_CREATE_IMAGE="yes"
NO_HOST_RELEASE_CHECK="yes"

0
hash-beta/foe Normal file
View File

Some files were not shown because too many files have changed in this diff Show More