Skip to content

Commit

Permalink
v20180726 init aml-s9xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
150balbes committed Jul 26, 2018
1 parent 043fbfa commit 68b0c7f
Show file tree
Hide file tree
Showing 462 changed files with 63,113 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### output directories
.tmp/
output/
cache/
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### Specific to building Armbian ###
/.vagrant/
ubuntu-*-cloudimg-console.log

### to ignore changes in a working copy
.ignore_changes

### compile configurations added by users
/config-*.conf
### but not default (supplied) files
!/config-docker.conf
!/config-vagrant.conf

### output directories
/.tmp/
/output/
/cache/
/userpatches/

### General annoyances ###
.DS_Store
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:16.04
RUN dpkg --add-architecture i386
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -y git dialog lsb-release binutils wget ca-certificates device-tree-compiler \
pv bc lzop zip binfmt-support build-essential ccache debootstrap ntpdate gawk gcc-arm-linux-gnueabihf \
qemu-user-static u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev ntpdate parted pkg-config libncurses5-dev whiptail \
debian-keyring debian-archive-keyring f2fs-tools libfile-fcntllock-perl rsync libssl-dev nfs-kernel-server btrfs-tools \
ncurses-term p7zip-full kmod dosfstools libc6-dev-armhf-cross fakeroot \
curl patchutils python liblz4-tool libpython2.7-dev linux-base swig libpython-dev \
systemd-container udev distcc g++-5-arm-linux-gnueabihf lib32stdc++6 \
libc6-i386 lib32ncurses5 lib32tinfo5 locales ncurses-base zlib1g:i386 aptly pixz
RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' TERM=screen
WORKDIR /root/armbian
COPY . /root/armbian
ENTRYPOINT [ "/bin/bash", "/root/armbian/compile.sh" ]
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
# Build-Armbian
Build Armbian for TV Box
# Armbian

Ubuntu and Debian images for ARM based single-board computers
https://www.armbian.com

## How to build my own image or kernel?

Supported build environments:

