diff --git a/scripts/README.md b/scripts/README.md index 754f7c9c3..bb1bdeee6 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -19,10 +19,13 @@ Syntax: ./build.sh [start_cmd] [-] [end_cmd] 1. Copy the `default_config.sh` file to `config.sh` in the scripts directory. 2. Make any necessary edits there, the script will pick up `config.sh` over `default_config.sh`. +3. If you need to copy some files to the chroot environment, you can put them in `chroot_files`. The directories +tree inside `chroot_files` will be reproduced inside chroot (files inside `chroot_files/tmp` will be cleanup). +/!\ `chroot_files/tmp` unix right's should be 1777 ## How to Update The configuration script is versioned with the variable CONFIG_FILE_VERSION. Any time that the configuration format is changed in `default_config.sh`, this value is bumped. Once this happens `config.sh` must be updated manually from the default file to ensure the new/changed variables are as desired. Once the merge is complete the `config.sh` file's -CONFIG_FILE_VERSION should match the default and the build will run. \ No newline at end of file +CONFIG_FILE_VERSION should match the default and the build will run. diff --git a/scripts/build.sh b/scripts/build.sh index 9d4f0939e..a8e5a529f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -75,7 +75,7 @@ function check_host() { # Load configuration values from file function load_config() { - if [[ -f "$SCRIPT_DIR/config.sh" ]]; then + if [[ -f "$SCRIPT_DIR/config.sh" ]]; then . "$SCRIPT_DIR/config.sh" elif [[ -f "$SCRIPT_DIR/default_config.sh" ]]; then . "$SCRIPT_DIR/default_config.sh" @@ -114,21 +114,25 @@ function run_chroot() { chroot_enter_setup # Setup build scripts in chroot environment - sudo ln -f $SCRIPT_DIR/chroot_build.sh chroot/root/chroot_build.sh - sudo ln -f $SCRIPT_DIR/default_config.sh chroot/root/default_config.sh + sudo ln -f $SCRIPT_DIR/default_config.sh chroot/tmp/default_config.sh if [[ -f "$SCRIPT_DIR/config.sh" ]]; then - sudo ln -f $SCRIPT_DIR/config.sh chroot/root/config.sh - fi + sudo ln -f $SCRIPT_DIR/config.sh chroot/tmp/config.sh + fi + + # Build chroot_files archive and extract it into chroot directory + tar -czf chroot_files.tar.gz -C chroot_files . + sudo tar --owner root --group root -C chroot -xzf chroot_files.tar.gz + # For an unknown reason tar change chroot ownership so we need this little hack + sudo chown root:root chroot + rm -f chroot_files.tar.gz # Launch into chroot environment to build install image. - sudo chroot chroot /root/chroot_build.sh - + sudo chroot chroot /tmp/chroot_build.sh - # Cleanup after image changes - sudo rm -f chroot/root/chroot_build.sh - sudo rm -f chroot/root/default_config.sh - if [[ -f "chroot/root/config.sh" ]]; then - sudo rm -f chroot/root/config.sh - fi + for i in $(ls chroot/tmp/ -1); do + sudo rm -f chroot/tmp/$i + done chroot_exit_teardown } diff --git a/scripts/chroot_build.sh b/scripts/chroot_files/tmp/chroot_build.sh similarity index 100% rename from scripts/chroot_build.sh rename to scripts/chroot_files/tmp/chroot_build.sh