File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -27,15 +27,14 @@ docker build -f tools/build/Dockerfile.builder -t vamos-builder "$DIR"
2727echo " Starting vamos-builder container"
2828CONTAINER_ID=$( docker run -d -u " $( id -u) :$( id -g) " -v " $DIR " :" $DIR " -w " $DIR " vamos-builder)
2929
30- trap " echo 'Cleaning up container:'; docker container rm -f $CONTAINER_ID ; rm -rf $TMP_DIR " EXIT
30+ trap cleanup EXIT
3131
3232apply_patches () {
3333 cd " $KERNEL_DIR "
3434
3535 # Reset submodule to committed state for deterministic builds
3636 echo " -- Resetting kernel submodule to clean state --"
37- git checkout .
38- git clean -fd
37+ clean_kernel_tree
3938
4039 if [ -d " $PATCHES_DIR " ] && ls " $PATCHES_DIR " /* .patch 1> /dev/null 2>&1 ; then
4140 echo " -- Applying patches --"
@@ -120,5 +119,19 @@ build_kernel() {
120119 ls -lh " $OUT_DIR /boot.img"
121120}
122121
122+ clean_kernel_tree () {
123+ git -C " $KERNEL_DIR " reset --hard HEAD > /dev/null 2>&1 || true
124+ git -C " $KERNEL_DIR " clean -fd > /dev/null 2>&1 || true
125+ }
126+
127+ cleanup () {
128+ echo " Cleaning up container and kernel tree..."
129+
130+ clean_kernel_tree
131+
132+ docker container rm -f " ${CONTAINER_ID:- } " > /dev/null 2>&1 || true
133+ rm -rf " $TMP_DIR "
134+ }
135+
123136# Run build inside container
124- docker exec -u " $( id -u) :$( id -g) " $CONTAINER_ID bash -c " set -e; export DEFCONFIG=$DEFCONFIG DIR=$DIR TOOLS=$TOOLS KERNEL_DIR=$KERNEL_DIR PATCHES_DIR=$PATCHES_DIR TMP_DIR=$TMP_DIR OUT_DIR=$OUT_DIR BOOT_IMG=$BOOT_IMG DTB=$DTB ; $( declare -f apply_patches build_kernel) ; build_kernel"
137+ docker exec -u " $( id -u) :$( id -g) " $CONTAINER_ID bash -c " set -e; export DEFCONFIG=$DEFCONFIG DIR=$DIR TOOLS=$TOOLS KERNEL_DIR=$KERNEL_DIR PATCHES_DIR=$PATCHES_DIR TMP_DIR=$TMP_DIR OUT_DIR=$OUT_DIR BOOT_IMG=$BOOT_IMG DTB=$DTB ; $( declare -f apply_patches build_kernel clean_kernel_tree ) ; build_kernel"
You can’t perform that action at this time.
0 commit comments