Dependencies installation moved to new function "prepare_host"
Modified list of dependencies Modified method of dependencies installation Experimental support for building kernels on Debian Jessie and Ubuntu Wily hosts
This commit is contained in:
parent
c15437c404
commit
a89198be5b
116
general.sh
116
general.sh
@ -281,4 +281,118 @@ while [[ $j -lt ${#DISTROS[@]} ]]
|
||||
|
||||
j=$[$j+1]
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
# prepare_host
|
||||
#
|
||||
# * checks and installs necessary packages
|
||||
# * creates directory structure
|
||||
# * changes system settings
|
||||
#
|
||||
prepare_host() {
|
||||
|
||||
display_alert "Preparing" "host" "info"
|
||||
|
||||
# dialog may be used to display progress
|
||||
if [[ "$(dpkg-query -W -f='${db:Status-Abbrev}\n' dialog 2>/dev/null)" != *ii* ]]; then
|
||||
display_alert "Installing package" "dialog" "info"
|
||||
apt-get install -qq -y dialog >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# wget is needed
|
||||
if [[ "$(dpkg-query -W -f='${db:Status-Abbrev}\n' wget 2>/dev/null)" != *ii* ]]; then
|
||||
display_alert "Installing package" "wget" "info"
|
||||
apt-get install -qq -y wget >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# need lsb_release to decide what to install
|
||||
if [[ "$(dpkg-query -W -f='${db:Status-Abbrev}\n' lsb-release 2>/dev/null)" != *ii* ]]; then
|
||||
display_alert "Installing package" "lsb-release" "info"
|
||||
apt-get install -qq -y lsb-release >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# packages list for host
|
||||
PAK="aptly ca-certificates device-tree-compiler pv bc lzop zip binfmt-support bison build-essential ccache debootstrap flex ntpdate pigz \
|
||||
gawk gcc-arm-linux-gnueabihf lvm2 qemu-user-static u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev ntpdate\
|
||||
parted pkg-config expect libncurses5-dev whiptail debian-keyring debian-archive-keyring"
|
||||
|
||||
# warning: apt-cacher-ng will fail if installed and used both on host and in container/chroot environment with shared network
|
||||
# set NO_APT_CACHER=yes to prevent installation errors in such case
|
||||
if [ "$NO_APT_CACHER" != "yes" ]; then PAK="$PAK apt-cacher-ng"; fi
|
||||
|
||||
local codename=$(lsb_release -sc)
|
||||
if [[ $codename == "" || "jessie trusty wily" != *"$codename"* ]]; then
|
||||
display_alert "Host system support was not tested" "${codename:-(unknown)}" "wrn"
|
||||
fi
|
||||
|
||||
if [ "$codename" = "jessie" ]; then
|
||||
PAK="$PAK crossbuild-essential-armhf";
|
||||
if [ ! -f "/etc/apt/sources.list.d/crosstools.list" ]; then
|
||||
display_alert "Adding repository for jessie" "cross-tools" "info"
|
||||
dpkg --add-architecture armhf > /dev/null 2>&1
|
||||
echo 'deb http://emdebian.org/tools/debian/ jessie main' > /etc/apt/sources.list.d/crosstools.list
|
||||
wget 'http://emdebian.org/tools/debian/emdebian-toolchain-archive.key' -O - | apt-key add - >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$codename" = "trusty" ]; then
|
||||
PAK="$PAK libc6-dev-armhf-cross";
|
||||
if [ ! -f "/etc/apt/sources.list.d/aptly.list" ]; then
|
||||
display_alert "Adding repository for trusty" "aptly" "info"
|
||||
echo 'deb http://repo.aptly.info/ squeeze main' > /etc/apt/sources.list.d/aptly.list
|
||||
apt-key adv --keyserver keys.gnupg.net --recv-keys E083A3782A194991
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$codename" = "wily" ]; then PAK="$PAK gcc-4.9-arm-linux-gnueabihf"; fi
|
||||
|
||||
local deps=()
|
||||
local installed=$(dpkg-query -W -f '${db:Status-Abbrev}|${binary:Package}\n' '*' 2>/dev/null | grep '^ii' | awk -F '|' '{print $2}' | cut -d ':' -f 1)
|
||||
|
||||
for packet in $PAK; do
|
||||
grep -q -x -e "$packet" <<< "$installed"
|
||||
if [ "$?" -ne "0" ]; then deps+=("$packet"); fi
|
||||
done
|
||||
|
||||
if [ "${#deps[@]}" -gt "0" ]; then
|
||||
eval '( apt-get update; apt-get -y install "${deps[@]}" )' \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/output.log'} \
|
||||
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Installing ${#deps[@]} host dependencies..." 20 80'} \
|
||||
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
|
||||
fi
|
||||
|
||||
# TODO: Check for failed installation process
|
||||
# test exit code propagation for commands in parentheses
|
||||
|
||||
# enable arm binary format so that the cross-architecture chroot environment will work
|
||||
test -e /proc/sys/fs/binfmt_misc/qemu-arm || update-binfmts --enable qemu-arm
|
||||
|
||||
# create directory structure
|
||||
mkdir -p $SOURCES $DEST/debug $SRC/userpatches/
|
||||
find $SRC/lib/patch -type d ! -name . | sed "s%lib/patch%userpatches%" | xargs mkdir -p
|
||||
|
||||
# TODO: needs better documentation
|
||||
echo 'Place your patches and kernel.config / u-boot.config here.' > $SRC/userpatches/readme.txt
|
||||
echo 'They will be automatically included if placed here!' >> $SRC/userpatches/readme.txt
|
||||
|
||||
# legacy kernel compilation needs cross-gcc version 4.9 or lower
|
||||
# gcc-arm-linux-gnueabihf installs gcc version 5 by default on wily
|
||||
if [ "$codename" = "wily" ]; then
|
||||
local GCC=$(which arm-linux-gnueabihf-gcc)
|
||||
while [ -L "$GCC" ]; do
|
||||
GCC=$(readlink "$GCC")
|
||||
done
|
||||
local version=$(basename "$GCC" | awk -F '-' '{print $NF}')
|
||||
if (( $(echo "$version > 4.9" | bc -l) )); then
|
||||
update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-4.9 10 \
|
||||
--slave /usr/bin/arm-linux-gnueabihf-cpp arm-linux-gnueabihf-cpp /usr/bin/arm-linux-gnueabihf-cpp-4.9 \
|
||||
--slave /usr/bin/arm-linux-gnueabihf-gcov arm-linux-gnueabihf-gcov /usr/bin/arm-linux-gnueabihf-gcov-4.9
|
||||
|
||||
update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-5 11 \
|
||||
--slave /usr/bin/arm-linux-gnueabihf-cpp arm-linux-gnueabihf-cpp /usr/bin/arm-linux-gnueabihf-cpp-5 \
|
||||
--slave /usr/bin/arm-linux-gnueabihf-gcov arm-linux-gnueabihf-gcov /usr/bin/arm-linux-gnueabihf-gcov-5
|
||||
|
||||
update-alternatives --set arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-4.9
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
74
main.sh
74
main.sh
@ -13,27 +13,19 @@
|
||||
#
|
||||
#
|
||||
|
||||
# Include here to make "display_alert" and "prepare_host" available
|
||||
source $SRC/lib/general.sh # General functions
|
||||
|
||||
# Script parameters handling
|
||||
for i in "$@"; do
|
||||
if [[ "$i" == *"="* ]]; then
|
||||
parameter=${i%%=*}
|
||||
value=${i##*=}
|
||||
echo "[info] Command line: setting $parameter to ${value:-(empty)}"
|
||||
display_alert "Command line: setting $parameter to" "${value:-(empty)}" "info"
|
||||
eval $parameter=$value
|
||||
fi
|
||||
done
|
||||
|
||||
# compile.sh version checking
|
||||
ver1=$(grep '^# VERSION' "$SRC/compile.sh" | cut -d'=' -f2)
|
||||
ver2=$(grep '^# VERSION' "$SRC/lib/compile.sh" | cut -d'=' -f2)
|
||||
if [ -z "$ver1" ] || [ "$ver1" -lt "$ver2" ]; then
|
||||
echo -e "[\e[0;35m warn \x1B[0m] File $0 is outdated. Please copy it again, \nchange options if needed and restart compilation process"
|
||||
read -p "Press <Ctrl-C> to abort compilation, <Enter> to continue"
|
||||
fi
|
||||
|
||||
# We'll use this tittle on all menus
|
||||
backtitle="Armbian building script, http://www.armbian.com | Author: Igor Pecovnik"
|
||||
|
||||
if [ "$PROGRESS_DISPLAY" = "none" ]; then
|
||||
OUTPUT_VERYSILENT=yes;
|
||||
elif [ "$PROGRESS_DISPLAY" != "plain" ]; then
|
||||
@ -41,22 +33,16 @@ elif [ "$PROGRESS_DISPLAY" != "plain" ]; then
|
||||
fi
|
||||
if [ "$PROGRESS_LOG_TO_FILE" = "yes" ]; then rm -f $DEST/debug/compilation.log; else unset PROGRESS_LOG_TO_FILE; fi
|
||||
|
||||
mkdir -p $DEST/debug $SRC/userpatches/kernel $SRC/userpatches/u-boot
|
||||
echo -e "Place your patches and kernel.config / u-boot.config here.\n" > $SRC/userpatches/readme.txt
|
||||
echo -e "They'll be automaticly included if placed here!" >> $SRC/userpatches/readme.txt
|
||||
# compile.sh version checking
|
||||
ver1=$(grep '^# VERSION' "$SRC/compile.sh" | cut -d'=' -f2)
|
||||
ver2=$(grep '^# VERSION' "$SRC/lib/compile.sh" | cut -d'=' -f2)
|
||||
if [ -z "$ver1" ] || [ "$ver1" -lt "$ver2" ]; then
|
||||
display_alert "File $0 is outdated. Please overwrite is with updated version from" "$SRC/lib" "wrn"
|
||||
read -p "Press <Ctrl-C> to abort compilation, <Enter> to ignore and continue"
|
||||
fi
|
||||
|
||||
# Install some basic support if not here yet
|
||||
if [ $(dpkg-query -W -f='${Status}' whiptail 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||
apt-get install -qq -y whiptail bc >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ $(dpkg-query -W -f='${Status}' bc 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||
apt-get install -qq -y bc >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ $(dpkg-query -W -f='${Status}' dialog 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||
apt-get install -qq -y dialog >/dev/null 2>&1
|
||||
fi
|
||||
# We'll use this title on all menus
|
||||
backtitle="Armbian building script, http://www.armbian.com | Author: Igor Pecovnik"
|
||||
|
||||
# if language not set, set to english
|
||||
[ "$LANGUAGE" == "" ] && export LANGUAGE="en_US:en"
|
||||
@ -64,13 +50,8 @@ fi
|
||||
# default console if not set
|
||||
[ "$CONSOLE_CHAR" == "" ] && export CONSOLE_CHAR="UTF-8"
|
||||
|
||||
# Add aptly repository for repo handling
|
||||
if [ ! -f "/etc/apt/sources.list.d/aptly.list" ]; then
|
||||
echo "deb http://repo.aptly.info/ squeeze main" > /etc/apt/sources.list.d/aptly.list
|
||||
apt-key adv --keyserver keys.gnupg.net --recv-keys E083A3782A194991
|
||||
apt-get update
|
||||
fi
|
||||
|
||||
# Check and fix dependencies, directory structure and settings
|
||||
prepare_host
|
||||
|
||||
# Choose destination - creating board list from file configuration.sh
|
||||
if [ "$BOARD" == "" ]; then
|
||||
@ -91,7 +72,6 @@ fi
|
||||
|
||||
if [ "$BOARD" == "" ]; then echo "ERROR: You have to choose one board"; exit; fi
|
||||
|
||||
|
||||
# This section is left out if we only compile kernel
|
||||
if [ "$KERNEL_ONLY" != "yes" ]; then
|
||||
|
||||
@ -114,7 +94,6 @@ if [ "$KERNEL_ONLY" != "yes" ]; then
|
||||
|
||||
if [ "$RELEASE" == "" ]; then echo "ERROR: You have to choose one distribution"; exit; fi
|
||||
|
||||
|
||||
# Choose to build a desktop
|
||||
if [ "$BUILD_DESKTOP" == "" ]; then
|
||||
IFS=";"
|
||||
@ -136,7 +115,6 @@ if [ "$KERNEL_ONLY" != "yes" ]; then
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# Choose for which branch you want to compile
|
||||
if [ "$BRANCH" == "" ]; then
|
||||
# get info crom configuration which kernel can be build for certain board
|
||||
@ -194,7 +172,7 @@ unset IFS
|
||||
# naming to distro
|
||||
if [[ "$RELEASE" == "precise" || "$RELEASE" == "trusty" ]]; then DISTRIBUTION="Ubuntu"; else DISTRIBUTION="Debian"; fi
|
||||
|
||||
# set hostname to the board
|
||||
# set hostname to the board
|
||||
HOST="$BOARD"
|
||||
|
||||
# The name of the job
|
||||
@ -202,15 +180,14 @@ VERSION="Armbian $REVISION ${BOARD^} $DISTRIBUTION $RELEASE $BRANCH"
|
||||
echo `date +"%d.%m.%Y %H:%M:%S"` $VERSION > $DEST/debug/install.log
|
||||
|
||||
# Load libraries
|
||||
source $SRC/lib/general.sh # General functions
|
||||
source $SRC/lib/configuration.sh # Board configuration
|
||||
source $SRC/lib/debootstrap.sh # System specific install
|
||||
source $SRC/lib/distributions.sh # System specific install
|
||||
source $SRC/lib/patching.sh # Source patching
|
||||
source $SRC/lib/boards.sh # Board specific install
|
||||
source $SRC/lib/desktop.sh # Desktop specific install
|
||||
source $SRC/lib/common.sh # Functions
|
||||
source $SRC/lib/makeboarddeb.sh # Create board support package
|
||||
source $SRC/lib/boards.sh # Board specific install
|
||||
source $SRC/lib/desktop.sh # Desktop specific install
|
||||
source $SRC/lib/common.sh # Functions
|
||||
source $SRC/lib/makeboarddeb.sh # Create board support package
|
||||
|
||||
# needed if process failed in the middle
|
||||
umount_image
|
||||
@ -241,15 +218,6 @@ else
|
||||
display_alert "Building" "$VERSION" "info"
|
||||
fi
|
||||
|
||||
# download packages for host
|
||||
PAK="aptly device-tree-compiler pv bc lzop zip binfmt-support bison build-essential ccache debootstrap flex ntpdate pigz "
|
||||
PAK=$PAK"gawk gcc-arm-linux-gnueabihf lvm2 qemu-user-static u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev "
|
||||
PAK=$PAK"parted pkg-config expect gcc-arm-linux-gnueabi libncurses5-dev whiptail debian-keyring debian-archive-keyring"
|
||||
|
||||
if [ "$(LANGUAGE=english apt-get -s install $PAK | grep "0 newly installed")" == "" ]; then
|
||||
install_packet "$PAK" "Checking and installing host dependencies" "host"
|
||||
fi
|
||||
|
||||
# sync clock
|
||||
if [ "$SYNC_CLOCK" != "no" ]; then
|
||||
display_alert "Synching clock" "host" "info"
|
||||
@ -279,7 +247,6 @@ if [[ -n "$MISC3" ]]; then fetch_from_github "$MISC3" "$MISC3_DIR"; fi
|
||||
if [[ -n "$MISC4" ]]; then fetch_from_github "$MISC4" "$MISC4_DIR"; fi
|
||||
if [[ -n "$MISC5" ]]; then fetch_from_github "$MISC5" "$MISC5_DIR"; fi
|
||||
|
||||
|
||||
# compile sunxi tools
|
||||
if [[ $LINUXFAMILY == sun*i ]]; then
|
||||
compile_sunxi_tools
|
||||
@ -314,7 +281,6 @@ patching_sources
|
||||
[ ! -f "$DEST/debs/$CHOOSEN_UBOOT" ] && compile_uboot
|
||||
[ ! -f "$DEST/debs/$CHOOSEN_KERNEL" ] && compile_kernel
|
||||
|
||||
|
||||
if [ "$KERNEL_ONLY" == "yes" ]; then
|
||||
[[ -n "$RELEASE" ]] && create_board_package
|
||||
display_alert "Kernel building done" "@host" "info"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user