Initial commit

Signed-off-by: default avatarHéctor Orón Martínez <hector.oron@collabora.com>
parents
This diff is collapsed.
General Information
===================
Here is the recipes collection for Apertis images creation.
To use these recipes, the debos tool needs to be installed: https://github.com/go-debos/debos
By default, this command will create a target Apertis OS package:
```
debos apertis-ospack.yaml
```
The target architecture can be changed with command line parameter '-t architecture:armhf'.
Architectures supported:
* armhf
Packages set selection via '-t type:target':
* target
Parameters for ospack and image versioning:
* suite: (-t suite:18.09)
* timestamp: (-t timestamp:`date +"%s"`)
Building in docker
==================
To ease testing on a wide variety of host systems (and building in Jenkins) a
docker file is provided which sets up the build environment. To build using
that:
* Pull and run the docker image:
You may pull and run the 18.09 image directly with:
```
RELEASE=18.09 # the Apertis release to be built
docker run --device /dev/kvm -w /recipes \
-u $(id -u) \
--group-add=$(getent group kvm | cut -d : -f 3) \
-i -v $(pwd):/recipes \
-t docker-registry.apertis.org/apertis/apertis-$RELEASE-image-builder \
debos apertis-ospack.yaml
```
Note: The examples are for the 18.09 release. You may change the
version if working on a different branch.
The image build will be run in the build docker image using your uid with the
additional kvm group (for debian based systems) to ensure debos/fakemachine can
use hardware virtualisation. For fedora/Redhat based systems the group-add is
likely not needed. For VirtualBox environments, just drop kvm lines since it is
not supported.
{{- $ospack := or .ospack "apertis-ospack.tar.gz" -}}
{{- $image := or .image "apertis-image.img" -}}
architecture: armhf
actions:
- action: unpack
compression: gz
file: {{ $ospack }}
- action: run
description: Enable persistent journal
command: mkdir -p /var/log/journal
- action: image-partition
imagename: {{ $image }}
imagesize: 3G
partitiontype: gpt
mountpoints:
- mountpoint: /
partition: root
flags: [ boot ]
partitions:
- name: root
fs: ext4
start: 8MB
end: 100%
- action: filesystem-deploy
description: Deploying filesystem onto image
- action: apt
description: Install hardware support packages
packages:
- linux-image-armmp
- u-boot-omap
- action: raw
description: Flash MLO
offset: {{ sector 256 }}
origin: filesystem
source: /usr/lib/u-boot/am335x_boneblack/MLO
- action: raw
description: Flash u-boot
origin: filesystem
offset: {{ sector 768 }}
source: /usr/lib/u-boot/am335x_boneblack/u-boot.img
- action: run
description: Create bmap file
postprocess: true
command: bmaptool create {{ $image }} > {{ $image }}.bmap
- action: run
description: Compress image
postprocess: true
command: gzip -f {{ $image }}
{{- $architecture := or .architecture "armhf" }}
{{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
{{- $suite := or .suite "18.09" -}}
{{- $ospack := or .ospack (printf "apertis-ospack.tar.gz") -}}
architecture: {{ $architecture }}
actions:
- action: debootstrap
suite: {{ $suite }}
components:
- target
mirror: {{ $mirror }}
variant: minbase
keyring-package: apertis-archive-keyring
merged-usr: true
# Extend apt sources list
- action: run
chroot: true
script: scripts/apt_source.chroot -m {{ $mirror }} -r {{ $suite }} target development
- action: overlay
source: overlays/base
- action: apt
description: "Core packages"
packages:
- sudo
- apt-transport-https
- dbus-user-session
- udev
- systemd-sysv
- openssh-server
- net-tools
- libnss-myhostname
- libnss-resolve
- kmod
- action: run
chroot: true
script: scripts/setup_user.chroot
- action: run
chroot: true
script: scripts/setup_networking.chroot
- action: pack
compression: gz
file: {{ $ospack }}
{{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
{{- $suite := or .suite "18.09" -}}
{{- $ospack := or .ospack "apertis-ospack.tar.gz" -}}
{{- $sysroot := or .sysroot "apertis-sysroot.tar.gz" -}}
architecture: armhf
actions:
- action: unpack
description: Unpack {{ $ospack }}
compression: gz
file: {{ $ospack }}
- action: run
chroot: true
script: scripts/apt_source.chroot -m {{ $mirror }} -r {{ $suite }} development
- action: apt
packages:
- apt-transport-https
- ca-certificates
- action: overlay
source: overlays/base
- action: run
chroot: true
command: apt-get update
- action: apt
description: Install development packages
packages:
- cmake
- qtbase5-dev
- symlinks
- action: overlay
source: overlays/sysroot
- action: run
chroot: true
command: symlinks -rc /
- action: run
chroot: true
command: echo "include ld.so.conf.d/*.conf" > /etc/ld.so.conf
- action: pack
compression: gz
file: {{ $sysroot }}
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
[Match]
Name=e*
[Network]
DHCP=yes
[Match]
Name=usb*
[Network]
DHCP=yes
[Unit]
Description=Setup RNDIS usb network card
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/setup-rndis
[Install]
WantedBy=multi-user.target
#!/bin/sh
set -e
cd /sys/kernel/config/usb_gadget/
mkdir g && cd g
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB 2.0
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol
mkdir -p strings/0x409
echo "Bosch" > strings/0x409/manufacturer
echo "Guardian" > strings/0x409/product
mkdir -p functions/acm.usb0 # serial
mkdir -p functions/rndis.usb0 # network
mkdir -p configs/c.1
echo 1000 > configs/c.1/MaxPower
ln -s functions/rndis.usb0 configs/c.1/
ln -s functions/acm.usb0 configs/c.1/
# OS descriptors
echo 1 > os_desc/use
echo 0xcd > os_desc/b_vendor_code
echo MSFT100 > os_desc/qw_sign
echo RNDIS > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
ln -s configs/c.1 os_desc
udevadm settle -t 5 || :
echo musb-hdrc.0 > UDC
#!/bin/sh
# Generate the content of a cmake-cross.txt file for usage to cross-compile
# against this chroot. Should be run once the chroot is in its final location
# to make sure all the patch are right
# Assumes that a cross-compiler can be found in $PATH (e.g
# gcc-arm-linux-gnueabihf is installed on Debian). Otherwise the paths should
# be adjusted
SYSROOT=$(dirname $(realpath $0))
GNU_TYPE=arm-linux-gnueabihf
cat << EOF
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSROOT ${SYSROOT})
set(CMAKE_STAGING_PREFIX ${SYSROOT}/usr/)
set(tools /usr)
set(CMAKE_C_COMPILER \${tools}/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER \${tools}/bin/arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
EOF
#!/bin/sh
export SYSROOT=$(dirname $(realpath $0))
CONFIGURE=$1
shift
CONFIGURE_ARGS=$@
export PKG_CONFIG=${SYSROOT}/pkg-config-sysroot
export GNU_TYPE=arm-linux-gnueabihf
SYSROOT_ARGS="--host=${GNU_TYPE} --with-sysroot=${SYSROOT}"
export CFLAGS="--sysroot=${SYSROOT} -g -O2"
export LDFLAGS="--sysroot=${SYSROOT}"
${CONFIGURE} ${SYSROOT_ARGS} ${CONFIGURE_ARGS}
#!/bin/sh
# Generate the content of a meson-cross.txt file for usage to cross-compile
# against this chroot. Should be run once the chroot is in its final location
# to make sure all the patch are right
# Assumes that a cross-compiler can be found in $PATH (e.g
# gcc-arm-linux-gnueabihf is installed on Debian). Otherwise the paths should
# be adjusted
SYSROOT=$(dirname $(realpath $0))
GNU_TYPE=arm-linux-gnueabihf
cat << EOF
[binaries]
c = 'arm-linux-gnueabihf-gcc'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'
pkgconfig = '${SYSROOT}/pkg-config-sysroot'
[properties]
has_function_printf = true
root = '${SYSROOT}'
c_args = ['--sysroot=${SYSROOT}']
c_link_args = ['--sysroot=${SYSROOT}',
'-L${SYSROOT}/lib',
'-L${SYSROOT}/lib/${GNU_TYPE}',
'-L${SYSROOT}/usr/lib',
'-L${SYSROOT}/usr/lib/${GNU_TYPE}']
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7hl'
endian = 'little'
EOF
#!/bin/sh
export SYSROOT=$(dirname $(realpath $0))
export GNU_TYPE=arm-linux-gnueabihf
PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig
PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/${GNU_TYPE}/pkgconfig:${PKG_CONFIG_LIBDIR}
PKG_CONFIG_LIBDIR=${SYSROOT}/usr/share/pkgconfig:${PKG_CONFIG_LIBDIR}
export PKG_CONFIG_LIBDIR
export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
pkg-config $@
#!/bin/sh
set -eu
SRCLIST=/etc/apt/sources.list
MIRROR=
RELEASE=
opts=$(getopt -o "m:r:" -l "mirror:,release:" -- "$@")
eval set -- "$opts"
while [ $# -gt 0 ]; do
case $1 in
-m|--mirror) MIRROR="$2"; shift 2;;
-r|--release) RELEASE="$2"; shift 2;;
--) shift; break;;
*) ;;
esac
done
if [ -z "$MIRROR" ] || [ -z "$RELEASE" ] || [ $# -eq 0 ]; then
echo "Please provive mirror, release and distribution(s)." >&2
exit 1
fi
for dist in $@; do
if ! grep -q "^deb .*$MIRROR.*$RELEASE.*$dist" $SRCLIST; then
echo "deb $MIRROR $RELEASE $dist" >> $SRCLIST
fi
if ! grep -q "^deb-src .*$MIRROR.*$RELEASE.*$dist" $SRCLIST; then
echo "deb-src $MIRROR $RELEASE $dist" >> $SRCLIST
fi
done
\ No newline at end of file
#!/bin/sh
set -e
# check to make sure sudoers file has ref for admin
ADMINEXISTS="$(awk '$1 == "%admin" { print $1 }' /etc/sudoers)"
if [ -z "$ADMINEXISTS" ]; then
# append admin entry to sudoers
echo "# Members of the admin group may gain root privileges" >> /etc/sudoers
echo "%admin ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
fi
# make sure that NOPASSWD is set for %admin
# expecially in the case that we didn't add it to /etc/sudoers
# just blow the %admin line away and force it to be NOPASSWD
sed -i -e '
/\%admin/ c \
%admin ALL = (ALL) NOPASSWD: ALL
' /etc/sudoers
#!/bin/sh
set -e
# Network management
systemctl enable systemd-networkd
# DNS resolving
systemctl enable systemd-resolved
# NTP client
systemctl enable systemd-timesyncd
#!/bin/sh
set -e
echo "I: create user"
adduser --gecos User --disabled-login user
echo "I: set user password"
echo "user:user" | chpasswd
adduser user sudo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment