mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-12 19:10:27 +03:00
Make the docker user id and group id match the running user's, so that files built by the container are seen as owned by the current user. Also set the current directory as "safe" in git so it's able to inspect the git history. _note_: this will successfully run in a rootless docker install, but the created files will have random uid/guids. You'll have to sudo to delete them or chown them. For normal docker installs there should be no issues. See [this issue](https://github.com/moby/moby/issues/41497) to track the rootless problem on the docker side.
49 lines
1.3 KiB
Bash
Executable file
49 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
if [[ $# == 0 ]]; then
|
|
echo -e "\
|
|
Usage syntax: ./build.sh <TARGET>
|
|
|
|
Notes:
|
|
* You can specify multiple targets.
|
|
./build.sh <TARGET_1> <TARGET_2> <TARGET_N>
|
|
* To get a list of all targets use \"help\". Hint: pipe the output through a pager.
|
|
./build.sh help | less
|
|
* To build all targets use \"all\"
|
|
./build.sh all
|
|
* To clean a target prefix it with \"clean_\".
|
|
./build.sh clean_MATEKF405SE
|
|
* To clean all targets just use \"clean\".
|
|
./build.sh clean"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$(docker images -q inav-build)" ]; then
|
|
echo -e "*** Building image\n"
|
|
docker build -t inav-build --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" .
|
|
echo -ne "\n"
|
|
fi
|
|
|
|
if [ ! -d ./build ]; then
|
|
echo -e "*** Creating build directory\n"
|
|
mkdir ./build && chmod 777 ./build
|
|
fi
|
|
|
|
if [ ! -d ./downloads ]; then
|
|
echo -e "*** Creating downloads directory\n"
|
|
mkdir ./downloads && chmod 777 ./downloads
|
|
fi
|
|
|
|
if [ ! -d ./tools ]; then
|
|
echo -e "*** Creating tools directory\n"
|
|
mkdir ./tools && chmod 777 ./tools
|
|
fi
|
|
|
|
echo -e "*** Building targets [$@]\n"
|
|
docker run --rm -it -v "$(pwd)":/src inav-build $@
|
|
|
|
if [ -z "$(ls ./build/*.hex &> /dev/null)" ]; then
|
|
echo -e "\n*** Built targets in ./build:"
|
|
stat -c "%n (%.19y)" ./build/*.hex
|
|
fi
|