- [Ubuntu Xenial 16.04 x64](http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd64/current/images/netboot/mini.iso) guest inside a [VirtualBox](https://www.virtualbox.org/wiki/Downloads) or other virtualization software,
- [Ubuntu Xenial 16.04 x64](http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd64/current/images/netboot/mini.iso) guest managed by [Vagrant](https://www.vagrantup.com/). This uses Virtualbox (as above) but does so in an easily repeatable way. Please check the [Armbian with Vagrant README](https://docs.armbian.com/Developer-Guide_Using-Vagrant/) for a quick start HOWTO,
- [Ubuntu Xenial 16.04 x64](http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd64/current/images/netboot/mini.iso) inside a [Docker](https://www.docker.com/), [systemd-nspawn](https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html) or other container environment [(example)](https://github.com/igorpecovnik/lib/pull/255#issuecomment-205045273). Building full OS images inside containers may not work, so this option is mostly for the kernel compilation,
- [Ubuntu Xenial 16.04 x64](http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd64/current/images/netboot/mini.iso) running natively on a dedicated PC or a server (**not** recommended unless you build kernel only, for full OS images always use virtualization as outlined above),
- **20GB disk space** or more and **2GB RAM** or more available for the VM, container or native OS,
- superuser rights (configured `sudo` or root access).

**Execution**

apt-get -y install git
git clone https://github.com/150balbes/Build-Armbian
cd build
./compile.sh

Make sure that full path to the build script does not contain spaces.

You will be prompted with a selection menu for a build option, a board name, a kernel branch and an OS release.
Please check the documentation for [advanced options](https://docs.armbian.com/Developer-Guide_Build-Options/) and [additional customization](https://docs.armbian.com/Developer-Guide_User-Configurations/).

Build process uses caching for the compilation and the debootstrap process, so consecutive runs with similar settings will be much faster.

## Reporting issues

Please read [this](https://github.com/150balbes/lib/blob/master/.github/ISSUE_TEMPLATE.md) notice first before opening an issue.

## More info:

- [Documentation](https://docs.armbian.com/Developer-Guide_Build-Preparation/)
- [Prebuilt images](https://www.armbian.com/download/)
- [Support forums](https://forum.armbian.com/ "Armbian support forum")
- [Project at Github](https://github.com/igorpecovnik/lib)
50 changes: 50 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version ">= 1.5"

$provisioning_script = <<SCRIPT
# use remote git version instead of sharing a copy from host to preserve proper file permissions
# and prevent permission related issues for the temp directory
git clone https://github.com/150balbes/build /home/vagrant/armbian
mkdir -p /vagrant/output /vagrant/userpatches
ln -sf /vagrant/output /home/vagrant/armbian/output
ln -sf /vagrant/userpatches /home/vagrant/armbian/userpatches
SCRIPT

Vagrant.configure(2) do |config|

# What box should we base this build on?
config.vm.box = "ubuntu/xenial64"
config.vm.box_version = ">= 20180126.0.0"

#######################################################################
# THIS REQUIRES YOU TO INSTALL A PLUGIN. RUN THE COMMAND BELOW...
#
# $ vagrant plugin install vagrant-disksize
#
# Default images are not big enough to build Armbian.
config.disksize.size = "40GB"

# provisioning: install dependencies, download the repository copy
config.vm.provision "shell", inline: $provisioning_script

# forward terminal type for better compatibility with Dialog - disabled on Ubuntu by default
config.ssh.forward_env = ["TERM"]

# default user name is "ubuntu", please do not change it

# SSH password auth is disabled by default, uncomment to enable and set the password
#config.ssh.password = "armbian"

config.vm.provider "virtualbox" do |vb|
vb.name = "Armbian Builder"

# uncomment this to enable the VirtualBox GUI
#vb.gui = true

# Tweak these to fit your needs.
#vb.memory = "8192"
#vb.cpus = "4"
end
end
67 changes: 67 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
#
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#
# This file is a part of the Armbian build script
# https://github.com/armbian/build/

# DO NOT EDIT THIS FILE
# use configuration files like config-default.conf to set the build configuration
# check Armbian documentation for more info

SRC="$(dirname "$(realpath "${BASH_SOURCE}")")"
# fallback for Trusty
[[ -z "${SRC}" ]] && SRC="$(pwd)"

# check for whitespace in $SRC and exit for safety reasons
grep -q "[[:space:]]" <<<"${SRC}" && { echo "\"${SRC}\" contains whitespace. Not supported. Aborting." >&2 ; exit 1 ; }

cd $SRC

if [[ -f $SRC/lib/general.sh && -L $SRC/main.sh ]]; then
source $SRC/lib/general.sh
else
echo "Error: missing build directory structure"
echo "Please clone the full repository https://github.com/armbian/build/"
exit -1
fi

# copy default config from the template
[[ ! -f $SRC/config-default.conf ]] && cp $SRC/config/templates/config-example.conf $SRC/config-default.conf

# source build configuration file
if [[ -n $1 && -f $SRC/config-$1.conf ]]; then
display_alert "Using config file" "config-$1.conf" "info"
source $SRC/config-$1.conf
else
display_alert "Using config file" "config-default.conf" "info"
source $SRC/config-default.conf
fi

if [[ $EUID != 0 ]]; then
display_alert "This script requires root privileges, trying to use sudo" "" "wrn"
sudo "$SRC/compile.sh" "$@"
exit $?
fi

if [[ ! -f $SRC/.ignore_changes ]]; then
echo -e "[\e[0;32m o.k. \x1B[0m] This script will try to update"
git checkout ${LIB_TAG:- "$GIT_BRANCH"}
git pull
CHANGED_FILES=$(git diff --name-only)
if [[ -n $CHANGED_FILES ]]; then
echo -e "[\e[0;35m warn \x1B[0m] Can't update since you made changes to: \e[0;32m\n${CHANGED_FILES}\x1B[0m"
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue"
read
fi
fi

if [[ $BUILD_ALL == yes || $BUILD_ALL == demo ]]; then
source $SRC/lib/build-all.sh
else
source $SRC/lib/main.sh
fi
109 changes: 109 additions & 0 deletions config-docker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# DO NOT EDIT THIS FILE
#
# This is a Docker launcher file. To set up the configuration, use command line arguments to compile.sh
# or create a config file named "config-docker-guest.conf" based on config-example.conf

[[ ! -c /dev/loop-control ]] && display_alert "/dev/loop-control does not exist, image building may not work" "" "wrn"

# remove "docker" from the command line since "docker-guest" will be passed instead
shift

# 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}

# build a new container based on provided Dockerfile
display_alert "Building a Docker container"
if ! docker build -t armbian . ; 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

DOCKER_FLAGS=()

# Running this container in privileged mode is a simple way to solve loop device access issues
#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

# mount 2 named volumes - for cacheable data and compiler cache
DOCKER_FLAGS+=(-v=armbian-cache:/root/armbian/cache -v=armbian-ccache:/root/.ccache)

# mount 2 local directories - output and userpatches
DOCKER_FLAGS+=(-v=$SRC/output:/root/armbian/output -v=$SRC/userpatches:/root/armbian/userpatches)

# 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
display_alert "Running the container" "" "info"
docker run "${DOCKER_FLAGS[@]}" -it armbian docker-guest "$@"

# 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
30 changes: 30 additions & 0 deletions config-vagrant.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# DO NOT EDIT THIS FILE
#
# This is a Vagrant launcher file. To set up the configuration, use command line arguments to compile.sh
# or create a config file named "config-vagrant-guest.conf" based on config-example.conf

# remove "vagrant" from the command line since "vagrant-guest" will be passed instead
shift

# check and install vagrant-disksize
if ! grep -q '^vagrant-disksize' <(vagrant plugin list); then
display_alert "Trying to install vargant-disksize plugin"
vagrant plugin install vagrant-disksize
fi

display_alert "Building and running the Vagrant box"
vagrant up

display_alert "SSH config for the Vagrant box"
vagrant ssh-config

display_alert "Trying to connect using SSH"

IFS=' ' vagrant ssh -c "cd armbian; sudo ./compile.sh vagrant-guest $*"

display_alert "Press <Enter> to halt the Vagrant box"
read
vagrant halt

# don't need to proceed further on the host
exit 0
17 changes: 17 additions & 0 deletions config/aptly-temp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rootDir": "/tmp/aptly-temp/",
"downloadConcurrency": 4,
"downloadSpeedLimit": 0,
"architectures": [],
"dependencyFollowSuggests": false,
"dependencyFollowRecommends": false,
"dependencyFollowAllVariants": false,
"dependencyFollowSource": false,
"gpgDisableSign": false,
"gpgDisableVerify": false,
"downloadSourcePackages": false,
"ppaDistributorID": "ubuntu",
"ppaCodename": "",
"S3PublishEndpoints": {},
"SwiftPublishEndpoints": {}
}
17 changes: 17 additions & 0 deletions config/aptly.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rootDir": "../output/repository",
"downloadConcurrency": 4,
"downloadSpeedLimit": 0,
"architectures": [],
"dependencyFollowSuggests": false,
"dependencyFollowRecommends": false,
"dependencyFollowAllVariants": false,
"dependencyFollowSource": false,
"gpgDisableSign": false,
"gpgDisableVerify": false,
"downloadSourcePackages": false,
"ppaDistributorID": "ubuntu",
"ppaCodename": "",
"S3PublishEndpoints": {},
"SwiftPublishEndpoints": {}
}
Loading

0 comments on commit 68b0c7f

Please sign in to comment.