@@ -31,6 +31,29 @@ function safe_copy {
3131 fi
3232}
3333
34+ function copy_buildroot_config
35+ {
36+ local buildroot_config=" configs/buildroot.config"
37+ local x11_config=" configs/x11.config"
38+ local output_config=" buildroot/.config"
39+ local merge_tool=" buildroot/support/kconfig/merge_config.sh"
40+
41+ if [ ! -f " $output_config " ]; then
42+ echo " Preparing initial Buildroot config..."
43+
44+ # Check X11 option
45+ if [[ $BUILD_X11 -eq 1 ]]; then
46+ # Compile Buildroot with X11
47+ " $merge_tool " -m -r -O buildroot " $buildroot_config " " $x11_config "
48+ else
49+ # Compile Buildroot without X11
50+ cp -f " $buildroot_config " " $output_config "
51+ fi
52+ else
53+ echo " $output_config already exists, skipping copy"
54+ fi
55+ }
56+
3457function do_buildroot
3558{
3659 if [ ! -d buildroot ]; then
@@ -40,7 +63,7 @@ function do_buildroot
4063 echo " buildroot/ already exists, skipping clone"
4164 fi
4265
43- safe_copy configs/buildroot.config buildroot/.config
66+ copy_buildroot_config
4467 safe_copy configs/busybox.config buildroot/busybox.config
4568 cp -f target/init buildroot/fs/cpio/init
4669
@@ -94,6 +117,7 @@ Usage: $0 [--buildroot] [--linux] [--extra-packages] [--all] [--external-root] [
94117
95118Options:
96119 --buildroot Build Buildroot rootfs
120+ --x11 Build Buildroot with X11
97121 --extra-packages Build extra packages along with Buildroot
98122 --linux Build Linux kernel
99123 --all Build both Buildroot and Linux kernel
105129}
106130
107131BUILD_BUILDROOT=0
108- BUILD_LINUX =0
132+ BUILD_X11 =0
109133BUILD_EXTRA_PACKAGES=0
134+ BUILD_LINUX=0
110135EXTERNAL_ROOT=0
111136CLEAN_BUILD=0
112137
@@ -115,6 +140,9 @@ while [[ $# -gt 0 ]]; do
115140 --buildroot)
116141 BUILD_BUILDROOT=1
117142 ;;
143+ --x11)
144+ BUILD_X11=1
145+ ;;
118146 --extra-packages)
119147 BUILD_EXTRA_PACKAGES=1
120148 ;;
@@ -193,6 +221,11 @@ if [[ $BUILD_EXTRA_PACKAGES -eq 1 && $BUILD_BUILDROOT -eq 0 ]]; then
193221 show_help
194222fi
195223
224+ if [[ $BUILD_X11 -eq 1 && $BUILD_BUILDROOT -eq 0 ]]; then
225+ echo " Error: --x11 requires --buildroot to be specified."
226+ show_help
227+ fi
228+
196229if [[ $CLEAN_BUILD -eq 1 && $BUILD_BUILDROOT -eq 1 && -d buildroot ]]; then
197230 echo " Removing buildroot/ for clean build..."
198231 rm -rf buildroot
0 commit comments