-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 86ecdba
Showing
24 changed files
with
869 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = tab | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/packages/ | ||
|
||
/sdk/bin/* | ||
!/sdk/bin/.gitkeep | ||
|
||
/sdk/build_dir/* | ||
!/sdk/build_dir/.gitkeep | ||
|
||
/sdk/dl/* | ||
!/sdk/dl/.gitkeep | ||
|
||
/sdk/feeds/* | ||
!/sdk/feeds/.gitkeep | ||
|
||
/sdk/logs/* | ||
!/sdk/logs/.gitkeep | ||
|
||
/sdk/overrides/* | ||
!/sdk/overrides/.gitkeep | ||
|
||
/sdk/package/feeds/* | ||
!/sdk/package/feeds/.gitkeep | ||
|
||
/sdk/sdk/* | ||
!/sdk/sdk/.gitkeep | ||
|
||
/sdk/staging_dir/hostpkg/* | ||
!/sdk/staging_dir/hostpkg/.gitkeep | ||
|
||
/sdk/staging_dir/target/* | ||
!/sdk/staging_dir/target/.gitkeep | ||
|
||
/sdk/tmp/* | ||
!/sdk/tmp/.gitkeep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changelog | ||
|
||
## 0.1.0 (2019-06-05) | ||
* Initial release |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Vivarium | ||
|
||
Build OpenWrt packages using Docker and the OpenWrt SDK | ||
|
||
## Introduction | ||
|
||
Vivarium is a way to compile packages for | ||
[OpenWrt](https://openwrt.org/) without having to install the necessary | ||
[build | ||
tools](https://openwrt.org/docs/guide-developer/build-system/install-buildsystem), | ||
using [Docker](https://www.docker.com/). | ||
|
||
Vivarium includes a "builder" Dockerfile for a local Docker image, based | ||
on the CircleCI Docker image used by the [OpenWrt packages | ||
feed](https://github.com/openwrt/packages). This local image will have | ||
the [OpenWrt | ||
SDK](https://openwrt.org/docs/guide-developer/using_the_sdk) set up | ||
inside. | ||
|
||
This also includes a Docker Compose file that holds all of the | ||
configuration options. The Compose file also sets up a number of bind | ||
mounts, allowing access to package source code from the Docker container | ||
and access to build artifacts from the host machine. | ||
|
||
## Requirements | ||
|
||
[Docker](https://docs.docker.com/install/#supported-platforms) and | ||
[Docker Compose](https://docs.docker.com/compose/install/) will need to | ||
be installed. | ||
|
||
Vivarium has only been tested with Linux (Ubuntu 19.04, to be exact). | ||
Testing with other platforms is welcome. | ||
|
||
## Getting started | ||
|
||
1. Download the source code and extract. | ||
|
||
If you will be using Git to manage your package source code, then | ||
you will want to download Vivarium as a zip or tar.gz to avoid | ||
nesting Git repositories. | ||
|
||
2. In the project directory, create a `packages` directory and add | ||
source code for packages, e.g. by checking out the OpenWrt packages | ||
feed: | ||
|
||
$ cd openwrt-vivarium | ||
$ git clone https://github.com/openwrt/packages.git | ||
|
||
3. If you are using Linux and your user ID is not 1000, you will need | ||
to change the ownership of the `packages` and `sdk` directories (and | ||
all files and subdirectories inside) to UID 1000, e.g.: | ||
|
||
$ sudo chown -R 1000:1000 packages sdk | ||
|
||
These directories need to be readable and writable by the normal | ||
user inside the Docker image (with UID 1000 / GID 1000). | ||
|
||
4. Build packages by using `docker-compose run`, e.g.: | ||
|
||
$ sudo docker-composer run --rm builder make package/python/compile V=s | ||
|
||
If the build was successful, the compiled package(s) will be in the | ||
`sdk/bin` directory. | ||
|
||
## Configuration | ||
|
||
All options can be found in the `docker-compose.yml` file. | ||
|
||
### Image build options | ||
|
||
* `SDK_HOST`, `SDK_PATH`, `SDK_FILE`: Which SDK to use | ||
|
||
If there is an SDK archive (matching `SDK_FILE`) in the `sdk/sdk` | ||
directory, then it will be used instead of downloading the archive | ||
from `SDK_HOST`. | ||
|
||
* `BRANCH`: Which branch to use when setting up package feeds, e.g. | ||
`master`, `openwrt-18.06`, etc. | ||
|
||
* `CUSTOM_FEED`: Controls how the `packages` directory is used | ||
* `n`: The directory is added as the "packages" feed, in | ||
place of the OpenWrt packages feed | ||
* `y`: The directory is added as a custom feed (the OpenWrt | ||
packages feed will be present as well) | ||
|
||
### Run-time options | ||
|
||
* `KEEP_SDK_FILE`: If `y`, the SDK archive within the Docker image | ||
will be copied to the `sdk/sdk` directory when the builder is run | ||
|
||
* `CONFIG_AUTOREMOVE`, `CONFIG_BUILD_LOG`: Sets the corresponding SDK | ||
config options (`y` or `n`) | ||
|
||
## Rebuild local Docker image | ||
|
||
To change SDKs or update to the latest snapshot SDK, the local Docker | ||
image will need to be rebuilt. | ||
|
||
If `KEEP_SDK_FILE` is `y`, it may be necessary clear the `sdk/sdk` | ||
directory first to ensure a new SDK archive is downloaded: | ||
|
||
$ rm -f sdk/sdk/* | ||
|
||
Then rebuild the image: | ||
|
||
$ sudo docker-compose build | ||
|
||
The `--no-cache` option may be needed to force a rebuild / re-download. | ||
|
||
## Directory cleaning | ||
|
||
The SDK commands for directory cleaning (`make clean`, `make dirclean`, | ||
etc.) are not aware of the Docker bind mounts and so may not work | ||
correctly. | ||
|
||
There are scripts in the `sdk` directory (`clean.sh`, `dirclean.sh`, | ||
`distclean.sh`) that emulate the SDK commands and can be run from the | ||
host. | ||
|
||
## License | ||
|
||
Copyright (C) 2019 Jeffery To | ||
https://github.com/jefferyto/openwrt-vivarium | ||
|
||
Vivarium is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 as | ||
published by the Free Software Foundation. | ||
|
||
Vivarium is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with Vivarium. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
Contains code from .circleci/config.yml of the OpenWrt packages feed | ||
Copyright (C) 2018 Etienne Champetier, Ted Hess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Dockerfile | ||
# This file is part of Vivarium. | ||
# | ||
# Copyright (C) 2019 Jeffery To | ||
# https://github.com/jefferyto/openwrt-vivarium | ||
# | ||
# Vivarium is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 as | ||
# published by the Free Software Foundation. | ||
# | ||
# Vivarium is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Vivarium. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
FROM docker.io/openwrtorg/packages-cci:v1.0.2 | ||
|
||
ARG SDK_HOST | ||
ARG SDK_PATH | ||
ARG SDK_FILE | ||
ARG BRANCH | ||
ARG CUSTOM_FEED | ||
|
||
ENV SDK_HOST=$SDK_HOST | ||
ENV SDK_PATH=$SDK_PATH | ||
ENV SDK_FILE=$SDK_FILE | ||
ENV BRANCH=$BRANCH | ||
ENV CUSTOM_FEED=$CUSTOM_FEED | ||
|
||
WORKDIR /home/build | ||
|
||
COPY builder/docker-run.sh sdk/sdk/$SDK_FILE / | ||
|
||
RUN sh -e /docker-run.sh | ||
|
||
COPY builder/docker-entrypoint.sh / | ||
|
||
ENTRYPOINT [ "sh", "-e", "/docker-entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh -e | ||
# | ||
# docker-entrypoint.sh | ||
# This file is part of Vivarium. | ||
# | ||
# Copyright (C) 2019 Jeffery To | ||
# https://github.com/jefferyto/openwrt-vivarium | ||
# | ||
# Vivarium is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 as | ||
# published by the Free Software Foundation. | ||
# | ||
# Vivarium is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Vivarium. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
cd $HOME | ||
|
||
if [ "$KEEP_SDK_FILE" = y ] && [ -d sdk ]; then | ||
cp -np $SDK_FILE sdk/ | ||
fi | ||
|
||
cd build_dir | ||
|
||
mkdir -p build_dir | ||
for path in build_dir_default/*; do | ||
if [ ! -d build_dir/$(basename $path) ]; then | ||
cp -pr $path build_dir/ | ||
fi | ||
done | ||
|
||
sed -i \ | ||
-e "/\s*config AUTOREMOVE$/{n;n;s/default [yn]/default ${CONFIG_AUTOREMOVE:-y}/}" \ | ||
-e "/\s*config BUILD_LOG$/{n;n;s/default [yn]/default ${CONFIG_BUILD_LOG:-n}/}" \ | ||
Config.in | ||
|
||
if [ -d ../overrides ] && [ -n "$(find ../overrides -mindepth 1 -maxdepth 1 \! -path '*/.*' -name '*' -print -quit)" ]; then | ||
cp -fpr ../overrides/* ./ | ||
fi | ||
|
||
./scripts/feeds update -a | ||
./scripts/feeds install -a | ||
|
||
if [ -f diffconfig ]; then | ||
cp -f diffconfig .config | ||
fi | ||
|
||
make defconfig | ||
|
||
mkdir -p logs | ||
cp -f .config logs/config | ||
|
||
if [ $# -gt 0 ]; then | ||
"$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/sh -e | ||
# | ||
# docker-run.sh | ||
# This file is part of Vivarium. | ||
# | ||
# Copyright (C) 2019 Jeffery To | ||
# https://github.com/jefferyto/openwrt-vivarium | ||
# | ||
# Vivarium is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 as | ||
# published by the Free Software Foundation. | ||
# | ||
# Vivarium is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Vivarium. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
# | ||
# Contains code from .circleci/config.yml of the OpenWrt packages feed | ||
# Copyright (C) 2018 Etienne Champetier, Ted Hess | ||
# | ||
|
||
cd $HOME | ||
|
||
if [ -z "$(find / -mindepth 1 -maxdepth 1 -name "$SDK_FILE" -print -quit)" ]; then | ||
echo "Download the SDK" | ||
|
||
mkdir sdk_dl | ||
cd sdk_dl | ||
|
||
# From https://github.com/openwrt/packages/blob/master/.circleci/config.yml | ||
curl "https://$SDK_HOST/$SDK_PATH/sha256sums" -sS -o sha256sums | ||
curl "https://$SDK_HOST/$SDK_PATH/sha256sums.asc" -sS -o sha256sums.asc | ||
gpg --with-fingerprint --verify sha256sums.asc sha256sums | ||
rsync -av "$SDK_HOST::downloads/$SDK_PATH/$SDK_FILE" . | ||
sha256sum -c --ignore-missing sha256sums | ||
|
||
cd .. | ||
ln -s sdk_dl/$SDK_FILE ./ | ||
|
||
else | ||
echo "Use saved SDK" | ||
|
||
ln -s /$SDK_FILE ./ | ||
fi | ||
|
||
echo "Prepare build_dir" | ||
|
||
mkdir build_dir | ||
cd build_dir | ||
|
||
tar Jxf ../$SDK_FILE --strip=1 | ||
|
||
mv build_dir build_dir_default | ||
|
||
mkdir staging_dir/target | ||
for path in build_dir_default/target-*; do | ||
ln -s target staging_dir/$(basename $path) | ||
done | ||
|
||
echo "src-git base https://github.com/openwrt/openwrt.git;$BRANCH" > feeds.conf | ||
if [ "$CUSTOM_FEED" = y ]; then | ||
echo "src-git packages https://github.com/openwrt/packages.git;$BRANCH" >> feeds.conf | ||
echo "src-link custom $HOME/openwrt_packages" >> feeds.conf | ||
else | ||
echo "src-link packages $HOME/openwrt_packages" >> feeds.conf | ||
fi | ||
echo "src-git luci https://github.com/openwrt/luci.git;$BRANCH" >> feeds.conf | ||
|
||
cat feeds.conf |
Oops, something went wrong.