refactored custom core processing, now uses a core directory in the /src
entrpoint now uses exec to call the entrypoint command thus not spawing a subshell updated uci shell code and added /root/shell so to avoid constant warning about it missing. add /opt/bin to path in dockerfilemaster
parent
70bbfd5c0b
commit
ca4713d56b
|
@ -4,6 +4,7 @@ _opt/
|
|||
.src
|
||||
TODO.md
|
||||
mnt/
|
||||
core/custom
|
||||
logs/
|
||||
Dockerfile
|
||||
.env
|
||||
|
|
|
@ -16,6 +16,9 @@ ARG VERBOSE
|
|||
ARG REBUILD
|
||||
WORKDIR /build
|
||||
|
||||
# put /opt/bin in path permently
|
||||
ENV PATH="/opt/bin:${PATH}"
|
||||
|
||||
# CORE
|
||||
RUN --mount=type=bind,source=./core,target=/build \
|
||||
<<eot
|
||||
|
|
|
@ -26,6 +26,13 @@ echo distro $LINUX_DISTRO was validated...continuing
|
|||
set_distro
|
||||
/bin/sh ./packages.sh
|
||||
/bin/bash -l ./core.sh
|
||||
if [ -f ./custom/run ]; then
|
||||
echo custom directory exists with run file inside
|
||||
cd ./custom || exit
|
||||
echo sourcing that run file now
|
||||
/bin/bash -l ./run
|
||||
cd ..
|
||||
fi
|
||||
echo
|
||||
echo "************* End UCI CORE build ********************"
|
||||
else
|
||||
|
|
17
build
17
build
|
@ -248,20 +248,18 @@ fi
|
|||
# make a copy of build source locally in build directory
|
||||
if [[ ! $BUILD_SRC = "_core_" ]]; then
|
||||
# copy or bind build source directory to temporary .src/ subdirectory in build repo
|
||||
_env_dir=rootfs/opt/env
|
||||
[[ -d $BDIR/.src ]] && rm -rf $BDIR/.src
|
||||
[[ -d $BDIR/core/$_env_dir ]] && rm -rf $BDIR/core/$_env_dir
|
||||
if [[ $(which rsync 2> /dev/null ) ]]; then
|
||||
rsync -aAru ${BUILD_SRC:-src}/ $BDIR/.src
|
||||
rsync -aAru $BDIR/.src/$_env_dir/ $BDIR/core/$_env_dir > /dev/null 2>&1
|
||||
else
|
||||
echo no rsync copying with cp
|
||||
/bin/cp -a ${BUILD_SRC:-src}/. $BDIR/.src > /dev/null 2>&1
|
||||
/bin/cp -a $BDIR/.src/rootfs/opt/env/. $BDIR/core/rootfs/opt/env > /dev/null 2>&1
|
||||
fi
|
||||
ls -la $BDIR/.src/rootfs
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# create Dockerfile from template
|
||||
if ! source $BDIR/Dockerfile.d/create; then
|
||||
echo unable to create Dockerfile from template, aborting build
|
||||
|
@ -291,7 +289,13 @@ fi
|
|||
EOF
|
||||
fi
|
||||
|
||||
[[ -f $BDIR/.src/custom-core.sh ]] && /bin/cp $BDIR/.src/custom-core.sh $BDIR/core/
|
||||
if [[ -d $BDIR/.src/core ]]; then
|
||||
[[ -d "$BDIR/core/custom" ]] && rm -rf "$BDIR/core/custom"
|
||||
echo adding the custom core directory to /custom in the core directory
|
||||
/bin/cp -a "$BDIR/.src/core/." "$BDIR/core/custom"
|
||||
rm -rf "$BDIR/.src/core/"
|
||||
ls -la $BDIR/core/custom
|
||||
fi
|
||||
|
||||
pushd "$BDIR" > /dev/null || return 3
|
||||
|
||||
|
@ -321,6 +325,9 @@ if [[ $TARGET == "private" ]]; then
|
|||
image_push -r $REPO $IMAGE_NAME
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
[[ -d "$BDIR/core/custom" ]] && rm -rf "$BDIR/core/custom"
|
||||
|
||||
}
|
||||
|
||||
# if script was executed then call the function
|
||||
|
|
|
@ -11,7 +11,6 @@ if [[ -f ./build.env ]]; then
|
|||
fi
|
||||
source $LIB_DIR/verbose.lib
|
||||
|
||||
[[ -f ./custom-core.sh ]] && echo "sourcing custom core script" && source "./custom-core.sh"
|
||||
echo appending pkg commands to core_run.env
|
||||
echo appending sourcing of $ENV_DIR/run.env if it exists
|
||||
cat <<ENV >> /opt/core_run.env
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/bin/bash
|
||||
env > /tmp/passed.env
|
||||
source /opt/core_run.env
|
||||
|
||||
cmd=$1
|
||||
|
||||
# [[ $DEVELOPMENT && $cmd == "${ENTRYPOINT_CMD:-start}" ]] && echo "development mode enabled, idling container" && cmd=idle
|
||||
|
||||
case "$cmd" in
|
||||
|
||||
maphostid)
|
||||
|
@ -34,7 +32,7 @@ cat | /bin/bash -l
|
|||
;;
|
||||
${ENTRYPOINT_CMD:-start})
|
||||
shift 1
|
||||
/bin/bash -l -c '${ENTRYPOINT_CMD_PATH:-$BIN_DIR/${ENTRYPOINT_CMD:-start}} $@' $0 "$@"
|
||||
exec /bin/bash -l -c '${ENTRYPOINT_CMD_PATH:-$BIN_DIR/${ENTRYPOINT_CMD:-start}} $@' $0 "$@"
|
||||
;;
|
||||
*)
|
||||
echo "--- command passed to container: $* ---"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export DEFAULT_DIR=/opt/bin
|
|
@ -25,5 +25,7 @@ else
|
|||
uci_bash_shell_install
|
||||
fi
|
||||
|
||||
mkdir /root/shell
|
||||
|
||||
echo "----------- uci shell install complete ------"
|
||||
|
||||
|
|
|
@ -261,10 +261,10 @@ local src; local spath; local spaths
|
|||
# will determine if there are any minimal build source files/directories
|
||||
check_dir () {
|
||||
if
|
||||
[ $(ls $1/packages/*system.pkgs 2> /dev/null) ] || \
|
||||
[ $(ls $1/packages/system/*.pkgs 2> /dev/null) ] || \
|
||||
[ -f $1/packages/repositories.sh ] || \
|
||||
[ -f $1/packages/packages.sh ]
|
||||
[[ "$(ls $1/packages/*system.pkgs 2> /dev/null)" ]] || \
|
||||
[[ "$(ls $1/packages/system/*.pkgs 2> /dev/null)" ]] || \
|
||||
[[ -f $1/packages/repositories.sh ]] || \
|
||||
[[ -f $1/packages/packages.sh ]];
|
||||
then
|
||||
_packages_=true
|
||||
return 0
|
||||
|
|
|
@ -85,7 +85,7 @@ try_container () {
|
|||
image=${image:-$IMAGE_NAME}
|
||||
|
||||
if [[ ! ( $build && $image ) ]]; then
|
||||
echo attempting to getting image name from environment file
|
||||
echo attempting to get image name from environment file
|
||||
source_env_file $efile
|
||||
image=$(make_image_name)
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
cat ./run
|
||||
echo This file is run file contents above was in the custom core directory
|
||||
echo so it was executed. It can now do any modifications to the core layer
|
||||
echo you can put any additional files you need and call them from this run file
|
||||
echo the script enters the custom directory so all your reference can be relative.
|
||||
source .env
|
||||
env | grep CUST
|
||||
ls -la
|
||||
echo rest of the copied core files can be found in /opt
|
||||
ls -la /opt
|
||||
echo now it will modify the core_run.env file
|
||||
echo "echo the core_run.env file was modifed by custom core script" >> /opt/core_run.env
|
||||
|
|
@ -1 +1,2 @@
|
|||
export DEFAULT_DIR=/opt/bin
|
||||
export DEFAULT_DIR=/opt/bin
|
||||
export TESTENVAR=thisisatest
|
Loading…
Reference in New Issue