Commit 51e5bb9a authored by Stefan Mavrodiev's avatar Stefan Mavrodiev

Add container for local repository

parent 0b15ecc4
# Olimex Image builder
## Description
## Directory structure
TODO
## Usage
### Use apt-cacher
```shell script
docker-compose up -d
docker exec -it olimage_apt-cacher-ng_1 tail -f /var/log/apt-cacher-ng/apt-cacher.log
```
### From sources
Generate docker image
```shell script
cd olimage
sudo docker build . -t olimage
```
Run new container
```shell script
docker run -it --privileged -v $(pwd):/olimage -v /dev:/dev olimage
```
Run script
```shell script
sudo python3 -m olimage --help
```
### Running tests
```shell script
python3 -m unittest -v
```
## Developer Manual
### Creating BSP patches
Cleanup the tree:
```shell script
cd output/dl/u-boot/v2019.07
git reset --hard HEAD
git clean -fdx
```
Create new patch:
```shell script
QUILT_PATCHES=/olimage/olimage/packages/u-boot/patches quilt new xxxx-something.patch
quilt add somefile.c
quilt refresh
```
### Generating kernel fragment files
Make sure the kernel tree is clean
```shell script
make mrproper
```
Apply defconfig specified in the board configuration file. For example:
```shell script
make ARCH=arm64 defconfig
```
Make modification with:
```shell script
make ARCH=arm64 menuconfig
```
Generate fragment file:
```shell script
scripts/diffconfig -m
```
python3 -m olimage -v --log=/dev/pts/2 rootfs a64-olinuxino-1G buster lite
\ No newline at end of file
......@@ -5,7 +5,7 @@ boards:
linux:
arch: *arch
defconfig: ~
refs: 'v5.4-rc5'
refs: 'v5.4'
#source: 'https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable'
source: 'https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux'
targets:
......@@ -15,7 +15,7 @@ boards:
toolchain:
prefix: 'aarch64-linux-gnu-'
version: 7
version: '5.4.0-rc5-1-olimex'
version: '5.4.0-1-olimex'
localversion: '-1-olimex'
bootloaders:
......
version: '3'
services:
apt-cacher-ng:
image: sameersbn/apt-cacher-ng:latest
restart: unless-stopped
volumes:
- apt-cacher-ng:/var/cache/apt-cacher-ng
nginx:
command: [nginx-debug, '-g', 'daemon off;']
image: nginx:latest
restart: always
volumes:
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
- reprepro:/var/www/reprepro
reprepro:
build:
context: ./docker/reprepro
command: /ENTRYPOINT.sh
depends_on:
- nginx
volumes:
- reprepro:/var/reprepro/debian
- ./docker/reprepro/ENTRYPOINT.sh:/ENTRYPOINT.sh
- ./docker/reprepro/debian/conf:/var/reprepro/debian/conf:ro
- ./docker/reprepro/keys:/var/reprepro/keys/
- ./docker/reprepro/packages:/var/reprepro/packages
volumes:
apt-cacher-ng:
reprepro:
......@@ -5,4 +5,8 @@ services:
image: sameersbn/apt-cacher-ng:latest
restart: unless-stopped
volumes:
- ./apt-cacher-ng:/var/cache/apt-cacher-ng
- apt-cacher-ng:/var/cache/apt-cacher-ng
volumes:
apt-cacher-ng:
version: '3'
services:
nginx:
command: [nginx-debug, '-g', 'daemon off;']
image: nginx:latest
restart: always
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
- reprepro:/var/www/reprepro
reprepro:
build:
context: ./reprepro
command: /data/ENTRYPOINT.sh
depends_on:
- nginx
volumes:
- reprepro:/var/reprepro/debian
- ./reprepro/debian/conf:/var/reprepro/debian/conf:ro
- ./reprepro/data:/data
volumes:
reprepro:
server {
root /var/www/reprepro;
location ^~ / {
allow all;
autoindex on;
}
}
FROM debian:latest
MAINTAINER Stefan Mavrodiev <stefan@olimex.com>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -yq --no-install-recommends \
gnupg2 reprepro && \
rm -rf /var/cache/apt/*
ENV REPREPRO_BASE_DIR /var/reprepro/debian
# Generate keys
ADD batch.gpg ./
RUN gpg2 --batch --generate-key batch.gpg
%echo Generating a basic OpenPGP key
Key-Type: default
Name-Real: Stefan Mavrodiev
Name-Email: stefan@olimex.com
Expire-Date: 0
Passphrase: olimex1234
%commit
%echo done
\ No newline at end of file
#!/usr/bin/env bash
gpg --list-keys --keyid-format LONG
key_id=$(gpg --list-keys --keyid-format LONG | grep "^pub " | sed "s/.*\/\([^ ]*\).*/\1/")
echo "Exporting key: ${key_id}"
gpg2 --armor --export ${key_id} | tee /olimage/keys/olimage.gpg | tee ${REPREPRO_BASE_DIR}/olimage.gpg
echo "Checking repository..."
reprepro check
# Keep the container alive
tail -f /dev/null
\ No newline at end of file
Codename: buster
Components: main
Architectures: armhf arm64 source
SignWith: EC5488437C053795ABE8EC5A4B9E3C712FA9C269
verbose
ask-passphrase
\ No newline at end of file
u-boot-olinuxino
================
About
-----
The suggested way of building the package is using docker.
Prepare
-------
See additional documentation about the used image here:
https://hub.docker.com/r/multiarch/qemu-user-static/
Register **binfmt_misc**:
.. code-block:: bash
docker run --rm --privileged multiarch/qemu-user-static:register --reset
Create a new Dockerfile:
.. code-block:: docker
FROM multiarch/debian-debootstrap:arm64-sid
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
bc \
bison \
build-essential \
debhelper-compat \
device-tree-compiler \
devscripts \
flex \
git \
git-buildpackage \
libfdt-dev \
libpython3-dev \
python3 \
python3-distutils \
swig && \
rm -rf /var/lib/apt/lists/*
**Note**: In the example arm64 architecture is used. To use armhf
change
.. code-block:: docker
FROM multiarch/debian-debootstrap:arm64-sid
to
.. code-block:: docker
FROM multiarch/debian-debootstrap:armhf-sid
Build the new image:
.. code-block:: bash
docker build . -t u-boot-olinuxino
Build package
-------------
.. code-block:: bash
mkdir u-boot
cd u-boot
git clone https://github.com/olimage/u-boot-olinuxino.git
docker run --rm -it -v $(pwd):/u-boot -w /u-boot/u-boot-olinuxino u-boot-olinuxino gbp buildpackage --git-upstream-tree=v2020.01 --git-builder='debuild --no-lintian -i -I'
**Note**: Here the latest used release is **v2020.01**. In the future this may change.
\ No newline at end of file
Local debian repository
=======================
About
-----
You can use a local debian repository for testing (or not). This
is done by using reprepro + nginx.
The mountpoints are:
* **/var/reprepro/debian** - the repository base directory
Include a new package
---------------------
Copy all files to *docker/reprepro/data/packages*.
Attach to the running reprepro container:
.. code-block:: bash
docker exec -it docker_reprepro_1 /bin/bash
Include package the with:
.. code-block:: bash
cd /data/packages
reprepro include <release> <package>.changes
......@@ -7,7 +7,6 @@ import pinject
import olimage.image
import olimage.rootfs
import olimage.packages
import olimage.environment as environment
......@@ -107,7 +106,7 @@ def cli(**kwargs):
# # Add sub-commands
cli.add_command(olimage.packages.build_packages)
# cli.add_command(olimage.packages.build_packages)
cli.add_command(olimage.rootfs.build_rootfs)
cli.add_command(olimage.image.build_image)
......@@ -131,7 +130,7 @@ def test(ctx: click.Context, **kwargs):
ctx.invoke(olimage.rootfs.build_rootfs, **kwargs)
# Install packages
ctx.invoke(olimage.packages.build_packages, board=kwargs['board'], package=None, command='install')
# ctx.invoke(olimage.packages.build_packages, board=kwargs['board'], package=None, command='install')
# Build image
ctx.invoke(olimage.image.build_image, source=environment.paths['debootstrap'], output=kwargs['output'])
......
---
type: map
mapping:
users:
type: str
pattern: N.*n
\ No newline at end of file
......@@ -19,7 +19,7 @@ class Boot(object):
'/usr/lib/olinuxino/kernel.its'
])
Utils.install('/etc/kernel/postinst.d/uboot-fit', mode='755')
Utils.template('/boot/uEnv.txt', configs=None)
Utils.template.install(env.paths['debootstrap'] + '/boot/uEnv.txt', configs=None)
# The FIT image is always located in /boot directory.
# If there is such defined partition retrieve it's number. Do the same for /
......
CONFIG_MMC_TEST=m
\ No newline at end of file
0001-dtb-symbol-generation.patch
0002-lcd-olinuxino.patch
0003-sunxi_mmc-support-hs200-tuning.patch
......@@ -119,6 +119,9 @@ class AbstractPackage(metaclass=abc.ABCMeta):
:return: None
"""
if not os.path.exists(self.paths['compile']):
Utils.archive.extract(self.paths['archive'], self.paths['build'])
Utils.patch.apply(self.paths['patches'], self.paths['compile'])
@stamp
......
......@@ -130,13 +130,6 @@ class Rootfs(object):
# Configure ssh
Setup.ssh(self._debootstrap, env.options['ssh'])
# # Install services
# Service.resize.install()
#
# # Setup boot
# # Note: This depends on olimex-sunxi-overlays
# Setup.boot(self._board, self._partitions)
@Printer("Installing services")
@rootfs_stamp
def services(self):
......
......@@ -26,33 +26,17 @@ if test "${devtype}" = "mmc"; then part uuid mmc ${mmc_bootdev}:{{ partitions.ro
# Set bootargs
setenv bootargs "root=PARTUUID=${partuuid} rootwait{% for key, value in bootargs.items() %} {{ key }}={{ '${' }}{{ key }}{{ '}' }}{% endfor %} ${optargs}"
if test ${load_legacy} && ${load_legacy}; then
# Load Image and
echo "Loading legacy image..."
if test -n ${load_legacy} && ${load_legacy}; then
echo "Loading legacy image format..."
for prefix in ${boot_prefixes}; do
if test -e mmc ${mmc_bootdev}:{{ partitions.boot }} ${prefix}Image; then
load mmc ${mmc_bootdev}:{{ partitions.boot }} ${kernel_addr_r} ${prefix}{{ fit.file }}
load mmc ${mmc_bootdev}:{{ partitions.boot }} ${fdt_addr_r} ${fdtfile}
# Load overlays
if test ${fdtoverlays}; then
fdt addr ${fdt_addr}
fdt resize 0x1000
for overlay in ${fdtoverlays}; do
echo "Applying overlay: ${overlay}"
load mmc ${mmc_bootdev} 0x4fc00000 ${overlay}
fdt apply 0x4fc00000 || setenv fdoverlays_error true
done
fi
if ${fdoverlays_error}; then
echo "Recovering original fdt file..."
if test -e mmc ${mmc_bootdev}:{{ partitions.boot }} ${prefix}Image; then
load mmc ${mmc_bootdev}:{{ partitions.boot }} ${kernel_addr_r} ${prefix}Image
load mmc ${mmc_bootdev}:{{ partitions.boot }} ${fdt_addr_r} ${fdtfile}
booti ${kernel_addr_r} - ${fdt_addr_r}
fi
booti ${kernel_addr_r} - ${fdt_addr_r}
fi
done
done
fi
......
# Put u-boot environment variables here. Before boot, boot.scr will use these variables:
#
# boot_config - Explicitly specify the boot configuration
# fdtoverlays - List of overlay files
# load_legacy - Load separate Image and fdt file,
# optargs - Optional arguments passed to the kernel
......
......@@ -10,12 +10,10 @@ if [[ ! -e ${template} ]]; then
fi
# Check if UUID is the same
current_uuid=$(cat /boot/kernel.its | grep "Generated UUID" | awk -F': ' '{print $2}')
new_uuid=$(cat ${template} | grep "Generated UUID" | awk -F': ' '{print $2}')
if [[ "${current_uuid}" != "${new_uuid}" ]]; then
echo >&1 "Generating FIT source"
sed "s/\${VERSION}/${version}/g" ${template} > /boot/kernel.its
fi
##current_uuid=$(cat /boot/kernel.its | grep "Generated UUID" | awk -F': ' '{print $2}')
# new_uuid=$(cat ${template} | grep "Generated UUID" | awk -F': ' '{print $2}')
echo >&1 "Generating FIT source"
sed "s/\${VERSION}/${version}/g" ${template} > /boot/kernel.its
echo >&1 "Generating FIT image"
mkimage -f /boot/kernel.its /boot/kernel.itb > /dev/null
......@@ -7,6 +7,10 @@ APT_CACHER_NAME="olimage_apt-cacher-ng_1"
APT_CACHER_HOST=""
APT_CACHER_PORT="3142"
NGINX_NAME="olimage_nginx_1"
NGINX_HOST=""
NGINX_PORT="80"
CONTAINER_NAME="olimage_work"
# Check for docker permissions
......@@ -21,20 +25,19 @@ if ! ${DOCKER} ps >/dev/null; then
exit 1
fi
# Run apt-cacher
if [[ "$(${DOCKER} ps -q --filter name=${APT_CACHER_NAME})" == "" ]]; then
if ! ${DOCKER}-compose up -d; then
echo "Failed to run docker-compose:"
${DOCKER}-compose up
exit 1
fi
else
echo "Service apt-cacher already running";
fi
#APT_CACHER_PORT=$(${DOCKER} port ${APT_CACHER_NAME} 3142 | cut -d':' -f2)
APT_CACHER_HOST=$(${DOCKER} inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${APT_CACHER_NAME})
echo "apt-cacher listening on: ${APT_CACHER_HOST}:${APT_CACHER_PORT}"
## Run apt-cacher
#if [[ "$(${DOCKER} ps -q --filter name=${APT_CACHER_NAME})" == "" ]]; then
# if ! ${DOCKER}-compose up -d; then
# echo "Failed to run docker-compose:"
# ${DOCKER}-compose up
# exit 1
# fi
#else
# echo "Service apt-cacher already running";
#fi
#
#APT_CACHER_HOST=$(${DOCKER} inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${APT_CACHER_NAME})
#echo "apt-cacher listening on: ${APT_CACHER_HOST}:${APT_CACHER_PORT}"
# Build image
docker build -t olimage "${DIR}"
......@@ -46,9 +49,9 @@ docker run --rm -it --privileged \
--volume /dev:/dev \
--volume /proc:/proc \
--volume $(pwd):/olimage \
--net "bf90bacc29204111f9d68872c46566d9ef2f3385a767911678cea5bce6f1d4f1" \
-w /olimage \
-e "GIT_HASH=$(git rev-parse HEAD)" \
-e "APT_CACHER_HOST=${APT_CACHER_HOST}" \
-e "APT_CACHER_PORT=${APT_CACHER_PORT}" \
olimage
--net 'host' \
-w /olimage olimage
# -e "GIT_HASH=$(git rev-parse HEAD)" \
# -e "APT_CACHER_HOST=${APT_CACHER_HOST}" \
# -e "APT_CACHER_PORT=${APT_CACHER_PORT}" \
# olimage
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